NeuralAnalysis / PyalData

Repository for the Python implementation of the TrialData analysis library.
GNU General Public License v3.0
7 stars 9 forks source link

Restrict to epoch using an "epoch function" #76

Closed bagibence closed 3 years ago

bagibence commented 3 years ago

Added an epoch_fun argument to restrict_to_interval and made start_point_name optional.

We've already generated a function from the arguments and passed that internally in utils.extract_interval_from_signal. Now the user has the option to pass their function to restrict_to_interval directly. This is necessary in cases where the idx_ fields store arrays instead of single indices (because there are multiple reaches in a trial) and one can do things like:

def after_go_cue(trial, i):
    return slice(trial.idx_go_cue[i], trial.idx_go_cue[i]+50)

first_reach_td = restrict_to_interval(df, epoch_fun = lambda trial: after_go_cue(trial, 0))
bagibence commented 3 years ago

Builds on #74