Skip to content

Commit

Permalink
🐛 : debug 3
Browse files Browse the repository at this point in the history
  • Loading branch information
CBroz1 committed Nov 12, 2024
1 parent 4d5ef7a commit cf70221
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 21 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ jobs:
curl_opts $VID_DIR $VID_ONE $VID1URL
curl_opts $VID_DIR $VID_TWO $VID2URL
- name: Run tests
run: | # DO NOT MERGE - must revert
pytest --no-docker --no-dlc tests/position/test_trodes.py -k test_trodes_video
run: |
pytest --no-docker --no-dlc tests/
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
name: spyglass
channels:
- conda-forge
- defaults
# - defaults # deprecated
- franklab
- edeno
# - pytorch # dlc-only
Expand Down
2 changes: 1 addition & 1 deletion environment_dlc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
name: spyglass-dlc
channels:
- conda-forge
- defaults
# - defaults # deprecated
- franklab
- edeno
- pytorch # dlc-only
Expand Down
30 changes: 13 additions & 17 deletions src/spyglass/position/v1/dlc_utils_makevid.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ def __init__(
_ = self._set_frame_info()
_ = self._set_plot_bases()

if test_mode: # CICD fails with ambiguous pool error
self._debug_one_frame()

logger.info(
f"Making video: {self.output_video_filename} "
+ f"in batches of {self.batch_size}"
Expand Down Expand Up @@ -307,15 +304,20 @@ def centroid_to_px(*idx):
)
)

def _set_orient_line(self, frame, pos_ind):
def orient_list(c):
return [c, c + 30 * np.cos(self.orientation_mean[pos_ind])]
def _get_orient_line(self, pos_ind):
orient = self.orientation_mean[pos_ind]
if isinstance(orient, np.ndarray):
orient = orient[0] # Trodes passes orientation as a 1D array

if np.all(np.isnan(self.orientation_mean[pos_ind])):
self.orientation_line.set_data((np.NaN, np.NaN))
def orient_list(c, axis="x"):
func = np.cos if axis == "x" else np.sin
return [c, c + 30 * func(orient)]

if np.all(np.isnan(orient)):
return ([np.NaN], [np.NaN])
else:
c0, c1 = self._get_centroid_data(pos_ind)
self.orientation_line.set_data(orient_list(c0), orient_list(c1))
x, y = self._get_centroid_data(pos_ind)
return (orient_list(x), orient_list(y, axis="y"))

def _generate_single_frame(self, frame_ind):
"""Generate a single frame and save it as an image."""
Expand Down Expand Up @@ -362,7 +364,7 @@ def _generate_single_frame(self, frame_ind):
)
)
self.centroid_position_dot.set_offsets(dlc_centroid_data)
_ = self._set_orient_line(frame, pos_ind)
self.orientation_line.set_data(self._get_orient_line(pos_ind))

time_delta = pd.Timedelta(
pd.to_datetime(self.position_time[pos_ind] * 1e9, unit="ns")
Expand All @@ -382,12 +384,6 @@ def _generate_single_frame(self, frame_ind):

return frame_ind

def _debug_one_frame(self):
"""Debug a single frame."""
frame_ind = 10
self.ffmpeg_extract(frame_ind, frame_ind + 1)
self._generate_single_frame(frame_ind)

def process_frames(self):
"""Process video frames in batches and generate matplotlib frames."""

Expand Down
1 change: 1 addition & 0 deletions src/spyglass/utils/database_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"lfp",
"waveform",
"mua",
"sharing",
]
GRANT_ALL = "GRANT ALL PRIVILEGES ON "
GRANT_SEL = "GRANT SELECT ON "
Expand Down

0 comments on commit cf70221

Please sign in to comment.