brainvisa / aims-free

Analysis of Images and Signal for neuroimaging
Other
6 stars 3 forks source link

`AimsApplyTransform` generates buggy output with Graphs that contain Volumes #74

Closed ylep closed 2 years ago

ylep commented 2 years ago

AimsApplyTransform generates buggy output with Graphs that contain Volumes

To Reproduce Steps to reproduce the behavior:

  1. AimsGraphConvert label_volume.nii good_graph.nii
  2. followed by AimsApplyTransform good_graph.arg bad_graph.arg (even with the default identity transformation the problem still occurs)
  3. Try to open bad_graph.arg in Anatomist
  4. :boom: Segmentation fault (this is a bug in itself: https://github.com/brainvisa/anatomist-free/issues/29)

Expected behavior The output Graph should be well-formed, and equivalent to the input Graph.

Environment:

denisri commented 2 years ago

When using AimsApplyTransform this way, we end up with a graph containing an empty bounding box:

boundingbox_max 
boundingbox_min 

whereas on the input graph (before AimsApplyTransform) I have for instance:

boundingbox_max 255 255 123
boundingbox_min 0 0 0

this is probably the cause of the problem. However I agree anatomist should not crash. I'll try to fix that.

denisri commented 2 years ago

In aims, the function transformGraph() builds a new bounding box, only if graph objects contain buckets. If the graph contains only volumes, meshes, or is empty, then the resulting bounding box is left empty. I'm fixing that by applying the transformation to the bbox, if it is affine, or leaving the initial one if nothing else works.