Back to the main page.

Bug 3174 - problems aligning CT and MRI using ft_volumerealign

Status CLOSED FIXED
Reported 2016-08-17 17:58:00 +0200
Modified 2019-08-10 12:33:08 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 normal
Assigned to: Arjen Stolk
URL:
Tags:
Depends on:
Blocks:
See also:

Diego Lozano Soldevilla - 2016-08-17 17:58:49 +0200

Created attachment 808 example plot I'm using CT and MRI data and I've found a problem displaying the realignment result (see attached plot). I got multiple warnings and the color intensity bar doesn't work (at least in windows). >> % co-register the CT to the MRI cfg = []; cfg.method = 'spm'; cfg.spmversion = 'spm12'; cfg.viewresult = 'yes'; % view realignment result cfg.coordsys = 'tal'; ct2 = ft_volumerealign(cfg, cttal, mri); the input is volume data with dimensions [256 256 200] Warning: could not determine dimord of "head2headOrig" in the following data > In utilities\private\getdimord at 549 In utilities\private\getdatfield at 39 In ft_datatype_volume at 131 In ft_checkdata at 237 In ft_volumerealign at 221 dim: [256 256 200] hdr: [1x1 struct] transform: [4x4 double] unit: 'mm' cfg: [1x1 struct] anatomy: [256x256x200 double] inside: [256x256x200 logical] transformorig: [4x4 double] coordsys: 'spm' vox2headOrig: [4x4 double] vox2head: [4x4 double] head2headOrig: [4x4 double] Warning: could not determine dimord of "vox2head" in the following data > In utilities\private\getdimord at 549 In utilities\private\getdatfield at 39 In ft_datatype_volume at 131 In ft_checkdata at 237 In ft_volumerealign at 221 dim: [256 256 200] hdr: [1x1 struct] transform: [4x4 double] unit: 'mm' cfg: [1x1 struct] anatomy: [256x256x200 double] inside: [256x256x200 logical] transformorig: [4x4 double] coordsys: 'spm' vox2headOrig: [4x4 double] vox2head: [4x4 double] head2headOrig: [4x4 double] Warning: could not determine dimord of "vox2headOrig" in the following data > In utilities\private\getdimord at 549 In utilities\private\getdatfield at 39 In ft_datatype_volume at 131 In ft_checkdata at 237 In ft_volumerealign at 221 dim: [256 256 200] hdr: [1x1 struct] transform: [4x4 double] unit: 'mm' cfg: [1x1 struct] anatomy: [256x256x200 double] inside: [256x256x200 logical] transformorig: [4x4 double] coordsys: 'spm' vox2headOrig: [4x4 double] vox2head: [4x4 double] head2headOrig: [4x4 double] Warning: could not reshape head2headOrig to the expected dimensions > In ft_datatype_volume at 136 In ft_checkdata at 237 In ft_volumerealign at 221 Warning: could not reshape vox2head to the expected dimensions > In ft_datatype_volume at 136 In ft_checkdata at 237 In ft_volumerealign at 221 Warning: could not reshape vox2headOrig to the expected dimensions > In ft_datatype_volume at 136 In ft_checkdata at 237 In ft_volumerealign at 221 SPM12: spm_coreg (v6435) 17:53:06 - 17/08/2016 ======================================================================== Completed : 17:55:57 - 17/08/2016 Warning: the estimated units are not very decisive, assuming that the units are "mm" > In plotting\private\ft_estimate_units at 56 In ft_plot_slice at 189 In ft_plot_ortho at 116 In ft_volumerealign>cb_redraw at 1452 In ft_volumerealign at 1295 Warning: the estimated units are not very decisive, assuming that the units are "mm" > In plotting\private\ft_estimate_units at 56 In ft_plot_slice at 189 In ft_plot_ortho at 130 In ft_volumerealign>cb_redraw at 1452 In ft_volumerealign at 1295 Warning: the estimated units are not very decisive, assuming that the units are "mm" > In plotting\private\ft_estimate_units at 56 In ft_plot_slice at 189 In ft_plot_ortho at 144 In ft_volumerealign>cb_redraw at 1452 In ft_volumerealign at 1295 Warning: assuming that the units are "mm" > In plotting\private\ft_estimate_units at 49 In ft_plot_slice at 189 In ft_plot_ortho at 116 In ft_volumerealign>cb_redraw at 1460 In ft_volumerealign at 1295 Warning: assuming that the units are "mm" > In plotting\private\ft_estimate_units at 49 In ft_plot_slice at 189 In ft_plot_ortho at 130 In ft_volumerealign>cb_redraw at 1460 In ft_volumerealign at 1295 Warning: assuming that the units are "mm" > In plotting\private\ft_estimate_units at 49 In ft_plot_slice at 189 In ft_plot_ortho at 144 In ft_volumerealign>cb_redraw at 1460 In ft_volumerealign at 1295 the call to "ft_volumerealign" took 176 seconds I don't know if the co-registration is acceptable. Arjen: do you have any example from tutorial data? I cannot run some mri parts from windows and I cannot access my linux machine


Diego Lozano Soldevilla - 2016-08-17 18:04:24 +0200

toy data to reproduce my plot https://www.dropbox.com/s/cd2u4yo1lnim49t/toydata.mat?dl=0 % co-register the CT to the MRI cfg = []; cfg.method = 'spm'; cfg.spmversion = 'spm12'; cfg.viewresult = 'yes'; % view realignment result cfg.coordsys = 'tal'; ct2 = ft_volumerealign(cfg, cttal, mri);


Arjen Stolk - 2016-08-17 18:14:17 +0200

(In reply to Diego Lozano Soldevilla from comment #0) Hey Diego, First off, as the tutorial states, the entire human ecog pipeline is new and under ongoing construction so do not expect things to work fluently, if at all. :) Having said that, .. "I'm using CT and MRI data and I've found a problem displaying the realignment result (see attached plot)." > .. it seems your plot is actually showing as intended, the CT (blue) overlayed on the MR (red). Was this not what you expected to see? Or do you see a better way to display the alignment result? "the color intensity bar doesn't work (at least in windows)" > The updating of colorlimits using the sliders is unfortunately terribly slow. I recommend doing large steps/slidedistances a time to see noticeable changes color changes. Haven't tested on windows. "I don't know if the co-registration is acceptable." > Looks good to me. You might want to click around a bit to see whether the CT (blue) nicely hugs the MR brain (red). "I got multiple warnings" > Same here. It's 'under construction'. "do you have any example from tutorial data" > ? it's there (UCI29.zip)


Arjen Stolk - 2016-08-17 18:19:02 +0200

(In reply to Arjen Stolk from comment #2) CCing Roemer as he implemented the cfg.viewresult functionality of volumerealign. But I think most of Diego's issue is a misunderstanding in terms of what viewresult is displaying? The warnings are mostly low-level issues, presumably not specific to this pipeline, but ideally needs to be looked at to confirm.


Diego Lozano Soldevilla - 2016-08-17 18:29:44 +0200

(In reply to Arjen Stolk from comment #2) First off, as the tutorial states, the entire human ecog pipeline is new and under ongoing construction so do not expect things to work fluently, if at all. :) Having said that, .. DL: Point taken! No intention to rush/blame you! Just checking how far I can go with it to include it or not in the guangzhou workshop :). > .. it seems your plot is actually showing as intended, the CT (blue) overlayed on the MR (red). Was this not what you expected to see? Or do you see a better way to display the alignment result? DL: The problem I referred is the color bar. > The updating of colorlimits using the sliders is unfortunately terribly slow. I recommend doing large steps/slidedistances a time to see noticeable changes color changes. Haven't tested on windows. DL: I already tried that but no appreciable result. It could be a windows issue but I cannot access my linux machine. > Looks good to me. You might want to click around a bit to see whether the CT (blue) nicely hugs the MR brain (red). DL: Cool! Thanks so much for your feedback > Same here. It's 'under construction'. DL: Cool! > ? it's there (UCI29.zip) DL: FT cannot read freesurfer *mgz files in pc... DL: No worries and thanks again for your help. For now Giani, I wont include this tutorial because things are still under construction. They use a bunch of deep electrodes (no grid so far) so no huge benefit.


Roemer van der Meij - 2016-08-17 21:56:48 +0200

The warnings are probably specific to the datasets, although the mm unit warning is very common I think. In my experience with the color intensity of the realigned CT has an extremely skewed distribution. Do you see a difference if you slide both bars almost all the way down? That will effectively make it binary, and compare that to both sliders all the way up. The difference should be really noticeable. If this doesn't have any effect, can you upload the MRI's (deidentified of course)? Or perhaps strongly downsampled (using ft_volumedownsample; also less identifiable), whatever problem exist should remain. What is your Matlab version? Apart from that, the realignment looks reasonable, although it's difficult to judge without going back and forth along the brain/csf/skull boundaries. If its a grid patient, there could be tremendous swelling causing part of the brain to shift inward (easily a cm or more). My hope would be that the skull is at least aligned well.


Robert Oostenveld - 2016-08-18 09:59:32 +0200

mac011> git commit ../utilities/private/getdatfield.m [master 50e2315] ENH - prevent warning for reshaping 4x4 transformation matrixes as possible data elements, see http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3174 1 file changed, 19 insertions(+), 9 deletions(-) This prevents the warnings of Warning: could not determine dimord of "xxx2yyy" in the following data and Warning: could not reshape xxx2yyy to the expected dimensions


Robert Oostenveld - 2016-08-18 10:16:00 +0200

mac011> git commit ../ft_volumerealign.m [master 43c185b] ENH - pass units to ft_plot_ortho and print head coordinates when plotting CT and MRI on top of each other. See http://bugzilla.fieldtriptoolbox.org/show_bug.cgi?id=3174 1 file changed, 218 insertions(+), 199 deletions(-) This prevents the 'mm' warning when plotting. I did some other general code cleanups. With the demo data (now in a test script) it works for me on matlab R2016b. The alignment seems reasonable (did not look in detail) and the sliders change the blue contrast. Is there anything left to be done to resolve this bug? If not, please close.


Diego Lozano Soldevilla - 2016-08-18 10:35:14 +0200

(In reply to Robert Oostenveld from comment #7) Thanks Robert! Closing it


Arjen Stolk - 2016-08-18 18:09:20 +0200

(In reply to Diego Lozano Soldevilla from comment #8) Big brother is watching and keeping an eye out for us. Thanks Robert! Lots of fun in Gangzhou, Diego. Wish I were there. :P


Diego Lozano Soldevilla - 2016-08-18 18:12:15 +0200

(In reply to Arjen Stolk from comment #9) Thank you Arjen! Best wishes for you too in CA! At some point we should turn back to Italy to organize something. I've made loads of italian friends here in toulouse :P


Arjen Stolk - 2016-08-18 18:16:45 +0200

(In reply to Diego Lozano Soldevilla from comment #10) For sure, I'm still nostalgic with and boasting the Italian cuisine, the Parmesan in particular!


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