Back to the main page.

Bug 3235 - improve ft_volumereslice

Status CLOSED FIXED
Reported 2017-01-22 15:27:00 +0100
Modified 2019-08-10 12:40:50 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P5 normal
Assigned to: Robert Oostenveld
URL:
Tags:
Depends on:
Blocks:
See also:

Robert Oostenveld - 2017-01-22 15:27:57 +0100

it could support flipping of the volume (instead of reslicing) and it should support other volumes than anatomy.


Robert Oostenveld - 2017-01-22 15:50:04 +0100

mac011> git commit -a [bug3235-reslice 2529123] ENH - added support to interpolate all 3D volumes, not only anatomy. Also improved provenance handling. See http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3235 1 file changed, 35 insertions(+), 24 deletions(-)


Robert Oostenveld - 2017-01-22 16:30:29 +0100

the call to volumepermute and volumeflip was a bit different than I indicated in the email. [bug3235-reslice 274bb9b] ENH - implemented flipping/permuting of volume as alternative to reslicing using an interpolation, see http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3235 3 files changed, 99 insertions(+), 83 deletions(-) [bug3235-reslice bd1d70a] ENH - added test script 1 file changed, 83 insertions(+) create mode 100644 test/test_bug3235.m @Arjen, can you please try this one out on your data? The code is under the bug3235-reslice branch under my (robertoostenveld) account on github. See the test script for instructions, basically only cfg.method='flip'.


Arjen Stolk - 2017-01-22 21:17:37 +0100

It worked well on one subject (the tutorial dataset), but threw errors on another two: Error using permute ORDER cannot contain repeated permutation indices. Error in volumepermute (line 41) volume = setsubfield(volume, fnames{k}, permute(getsubfield(volume, fnames{k}), permutevec)); Error in ft_volumereslice (line 163) resliced = volumepermute(mri); % this makes the transform approximately diagonal > the problem seems to occur at line 38 in volumepermute "if ~all(permutevec==[1 2 3])", where permutevec is [1 3 3] (for both scans). Permutevec is defined by: if ischar(permutevec) % determine the order of permutation to make the transformatiom matrix approximately diagonal [dum, m1] = max(abs(T(1,1:3))); [dum, m2] = max(abs(T(2,1:3))); [dum, m3] = max(abs(T(3,1:3))); permutevec = [m1 m2 m3]; end I'm uploading IR32 to our pipeline dropbox folder, in case you want to play with it. As a note to myself, how I pulled your branch: git remote add roboos https://github.com/robertoostenveld/fieldtrip.git git fetch roboos git checkout --track roboos/bug3235-reslice git checkout bug3235-reslice git pull


Arjen Stolk - 2017-01-23 02:10:13 +0100

In the error case, T = -0.3809 0.0065 -0.1962 104.7493 0.0355 0.1908 -1.7399 -19.9481 0.0129 -0.3318 -1.0043 162.3170 0 0 0 1.0000 [dum, m1] = max(abs(T(1,1:3))) dum = 0.3809 m1 = 1 [dum, m2] = max(abs(T(2,1:3))) dum = 1.7399 m2 = 3 [dum, m3] = max(abs(T(3,1:3))) dum = 1.0043 m3 = 3


Robert Oostenveld - 2017-02-01 13:14:19 +0100

(In reply to Arjen Stolk from comment #4) I improved the permute and also added the data to the test case. The problem was the very uneven voxel dimensions and the 30 degree tilt. It now shows up fine. [bug3235-reslice 0114a00] ENH - improve automatic detection of permute order for anatomical data, see http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3235 2 files changed, 22 insertions(+), 2 deletions(-)


Robert Oostenveld - 2017-02-01 13:59:30 +0100

I added it to the documentation [bug3235-reslice 1ace957] DOC - added method=flip to the documentation of ft_volumereslice, included ft_volumereslice in more test scripts as dependency 6 files changed, 27 insertions(+), 21 deletions(-) I am now passing revision 1ace957 through some tests >> ft_test run dependency ft_volumereslice >> ft_test report fieldtripversion 1ace957 | matlabversion | fieldtripversion | branch | arch | hostname | user | passed | runtime | functionname | ------------------------------------------------------------------------------------------------------------------------------- | 2016b | 1ace957 | bug3235-reslice | maci64 | mac011 | roboos | true | 69 | test_bug2986 | | 2016b | 1ace957 | bug3235-reslice | maci64 | mac011 | roboos | true | 17 | test_bug3190 | | 2016b | 1ace957 | bug3235-reslice | maci64 | mac011 | roboos | true | 30 | test_bug3235 | | 2016b | 1ace957 | bug3235-reslice | maci64 | mac011 | roboos | true | 19 | test_ft_volumerealign | | 2016b | 1ace957 | bug3235-reslice | maci64 | mac011 | roboos | true | 136 | test_tutorial_MNE | | 2016b | 1ace957 | bug3235-reslice | maci64 | mac011 | roboos | true | 130 | test_tutorial_plotting | According to the http://www.fieldtriptoolbox.org/development/git?&#development_workflow procedure (all new ;-) this means that I am allowed to pull it into the master.


Robert Oostenveld - 2017-02-01 14:02:53 +0100

I created a PR at https://github.com/fieldtrip/fieldtrip/pull/315


Arjen Stolk - 2017-02-01 18:47:00 +0100

Great work. One tiny issue, cfg.method = 'flip' is overwritten by 'linear' when cfg.method (documented) is used instead of cfg.interpmethod (undocumented, but perhaps used by other functions): line 88: cfg.method = ft_getopt(cfg, 'interpmethod', 'linear'); Easy to replace interpmethod by method, but this may break other functionalities depending on cfg.interpmethod.


Robert Oostenveld - 2017-02-01 21:07:03 +0100

(In reply to Arjen Stolk from comment #8) Thanks for the feedback. I fixed the last issue. commit a5ed74f15cbdf894d39e640c1f9c549680e8d97c Author: Robert Oostenveld <r.oostenveld@xxx> Date: Wed Feb 1 20:54:20 2017 +0100 ENH - added additional test for default value commit c8b5ea03d18f9a4e68ffb6b0850bb904595e00a8 Author: Robert Oostenveld <r.oostenveld@xxx> Date: Wed Feb 1 20:51:18 2017 +0100 HOTFIX - default for the new cfg.method was not handled properly, thanks to Arjen for noticing


Robert Oostenveld - 2019-08-10 12:34:40 +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.


Robert Oostenveld - 2019-08-10 12:40:50 +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.