plotting clusters
Robert Oostenveld
r.oostenveld at FCDONDERS.RU.NL
Tue Mar 25 13:16:00 CET 2008
Hi Andrew,
There is a clusterplot function included with fieldtrip. See http://
www2.ru.nl/fcdonders/fieldtrip/doku.php?
id=fieldtrip:documentation:tutorial:plotting#plotting_clusters
You could compare your figures to the ones from clusterplot. Note
that it may very well be possible that the significant clusters in
your data are very large, up to the point that most channels in a
timeframe of interest are significant. E.g. think of a large ERP
component, which is visible on many channels (depending on the choise
of reference). But that is something that I would not neccessarily
expect in the case of whole-head MEG.
best regards,
Robert
On 19 Mar 2008, at 16:28, Andrew Smart wrote:
> Hi,
>
> We have made a plotting function for the clutster analysis, but
> sometimes
> we get very weird results. For example in one dataset for a certain
> time
> period the whole head (i.e., all the sensors) belongs to a significant
> cluster.
>
> I have attached the m-file that we use. All of the calls to the
> preprocessing and stat functions have been made, so this function just
> takes the data and the output of those functions and plots the
> significant
> clusters.
>
> Is there anything that we are missing or have done to make the
> plots output
> something different than intended?
>
> Thank you!
> andy
>
> ----------------------------------
> The aim of this list is to facilitate the discussion between users
> of the FieldTrip toolbox, to share experiences and to discuss new
> ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/
> archives/fieldtrip.html and http://www.ru.nl/fcdonders/fieldtrip.
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> % The plotting function for FieldTrip data
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> function fieldtrip_plots(ft_args)
>
> % Try to clear
> save('TempArgs.mat', 'ft_args');
> clear all;
> load('TempArgs.mat');
>
> % Grab these
> fprintf('Loading Stats...\n');
> sFile = '';
> try
> sFile = ft_args.statsFile;
> catch
> sFile = [ft_args.experimentName 'Stats.mat'];
> end
> fprintf('Using %s\n', sFile);
> load(sFile);
>
> % Load the data
> try
> dFile1 = ft_args.gAvgFile1;
> catch
> dFile1 = [ft_args.experimentName 'GrandAvgData1.mat'];
> end
> try
> dFile2 = ft_args.gAvgFile2;
> catch
> dFile2 = [ft_args.experimentName 'GrandAvgData2.mat'];
> end
>
> % Load the first
> fprintf('Loading Avg1...\n');
> fprintf('Using %s\n', dFile1);
> load(dFile1);
> grandAvg = grandAvgData;
>
> % Load the second
> fprintf('Loading Avg2...\n');
> fprintf('Using %s\n', dFile2);
> load(dFile2);
> grandAvg.avg = grandAvg.avg - grandAvgData.avg;
>
> fprintf('Plotting...\n');
>
> % Sorry... Feel free to fix
> %fprintf('Sorry, plotting down for now. Feel free to fix it at
> your leisure.\n');
> %return;
>
> % TTest
> % Find the significant clusters
> sigClusters = {};
> for i = 1:length(stats.posclusters)
> if stats.posclusters(i).prob < ft_args.alpha
>
> % Find the column and row corresponding to that cluster
> [m,n] = find(stats.posclusterslabelmat == i);
> sigClusters{length(sigClusters)+1} = [m,n];
> else
> break;
> end
> end
>
> % And do the same for negative clusters
> for i = 1:length(stats.negclusters)
> if stats.negclusters(i).prob < ft_args.alpha
> [m,n] = find(stats.negclusterslabelmat == i);
> sigClusters{length(sigClusters)+1} = [m,n];
> else
> break;
> end
> end
>
> if isempty(sigClusters)
> fprintf('Sorry, no significant clusters. Exiting...\n');
> return;
> end
>
> % Get how long each sample is
> secPerSample = (ft_args.stats_epoch(2) - ft_args.stats_epoch(1)) / ...
> size(stats.posclusterslabelmat,2);
>
> % And plot each significant cluster
> numPlots = length(sigClusters);
> for k = 1:numPlots
>
> % Layout the plots
> subplot(ceil(sqrt(numPlots)), ceil(sqrt(numPlots)),k);
>
> % Get the bounds of this plot
> currCluster = sigClusters{k};
>
> % Setup the config argument for plotting
> cfg = [];
>
> % This should be the bounds in seconds
> cfg.xlim = [ft_args.stats_epoch(1) + secPerSample*currCluster
> (1,2) ...
> ft_args.stats_epoch(1) + secPerSample*currCluster(length
> (currCluster),2)];
>
> % Have to have the user set for now, because not sure
> % how to grab from the raw data yet.
> cfg.zlim = ft_args.plotScale;
> cfg.layout='CTF275.lay';
>
> % Want to highlight all the sensors in the
> % significant cluster
> % TODO: Figure out how to interpret clusters
> clusterTimePoints = currCluster(length(currCluster),2) -
> currCluster(1,2);
> sigLimit = ceil(0*clusterTimePoints);
> cfg.highlight = [];
> for j = 1:size(stats.posclusterslabelmat,1)
> if (length(find(currCluster(:,1) == j)) > sigLimit)
> cfg.highlight(size(cfg.highlight)+1) = j;
> end
> end
>
> cfg.comment = 'xlim';
> cfg.commentpos = 'title';
>
> % And plot it
> topoplotER(cfg, grandAvg);
> end
>
> % Done with these
> clear all;
>
>
> ----------------------------------
> The aim of this list is to facilitate the discussion between users
> of the FieldTrip toolbox, to share experiences and to discuss new
> ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/
> archives/fieldtrip.html and http://www.ru.nl/fcdonders/fieldtrip.
----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/fcdonders/fieldtrip.
More information about the fieldtrip
mailing list