Skip to content

Commit

Permalink
Cleanup errors from removal of PoseOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelbray32 committed Dec 20, 2024
1 parent fc46b37 commit c3c7b84
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
8 changes: 7 additions & 1 deletion src/spyglass/behavior/core.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
from pathlib import Path
from typing import List

Expand Down Expand Up @@ -45,6 +46,11 @@ def create_group(
group_key = {
"pose_group_name": group_name,
}
if self & group_key:
warnings.warn(
f"Pose group {group_name} already exists. Skipping insertion."
)
return
self.insert1(
{
**group_key,
Expand Down Expand Up @@ -87,7 +93,7 @@ def fetch_pose_datasets(
video_name = Path(
(PositionOutput & merge_key).fetch_video_path()
).name
bodyparts_df = (PositionOutput & merge_key).fetch_dataframe()
bodyparts_df = (PositionOutput & merge_key).fetch_pose_dataframe()
if bodyparts is None:
bodyparts = (
bodyparts_df.keys().get_level_values(0).unique().values
Expand Down
8 changes: 4 additions & 4 deletions src/spyglass/behavior/moseq.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ def make(self, key):

# set up the project and config
project_dir = (
"/home/sambray/Documents/moseq_test_proj2" # TODO: make this better
"/home/sambray/Documents/moseq_test_proj3" # TODO: make this better
)
video_dir = (
"/home/sambray/Documents/moseq_test_vids2" # TODO: make this better
"/home/sambray/Documents/moseq_test_vids3" # TODO: make this better
)
# make symlinks to the videos in a single directory
os.makedirs(video_dir, exist_ok=True)
Expand Down Expand Up @@ -289,12 +289,12 @@ def validate_bodyparts(self, key):
return
model_bodyparts = (PoseGroup & key).fetch1("bodyparts")
merge_key = {"merge_id": key["pose_merge_id"]}
bodyparts_df = (PositionOutput & merge_key).fetch_dataframe()
bodyparts_df = (PositionOutput & merge_key).fetch_pose_dataframe()
data_bodyparts = bodyparts_df.keys().get_level_values(0).unique().values
for bodypart in model_bodyparts:
if bodypart not in data_bodyparts:
raise ValueError(
f"Error in row {row}: " + f"Bodypart {bodypart} not in data"
f"Error in row {key}: " + f"Bodypart {bodypart} not in data"
)


Expand Down
7 changes: 2 additions & 5 deletions src/spyglass/position/position_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
from pandas import DataFrame

from spyglass.common.common_position import IntervalPositionInfo as CommonPos
from spyglass.position.v1.position_dlc_pose_estimation import (
DLCPoseEstimation,
DLCPoseEstimationSelection,
)
from spyglass.position.v1.position_dlc_pose_estimation import DLCPoseEstimation
from spyglass.position.v1.position_dlc_selection import DLCPosV1
from spyglass.position.v1.position_trodes_position import TrodesPosV1
from spyglass.utils import SpyglassMixin, _Merge
Expand Down Expand Up @@ -91,7 +88,7 @@ def fetch_pose_dataframe(self):
)
return query.fetch_pose_dataframe()

def fetch_video_parh(self):
def fetch_video_path(self):
key = self.merge_restrict(self.proj()).proj()
query = (
source_class_dict[
Expand Down

0 comments on commit c3c7b84

Please sign in to comment.