Skip to content

Commit 3f5afc0

Browse files
committed
add FPLR extractors
1 parent 09bd133 commit 3f5afc0

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Bpod extractor for alejandro's FPLOptoChoiceWorld and FPROptoChoiceWorld task.
2+
3+
This is the same as biasedChoiceWorld with the addition of one dataset, `trials.laserStimulation`; The trials which the
4+
laser was on. For th FPLOptoChoiceWorld protocol the laser was on when the stimulus was on the left hand side and for
5+
the FPROptoChoiceWorld protocol the laser was on when the stimulus was on the right hand side of the screen
6+
7+
"""
8+
import numpy as np
9+
from ibllib.io.extractors.base import BaseBpodTrialsExtractor, run_extractor_classes
10+
from ibllib.io.extractors.bpod_trials import BiasedTrials
11+
12+
13+
class TrialsFPLROpto(BaseBpodTrialsExtractor):
14+
var_names = BiasedTrials.var_names + ('laser_stimulation',)
15+
save_names = BiasedTrials.save_names + ('_ibl_trials.laserStimulation.npy',)
16+
17+
def _extract(self, extractor_classes=None, **kwargs) -> dict:
18+
19+
# Extract common biased choice world datasets
20+
out, _ = run_extractor_classes(
21+
[BiasedTrials], session_path=self.session_path, bpod_trials=self.bpod_trials,
22+
settings=self.settings, save=False, task_collection=self.task_collection)
23+
24+
# Extract laser stimulation dataset
25+
laser_stimulation = np.zeros_like(out['table']['contrastLeft'])
26+
if 'FPR' in self.settings['PYBPOD_PROTOCOL']:
27+
laser_stimulation[~np.isnan(out['table']['contrastRight'])] = 1
28+
elif 'FPL' in self.settings['PYBPOD_PROTOCOL']:
29+
laser_stimulation[~np.isnan(out['table']['contrastLeft'])] = 1
30+
31+
out['laser_stimulation'] = laser_stimulation
32+
33+
return {k: out[k] for k in self.var_names} # Ensures all datasets present and ordered

projects/task_extractor_map.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"_iblrig_tasks_neuromodulatorChoiceWorld": "projects.neuromodulators.TrialsTableNeuromodulator",
44
"nate_optoBiasedChoiceWorld": "projects.nate_optoBiasedChoiceWorld.TrialsOpto",
55
"FPChoiceWorld": "BiasedTrials",
6-
"FPROptoChoiceWorld": "BiasedTrials",
7-
"FPLOptoChoiceWorld": "BiasedTrials"
6+
"FPROptoChoiceWorld": "projects.alejandro_FPLROptoChoiceWorld.TrialsFPLROpto",
7+
"FPLOptoChoiceWorld": "projects.alejandro_FPLROptoChoiceWorld.TrialsFPLROpto"
88
}

0 commit comments

Comments
 (0)