Skip to content

Commit

Permalink
Only extract periods where laser is on
Browse files Browse the repository at this point in the history
  • Loading branch information
k1o0 committed Mar 6, 2024
1 parent ca0593f commit 2da8f2a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion iblrig_custom_tasks/nate_optoBiasedChoiceWorld/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def extra_parser():
default=DEFAULTS['OPTO_STIM_STATES'],
nargs='+',
type=str,
help=f'list of the state machine states where opto stim should be delivered',
help='list of the state machine states where opto stim should be delivered',
)
return parser

Expand Down
7 changes: 4 additions & 3 deletions projects/nate_optoBiasedChoiceWorld.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ def _extract(self, extractor_classes=None, **kwargs) -> dict:
settings=settings, save=False, task_collection=self.task_collection)

# Extract laser dataset
out['laser_intervals'] = np.full((len(self.bpod_trials), 2), np.nan)
for i, trial in enumerate(self.bpod_trials):
laser_intervals = []
for trial in filter(lambda t: t['opto_stimulation'], self.bpod_trials):
states = trial['behavior_data']['States timestamps']
# Assumes one of these states per trial: takes the timestamp of the first matching state
start = next((v[0][0] for k, v in states.items() if k in settings['OPTO_TTL_STATES']), np.nan)
stop = next((v[0][0] for k, v in states.items() if k in settings['OPTO_STOP_STATES']), np.nan)
out['laser_intervals'][i, :] = (start, stop)
laser_intervals.append((start, stop))
out['laser_intervals'] = np.array(laser_intervals, dtype=np.float64)

return {k: out[k] for k in self.var_names} # Ensures all datasets present and ordered
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "project_extraction"
version = "0.2.0"
version = "0.2.1"
description = "Custom extractors for satellite tasks"
dynamic = [ "readme" ]
keywords = [ "IBL", "neuro-science" ]
Expand Down

0 comments on commit 2da8f2a

Please sign in to comment.