Trk Files in DIPY Header File incorrect

Hi All,

I am new to DIPY and hoping to visualize streamlines (trk.gz or .trk files) that have been generated in DSI Studio.

It turns out that the header information may not be correct. When I check the trk files against a reference image I receive the following: HeaderError: Invalid hdr_size: [-150847129] instead of 1000

I know that there is code to resize or reformat the nifti header but is there a method to reformat the trk header as well? Or do I need to match the nifti header to the trk header? (the other way around)

-Steve

Just to make sure the streamlines are valid, have you tried to visualize them in Trackvis (http://trackvis.org/), which natively handles .trk files?

  1. Likewise, I would be interested to know if Surfice handles these.
  2. Have you tried Emanuele Olivetti’s optimized TRK loader for nibabel?

Hi Steven and Chris,

Thank you for the response!! And rapid response at that!

The optimized trk loader ended up working for my purposes!

I wasn’t able to check trackvis though but the streamlines visible through DIPY programs was comparable to the visualization through DSI Studio. Thanks again!

-Steve

Hi @Steven_Jay_Granger, I wrote the TRK parser in NiBabel (which is used by Dipy). Do you mind sharing the problematic .trk file with me, so I can have a look?

@Chris_Rorden since you mentioned Emnuaele’s loader, I’ve made a PR to Nibabel to improve TRK loading speed. I’d love to get feedback on it.

1 Like

@Steven_Jay_Granger actually did you try to load the .trk directly with Dipy, i.e. dipy.io.load_tractogram, or with NiBabel, i.e. nibabel.streamlines.load ?