Combining two lists of epochs with different time-windows

  • MNE version: e.g. 1.3.1
  • operating system: e.g. Ubuntu 18.04

Hello there,

I am currently analyzing the data from an MEG experiment. I have two datasets with 38 participants each. Both datasets are already preprocessed pandas dataframes. I have the information about how the data was originally epoched and the underlying montage, so I am able to “re-epoch” the dataframes,respectively. This gives me two lists of epochs, where each element in one list corresponds to one participants, so both lists have the length 38.

One list corresponds to the re-epoched data from dataframe 1, the other to re-epoched data from dataframe 2.

I would now like to fit my predictor variables to this data. To this end, I would usually create my design matrices (per participant) and then fit one linear regression model per participant.

For my current analysis, I am also interested in the interaction between these two datasets. So my original idea was to create one grouping factor (dummy variable) per dataset, concatenate the two list of epochs, concatenate the design matrices per dataset, and then run the linear regression.

The problem I am facing is that the times in datasets 1 and datasets 2 vary: While the frequency is the same, dataset 1 has earlier timeframes than dataset 2. To my understanding, this does makes it impossible for me to concatenate the two list of epochs using mne.concatenate_epochs().

I suspect that I could concatenate the dataframes by re-coding the times of dataset 1 to match the times of dataset 2. However, ultimately I am interested in running a time-spatio-cluster analysis, using the obtained beta coefficients from the linear regression analysis. I believe that it would be unwise to artifically recoding time points for this analysis.

Is there any way I could analyze the interaction between these two dataframes using the mne.linear_regression() function? I am aiming to model the following equation:

activity ~ Intercept + Groupingvariable (so 1s for dataset 1 and 0s for dataset2) + predictor 1 + predictor 1 * Groupingvariable

I hope that I made my question clear. If there are any questions, I am more than happy to provide more information.

The long story short: I have two lists of epochs which corresponds to two different dataframes with varying time windows (but same frequencies). I would like to run a linear regression on the combined dataset.

I did try to concatenate the two pandas datasets before creating the epochs, but here, I have the same problems: The information about the different time-windows gets lost, once I re-epoch. Thats why I decided to re-epoch per dataframe, and not across dataframes.

I appreciate any help.

All the best and many thanks in advance.

In order for the linear regression to work across both datasets, we need to align their timestamps somehow. In this case, I do believe your best option is to create temporary “fake” timestamps such that both datasets have the same .times attribute. After you’ve run mne.linear_regression, you can change the timestamps of the result back to match either dataset 1 or dataset 2.

Hello there,

thank you for your reply! I think that is a good idea, and I did end-up going with that approach.

Best