NeuroKit
NeuroKit copied to clipboard
epochs_start param of function epochs_create() unable to take in a list
My events is a dict of n events: {'onset':[.......n], 'duration':[.......n], 'condition':[.......n], 'label': [.......n]}
When trying to supply a list of length n for epochs_start
parameter to the function epochs_create(...)
,
I get the following error:
File ~/opt/miniconda3/envs/heartbrain/lib/python3.9/site-packages/neurokit2/epochs/epochs_create.py:157, in epochs_create(data, events, sampling_rate, epochs_start, epochs_end, event_labels, event_conditions, baseline_correction) 155 # Find the maximum numbers of samples in an epoch 156 parameters["duration"] = list(np.array(parameters["end"]) - np.array(parameters["start"])) --> 157 epoch_max_duration = int(max((i * sampling_rate for i in parameters["duration"]))) 159 # Extend data by the max samples in epochs * NaN (to prevent non-complete data) 160 length_buffer = epoch_max_duration
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
It however works with a single number input for epochs_start, for example: epochs_start = 0.7 works but epochs_start = [-0.3,0.2,0.1, 0.4, ..... n values] gives the above error. What should I do?
epochs_end also works with a single number input but not with a list as specified in this documentation page
System Specifications
- OS: Darwin ( 64bit)
- Python: 3.9.12
- NeuroKit2: 0.2.7
- NumPy: 1.24.3
- Pandas: 1.5.3
- SciPy: 1.9.1
- sklearn: 1.1.1
- matplotlib: 3.4.3
I would be really helpful to resolve this as it's an important function parameter, thanks a lot in advance!