Comments (2)
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.
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)
- Extend get_coeffs to extract coefficients of original/preconditioned problem HOT 1
- Improve precision of values stored in file `streamline_weights.txt` HOT 1
- Peaks file requirement for COMMIT2 HOT 3
- Numpy version incompatability? HOT 2
- [fix] tckedit command in Wiki is too long HOT 3
- COMMIT2 on QSIPrep/QSIRecon Outputs HOT 14
- It takes too long to fit model. HOT 20
- From what I see there is no difference between outputs of COMMIT1 and COMMIT2 HOT 18
- Unlike yours, the number of tracks in my tck file decreased HOT 2
- trk2dictionary not working with spyder HOT 2
- Final Output from COMMIT2 Not Aligned HOT 9
- Index is out of bounds for axis 0 in iFOD2 algorithms. HOT 6
- "Inhomogeneous shape error" with Numpy version 1.24.0 HOT 2
- Building operator A error: no EC compartments HOT 4
- Operator is not recompiled when parameters change
- Errors in COMMIT2 tutorial HOT 5
- Add integration with Travis CI HOT 1
- Improve progress bar in Jupyter notebook/labs HOT 1
- see an error in trk2dictionary HOT 7
- How to obtain a file like demo01_fibers_connection.tck when the tractogram and the number of gray-matter ROIs are huge. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commit.