Back to the main page.
Bug 302 - sourceanalysis fails due to ft_prepare_leadfield throwing away the data
Status | CLOSED FIXED |
Reported | 2010-12-13 14:19:00 +0100 |
Modified | 2011-08-17 14:45:28 +0200 |
Product: | FieldTrip |
Component: | forward |
Version: | unspecified |
Hardware: | PC |
Operating System: | Mac OS |
Importance: | P1 normal |
Assigned to: | Johanna |
URL: | |
Tags: | |
Depends on: | |
Blocks: | |
See also: |
Robert Oostenveld - 2010-12-13 14:19:29 +0100
Begin forwarded message: From: Kaoru Amano <amano@brain.k.u-tokyo.ac.jp> Date: 13 December 2010 12:15:15 GMT+01:00 To: Robert Oostenveld <r.oostenveld@donders.ru.nl> Cc: amano@brain.k.u-tokyo.ac.jp, jan-mathijs schoffelen <jan.schoffelen@DONDERS.RU.NL> Subject: Re: Statistics on source timecourse Reply-To: amano@brain.k.u-tokyo.ac.jp ... In order to calculate the timecourse of each single trial, I run the following script (run sourceanalysis on the average with cfg.keepfilter=yes, and then rerun sourceanalysis where I specify cfg.grid=source2grid(source), and cfg.rawtrial=yes), but an error message appeared. ??? error ==> prepare_headmodel at 92 no electrodes or gradiometers specified error ==> ft_prepare_leadfield at 146 [vol, sens, cfg] = prepare_headmodel(cfg, data); error ==> ft_sourceanalysis at 355 [grid, cfg] = ft_prepare_leadfield(cfg, data); This is because 'data' is removed at the following part of "ft_prepare_leadfield" if inputfile is not specified. Is it OK to change "data=[];" to "data=data;"? if ~isempty(cfg.inputfile) % the input data should be read from file if hasdata error('cfg.inputfile should not be used in conjunction with giving input data to this function'); else data = loadvar(cfg.inputfile, 'data'); end else data = []; end ---------------- cfg = []; cfg.covariance = 'yes'; cfg.covariancewindow = [ave_time]; avg_dataPost = ft_timelockanalysis(cfg, data); cfg = []; cfg.method = 'lcmv'; cfg.grad = grad; cfg.grid = grid; cfg.vol = vol; cfg.keepfilter = 'yes'; source = ft_sourceanalysis(cfg, avg_dataPost); cfg = []; cfg.keeptrials = 'yes'; cfg.covariance = 'yes'; cfg.covariancewindow = ave_time; avg_dataPost = timelockanalysis(cfg, data); %% use the common filter to estimate the source for each single trial cfg = []; cfg.method = 'lcmv'; cfg.rawtrial = 'yes'; cfg.projectnoise = 'yes'; cfg.projectmom = 'yes'; cfg.grid = source2grid(source); cfg.vol = vol; cfg.lambda = '5%'; sourcePost = sourceanalysis(cfg, avg_dataPost);
Johanna - 2011-03-30 15:18:50 +0200
Hi, I was about to file a similar bug, but then noticed this one. It does indeed seem a bug where Kaoru mentioned, leading to data=[]; unncessarily, or perhaps unintentionally, and related to the if-statements regarding cfg.inputfile. From what I gather, the channel info needs to be obtained either 1) from the cfg.grad, or 2) from the data, which can be given either as 'data' variable input or by cfg.inputfile. There is also a mismatch between the help-comments and what the code does, but that can be modified once the code is clear. I would suggest, but have only so far tested in my case of calling ft_prepare_leadfield directly (not via ft_sourceanalysis): hasdata = (nargin>1); if isfield(cfg,'grad') if hasdata % need to check if data.grad and cfg.grad are same? data = []; % clear for memory reasons and because we won't use it. % need to warn/error user that we use cfg.grad and not data.grad? end else if ~isempty(cfg.inputfile) % the input data should be read from file if hasdata error('cfg.inputfile should not be used in conjunction with giving input data to this function'); else data = loadvar(cfg.inputfile, 'data'); end else if ~hasdata error('Either data, cfg.inputfile, or cfg.grad must be specified'); end end end
Johanna - 2011-03-30 15:26:58 +0200
oops, the first 'if hasdata' should be removed, as data=[] should be set if 'data' is not an input at all.