Skip to content

Commit

Permalink
remove behavior flag, infer from files
Browse files Browse the repository at this point in the history
  • Loading branch information
mayofaulkner committed Oct 10, 2023
1 parent 7d5bfc1 commit b567a3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 1 addition & 2 deletions ibllib/io/extractors/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ def _extract(self, sync=None, chmap=None, video_path=None, sync_label='audio',
_logger.warning('Attempting to align using wheel')

try:
motion_class = vmotion.MotionAlignmentFullSession(self.session_path, self.label, behavior=False,
upload=True)
motion_class = vmotion.MotionAlignmentFullSession(self.session_path, self.label, upload=True)
new_times = motion_class.process()
if not motion_class.qc_outcome:
raise ValueError(f'Wheel alignment failed to pass qc: {motion_class.qc}')
Expand Down
11 changes: 7 additions & 4 deletions ibllib/io/extractors/video_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from brainbox.behavior.dlc import likelihood_threshold, get_speed
from brainbox.task.trials import find_trial_ids
import one.alf.io as alfio
from one.alf.exceptions import ALFObjectNotFound
from one.alf.spec import is_session_path, is_uuid_string


Expand Down Expand Up @@ -400,19 +401,18 @@ def __init__(self, session_path, label, **kwargs):
self.session_path = session_path
self.label = label
self.threshold = kwargs.get('threshold', 20)
self.behavior = kwargs.get('behavior', False)
self.upload = kwargs.get('upload', False)
self.twin = kwargs.get('twin', 150)
self.nprocess = kwargs.get('nprocess', int(cpu_count() - cpu_count() / 4))

self.load_data(sync=kwargs.get('sync', 'nidq'), location=kwargs.get('location', None), behavior=self.behavior)
self.load_data(sync=kwargs.get('sync', 'nidq'), location=kwargs.get('location', None))
self.roi, self.mask = self.get_roi_mask()

if self.upload:
self.one = ONE(mode='remote')
self.eid = self.one.path2eid(self.session_path)

def load_data(self, sync='nidq', location=None, behavior=False):
def load_data(self, sync='nidq', location=None):
def fix_keys(alf_object):
ob = Bunch()
for key in alf_object.keys():
Expand Down Expand Up @@ -454,10 +454,13 @@ def fix_keys(alf_object):

self.frate = round(1 / np.nanmedian(np.diff(self.ttl_times)))

if behavior:
try:
self.trials = alfio.load_file_content(next(alf_path.glob('_ibl_trials.table.*.pqt')))
self.dlc = alfio.load_file_content(next(alf_path.glob(f'_ibl_{self.label}Camera.dlc.*.pqt')))
self.dlc = likelihood_threshold(self.dlc)
self.behavior = True
except ALFObjectNotFound:
self.behavior = False

self.frame_example = vidio.get_video_frames_preload(self.camera_path, np.arange(10, 11), mask=np.s_[:, :, 0])

Expand Down

0 comments on commit b567a3c

Please sign in to comment.