Here is the extracting epochs step, adapted to my project. I have marked what I think I need to add, and what I don’t need (marked with ***). I have done most of the steps when calculating individual TFRs before doing the grand average. Do I have to run this separate from the process I used to calculate grand average? I noticed some differences from the grand average pathway: for example, there is tfr_epochs = epochs.compute_tfr( instead of mne.time_frequency.tfr_morlet( and there is logratio baseline instead of percentage. Please take a look and let me know anything I need to change:
#already have with loading EEG datasets, no need to add
data_path = sample.data_path()
meg_path = data_path / “MEG” / “sample”
raw_fname = meg_path / “sample_audvis_raw.fif” # did this with EDF
tmin, tmax, event_id = -0.3, 0.6, 1
raw = mne.io.read_raw_fif(raw_fname)
events = mne.find_events(raw, stim_channel=“STI 014”)
#don’t need
***include = []
raw.info[“bads”] += [“MEG 2443”, “EEG 053”] # bads + 2 more***
#don’t need
*** for speed, we’ll only look at right-temporal gradiometers (and EOG)
picks_eog = mne.pick_types(raw.info, eog=True)
picks_grad = mne.pick_types(raw.info, meg=“grad”, exclude=“bads”)
picks_rtemp = mne.pick_channels(
raw.info[“ch_names”], mne.read_vectorview_selection(“Right-temporal”), ordered=True
)
picks = list((set(picks_rtemp) & set(picks_grad)) | set(picks_eog))***
# Load condition 1
event_id = 1
epochs = mne.Epochs(
raw,
events,
event_id,
tmin,
tmax,
picks=picks,
baseline=(None, 0),
preload=True,
***reject=dict(grad=4000e-13, eog=150e-6),*** #don’t need
)
#do same with condition 2
evoked = epochs.average()
#do the same with condition 2
freqs = np.arange(8, 40, 2)
#do the same with condition 2
tfr_epochs = epochs.compute_tfr(
“morlet”,
freqs,
n_cycles=4.0,
decim=decim,
average=False,
return_itc=False,
n_jobs=None,
)
#do the same with condition 2```
I already did similar steps as the above code when looping through participants before doing the grand average. I just want to know if I should do it new for statistical test.
tfr_epochs.apply_baseline(mode="logratio", baseline=(-0.100, 0)) - #why are we doing logratio? Do I need to add this?
evoked.crop(-0.1, 0.4)
tfr_epochs.crop(-0.1, 0.4)
#do the same with condition 2
epochs_power = tfr_epochs.data
#do the same with condition 2
power_list_left_mu.append(power_mu_left)
power_list_right_mu.append(power_mu_right)```