From b5bea11a8c5d680a07027c53e5881afb85071ff8 Mon Sep 17 00:00:00 2001 From: CBroz1 Date: Fri, 9 Feb 2024 16:22:26 -0600 Subject: [PATCH] Fix linting errors --- src/spyglass/common/common_behav.py | 1 + src/spyglass/position/v1/dlc_utils.py | 5 +-- .../v1/position_dlc_pose_estimation.py | 42 +------------------ 3 files changed, 5 insertions(+), 43 deletions(-) diff --git a/src/spyglass/common/common_behav.py b/src/spyglass/common/common_behav.py index 413ba420c..530cdac36 100644 --- a/src/spyglass/common/common_behav.py +++ b/src/spyglass/common/common_behav.py @@ -1,4 +1,5 @@ import pathlib +import re from functools import reduce from typing import Dict diff --git a/src/spyglass/position/v1/dlc_utils.py b/src/spyglass/position/v1/dlc_utils.py index 5bd067437..8ef76074e 100644 --- a/src/spyglass/position/v1/dlc_utils.py +++ b/src/spyglass/position/v1/dlc_utils.py @@ -18,6 +18,7 @@ import pandas as pd from tqdm import tqdm as tqdm +from spyglass.common.common_behav import VideoFile from spyglass.settings import dlc_output_dir, dlc_video_dir, raw_dir @@ -418,8 +419,6 @@ def get_video_path(key): """ import pynwb - from ...common.common_behav import VideoFile - vf_key = {"nwb_file_name": key["nwb_file_name"], "epoch": key["epoch"]} VideoFile()._no_transaction_make(vf_key, verbose=False) video_query = VideoFile & vf_key @@ -434,7 +433,7 @@ def get_video_path(key): with pynwb.NWBHDF5IO(path=nwb_path, mode="r") as in_out: nwb_file = in_out.read() nwb_video = nwb_file.objects[video_info["video_file_object_id"]] - video_filepath = common_behav.VideoFile.get_abs_path(video_key) + video_filepath = VideoFile.get_abs_path(vf_key) video_dir = os.path.dirname(video_filepath) + "/" video_filename = video_filepath.split(video_dir)[-1] meters_per_pixel = nwb_video.device.meters_per_pixel diff --git a/src/spyglass/position/v1/position_dlc_pose_estimation.py b/src/spyglass/position/v1/position_dlc_pose_estimation.py index 9f5cefc0c..4f964bb2a 100644 --- a/src/spyglass/position/v1/position_dlc_pose_estimation.py +++ b/src/spyglass/position/v1/position_dlc_pose_estimation.py @@ -10,12 +10,11 @@ from spyglass.common.common_behav import ( # noqa: F401 RawPosition, - VideoFile, convert_epoch_interval_name_to_position_interval_name, ) +from spyglass.common.common_nwbfile import AnalysisNwbfile +from spyglass.utils.dj_mixin import SpyglassMixin -from ...common.common_nwbfile import AnalysisNwbfile -from ...utils.dj_mixin import SpyglassMixin from .dlc_utils import OutputLogger, infer_output_dir from .position_dlc_model import DLCModel @@ -124,43 +123,6 @@ def insert_estimation_task( logger.logger.info("inserted entry into Pose Estimation Selection") return {**key, "task_mode": task_mode} - @classmethod - def get_video_crop(cls, video_path): - """ - Queries the user to determine the cropping parameters for a given video - - Parameters - ---------- - video_path : str - path to the video file - - Returns - ------- - crop_ints : list - list of 4 integers [x min, x max, y min, y max] - """ - - cap = cv2.VideoCapture(video_path) - _, frame = cap.read() - fig, ax = plt.subplots(figsize=(20, 10)) - ax.imshow(frame) - xlims = ax.get_xlim() - ylims = ax.get_ylim() - ax.set_xticks(np.arange(xlims[0], xlims[-1], 50)) - ax.set_yticks(np.arange(ylims[0], ylims[-1], -50)) - ax.grid(visible=True, color="white", lw=0.5, alpha=0.5) - display(fig) - crop_input = input( - "Please enter the crop parameters for your video in format " - "xmin, xmax, ymin, ymax, or 'none'\n" - ) - plt.close() - if crop_input.lower() == "none": - return None - crop_ints = [int(val) for val in crop_input.split(",")] - assert all(isinstance(val, int) for val in crop_ints) - return crop_ints - @schema class DLCPoseEstimation(SpyglassMixin, dj.Computed):