Open daniel-ge opened 5 years ago
Hi @daniel-ge, thanks for the report. I don't have any experience with these file formats, so I'll leave evaluation to others. Would you have any interest in submitting a pull request? We almost certainly have round-trip tests, so adding your failing file to the battery would be a useful addition, along with fixes to ensure that your file is correctly loaded (if valid) or rejected (if actually invalid).
@MarcCote Do you have time to check on this and potentially review a PR?
Hi, I can have a closer look next week. I'd be happy to review a PR fixing that issue.
@daniel-ge the link to the data is now invalid.
Hi @daniel-ge, can you update this issue with a fresh link?
@daniel-ge Just a bump on this. Can the data be made available again? I can grab it so we're less sensitive to delays next time.
I may be having a related issue where nibabel.streamlines.save
appears to be overwriting the given affine with np.eye(4)
. I described the issue on neurostars, with help from @arokem : https://neurostars.org/t/dipy-streamlines-not-aligning-with-image-space/3889/5
The key part is this:
I set the DWI-derived affine as the new affine:
tractogram = Tractogram(sl, affine_to_rasmm=affine)
tractogram.affine_to_rasmm
Out[25]:
array([[ -1.04999995, 0. , 0. , 90. ],
[ 0. , 1.04999995, 0. , -126. ],
[ 0. , 0. , 1.04999995, -72. ],
[ 0. , 0. , 0. , 1. ]])
and I saved it:
save(tractogram, 'tractogram_affine-fa.trk')
but when I load this new .trk file, the affine is back to an eye:
In [17]: sl_aff_fa, hdr_aff_fa = load_trk('tractogram_affine-fa.trk')
In [18]: hdr_aff_fa['voxel_to_rasmm']
Out[18]:
array([[1., 0., 0., 0.],
[0., 1., 0., 0.],
[0., 0., 1., 0.],
[0., 0., 0., 1.]], dtype=float32)
EDIT: my issue is not a nibabel bug – I resolved it by creating a header
and feeding it to save()
along with the tractogram
object (see this dipy issue)
Thanks for letting us know. There is some work in progress about making tractogram manipulation more robust in Dipy (https://github.com/nipy/dipy/pull/1812). Hopefully, we'll be able to bring most of the checks in Nibabel.
I am attempting to write files in Trackvis-Format (trk). So loading a trk-file and saving it without any further changes should work. But unfortunately it fails in the following example:
Failing example
Working example
I figured out that this error is related to the creation of the affine transformation in
get_affine_rasmm_to_trackvis
. After redefinition of this function the saved file contains the same data as the original one.