@@ -1376,7 +1376,6 @@ def build_trials(self, sync, chmap, display=False, **kwargs):
13761376 'intervals_1' : bpod_event_intervals ['trial_iti' ][:, 0 ],
13771377 'goCue_times' : audio_event_intervals ['ready_tone' ][:, 0 ]
13781378 })
1379- n_trials = self .bpod_trials ['intervals' ].shape [0 ]
13801379
13811380 # Sync the Bpod clock to the DAQ.
13821381 self .bpod2fpga , drift_ppm , ibpod , ifpga = self .sync_bpod_clock (self .bpod_trials , fpga_events , self .sync_field )
@@ -1390,26 +1389,25 @@ def build_trials(self, sync, chmap, display=False, **kwargs):
13901389 # Assigning each event to a trial ensures exactly one event per trial (missing events are NaN)
13911390 assign_to_trial = partial (_assign_events_to_trial , fpga_events ['intervals_0' ])
13921391 trials = alfio .AlfBunch ({
1393- 'goCue_times' : assign_to_trial (fpga_events ['goCue_times' ], take = 'first' )[: n_trials ] ,
1394- 'feedback_times' : assign_to_trial (fpga_events ['feedback_times' ])[: n_trials ] ,
1395- 'stimCenter_times' : assign_to_trial (self .frame2ttl ['times' ], take = - 2 )[: n_trials ] ,
1396- 'stimOn_times' : assign_to_trial (self .frame2ttl ['times' ], take = 'first' )[: n_trials ] ,
1397- 'stimOff_times' : assign_to_trial (self .frame2ttl ['times' ])[: n_trials ] ,
1392+ 'goCue_times' : assign_to_trial (fpga_events ['goCue_times' ], take = 'first' ),
1393+ 'feedback_times' : assign_to_trial (fpga_events ['feedback_times' ]),
1394+ 'stimCenter_times' : assign_to_trial (self .frame2ttl ['times' ], take = - 2 ),
1395+ 'stimOn_times' : assign_to_trial (self .frame2ttl ['times' ], take = 'first' ),
1396+ 'stimOff_times' : assign_to_trial (self .frame2ttl ['times' ]),
13981397 })
1398+ out .update ({k : trials [k ][ifpga ] for k in trials .keys ()})
13991399
14001400 # If stim on occurs before trial end, use stim on time. Likewise for trial end and stim off
1401- to_correct = ~ np .isnan (trials ['stimOn_times' ]) & (trials ['stimOn_times' ] < out ['intervals' ][:, 0 ])
1401+ to_correct = ~ np .isnan (out ['stimOn_times' ]) & (out ['stimOn_times' ] < out ['intervals' ][:, 0 ])
14021402 if np .any (to_correct ):
14031403 _logger .warning ('%i/%i stim on events occurring outside trial intervals' , sum (to_correct ), len (to_correct ))
1404- out ['intervals' ][to_correct , 0 ] = trials ['stimOn_times' ][to_correct ]
1405- to_correct = ~ np .isnan (trials ['stimOff_times' ]) & (trials ['stimOff_times' ] > out ['intervals' ][:, 1 ])
1404+ out ['intervals' ][to_correct , 0 ] = out ['stimOn_times' ][to_correct ]
1405+ to_correct = ~ np .isnan (out ['stimOff_times' ]) & (out ['stimOff_times' ] > out ['intervals' ][:, 1 ])
14061406 if np .any (to_correct ):
14071407 _logger .debug (
14081408 '%i/%i stim off events occurring outside trial intervals; using stim off times as trial end' ,
14091409 sum (to_correct ), len (to_correct ))
1410- out ['intervals' ][to_correct , 1 ] = trials ['stimOff_times' ][to_correct ]
1411-
1412- out .update ({k : trials [k ][ifpga ] for k in trials .keys ()})
1410+ out ['intervals' ][to_correct , 1 ] = out ['stimOff_times' ][to_correct ]
14131411
14141412 if display : # pragma: no cover
14151413 width = 0.5
0 commit comments