Back to the main page.
Bug 3190 - ft_sourceparcellate's handling of ft_sourceinterpolate's output for atlases
Status | CLOSED FIXED |
Reported | 2016-10-24 14:37:00 +0200 |
Modified | 2017-01-17 11:29:47 +0100 |
Product: | FieldTrip |
Component: | core |
Version: | unspecified |
Hardware: | PC |
Operating System: | Windows |
Importance: | P5 normal |
Assigned to: | Robert Oostenveld |
URL: | |
Tags: | |
Depends on: | 2968 |
Blocks: | |
See also: |
Jens Klinzing - 2016-10-24 14:37:57 +0200
When interpolating an atlas onto a sourcemodel and using the result to parcellate a source-level connectivity, two issues arise that force you to manually fiddle with the sourceinterpolate output. % Lets load atlas, sourcemodel, and a connectivity structure (e.g. % from https://www.dropbox.com/s/3uoc28yn23ultgk/source_pco_new.mat?dl=0) atlas = ft_read_atlas('ROI_MNI_V4.nii'); load('standard_sourcemodel3d10mm.mat'); % 'sourcemodel' load('source_pco_new.mat'); % 'source_pco' source_pco = ft_convert_units(source_pco, 'cm'); atlas = ft_convert_units(atlas, 'cm'); sourcemodel = ft_convert_units(sourcemodel, 'cm'); % For parcellation we need an atlas that corresponds to our sourcemodel cfg_int = []; cfg_int.interpmethod = 'nearest'; cfg_int.parameter = 'tissue'; atlas_templ = ft_sourceinterpolate(cfg_int, atlas, sourcemodel); % All of these have to be identical source_pco.pos = sourcemodel.pos; atlas_templ.pos = sourcemodel.pos; % ISSUE 1: The field tissuelabel was dropped during interpolation. If it is % not present we dont know what the tissue indices mean but also % ft_checkdata does not recognize the atlas as a parcellation atlas_templ.tissuelabel = atlas.tissuelabel; % ISSUE 2: ft_sourceparcellation cannot deal with NaNs, because again ft_checkdata objects to having more unique tissues (each NaN counts indovodually) than there are tissue labels. atlas_templ.tissue(isnan(atlas_templ.tissue)) = 0; % Now the parcellation works cfg = []; cfg.parcellation = 'tissue'; cfg.parameter = 'powcorrspctrm'; source_pco_parc = ft_sourceparcellate(cfg, source_pco, atlas_templ); imagesc(source_pco_parc.powcorrspctrm)
Robert Oostenveld - 2016-10-24 17:08:34 +0200
Both issues are due to an unusual application of ft_sourceinterpolate. Should we fix them by detecting this unusual case in ft_sourceinterpolate? I'll make a branch on github and come with a proposal... PS I renamed and copied the data here: mac011> mv source_pco_new.mat bug3190.mat mac011> scp bug3190.mat mentat001:/home/common/matlab/fieldtrip/data/test
Jan-Mathijs Schoffelen - 2016-10-24 17:30:10 +0200
at the moment I am working in a branch 'parcel_conn' which I could push to schoffelen/fieldtrip. The purpose of this branch is to streamline the processing of parcellated data (e.g. to compute connectivity after parcellating). Would it make sense to work on this issue in the same branch? If so, I can push it to github.
Robert Oostenveld - 2016-10-24 17:40:03 +0200
(In reply to Jan-Mathijs Schoffelen from comment #2) @Jan-Mathijs: I was just typing this: ---- @Jens: Could you have a look at https://github.com/robertoostenveld/fieldtrip/tree/bug3190-interpolate-atlas and specifically at these changes https://github.com/robertoostenveld/fieldtrip/commit/2d8500a9475d10ad6d2c625758110b19eafd7ff6 I also made a test script, see fieldtrip/test/test_bug3190.m Note that these changes all live on a branch and are not on home/common yet. If you confirm this as a good solution, I will merge it into the master release. ----
Robert Oostenveld - 2016-10-24 17:41:58 +0200
(In reply to Jan-Mathijs Schoffelen from comment #2) does this match your work, or conflict with it? It is only a small fix in ft_datatype and an extension of ft_sourceinterpolate (conditional on the input and cfg.interpmethod). PS why is it called cfg.interpmethod and not cfg.method?
Jens Klinzing - 2016-10-24 18:06:52 +0200
(In reply to Robert Oostenveld from comment #3) Yes that seems to work for me! Thanks!
Jens Klinzing - 2016-10-25 11:47:17 +0200
(In reply to Robert Oostenveld from comment #3) Wait, that version actually fails when calling ft_volumereslice. cfg = []; cfg.resolution = 1; cfg.dim = [256 256 256]; mrirs = ft_volumereslice(cfg, mri); Reference to non-existent field 'interpmethod'. Error in ft_sourceinterpolate (line 133) if strcmp(cfg.interpmethod, 'nearest') && (ft_datatype(functional, 'volume+label') || ft_datatype(functional, 'source+label')) Error in ft_volumereslice (line 180) resliced = ft_sourceinterpolate(tmpcfg, mri, resliced);
Robert Oostenveld - 2016-10-27 10:46:03 +0200
(In reply to Jens Klinzing from comment #6) right, the default for interpmethod is only set later. I changed it. mac011> git commit -a [bug3190-interpolate-atlas cae3620] FIX - set interpmethod to [] to start with, otherwise it fails. See http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3190#c6 2 files changed, 11 insertions(+), 3 deletions(-) mac011> git push X11 forwarding request failed on channel 0 Counting objects: 13, done. Delta compression using up to 4 threads. Compressing objects: 100% (13/13), done. Writing objects: 100% (13/13), 1.99 KiB | 0 bytes/s, done. Total 13 (delta 9), reused 0 (delta 0) remote: Resolving deltas: 100% (9/9), completed with 5 local objects. To git@github.com:robertoostenveld/fieldtrip.git 2d8500a..cae3620 bug3190-interpolate-atlas -> bug3190-interpolate-atlas
Robert Oostenveld - 2016-10-27 10:48:36 +0200
(In reply to Robert Oostenveld from comment #7) I made this PR https://github.com/fieldtrip/fieldtrip/pull/245 and merged it. thanks for testing