-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GFP vs Cluster #195
Comments
Hello @ivano7777, Thank you for reaching out, In group analysis scenarios, it's not always necessary to compute GFP peaks. Extracting GFP peaks can be done on when preprocessed recordings to select samples with a high signal-to-noise ratio. This approach not only yields smoother maps but also reduces the number of samples needed for K-means clustering, consequently lowering computation times. For instance, in the tutorial group-level-with-individual-clusters, we can bypass the GFP peaks extraction as demonstrated below: individual_cluster_centers = list()
for subject_id in subject_ids:
# Load data
raw_fname = lemon.data_path(subject_id=subject_id, condition=condition)
raw = read_raw_eeglab(raw_fname, preload=True)
raw = lemon.standardize(raw)
raw.pick("eeg")
raw.set_eeg_reference("average")
# Subject level clustering
ModK = ModKMeans(n_clusters=5, random_state=42)
ModK.fit(raw, n_jobs=2)
individual_cluster_centers.append(ModK.cluster_centers_)
# Assemble individual cluster centers
group_cluster_centers = np.vstack(individual_cluster_centers).T
group_cluster_centers = ChData(group_cluster_centers, ModK.info)
# Group level clustering
ModK = ModKMeans(n_clusters=5, random_state=42)
ModK.fit(group_cluster_centers, n_jobs=2)
ModK.plot() In this scenario, individual maps are derived from all samples in your recording, not just the GFP peaks. This approach is more time-consuming but remains a valid method. It's important to note that the definition of GFP differs between EEG and MEG data. Our current implementation of the extract_gfp_peaks function is tailored for EEG data. The formula for MEG is not yet supported (please refer to issue #160 for a more detailled discussion). Given this, I recommend skipping the GFP extraction step for now and using the code snippet provided above for your analysis. I plan to work on implementing GFP peak extraction for MEG data in the coming weeks. Let me know if you need further clarification on any points! |
Thank you for your reply. I understand that the tutorial uses a fitting process involving GFP to determine the cluster center, which was initially confusing to me ( ModK.fit(gfp_peaks, n_jobs=2) ). Based on our recent discussion, the tutorial could be improved by explicitly stating the method used for GFP calculation and considering the potential impact of reference and data type. I'll definitely try your approach. Thanks again for your help. Ivano PS: Regarding the GFP calculation for both MEG and EEG, maybe it might be beneficial to compute the variance around the average. This approach would ensure consistency across different reference systems and recording types. |
Hello,
I tried the tool following the tutorial, but applying it to MEG, instead of EEG (of course modifying a few details). I liked the individual microstates that I computed, after selecting my "meg_good_segments" this way:
epochs = mne.make_fixed_length_epochs(meg_good_segments, duration=2)
#I tried without, results are similar. but don;t use too short epochs.
ModK = ModKMeans(n_clusters=n_microstates, random_state=42)
ModK.fit(epochs, n_jobs=4, picks = 'meg')
ModK.rename_clusters(new_names=["A", "B", "C", "D"])
ModK.plot(show_gradient=True)
Then, always according to the tutorial, for group analysis (whatever we want to use clusters or GFP) we need to compute the individual gfp. I did it, and lookes at the microstates using the gfp, and they are weird.
Questions:
Thanks
The text was updated successfully, but these errors were encountered: