Back to the main page.
Bug 2669 - use of 'avg' field with ft_sourceinterpolate
Status | CLOSED FIXED |
Reported | 2014-08-06 11:34:00 +0200 |
Modified | 2019-08-10 12:28:50 +0200 |
Product: | FieldTrip |
Component: | core |
Version: | unspecified |
Hardware: | PC |
Operating System: | Mac OS |
Importance: | P5 normal |
Assigned to: | Eelke Spaak |
URL: | |
Tags: | |
Depends on: | |
Blocks: | |
See also: |
Philipp Ruhnau - 2014-08-06 11:34:30 +0200
Dear ft developers, we just encountered a problem (see example below) when trying to interpolate multiple field with ft_sourceinterpolate and an 'avg' field is present in the data set. The problem emerges (irregardless of whether the field 'avg' is to be interpolated or not) because the function parameterselection (line 46 in my version) assumes that, given an 'avg' field in the data it must be a structure. The problem can be fixed by adding a check for a struct to that same if-case. (i.e.: if isfield(data, 'avg') && isstruct(data.avg) tmp = fieldnames(data.avg); for i=1:length(tmp) tmp{i} = ['avg.' tmp{i}]; end allparam = cat(1, allparam, tmp); end ) best philipp %% Example %% clear all load standard_sourcemodel3d10mm % create a fake source data set data = []; data = sourcemodel; % with data in an avg field data.avg = nan([sourcemodel.dim]); data.avg = data.avg(:); % make it one column data.avg(sourcemodel.inside) = 1; %% now try to interpolate mri = ft_read_mri('single_subj_T1.nii'); cfg = []; cfg.parameter = 'avg'; interp= ft_sourceinterpolate(cfg, data, mri); % --> error %% check again with different field name ('classic ft way') data = []; data = sourcemodel; % with data in an avg.pow field data.avg.pow = nan([sourcemodel.dim]); data.avg.pow = data.avg.pow(:); % make it one column data.avg.pow(data.inside) = 1; mri = ft_read_mri('single_subj_T1.nii'); cfg = []; cfg.parameter = 'avg.pow'; interp = ft_sourceinterpolate(cfg, data, mri); % --> works % one can also just rename 'avg' to 'avg1' and it works
Eelke Spaak - 2014-08-06 11:52:09 +0200
Thanks for the report, I just added the isstruct() test. bash-4.1$ svn commit private/parameterselection.m Sending private/parameterselection.m Transmitting file data . Committed revision 9766.