aolabNeuro / aolabNeuro/analyze

timestamps2trials

Aperta
#271 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Python
Stelle
7
Fork
0
Merge medio
22h 29m
PR unite (30g)
2

Descrizione

useful function to find the trial number in which an event occured:
```
def timestamps2trials(timestamps, events, event_times, start_events, end_events):
'''
Converts timestamps into integer trial numbers during which they occurred

Args:
timestamps (nts): floating point timestamps to convert
events (nevents): events vector, can be codes, event names, anything to match
event_times (nevents): time of events in 'events'
start_events (int, str, or list, optional): set of start events to match
end_events (int, str, or list, optional): set of end events to match

Returns:
nts: integer trial numbers during which the timestamps occurred
'''

# Get event time information
_, times = aopy.preproc.get_trial_segments(events, event_times, start_events, end_events)
trials = []
for t in timestamps:
ts = np.where(times[:,0] > t)[0]
if len(ts) > 0:
trials.append(ts[0])
else:
trials.append(len(times))
return np.array(trials)
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.