View Issue Details

IDProjectCategoryView StatusLast Update
0002466Slicer4Core: CLI infrastructurepublic2018-03-02 11:06
Reporterfedorov Assigned Toinorton  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Product Version 
Target VersionSlicer 4.5.0-1Fixed in VersionSlicer 4.5.0-1 
Summary0002466: CLIs that use DVW nodes crash in MRMLIDImageIO
Description

// ---------

EDIT by Jc based on Francois comment 12656

Steps to reproduce the error:
-Download latest nightly (r23755)
-Start Slicer and download the example DWI image (Download Sample Data->Download DWIVolume)
-Open Resample Scalar/Vector/DWI Volume
-Select "dwi" as your input node
-Create new volume for the output volume
-Run
->Crash
// ---------

At this point I have a crash:

Thread 4 Crashed:
0 libMRMLIDIO.dylib 0x0000000126f13691 itk::MRMLIDImageIO::SetDWNodeValues(vtkMRMLDiffusionWeightedVolumeNode, itk::MetaDataDictionary&) + 1941 (itkMRMLIDImageIO.cxx:877)
1 libMRMLIDIO.dylib 0x0000000126f14da1 itk::MRMLIDImageIO::WriteImageInformation(vtkMRMLVolumeNode
, vtkImageData) + 2739 (itkMRMLIDImageIO.cxx:571)
2 libMRMLIDIO.dylib 0x0000000126f15735 itk::MRMLIDImageIO::Write(void const
) + 237 (itkMRMLIDImageIO.cxx:617)
3 ...larVectorDWIVolumeLib.dylib 0x00000001380831e8 itk::ImageFileWriter<itk::VectorImage<unsigned short, 3u> >::GenerateData() + 2472 (itkImageFileWriter.txx:419)
4 ...larVectorDWIVolumeLib.dylib 0x00000001380cc277 itk::ImageFileWriter<itk::VectorImage<unsigned short, 3u> >::Write() + 7749 (itkImageFileWriter.txx:341)
5 ...larVectorDWIVolumeLib.dylib 0x0000000137dd9e92 itk::ImageFileWriter<itk::VectorImage<unsigned short, 3u> >::Update() + 50 (itkImageFileWriter.h:158)
6 ...larVectorDWIVolumeLib.dylib 0x0000000137dc5ea5 int (anonymous namespace)::Rotate<unsigned short>((anonymous namespace)::parameters&) + 2266 (ResampleScalarVectorDWIVolume.cxx:1247)
7 ...larVectorDWIVolumeLib.dylib 0x0000000137dd1aea ModuleEntryPoint + 41337 (ResampleScalarVectorDWIVolume.cxx:1316)
8 libqSlicerBaseQTCLI.dylib 0x00000001001d41fb vtkSlicerCLIModuleLogic::ApplyTask(void) + 32017 (vtkSlicerCLIModuleLogic.cxx:1578)
9 libSlicerBaseLogic.dylib 0x0000000103b35600 vtkSlicerTask::Execute() + 160 (vtkSlicerTask.cxx:36)
10 libSlicerBaseLogic.dylib 0x0000000103b20eee vtkSlicerApplicationLogic::ProcessProcessingTasks() + 338 (vtkSlicerApplicationLogic.cxx:468)
11 libSlicerBaseLogic.dylib 0x0000000103b20fee vtkSlicerApplicationLogic::ProcessingThreaderCallback(void
) + 62 (vtkSlicerApplicationLogic.cxx:427)
12 libSystem.B.dylib 0x00007fff878c4fd6 _pthread_start + 331
13 libSystem.B.dylib 0x00007fff878c4e89 thread_start + 13

TagsNo tags attached.

Relationships

related to 0001859 closedfbudin ResampleDTI does not handle the measurement frame 
has duplicate 0004053 closedinorton slicer 4.4.4 crashes with DTI resampling (Windows 10) 
has duplicate 0004030 closedinorton Can't read back DWI nodes with MRML IO (shared library) 
related to 0002400 closedalexy Rename the "Create and rename new Node" command to "Create new Node as..." 

Activities

alexy

alexy

2012-12-18 06:08

developer   ~0007521

Demian, you commented out bvalue computation on line 853 in MRMLIDImageIO
::SetDWNodeValues(). That's what causing the crash. Please investigate.

pieper

pieper

2013-07-16 11:23

administrator   ~0009076

Demian can also help sort this out.

fbudin

fbudin

2013-07-17 11:41

developer   ~0009106

I am pretty sure the problem comes from Slicer, but I could be wrong. When I run this module in a terminal, it seems to work perfectly. However, from within Slicer4, it crashes, or gives a bad output.
The type of the output image is defined by <image type="any"> in the xml description file. In Slicer3, that meant that the user had to choose the type of node for the output image (Scalar, Vector, DWI). However, in Slicer4 this option has disappeared, and I am guessing Slicer creates the wrong type of node, thus leading to a crash of the application.

pieper

pieper

2013-07-17 14:11

administrator   ~0009115

I just tried to replicate this bug on a build of the current trunk (r22207). I followed the steps listed above but got no crash and the result looked reasonable (mac, debug build).

fbudin

fbudin

2013-07-18 05:48

developer   ~0009123

I just realized some tests with the nightly build for linux64 (r22208) and here are my results:
-I select a DWI as an input, and create a new node as an output->It runs but the result is an image with diagonal stripes and multiple slices on one slice (4D image badly converted into a 3D image?)
-I select a DWI as an input and select the same node as the output->Slicer crashes
-If I run the module in a terminal and load the result in Slicer->It works

pieper

pieper

2013-07-18 06:09

administrator   ~0009125

I was able to reproduce this. I'm using a mac with a developer build of the current trunk (r22209).

Steps:

  • download sample data DWI
  • select resample scalar/vector/dwi module
  • pick dwi as both input and output (other parameters as defaults)
  • run the module and there is a crash with a similar dump as in the original report.
pieper

pieper

2013-07-18 06:36

administrator   ~0009128

@Demian -

Can you have another look at what you did in this commit:

https://github.com/Slicer/Slicer/commit/bc3f4d6b

You commented out a block of code (why?) that included the line which populates the bvalues vector:

https://github.com/Slicer/Slicer/blob/master/Libs/MRML/IDImageIO/itkMRMLIDImageIO.cxx#L859

As a result, when I run the steps from my previous note in the debugger, it crashes at line 875 because it accesses past the end of the vector:

https://github.com/Slicer/Slicer/blob/master/Libs/MRML/IDImageIO/itkMRMLIDImageIO.cxx#L875

Thanks in advance,
-Steve

jcfr

jcfr

2013-07-31 20:49

administrator   ~0009324

Reminder sent to: demian

@Demian: What do you think of Steve remark ? (see note 9128)

demian

demian

2013-08-06 08:33

developer   ~0009399

I had commented that because it was performing the normalization of the gradients. And, in some cases incurr in a divided by 0 error on line 884 and also generated a discrepancy when loading and saving the same file without modificationts.

https://github.com/Slicer/Slicer/blob/master/Libs/MRML/IDImageIO/itkMRMLIDImageIO.cxx#L884

The gradients of the DWI image should be normalized by its specification so, including a new normalization seemed like something that should not have been done here. Probably a better idea would have been to throw an exception and force the code making use of this of this IO to perform the normalization on the outside.

What do you think?

demian

demian

2013-08-06 08:42

developer   ~0009401

I forgot to say that the NRRD spec is that there is only 1 reference b-value and then the norm of each gradient times that b-value is the actual b-value of the DWI image. When I looked at the code to handle this in ITK, this was the case but maybe it was update to a different scheme now?
(comment for François on the bottom)

It is not clearly documented if we should keep that (meaning erasing line 895) or normalize all gradients again.

I'm currently off site. I can check this beter next week.

@Francois, could you check how is that you are feeding the gradient directions into the output? Are they according to the NRRD standard? (1 reference bvalue and the b-value of each gradient is the norm of the gradient times the reference one)

Thanks

jcfr

jcfr

2013-08-06 08:47

administrator   ~0009402

Reminder sent to: fbudin

@Francois: Could you comment. Thanks

fbudin

fbudin

2013-08-07 09:14

developer   ~0009421

In ResampleScalarVectorDWIVolume, when transforming a DWI, the transform is applied directly to the gradient vector. The vector is not normalized. This, as far as I understand follows the NRRD specifications that Demian was mentioning. See:
https://github.com/Slicer/Slicer/blob/master/Modules/CLI/ResampleScalarVectorDWIVolume/ResampleScalarVectorDWIVolume.cxx#L1009-L1024

The gradient directions are then just written in the output image metadata dictionary as they were in the input image.

Warning: obviously, the user has to be careful to only apply a rotation or a translation transform (rigid transform in ITK3), otherwise the output image will be meaningless.

pieper

pieper

2013-08-27 11:54

administrator   ~0009640

Did we get a final resolution on this?

fedorov

fedorov

2013-09-03 03:32

developer   ~0009815

@pieper: the steps provided in the original report crash Slicer as before, so nothing changed as far as the user is concerned

fbudin

fbudin

2014-03-06 10:47

developer   ~0011256

The problem is still the same. Seem my comment (0009106) above. Slicer4 still does not offer to choose the type of the output node for a CLI. In Slicer3, the user had to choose. In Slicer4, to select the output of the CLI, the user can either create a new volume (scalar, no choice), or use an existing volume.
If the user specifies an existing volume that is a DWI to resample a DWI, it is going to work. If the user specifies a volume that is not a DWI, or creates a new volume (which is going to be a scalar volume), Slicer is going to crash.

pieper

pieper

2014-03-07 05:56

administrator   ~0011320

We think we have a plan:

  • vtkMRMLNode* qMRMLNodeComboBox::addNode() could be expanded to accept a parameter of what class to create
    • the CLI widget could be configured to have all the valid classes that the output could create (right now the variable output types of this module are specified by the "any" type)
pieper

pieper

2014-03-07 05:56

administrator   ~0011321

Reminder sent to: finetjul

@j2 - can you comment on this plan?

alexy

alexy

2014-06-13 09:55

developer   ~0012058

It seems feedback from Julian is needed.

finetjul

finetjul

2014-06-16 04:34

administrator   ~0012070

Seems like a good plan. The baseName property could become a QStringList to support multiple node types that can be created by the combobox.
As a hack, qMRMLNodeComboBox:: addMenuAction() could also be used.

jcfr

jcfr

2014-10-28 21:54

administrator   ~0012655

Resolving the issue since I am not able to reproduce this problem using Slicer r23759.

Please, re-open if this is still a problem.

fbudin

fbudin

2014-10-29 06:18

developer   ~0012656

Steps to reproduce the error:
-Download latest nightly (r23755)
-Start Slicer and download the example DWI image (Download Sample Data->Download DWIVolume)
-Open Resample Scalar/Vector/DWI Volume
-Select "dwi" as your input node
-Create new volume for the output volume
-Run
->Crash

Additional note: If you run the module with a scalar image, it will work correctly. The problem is that Resample Scalar/Vector/DWI Volume can create different types of output depending on the input image. In Slicer3, the user would select the type of the output node when creating a new output volume. In Slicer4, this is not the case anymore. The output volume created is always a scalar volume, which will lead to Slicer crashing if you run this module with a vector image or a DWI.

jcfr

jcfr

2015-09-22 09:46

administrator   ~0013294

Looking at this issue, I tried the following:
(1) Load DWIVolume from sample data
(2) Open "ResampleScalarVectorDWIVolume" module
(3) Create a new parameter set
(4) Select "dwi" as input
(5) Create a new ouput of type "DiffusionWeightedVolume"
(6) Click on "Run"

Then, if I either wait or click on "Cancel", it crashed in the function "MRMLIDImageIO::SetDWNodeValues".

The function tried to get the values of the "bvalues" vector never filled with values. See [1]

This regression was most likely introduced by r20150 (BUG: Fixed bug 0002062, 0001781: problem when loading and saving DWI files) in an attempt to address 0002062 and 0001781

[1] https://github.com/Slicer/Slicer/blob/e4ebd3b2cb90a228871474bfa679cba453fb841d/Libs/MRML/IDImageIO/itkMRMLIDImageIO.cxx#L905-L950

pieper

pieper

2015-09-22 11:52

administrator   ~0013303

We revisited this issue as part of our developer hangout [1]. Looking at the code that was commented out [2] it seems that

(1) the b-values are needed in order to avoid the crash reported here

(2) the gradients should be normalized for a mrml diffusion weighted volume node [3]

(3) there seems to be a mistake in the commented out code that it is missing a factor of 2 compared to the documentation [4]. That is, if the reference b-value is 1000, a vector 1,1,0 should have a b-value 1000 and a vector .707,.707,0 should have a b-value of 500, but the code in the block that is comment out [2] doesn't account for that factor of 2.

[1] http://www.slicer.org/slicerWiki/index.php/Developer_Meetings/20150922#To_Discuss

[2] https://github.com/Slicer/Slicer/blob/e4ebd3b2cb90a228871474bfa679cba453fb841d/Libs/MRML/IDImageIO/itkMRMLIDImageIO.cxx#L924-L937

[3] https://github.com/Slicer/Slicer/blob/e4ebd3b2cb90a228871474bfa679cba453fb841d/Libs/MRML/Core/vtkMRMLDiffusionWeightedVolumeNode.h#L27-L33

[4] http://wiki.na-mic.org/Wiki/index.php/NAMIC_Wiki:DTI:Nrrd_format#Describing_DWIs_with_different_b-values

fbudin

fbudin

2015-10-06 07:23

developer   ~0013338

I don't think this issue should be assigned to me. It is a problem in Slicer, not in ResampleScalarVectorDWIVolume.

jcfr

jcfr

2015-10-06 09:42

administrator   ~0013340

Hi Francois,

I guess it was assigned to you because the problem initially happen when using ResampleScalarVectorDWIVolume.

That said, what do you think of the comment in http://www.na-mic.org/Bug/view.php?id=2466#c13303 ?

fbudin

fbudin

2015-10-06 09:57

developer   ~0013341

To answer Demian's question, ResampleScalarVectorDWIVolume does not much with the gradients. If the input image contains gradients (i.e. it is a DWI), it transforms them if the given transform is invertible. If the transform is not invertible, it gives a warning/error message. So if the input DWI respects the NRRD standard, the output DWI will also respect the NRRD standard. One should not use this module to resample a DWI with an affine transform. Even though this module will give an output, the output is not going to be correct.

lauren

lauren

2015-10-06 10:13

developer   ~0013342

Hi guys. I see this is assigned to me but I am confused. Is there still a crash in this module as in the initial bug? Or is the bug now that the expected behavior is not produced when the DWI volume is inside an affine transform?

As another note, I believe the documentation [4] mentioned by Steve is incorrect, as I noticed looking at it recently, so this should be revisited. I believe the numbers in the example are wrong (the .707 should either be squared or the square root, or similar. I forget exactly what now).

[4] http://wiki.na-mic.org/Wiki/index.php/NAMIC_Wiki:DTI:Nrrd_format#Describing_DWIs_with_different_b-values [^]

jcfr

jcfr

2015-10-06 10:31

administrator   ~0013343

Thanks for your comment.

And do you have any feedback regarding the specific issue reported in http://www.na-mic.org/Bug/view.php?id=2466#c13303

lauren

lauren

2015-10-06 10:49

developer   ~0013344

Thanks JC. I see now where I should look. I will have to look into this more next week when I am back from MICCAI.

fbudin

fbudin

2015-10-06 13:47

developer   ~0013348

I don't have any additional comment. The only thing that is dangerous with Slicer though is that if you let the user choose the type of output volume like in ResampleScalarVectorDWIVolume, even if everything goes well during the computation and that the problem mention above is corrected, Slicer might still crash if the user chooses the wrong type of output (e.g. if the user chooses a DTI or scalar output node when the input was actually a DWI). But that is a different issue.

pieper

pieper

2015-10-07 00:09

administrator   ~0013358

I agree with Francois that we should look at how to handle this polymorphic case in the execution model.

Lauren, maybe you and I can talk about it at some point. I agree that documentation in [4] surprised me.

fbudin

fbudin

2015-10-07 07:31

developer   ~0013361

I believe what is wrong in [4] is that the b-value in the NRRD header should be 500 as it would have the b-vectors corresponding to b=500 normalized (which they are) and the b-vectors corresponding to b=1000 with a norm that is larger than one [norm_7 = 1 sqrt (1000/500) = sqrt(2) = sqrt( 11 + 00 + 11 ) ]. Otherwise the norm of the b-vectors that correspond to b-val=1000 should be normalized and the norm of the vector corresponding to b-val=500 should be smaller than 1 (sqrt(1/2)), and therefore DWMRI_gradient_0001:=.5 0 .5

jcfr

jcfr

2015-11-11 11:50

administrator   ~0013592

Fixed in r24724
See http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&amp;revision=24724

Related Changesets

Import 2017-06-07 23:51:09: master 832654c9

2015-11-11 16:12:13

jcfr

Details Diff
BUG: Fix 0002466, MRMLIDImageIO crashes with DWMRI volume

http://www.na-mic.org/Bug/view.php?id=2466

Restore handling of b-values and gradients, and make code consistent
with DWIConvert: use the `sqrt(b/b_max)` scaling factor as documented
on the NA-MIC wiki page:

http://wiki.na-mic.org/Wiki/index.php/NAMIC_Wiki:DTI:Nrrd_format

Reviewed-by: Francois Budin <fbudin@unc.edu>
Reviewed-by: Lauren O'Donnell <odonnell@bwh.harvard.edu>
Reviewed-by: Steve Pieper <pieper@isomics.com>
Tested-by: Isaiah Norton <inorton@bwh.harvard.edu>

From: Isaiah Norton <inorton@bwh.harvard.edu>

git-svn-id: http://svn.slicer.org/Slicer4/trunk@24724 3bd1e089-480b-0410-8dfb-8563597acbee
mod - Libs/MRML/Core/vtkMRMLNRRDStorageNode.cxx Diff File
mod - Libs/MRML/IDImageIO/itkMRMLIDImageIO.cxx Diff File
mod - Libs/vtkTeem/vtkNRRDWriter.cxx Diff File

Issue History

Date Modified Username Field Change
2012-09-03 09:50 fedorov New Issue
2012-09-03 09:50 fedorov Status new => assigned
2012-09-03 09:50 fedorov Assigned To => millerjv
2012-10-30 10:38 pieper Assigned To millerjv => alexy
2012-12-08 10:10 jcfr Target Version => Slicer 4.2.3
2012-12-18 06:08 alexy Note Added: 0007521
2012-12-18 06:08 alexy Assigned To alexy => demian
2013-01-10 07:58 demian Relationship added related to 0001859
2013-02-12 09:37 jcfr Target Version Slicer 4.2.3 => Slicer 4.3.0
2013-07-16 11:23 pieper Assigned To demian => fbudin
2013-07-16 11:23 pieper Note Added: 0009076
2013-07-16 11:23 pieper Status assigned => feedback
2013-07-17 11:41 fbudin Note Added: 0009106
2013-07-17 14:11 pieper Note Added: 0009115
2013-07-18 05:48 fbudin Note Added: 0009123
2013-07-18 06:09 pieper Note Added: 0009125
2013-07-18 06:32 pieper Status feedback => assigned
2013-07-18 06:32 pieper Assigned To fbudin => demian
2013-07-18 06:36 pieper Note Added: 0009128
2013-07-31 20:49 jcfr Note Added: 0009324
2013-08-06 08:33 demian Note Added: 0009399
2013-08-06 08:42 demian Note Added: 0009401
2013-08-06 08:47 jcfr Note Added: 0009402
2013-08-07 09:14 fbudin Note Added: 0009421
2013-08-27 11:54 pieper Note Added: 0009640
2013-08-27 12:07 jcfr Status assigned => feedback
2013-09-02 19:15 jcfr Target Version Slicer 4.3.0 => Slicer 4.3.1
2013-09-03 03:32 fedorov Note Added: 0009815
2013-09-03 03:33 fedorov Status feedback => assigned
2013-10-04 00:52 jcfr Target Version Slicer 4.3.1 => Slicer 4.3.2
2014-03-06 10:15 nicole Target Version Slicer 4.3.2 => Slicer 4.4.0
2014-03-06 10:20 nicole Assigned To demian => alexy
2014-03-06 10:47 fbudin Note Added: 0011256
2014-03-07 05:56 pieper Note Added: 0011320
2014-03-07 05:56 pieper Note Added: 0011321
2014-03-07 05:56 pieper Status assigned => feedback
2014-03-07 06:47 pieper Relationship added related to 0002400
2014-06-13 09:55 alexy Note Added: 0012058
2014-06-13 09:55 alexy Assigned To alexy => finetjul
2014-06-16 04:34 finetjul Note Added: 0012070
2014-10-28 21:54 jcfr Note Added: 0012655
2014-10-28 21:54 jcfr Status feedback => resolved
2014-10-28 21:54 jcfr Fixed in Version => Slicer 4.4.0
2014-10-28 21:54 jcfr Resolution open => unable to reproduce
2014-10-29 06:11 fbudin Status resolved => confirmed
2014-10-29 06:18 fbudin Note Added: 0012656
2014-10-29 08:08 jcfr Description Updated
2014-10-29 08:09 jcfr Assigned To finetjul => jcfr
2014-10-29 08:09 jcfr Description Updated
2014-11-02 03:31 jcfr Target Version Slicer 4.4.0 => Slicer 4.4.1
2015-09-09 08:28 jcfr Target Version Slicer 4.4.1 => Slicer 4.5.0-1
2015-09-22 09:46 jcfr Note Added: 0013294
2015-09-22 09:47 jcfr Assigned To jcfr => fbudin
2015-09-22 09:47 jcfr Status confirmed => feedback
2015-09-22 09:47 jcfr Description Updated
2015-09-22 11:52 pieper Note Added: 0013303
2015-10-06 07:23 fbudin Note Added: 0013338
2015-10-06 09:42 jcfr Note Added: 0013340
2015-10-06 09:42 jcfr Status feedback => assigned
2015-10-06 09:42 jcfr Assigned To fbudin => lauren
2015-10-06 09:42 jcfr Status assigned => feedback
2015-10-06 09:57 fbudin Note Added: 0013341
2015-10-06 10:13 lauren Note Added: 0013342
2015-10-06 10:31 jcfr Note Added: 0013343
2015-10-06 10:49 lauren Note Added: 0013344
2015-10-06 13:47 fbudin Note Added: 0013348
2015-10-07 00:09 pieper Note Added: 0013358
2015-10-07 07:31 fbudin Note Added: 0013361
2015-11-04 06:26 inorton Status feedback => assigned
2015-11-04 06:26 inorton Assigned To lauren => inorton
2015-11-11 08:39 inorton Relationship added has duplicate 0004053
2015-11-11 08:41 inorton Relationship added has duplicate 0004030
2015-11-11 11:50 jcfr Note Added: 0013592
2015-11-11 11:50 jcfr Status assigned => resolved
2015-11-11 11:50 jcfr Fixed in Version Slicer 4.4.0 => Slicer 4.5.0-1
2015-11-11 11:50 jcfr Resolution unable to reproduce => fixed
2017-06-10 08:51 jcfr Changeset attached => Slicer master 832654c9
2018-03-02 11:06 jcfr Status resolved => closed