Closed AJQuinn closed 3 years ago
@AJQuinn thanks this is a good use case. I have fed MNE epochs to fitgrid along these lines with a modicum of dataframe wrangling.
Far as I can see, there's not much wrong, your df
dataframe looks fine.
fitgrid wants to slurp a dataframe already row-indexed for time and epoch for efficient slicing.
When MNE dumps mne.Epochs D
to the pandas.DataFrame df
it puts index-like information in the df["epoch", "time"]
columns but not in the index itself which is the default row index 0 .. 88233 as you see on the left.
So I think one line of set_index()
to convert the columns to a (Multi)Index should make fitgrid happy except swap epoch
for condition
which I'm guessing is a categorical variable not a single-trial epoch index.
df = D.to_data_frame()
df.set_index(['time', 'epoch'], inplace=True)
epochs = fitgrid.epochs_from_dataframe(df, 'time', 'epoch', ep.info['ch_names'])
This is along the lines of the v0.5.0 Quickstart step 2. which also starts with a row-indexed dataframe and the time and epoch info in the columns and does the set_index()
trick.
p3_df.set_index(['epoch_id', 'time_ms'], inplace=True)
p3_epochs_fg = fg.epochs_from_dataframe(
p3_df,
epoch_id='epoch_id',
time='time_ms',
channels=['MiPf', 'MiCe', 'MiPa', 'MiOc'],
)
Great, this is working. Thank you!
Hello - I'm having trouble loading some data into fitgrid via the dataframe option. I have some epoched data in MNE-python Epochs format which I've transformed to a pandas data frame and am trying to load into fitgrid with
The dataframe seems to contain the expected information, including the time and conditions columns
However, I'm getting the following traceback from
fitgrid.epochs_from_dataframe
Not sure what I've got wrong, perhaps the dataframe is not properly formatted? I'm running fitgrid version 0.5.0 in python 3.7.
Cheers