PhysioLabXR / PhysioLabXR-Community

GNU General Public License v3.0
31 stars 13 forks source link

Question: Parameter explanation tmin at physiolabxr/scripting/physio/epochs.py: get_event_locked_data #137

Closed UdaiLaith closed 4 months ago

UdaiLaith commented 4 months ago

Dear all,

Firstly, awesome framework you all came up with. In the past few days I was trying to understand some functions. Could someone explain to me if the value for tmin needs to be positive or negative in: physiolabxr/scripting/physio/epochs.py:

def get_event_locked_data(event_marker, data, events_of_interest, tmin, tmax, srate, return_last_event_time=False, event_channel=0, verbose=None, **kwargs):
    """
    this function is used to get event locked data from a single modality or multiple modalities

    @param event_marker: tuple of event marker and its timestamps
    @param data: tuple of data and its timestamps, can be a dictionary of multiple modalities
    @param events_of_interest: iterable of event markers with which to get event aligned data
    @param tmin: time before event marker to include in the epoch
    @param tmax: time after event marker to include in the epoch
    @param srate: sampling rate of the datar
    @param reject: int, reject the epoch with peak-to-peak amplitude greater than this value
    @param return_last_event_time: whether to return the time of the last found in the data
    @param verbose: whether to print out the number of events found for each event marker

The comment says it's the time before an event marker to include. In the motor imaginary example I've seen a positive value and in the ERP example I've seen negative values. If I look at the variable:

epoch_length = int((tmax - tmin) * srate)

A negative value would mean we are including the time before the epoch. Is that correct? And if so, why are we taking a positive tmin value in the motor imaginary example? Is it because we do not want to have the initial concentration phase?

Thank you in advance.

BR Udai

ApocalyVec commented 4 months ago

Hey BR Udai,

Thank you for your interest in PhysioLabXR!

To answer your question, yes tmin can be negative, and if it's negative. The start of the epoch is before the event marker.

You are right. For motor imagery, when the event marker signals the initial concentration, it makes more sense to use a positive value when the desynchronization actually kicks in.

On the other hand, for ERP, we take the 0.1 second before the epoch to perform baselining for the epoch.

I just updated the docstring to make it more information. Check it out.

Hope it helps :)

UdaiLaith commented 4 months ago

Dear ApocalyVec

Thank you very much, for answering and clarifying. Also, thank you for updating the docstring.

Helps a lot.

Cheers, Udai