Welcome to fieldtrip2mne’s documentation!

fieldtrip2mne.read_raw(ft_structure_path, data_name='data')[source]

This function extracts FieldTrip single trial raw data structures (FT_DATATYPE_RAW) from .mat files and converts them to MNE RawArrays.

Parameters:
  • ft_structure_path (str) – Path and filename of the .mat file containing the data.
  • data_name (str, optional) – Name of heading dict/ variable name under which the data was originally saved in MATLAB. Default is ‘data’.
Returns:

A MNE RawArray structure consisting of the raw array and measurement info

Return type:

mne.io.RawArray

Examples

>>> read_raw("/home/usr/Documents/FieldTripRawFile.mat")
<RawArray  |  None, n_channels x n_times : 402 x 60001 (60.0 sec), ~185.0 MB, data loaded>
>>> read_raw("FieldTripRawFile2.mat", data_name="rawdata")
<RawArray  |  None, n_channels x n_times : 323 x 35001 (35.0 sec), ~117.0 MB, data loaded>
fieldtrip2mne.read_epoched(ft_structure_path, data_name='data', trialinfo_map=None, omit_trialinfo_index=True, omit_non_unique_trialinfo_index=True)[source]

This function extracts FieldTrip multiple trial raw data structures (FT_DATATYPE_RAW) from .mat files and converts them to MNE EpochsArrays.

Warning

Only epochs with the same amount of channels and samples are supported!

The data is read as it is. Events however are represented entirely different in FieldTrip compared to MNE.

In FieldTrip, each epoch corresponds to one row in the trialinfo field. This field can have one or more columns. The function first removes columns according to the two omit parameters.

  • If only one column remains, its values are used as event values in the MNE Epoch.
  • If two or more columns remain, each unique combination of these values receives a new event value. These event values are created automatically. In order to match these to conditions, you can use the trialinfo_map parameter.
Parameters:
  • ft_structure_path (str) – Path and filename of the .mat file containing the data.
  • data_name (str, optional) – Name of heading dict/ variable name under which the data was originally saved in MATLAB. Default is ‘data’.
  • trialinfo_map (dict, optional) – A dictionary mapping condition strings (MNE’s event_ids) to the trialinfo column. The values should be 1D numpy arrays. See examples for details.
  • omit_trialinfo_index (bool, optional) – Omit trialinfo columns that look like an index of the trials, i.e. in which every row is the row before + 1.
  • omit_non_unique_trialinfo_index (bool, optional) – Omit trialinfo columns that contain a different value for each row. These are most likely additional data like reaction times that cannot be represented in MNE.
Returns:

A MNE EpochsArray structure consisting of the epochs arrays, an event matrix, start time before event (if possible, else defaults to 0) and measurement info.

Return type:

mne.EpochsArray

Examples

>>> read_epoched("/home/usr/Documents/FieldTripEpochsFile.mat")
<EpochsArray  |  n_events : 123 (all good), tmin : -1.0 (s), tmax : 2.99 (s), baseline : None, ~115.7 MB, data loaded,
'1': 21, '2': 9, '3': 12, '4': 22, '5': 20, '6': 7, '7': 9, '8': 23>
>>> read_epoched("FieldTripEpochsFile2.mat", data_name="epoched")
<EpochsArray  |  n_events : 10 (all good), tmin : -0.1 (s), tmax : 0.5 (s), baseline : None, ~87.5 MB, data loaded,
'1': 5, '2': 5>
>>> read_epoched('FieldTripEpochsFile', trialinfo_map={
>>>    'audio/attend': numpy.array([0, 1]),
>>>    'visual/attend': numpy.array([1, 1]),
>>>    'audio/non_attend': numpy.array([0, 0]),
>>>    'visual/non_attend': numpy.array([1, 0])})
fieldtrip2mne.read_avg(ft_structure_path, condition='unspecified condition', data_name='data')[source]

This function extracts FieldTrip timelock data structures (FT_DATATYPE_TIMELOCK) from .mat files and converts them to MNE EvokedArrays.

Parameters:
  • ft_structure_path (str) – Path and filename of the .mat file containing the data.
  • condition (str, optional) – Name or comment on the evoked condition. Default is ‘unspecified condition’
  • data_name (str, optional) – Name of heading dict/ variable name under which the data was originally saved in MATLAB. Default is ‘data’.
Returns:

A MNE EvokedArray structure consisting of the averaged data array,

comment or condition and measurement info.

Return type:

mne.EvokedArray

Examples

>>> read_avg("/home/usr/Documents/FieldTripTimelockFile.mat")
<Evoked  |  comment : 'unspecified condition', kind : average, time : [0.000000, 3.990000], n_epochs : 1, n_channels x n_times : 306 x 400, ~1.7 MB>
>>> read_avg("FieldTripTimelockFile2.mat", data_name="evoked")
<Evoked  |  comment : 'unspecified condition', kind : average, time : [0.000000, 2.490000], n_epochs : 1, n_channels x n_times : 306 x 250, ~1.1 MB>
>>> read_avg("FieldTripTimelockFile.mat", condition= "visual stimulus")
<Evoked  |  comment : 'visual stimulus', kind : average, time : [0.000000, 3.990000], n_epochs : 1, n_channels x n_times : 306 x 400, ~1.7 MB>