GithubHelp home page GithubHelp logo

Comments (2)

daducci avatar daducci commented on August 22, 2024

Hi JC, what do you suggest, shall we use nibabel.streamlines or dipy.io.streamlines? I'm a bit lost.

Also, we made few tries with the nibabel.streamlines interface, and we are puzzled. If we load a tractogram and then re-save it right after, the coordinates are being changed by this operations. For example:

trk_file = nibabel.streamlines.load( 'fibers.trk' )
streamlines_out = trk_file.streamlines
affine = nibabel.streamlines.trk.get_affine_trackvis_to_rasmm( trk_file.header )
tractogram_out = nibabel.streamlines.tractogram.Tractogram( streamlines=streamlines_out, affine_to_rasmm=affine )
nibabel.streamlines.save( tractogram_out, 'fibers__MOD.trk' )

but the two files have different content (a shift). We tried with different affine matrices, e.g. identity, but the problem is not solved.
Any clue?

from commit.

jchoude avatar jchoude commented on August 22, 2024

Hi Alessandro,

I think the simplest way is to use dipy.io.streamlines, since it will keep track of the space for you.

However, in your specific case, without having direct access to the file to validate what I'm saying, the first issue is that the nibabel.streamlines API always loads your streamlines in world (RASMM) space. In this case, since you don't change that space with your other modifications, you should instead use:

tractogram_out = nibabel.streamlines.tractogram.Tractogram( streamlines=streamlines_out, affine_to_rasmm=numpy.eye(4) ),

since your streamlines are already in world space. In your use case, using affine_to_rasmm=affine will apply an additionnal transform. Instead, you should use numpy.eye(4), and then save as

nibabel.streamlines.save( tractogram_out, 'fibers__MOD.trk', header=trk_file.header )

where the header should correctly save them (as long as the content of the original header made sense).

If it still doesn,t work, feel free to write offline with a file and I'll check if something weird is happening.

from commit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.