skoudoro on master
NF - WIP: calculation of tensor… NF - WIP: calculation of b-tens… BF: documentation fix and 9 more (compare)
Hi all, I'm trying to save generated streamlines using StatefulTractogram but get the error message below. Also, I'm able to save tractograms from raw and eddy corrected images. However, I am getting this problem after distortion correction using ANTs. But, the streamlines are generated and can be visualized with the fury package for raw, eddy and distortion+eddy correction. Any help would be greatly appreciated. Thanks.
ValueError Traceback (most recent call last)
<ipython-input-33-25d7d840788d> in <module>()
36 from dipy.io.streamline import save_trk
---> 38 sft = StatefulTractogram(streamlines, img, Space.RASMM)
39 #save_trk(sft, "DTItractogram_deterministic_ctxwm-lh-postcentral_T1space-disteddy.trk")
~/miniconda3/envs/ants/lib/python3.6/site-packages/dipy/io/stateful_tractogram.py in init(self, streamlines, reference, space, origin, data_per_point, data_per_streamline)
119 'using them with StatefulTractogram.')
--> 121 space_attributes = get_reference_info(reference)
122 if space_attributes is None:
123 raise TypeError('Reference MUST be one of the following:\n'
~/miniconda3/envs/ants/lib/python3.6/site-packages/dipy/io/utils.py in get_reference_info(reference)
277 if not affine[0:3, 0:3].any():
--> 278 raise ValueError('Invalid affine, contains only zeros.'
279 'Cannot determine voxel order from transformation')
280 voxel_order = ''.join(nib.aff2axcodes(affine))
ValueError: Invalid affine, contains only zeros.Cannot determine voxel order from transformation
Hi @ejb119 ! The mapping object that get_map() returns is created in the optimize() method, so get_map() can only be used after running the optimize() method. I was able to reproduce the issue with
from dipy.align.imwarp import SymmetricDiffeomorphicRegistration from dipy.align.metrics import EMMetric metric = EMMetric(3) sdr = SymmetricDiffeomorphicRegistration(metric, level_iters=[10, 10, 5]) mapping = sdr.get_map()
Also, the same mapping object is returned by the optimize() method as well.
mapping = sdr.optimize(static, moving)
For visualizing the deformation map, you can look at the 2D example: https://dipy.org/documentation/1.1.1./examples_built/syn_registration_2d