Back to the main page.

Bug 3160 - ft_sourceanalysis cannot deal with larger .grad structure than data

Status CLOSED DUPLICATE
Reported 2016-07-13 14:27:00 +0200
Modified 2019-08-10 12:32:27 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Linux
Importance: P5 normal
Assigned to:
URL:
Tags:
Depends on:
Blocks:
See also:

Stephen Whitmarsh - 2016-07-13 14:27:02 +0200

ft_sourceanalysis has a problem when supplying a cfg.grad which is based on more sensors than are in the data, i.e. the latter only containing gradiometers. This is because I lose my grad when I combine data sets, so I retrieve it from a previous dataset, that also has more channels (i.e. magnetometers as well). It ends up breaking at: -------------- Error using reshape To RESHAPE the number of elements must not change. Error in ft_sourceanalysis (line 645) Cf = reshape(Cf , [1 Nchans Nchans]); -------------- This is because it created the headmodel as well as a cfg previously (line 344, ft_sourceanalysis): % collect and preprocess the electrodes/gradiometer and head model [headmodel, sens, cfg] = prepare_headmodel(cfg, data); Which was used to determine the number of channels (line 357, ft_sourceanalysis): % It might be that the number of channels in the data, the number of % channels in the electrode/gradiometer definition and the number of % channels in the localspheres volume conduction model are different. % Hence a subset of the data channels will be used. Nchans = length(cfg.channel); And that is because ft_fetch_sens (line 53, prepare_headmodel) returned both gradiometers and magnetometers, i.e. 306 sensors, based on the cfg.grad structure (there is no grad in the data): % get the gradiometer or electrode definition, these can be in the cfg or in the data sens = ft_fetch_sens(cfg, data); Now, I don't know if this is a bug, or just my problem. I should ofcourse be able to solve this by taking my reference data, and running selectdata on that. It's just that it takes another couple of Gig of memory to do so. Also, it seems that the 'subset of data channels' is perhaps wrongly implemented. Perhaps there is a way for me to do something like ft_selectdata or ft_fetch_sens to select channels for grad output? Cheers, Stephen


Robert Oostenveld - 2016-07-14 13:03:28 +0200

stephen sent me teh data, it is now in the test dir mac011> scp bug3160.mat mentat001:/home/common/matlab/fieldtrip/data/test bug3160.mat 100% 2342KB 2.3MB/s 00:00


Jan-Mathijs Schoffelen - 2016-07-20 17:57:04 +0200

als ik doe: load bug3160 data = common_FFT; % 'k snap niet waarom mensen altijd creatief willen zijn met variable names cfg = []; cfg.method = 'dics'; cfg.frequency = data.freq; cfg.headmodel.o = [0 0 4]; cfg.headmodel.r = 8; % je moet iets, supplied data is tamelijk minimaal cfg.grid.resolution = 1; source = ft_sourceanalysis(cfg, data); % this works without problems for me, on my git-repo, pulled from upstream master yesterday.


Stephen Whitmarsh - 2016-07-20 23:06:26 +0200

Ah ja, ik zal morgen de cfg met de grad uploaden, daar gaat het mee mis.


Stephen Whitmarsh - 2016-07-21 10:36:33 +0200

JM: op je gmail


Stephen Whitmarsh - 2016-07-21 10:40:57 +0200

JM, probeer aub met de cfg die ik je gestuurd heb, het volgende: cfg = []; cfg.method = 'dics'; cfg.grad = hdr.grad; cfg.grid = leadfield; cfg.channel = 'MEGGRAD'; cfg.headmodel = headmodel_meg; cfg.dics.keepfilter = 'yes'; cfg.dics.lambda = '5%'; % cfg.dics.reducerank = 2; source_common = ft_sourceanalysis(cfg, data);


Jan-Mathijs Schoffelen - 2016-07-21 11:06:48 +0200

saved cfg as bug3160b on /home/common/matlab/fieldtrip/data/test/


Stephen Whitmarsh - 2016-07-21 11:12:51 +0200

I see that at line 488 in source_analysis, data.label is empty. I therefor suspect it actually is related to bug 3164 (solved in my pull request)...


Jan-Mathijs Schoffelen - 2016-07-21 11:16:22 +0200

(In reply to Stephen Whitmarsh from comment #7) I hope not, because this would mean that you use ft_combineplanar prior to sourceanalysis, which is not good.


Jan-Mathijs Schoffelen - 2016-07-21 11:18:07 +0200

The problematic thing is a call to ft_selectdata with cfg.channel = 'MEGGRAD'; This indeed returns an empty powspctrm and label. If I change cfg.channel to cfg.channel = ft_channelselection('MEGGRAD',common_FFT.label); and then call ft_sourceanalysis, it runs through without error. My diagnosis is that ft_selectdata has problems in appropriately using the wildcard MEGGRAD in the channel selection.


Stephen Whitmarsh - 2016-07-21 11:20:58 +0200

Exactly, so a similar cause as http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3164 I.e. a problem of ft_channelselection because of a problem in ft_senstype. See pull-request


Stephen Whitmarsh - 2016-07-21 14:16:44 +0200

And thanks for the work-around JM! At least I can keep going now! *** This bug has been marked as a duplicate of bug 3164 ***


Robert Oostenveld - 2019-08-10 12:32:27 +0200

This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue on https://github.com/fieldtrip/fieldtrip/issues.