redefinetrial#
- syncopy.redefinetrial(data_obj, trials=None, minlength=None, offset=None, toilim=None, begsample=None, endsample=None, trl=None)[source]#
This function allows you to adjust the time axis of your data, i.e. to change from stimulus-locked to response-locked. Furthermore, it allows you to select a time window of interest, or to resegment your long trials into shorter fragments.
The parameters listed below can be provided as is or a via a cfg configuration ‘structure’, see Notes for details.
- Parameters:
data_obj (Syncopy data object (
BaseData
-like)) –trials (list or ndarray) – List of integers representing trial numbers to be selected
minlength (float or str) – Minimum length of trials in seconds, can be ‘maxperlen’. Trials which are shorter get thrown out.
toilim ([begin, end]) – specify latency window in seconds, to cut out a time window of interest from each trial.
offset (int or Mx1 ndarray) – Realign the time axes of all trials to a new reference time point (i.e. change the definition of t=0). Expressed in samples relative to current t=0.
begsample (int or Mx1 ndarray of ints) – Specify the begin sample for each trial (see also endsample). Expressed in samples relative to the start of the input trial.
endsample (int or Mx1 ndarray of ints) – Specify the end sample for each trial (see also begsample). Expressed in samples relative to the start of the input trial.
trl (Mx3 ndarray) – New trial definition. [start, stop, trigger_offset] sample indices for M trials
- Returns:
ret_obj
- Return type:
Syncopy data object (
BaseData
-like))
Notes
This function can be either called providing its input arguments directly or via a cfg configuration ‘structure’. For instance, the following function calls are equivalent
>>> spy.redefinetrial(data_obj, trials=...) >>> cfg = spy.StructDict() >>> cfg.trials = ... >>> spy.redefinetrial(cfg, data_obj) >>> cfg.data_obj = data_obj >>> spy.redefinetrial(cfg)
Please refer to Syncopy for FieldTrip Users for further details.
This is a compatibility function, mimicking
ft_redefinetrial
. However, if selected sample ranges (viatoilim
ortrl
) are (partially) outside of the available data, an error is thrown. This is different to FieldTrips’ implementation, where missing data is filled up with NaNs.See also
- definetrial
definetrial()
Manipulate the trial definition
- selectdata
selectdata()
Select along general attributes like channel, frequency, etc.
FieldTrip’s redefinetrial <https://https://github.com/fieldtrip/fieldtrip/blob/master/ft_redefinetrial.m>