Hello everyone!
Earlier in the forum, someone asked about working with data on sources with different numbers of averaged epochs per CONDITION. Here is the past discussion. here, here and here.
I have a related issue with SUBJECTS having different numbers of epochs.
[The example below is for a single subject, but let us imagine that these are different subjects]
‘Subject A’ has 453 epochs and ‘subject B’ has 905 epochs. At sensors, the evoked responses have similar amplitude (fig).
However, while solving the inverse problem, MNE-Python scales stc amplitudes proportionally to ‘nave’. As a result, in the source space, B>A (fig), which means that we see a difference that is not really there.
Questions:
-
Is it possible to somehow normalize the stc amplitudes for the number of averages in order to perform group comparison (we have different numbers of averages in different groups)? If yes, what would be the best way to do so?
-
Can I use evoked.nave=1 to offset the effect of the inverse problem of having different numbers of averages in subjects A and B?
best regards
Kirill
import mne
import numpy as np
import matplotlib.pyplot as plt
subjects_dir = ‘/freesurfer/’
subject = ‘F001’
lambda2 = 1. / 3 ** 2
method = 'sLORETA'
inv = mne.minimum_norm.read_inverse_operator(myinv+'-inv.fif')
src = mne.setup_source_space(subject, spacing=spacing, subjects_dir=subjects_dir, add_dist=False)
lh_label = mne.read_label(mylabel + '-lh.label')
rh_label = mne.read_label(mylabel + '-rh.label')
epochs = mne.read_epochs(myepochs + '-epo.fif', preload=False)
evoked = epochs.average()
f = mne.viz.plot_compare_evokeds(evoked,
picks="meg",
combine='mean',
title='nave = ' + str(evoked.nave),
legend=False,
ylim = dict(mag=[0, 100],grad=[0, 30]))
epochs_crop = epochs.copy()[::2]
evoked_crop = epochs_crop.average()
f = mne.viz.plot_compare_evokeds(evoked_crop,
picks="meg",
combine='mean',
title='nave = ' + str(evoked_crop.nave),
legend=False,
ylim = dict(mag=[0, 100],grad=[0, 30]))
f, ax = plt.subplots(1,2, figsize=(10,5))
f.suptitle('data from sourses', size=20)
for nhemi, (hemi,label) in enumerate(zip(['left auditory cortex','right auditory cortex'],[lh_label,rh_label])):
for evk in [evoked, evoked_crop]:
stc = mne.minimum_norm.apply_inverse(evk, inverse_operator=inv, method=method, lambda2=lambda2, pick_ori=None)
flip = stc.extract_label_time_course(label, src, mode='mean_flip')[0,:]
if flip[800:1300].mean() > 0:
flip = flip*-1
ax[nhemi].plot(flip, label = 'nave = ' + str(evk.nave))
ax[nhemi].set_title(hemi, size = 15)
ax[nhemi].set_ylabel('Amplitude', fontsize = 15)
ax[nhemi].set_ylim([-35,35])
ax[nhemi].set_xlabel('Time (ms)', fontsize = 15)
ax[nhemi].set_xticks(range(0,1201,200))
ax[nhemi].set_xticklabels(range(-200,1001,200))
ax[nhemi].grid(True)
ax[nhemi].legend()
f.tight_layout()