Hi Mike and all,
I have a question about if there is an easy way to extract cluster sizes from a topographic map?
For more details we learned from the ‘multiple comparisons and their corrections’ lecture that for time-frequency data we can use bwconncomp from the image processing tool box to extract cluster sizes, but seems that requires the input of a time-frequency matrix. Now I have a vector of t values for my 64 channels, and channel locations from EEGLAB. I want to select clusters of electrodes with a size larger than chance (determined by 1000 permutations). Is there an easy way to extract cluster sizes from a topographic map?
Thanks so much!!
Hi Mengsi. The easiest way to do this is to use the second output of the topoplot function to obtain the 64x64 matrix of spatially interpolated values. You can run statistics on that map similar to how you would treat a time-frequency plot.
Thanks so much for getting back to me! I tried this with the following code.
% compute cluster size in the raw data
[~, topomap_raw, ~, ~, ~] = topoplot(MI_lm_t_avrSub, EEG.chanlocs); % MI_lm_t_avrSub is my t-value vector
islands_raw = bwconncomp(topomap_raw);
clustsizes = cellfun(@length, islands_raw.PixelIdxList);
topomap_raw turned out to be a 67x67 matrix with off-head points as NaNs. And seems bwconncomp detected the whole image as one cluster, as islands_raw.PixelIdxList contains a single cell of 4489 (=67x67). However, my topoplot is as below. It does look like I should get multiple islands from it?
Am I doing this correctly? The results confused me.
Many thanks again!
Ah I see. So bwconncomp can only be used on thresholded images such that zeros are used to isolate islands.
Yes, exactly. You would first threshold that map, then apply bwconncomp to extract the clusters. Basically the same as a TF map.
Thanks for all your help again if you don’t mind me asking a follow-up question.
So I could:
- get the 2D topo map matrix for the raw data and all permutations first and do thresholding;
- or I could do thresholding on the raw channel-value vectors, and then get a topo matrix with this thresholded vector.
The two methods gave me different results. I think the first way is correct? But I’m not quite sure what’s the problem with the second. Sorry if this is a naive question I’m still learning a lot!
Hi Mengsi. You want to go with option #1. The issue with #2 is that thresholding is a nonlinear operation while the interpolation is linear. So, first you would interpolate over space to get the topomap matrix, then do the permutations/thresholding.
That makes total sense! Many thanks again.