Skip to content

Commit

Permalink
camera recording for passive and ephys choice world in local and remote
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Winter committed Jul 6, 2023
1 parent b8dc796 commit e32df5d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion iblrig/base_choice_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ def get_state_machine_trial(self, i):
sma.add_state(
state_name="trial_start",
state_timer=0,
state_change_conditions={"Port1In": "delay_initiation"},
# state_change_conditions={"Port1In": "delay_initiation"},
state_change_conditions={"Tup": "delay_initiation"},
output_actions=[("SoftCode", 3), ("BNC1", 255)],
) # start camera
sma.add_state(
Expand Down
10 changes: 6 additions & 4 deletions iblrig/base_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def stop_mixin_bonsai_recordings(self):
def start_mixin_bonsai_microphone(self):
# the camera workflow on the behaviour computer already contains the microphone recording
# so the device camera workflow and the microphone one are exclusive
if self._camera_mixin_bonsai_get_workflow_file(self.hardware_settings.device_cameras) is not None:
if self._camera_mixin_bonsai_get_workflow_file(self.hardware_settings.get('device_cameras', None)) is not None:
return
if not self.task_params.RECORD_SOUND:
return
Expand Down Expand Up @@ -491,7 +491,8 @@ def start_mixin_bonsai_cameras(self):
This prepares the cameras by starting the pipeline that aligns the camera focus with the
desired borders of rig features, the actual triggering of the cameras is done in the trigger_bonsai_cameras method.
"""
if self._camera_mixin_bonsai_get_workflow_file(self.hardware_settings.device_cameras) is None:

if self._camera_mixin_bonsai_get_workflow_file(self.hardware_settings.get('device_cameras', None)) is None:
return

bonsai_camera_file = self.paths.IBLRIG_FOLDER.joinpath('devices', 'camera_setup', 'setup_video.bonsai')
Expand All @@ -503,9 +504,10 @@ def start_mixin_bonsai_cameras(self):
log.info("Bonsai cameras setup module loaded: OK")

def trigger_bonsai_cameras(self):
workflow_file = self._camera_mixin_bonsai_get_workflow_file(self.hardware_settings.device_cameras)
workflow_file = self._camera_mixin_bonsai_get_workflow_file(self.hardware_settings.get('device_cameras', None))
if workflow_file is None:
return
log.info("attempt to launch Bonsai camera recording")
workflow_file = self.paths.IBLRIG_FOLDER.joinpath(*workflow_file.split('/'))
cmd = [
str(self.paths.BONSAI),
Expand All @@ -517,7 +519,7 @@ def trigger_bonsai_cameras(self):
f"-p:RecordSound={self.task_params.RECORD_SOUND}",
"--no-boot",
]
log.info('starting Bonsai camera recording')
log.info('Bonsai camera recording process started')
log.info(' '.join(cmd))
subprocess.Popen(cmd, cwd=workflow_file.parent)

Expand Down
3 changes: 2 additions & 1 deletion iblrig_tasks/_iblrig_tasks_passiveChoiceWorld/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def _run(self):
This is the method that runs the task with the actual state machine
:return:
"""
log.info("Starting passive protocol")
self.trigger_bonsai_cameras()
log.info("Starting spontaneous activity followed by receptive field mapping")
# Run the passive part i.e. spontaneous activity and RFMapping stim
self.run_passive_visual_stim(sa_time="00:10:00")
# Then run the replay of task events: V for valve, T for tone, N for noise, G for gratings
Expand Down
3 changes: 1 addition & 2 deletions settings/hardware_settings_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ device_valve:
WATER_CALIBRATION_OPEN_TIMES: [50, 100]
WATER_CALIBRATION_RANGE: [40, 140]
WATER_CALIBRATION_WEIGHT_PERDROP: [1.25, 2.75]
# set to null if a dedicated computer runs bonsai video acquisition
device_cameras:
device_cameras: # remove the whole section if no camera is used on the rig
left:
BONSAI_WORKFLOW: devices/camera_recordings/TrainingRig_SaveVideo_TrainingTasks.bonsai
VERSION: 1.0.0

0 comments on commit e32df5d

Please sign in to comment.