[Neuroimaging] Covert .trk to JSON

Eleftherios Garyfallidis elef at indiana.edu
Wed May 17 22:12:49 EDT 2017


Hi Jorge,

With the new API for streamlines available in nibabel.streamlines you can
load .trk files and then get all the points of all the streamlines in one
buffer and in another the offsets (starting points) and lenghts of each
streamline.

Here is how
trkfile = nib.streamlines.load('test.trk')
streamlines = trkfile.streamlines
all_points = streamlines.data
offsets = streamlines._offsets
lengths = streamlines._lengths

You can probably save these 3 arrays in a json file with no problem. You
may also want to save the affine. You can get this from trkfile.affine.

I hope this helps.
Best,
Eleftherios

On Wed, May 17, 2017 at 6:30 PM Jorge Rudas <jrudascas at gmail.com> wrote:

> Hi dipy experts
>
> There is a direct way to covert a tractography file in .trk format to JSON
> format?
>
> Cheers
>
> *Jorge Rudas*
>
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20170518/d46c1954/attachment.html>


More information about the Neuroimaging mailing list