Hello,
I’m trying to analyse 3 electrodes of interests along the time of the whole evoked period as I think those electrodes are relevant considering the litterature.
However, I would like to do permutation test rather then a simple one sample t.test to get robust results.
Here is my code:
NeutralCondition = "Stimulus/S 10"
PersonalizedCondition = "Stimulus/S 14"
Conditions = [NeutralCondition, PersonalizedCondition]
CombinedEvokeds = NeutralEvokeds + PersonalizedEvokeds
CombinedEvokeds = [d for Evoked in CombinedEvokeds for d in Evoked]
Evokeds = {}
for Condition in Conditions:
Evokeds[Condition] = []
for Evoked in CombinedEvokeds:
if Condition == Evoked.comment:
Evokeds[Condition].append(Evoked)
continue
else:
continue
ConditionContrasts = []
for i in range(len(Evokeds[NeutralCondition])):
ConditionContrasts.append([mne.combine_evoked([Evokeds[PersonalizedCondition][i], Evokeds[NeutralCondition][i]], weights = [1, -1])])
ConditionContrasts = [d for Contrast in ConditionContrasts for d in Contrast]
Info = ConditionContrasts[0].info
X_AllChannels = [] # X format will be n_subjects arrays. In each arrays, there will be n_channels lists. And in each lists, there will be n_timepoints potential values
for Contrast in ConditionContrasts:
X_AllChannels.append(Contrast.get_data())
# then I have to select the channels I want to study, so I select their indices
ROI = ["AFz", "Fz", "FCz"]
ROIIndex = []
for Channel in ROI:
ROIIndex.append(ConditionContrasts[0].ch_names.index(Channel))
continue
print(ROIIndex)
print(Info)
Ch_Adjacency, Ch_Names = mne.channels.find_ch_adjacency(Info, "eeg")
print(type(Ch_Adjacency))
X_ChannelSelected = []
for Subject in X_AllChannels:
SubjectData = []
for i in ROIIndex:
SubjectData.append(Subject[i])
continue
X_ChannelSelected.append(SubjectData)
continue
X_ChannelSelected = np.array(X_ChannelSelected) # I got a np.array of shape: n_subjects, n_channels, n_timepoints
# now I have to get the good array shape which should be: n_subjects, n_timepoints, n_channels
X_ChannelSelected_GoodShape = np.transpose(X_ChannelSelected, (0, 2, 1))
# now I have parameters for mne.stats.permutation_cluster_1samp_test with X and adjacency
T_Obs, Clusters, Cluster_P_Values, HO = mne.stats.permutation_cluster_1samp_test(
X_ChannelSelected_GoodShape,
n_permutations = 5000,
adjacency = Ch_Adjacency,
seed = 1)
print(Cluster_P_Values)
running this mne.stats.permutation_cluster_1samp_test() function raised the error
ValueError: adjacency (len 64) must be of the correct size, i.e. be equal to or evenly divide the number of tests (10503).
I think itis because of the adjacency.
So here is my question, how could I get the adjacency only for my sensors of interest? And if my question is senseless, could you tell me why and suggest an alternative?
PS: sorry for my poor English…