[FieldTrip] Error in source localisation statistics
Xavier Vrijdag
x.vrijdag at auckland.ac.nz
Wed Feb 20 21:32:50 CET 2019
Hi Jan-Mathijs,
Thank you for your help. I went in to have a look at what is going on inside those loops and found that the error is occurring in iteration 6, when the field source.trial(1).label is concatenated. It uses the indexes for the big data cells (ori, mom & filter) which clearly doesn’t work on the small cell with the labels. This seems to me that this is a bug.
I added a piece of code in front of the loop that was giving the error (before line 177 and make the if and elseif.
if isequal(fn{i}, 'label')
for j=1:nrpt
source_new.label(:,j) = source.trial(j).label;
end
elseif iscell(dat)
This worked to circumvent the problem. However, I do get the warning that the dimord of “ori” and “df” could not be determined. When using this cleaned source struct in source statistics I get further errors.
It looks like an issue with how the source struct is built by the source analysis function with trials, and lateron needs to be restructured. SO I would like to know what is the needed structure for ft_sourcestatistics, so we can adjust the code correctly.
Regards,
Xavier
From: fieldtrip <fieldtrip-bounces at science.ru.nl> on behalf of "Schoffelen, J.M. (Jan Mathijs)" <jan.schoffelen at donders.ru.nl>
Reply-To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Date: Wednesday, 20 February 2019 at 2:59 AM
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] Error in source localisation statistics
Hi Xavier,
My recommendation here would be to use the matlab debugger and inspect the cause of the error. The ‘Index exceeds array bounds’ is quite a clear error message, and suggests that there is a mismatch between the number of elements in dat/val, and the numbers represented in indx(k).
Good luck,
Jan-Mathijs
On 18 Feb 2019, at 07:23, Xavier Vrijdag <x.vrijdag at auckland.ac.nz<mailto:x.vrijdag at auckland.ac.nz>> wrote:
Hello,
I have a dataset from an experiment where 12 participants were exposed to 3 levels of nitrous oxide, while I measured their EEG. I also have a baseline recording. I took for each exposure (and baseline) a 1 minute sample for further analysis. I want to do source localization to better understand which parts of the brain are involved. I don’t have MRI scans of my participants, so I used the standard MRI and BEM. I would like to thanks the persons who made the various manuals and analysis examples on the website, as they helped me tremendously to do this analysis.
After cleaning and preprocessing, I combined the datasets into one for further analysis. I also chose to make 5 sec “trials” for further analysis. For this source analysis I loaded the data of 1 exposure and the baseline data, to compare them.
%Calculate the channel covariance matric
cfg = [];
cfg.covariance = 'yes';
cfg.covariancewindow = 'all';
cfg.keeptrials = 'yes';
timelock = ft_timelockanalysis(cfg, data_filt);
%Global filter
cfg = [];
cfg.headmodel = vol;
cfg.elec = elec_aligned;
cfg.grid = grid;
cfg.method = 'lcmv';
cfg.lcmv.projectnoise='yes'; %needed for neural activity index
cfg.lcmv.fixedori = 'yes'; %Project onto largest variance orientation
cfg.lcmv.keepfilter = 'yes'; %Keep the beamformer weights
cfg.lcmv.lambda = '5%'; %Regularise a little
cfg.rawtrial = 'yes'; % project each single trial through the filter.
cfg.keeptrials = 'yes';
source = ft_sourceanalysis(cfg, timelock);
cfg = [];
cfg.dim = source.dim;
cfg.method = 'montecarlo';
cfg.statistic = 'ft_statfun_indepsamplesT';
cfg.parameter = 'pow';
cfg.correctm = 'cluster';
cfg.numrandomization = 1000;
cfg.alpha = 0.05; % note that this only implies single-sided testing
cfg.tail = 0;
cfg.design(1,:) = [1:nTrials 1:nTrials];
cfg.design(2,:) = [ones(1,nTrials) ones(1,nTrials).*2];
cfg.uvar = 1; % row of design matrix that contains unit variable (in this case: trials)
cfg.ivar = 2; % row of design matrix that contains independent variable (the conditions)
stat = ft_sourcestatistics(cfg, source);
After the source analysis the source statistics script calls the checkdata script and I get the following error:
Index exceeds array bounds.
Error in ft_datatype_source (line 183)
val{indx(k)}(1,:,:,:) = dat{indx(k)};
Error in ft_checkdata (line 278)
data = ft_datatype_source(data);
Error in ft_sourcestatistics (line 94)
varargin{i} = ft_checkdata(varargin{i}, 'datatype', 'source', 'feedback', 'no');
Error in sourcelocalisation_N2O (line 114)
stat = ft_sourcestatistics(cfg, source);
The source struct has the following content:
time: [1×15360 double]
dim: [24 31 25]
inside: [18600×1 logical]
pos: [18600×3 double]
method: 'rawtrial'
trial: [1×24 struct]
df: 24
cfg: [1×1 struct]
With source.trial:
1×24 struct array with fields:
ori
pow
mom
noise
filter
label
filterdimord
I would like your help to understand the error and how to fix it.
Regards,
Xavier Vrijdag
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190220/53b77254/attachment-0002.html>
-------------- next part --------------
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202
More information about the fieldtrip
mailing list