@@ -1376,7 +1376,6 @@ def build_trials(self, sync, chmap, display=False, **kwargs):
1376
1376
'intervals_1' : bpod_event_intervals ['trial_iti' ][:, 0 ],
1377
1377
'goCue_times' : audio_event_intervals ['ready_tone' ][:, 0 ]
1378
1378
})
1379
- n_trials = self .bpod_trials ['intervals' ].shape [0 ]
1380
1379
1381
1380
# Sync the Bpod clock to the DAQ.
1382
1381
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):
1390
1389
# Assigning each event to a trial ensures exactly one event per trial (missing events are NaN)
1391
1390
assign_to_trial = partial (_assign_events_to_trial , fpga_events ['intervals_0' ])
1392
1391
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' ]),
1398
1397
})
1398
+ out .update ({k : trials [k ][ifpga ] for k in trials .keys ()})
1399
1399
1400
1400
# 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 ])
1402
1402
if np .any (to_correct ):
1403
1403
_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 ])
1406
1406
if np .any (to_correct ):
1407
1407
_logger .debug (
1408
1408
'%i/%i stim off events occurring outside trial intervals; using stim off times as trial end' ,
1409
1409
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 ]
1413
1411
1414
1412
if display : # pragma: no cover
1415
1413
width = 0.5
0 commit comments