Skip to content

Commit

Permalink
WIP: Tidy position 2
Browse files Browse the repository at this point in the history
  • Loading branch information
CBroz1 committed Mar 14, 2024
1 parent 01faadd commit 66d8494
Show file tree
Hide file tree
Showing 18 changed files with 1,365 additions and 1,450 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ dmypy.json
*.videoTimeStamps
*.cameraHWSync
*.stateScriptLog
tests/_data/*

*.nwb
*.DS_Store
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@

### Pipelines

- Common:
- Add ActivityLog to `common_usage` to track unreferenced utilities. #870
- Position:
- Fixes to `environment-dlc.yml` restricting tensortflow #834
- Video restriction for multicamera epochs #834
- Fixes to `_convert_mp4` #834
- Replace deprecated calls to `yaml.safe_load()` #834
- Refactoring to reduce redundancy #870
- Migrate `OutputLogger` behavior to decorator #870
- Spikesorting:
- Increase`spikeinterface` version to >=0.99.1, <0.100 #852
- Increase`spikeinterface` version to >=0.99.1, \<0.100 #852
- Bug fix in single artifact interval edge case #859
- LFP
- In LFPArtifactDetection, only apply referencing if explicitly selected #863
Expand Down Expand Up @@ -193,3 +197,4 @@
[0.4.2]: https://github.com/LorenFrankLab/spyglass/releases/tag/0.4.2
[0.4.3]: https://github.com/LorenFrankLab/spyglass/releases/tag/0.4.3
[0.5.0]: https://github.com/LorenFrankLab/spyglass/releases/tag/0.5.0
[0.5.1]: https://github.com/LorenFrankLab/spyglass/releases/tag/0.5.1
42 changes: 24 additions & 18 deletions src/spyglass/common/common_behav.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ class VideoFile(SpyglassMixin, dj.Imported):
def make(self, key):
self._no_transaction_make(key)

def _no_transaction_make(self, key, verbose=True):
def _no_transaction_make(self, key, verbose=True, skip_duplicates=False):
if not self.connection.in_transaction:
self.populate(key)
return
Expand All @@ -394,6 +394,7 @@ def _no_transaction_make(self, key, verbose=True):
"interval_list_name": interval_list_name,
}
).fetch1("valid_times")

cam_device_str = r"camera_device (\d+)"
is_found = False
for ind, video in enumerate(videos.values()):
Expand All @@ -403,26 +404,31 @@ def _no_transaction_make(self, key, verbose=True):
# check to see if the times for this video_object are largely
# overlapping with the task epoch times

if len(
if not len(
interval_list_contains(valid_times, video_obj.timestamps)
> 0.9 * len(video_obj.timestamps)
):
nwb_cam_device = video_obj.device.name
# returns whatever was captured in the first group (within the parentheses) of the regular expression -- in this case, 0
key["video_file_num"] = int(
re.match(cam_device_str, nwb_cam_device)[1]
continue

nwb_cam_device = video_obj.device.name

# returns whatever was captured in the first group (within the
# parentheses) of the regular expression - in this case, 0

key["video_file_num"] = int(
re.match(cam_device_str, nwb_cam_device)[1]
)
camera_name = video_obj.device.camera_name
if CameraDevice & {"camera_name": camera_name}:
key["camera_name"] = video_obj.device.camera_name
else:
raise KeyError(
f"No camera with camera_name: {camera_name} found "
+ "in CameraDevice table."
)
camera_name = video_obj.device.camera_name
if CameraDevice & {"camera_name": camera_name}:
key["camera_name"] = video_obj.device.camera_name
else:
raise KeyError(
f"No camera with camera_name: {camera_name} found "
+ "in CameraDevice table."
)
key["video_file_object_id"] = video_obj.object_id
self.insert1(key)
is_found = True
key["video_file_object_id"] = video_obj.object_id
self.insert1(key, skip_duplicates=skip_duplicates)
is_found = True

if not is_found and verbose:
logger.info(
Expand All @@ -431,7 +437,7 @@ def _no_transaction_make(self, key, verbose=True):
)

@classmethod
def update_entries(cls, restrict={}):
def update_entries(cls, restrict=True):
existing_entries = (cls & restrict).fetch("KEY")
for row in existing_entries:
if (cls & row).fetch1("camera_name"):
Expand Down
2 changes: 2 additions & 0 deletions src/spyglass/common/common_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,8 @@ def prompt_insert(

if table_type:
table_type += " "
else:
table_type = ""

logger.info(
f"{table}{table_type} '{name}' was not found in the"
Expand Down
5 changes: 3 additions & 2 deletions src/spyglass/common/common_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ActivityLog(dj.Manual):
"""

@classmethod
def log(cls, name):
logger.warning(f"Function scheduled for deprecation: {name}")
def log(cls, name, warning=True) -> None:
if warning:
logger.warning(f"Function scheduled for deprecation: {name}")
cls.insert1(dict(dj_user=dj.config["database.user"], function=name))
7 changes: 2 additions & 5 deletions src/spyglass/position/position_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@
from datajoint.utils import to_camel_case

from spyglass.common.common_position import IntervalPositionInfo as CommonPos
from spyglass.position.v1.dlc_utils import (
check_videofile,
get_video_path,
make_video,
)
from spyglass.position.v1.dlc_utils import check_videofile, get_video_path
from spyglass.position.v1.dlc_utils_makevid import make_video
from spyglass.position.v1.position_dlc_pose_estimation import (
DLCPoseEstimationSelection,
)
Expand Down
30 changes: 0 additions & 30 deletions src/spyglass/position/v1/dlc_decorators.py

This file was deleted.

Loading

0 comments on commit 66d8494

Please sign in to comment.