|
| 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 |
0 commit comments