Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
CBroz1 committed Feb 9, 2024
1 parent 8ef0f39 commit b5bea11
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 43 deletions.
1 change: 1 addition & 0 deletions src/spyglass/common/common_behav.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pathlib
import re
from functools import reduce
from typing import Dict

Expand Down
5 changes: 2 additions & 3 deletions src/spyglass/position/v1/dlc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
42 changes: 2 additions & 40 deletions src/spyglass/position/v1/position_dlc_pose_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit b5bea11

Please sign in to comment.