Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking workflow header affine issue & fix #1832

Open
sitek opened this issue May 14, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@sitek
Copy link
Contributor

commented May 14, 2019

Description

Using LocalFiberTrackingPAMFlow in 0.16, I found that streamlines were in an incorrect space relative to the input DWI files. (see first post with image on neurostars issue here)

I resolved the issue by adding a header to the nib.streamlines.save() call:

from nibabel.orientations import aff2axcodes
from nibabel.streamlines import Field
import nibabel as nib

# import fa image (or other DWI)
img = nib.load(stopping_path)

# header inputs
affine = img.affine
vox_size = img.header.get_zooms()[:3]
fov_shape = img.get_fdata().shape[:3]

# create header
hdr = {}
hdr[Field.VOXEL_TO_RASMM] = affine.copy()
hdr[Field.VOXEL_SIZES] = vox_size
hdr[Field.DIMENSIONS] = fov_shape
hdr[Field.VOXEL_ORDER] = "".join(aff2axcodes(affine))

# create and save tractogram object with the header
tractogram = Tractogram(streamlines_generator, affine_to_rasmm=np.eye(4))
save(trk_file, 'tractogram_correct_affine.trk', header=hdr)

**note that the Tractogram object is created with a blank affine (np.eye(4)) but the header takes the image affine

Adding this or similar code here could resolve this issue. I can make a pull request if this seems like an optimal solution, but I'm open to other solutions as well (assuming other people have the same issue).

@skoudoro

This comment has been minimized.

Copy link
Member

commented May 15, 2019

Hi @sitek,

Thank for the report, it seems to be related to PR #1812 and issue #1722. We are in a redesign process. Feel free to give your opinion on #1812

@skoudoro skoudoro added this to the 1.0 milestone May 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.