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

Tck file format #18

Open
gelazari opened this issue Feb 17, 2015 · 16 comments
Open

Tck file format #18

gelazari opened this issue Feb 17, 2015 · 16 comments

Comments

@gelazari
Copy link

As the software only supports the .vtk format, I would like to ask suggestions/proposals to incorporate the usage of .tck format as follows: For example, is it possible to modify the code so as to give as input .tck format, then .tck to be converted to .vtk format within the code and then continue with the execution as normally. I am asking this because the code is not very easily understood for a non professional coder without the proper documentation and i would really appreciate any help/hints.

Thanks in advance for your time and consideration

@demianw
Copy link
Owner

demianw commented Feb 17, 2015

Hello @gelazari !

Tract_querier supports VTK as well as TRK (trackvis).

If you want to add tck format, you should add two functions similar to
tract_querier.tractography.tractography_from_trackvis_file(filename)
and
tract_querier.tractography.tractography_to_trackvis_file(filename, tractography, affine=None, image_dimensions=None)

with in the same file as these. Then, modify the functions

tract_querier.tractography.tractography_from_file(filename)
tract_querier.tractography.tractography_to_file(filename, tractography, **kwargs)

to add handling for the third data format transparently. The NIPy people have developed a MRTRix to TrackVis converter. You can probably use this as an example:
http://nipy.sourceforge.net/nipype/interfaces/generated/nipype.interfaces.mrtrix.convert.html

Let me know if this is helpful!
Best
Demian

@gelazari
Copy link
Author

All of the above operations should be done in the tractography.py file right?Also, in the WMQL documentation, only the support for VTK file format is mentioned i.e "A full-brain tractography in VTK format: It must be a vtkPolyData object where all the cells are lines". Anyhow, I'm only interested in the .tck format from Mrtrix and not the .trk (TrackVis) format unless needed. But what do you think is better? To incorporate the .tck format or to pre-convert my .tck files to .vtk or .trk (since you say it's supported by the querier) format? I don't know if i have the required programming skills to mess with your code.

@gelazari
Copy link
Author

I also saw that the Nipy code is available in Github so the .tck functions needed to do the job are already implemented.

@demianw
Copy link
Owner

demianw commented Feb 17, 2015

Regarding tck and trk, file formats in medical imaging are all but simple with many nuances. So I wouldn't mess with the code if that's not your priority. But, you are willing to make a contribution to a software package, I will be glad to help!

Also, I will update the documentation soon! Thanks for noticing.

On Feb 17, 2015, at 17:55, gelazari [email protected] wrote:

I also saw that the Nipy code is available in Github so the .tck functions needed to do the job are already implemented.


Reply to this email directly or view it on GitHub.

@gelazari
Copy link
Author

Of course I am willing to contribute as long as we can do it together so as to learn and at the same time improve the software for everyone. :)

@mdesco
Copy link

mdesco commented Feb 17, 2015

Guys,

If I may jump in, we've been developing a TractConverter tool that can save
you a lot of time.

You can get it here:
sudo pip install --upgrade https://github.com/MarcCote/tractconverter
/archive/master.zip
This is in the process of being ported to NiBabel. I have added in CC
Marc-Alex and JC Houde.

You can convert from trk to tck to vtk to etc...

Maxime Descoteaux, PhD
Professor
Sherbrooke Connectivity Imaging Laboratory (SCIL)
Centre de Recherche CHUS
Computer Science department
Sherbrooke University
2500 Boul. Université
Sherbrooke, Québec
J1K 2R1, Canada
phone: +1 819 821-8000 x66129
fax: +1 819 821-8200
http://scil.dinf.usherbrooke.ca

Scientific director
Visualization and Image Analysis Plateform (PAVI)
http://pavi.dinf.usherbrooke.ca/

On Tue, Feb 17, 2015 at 12:57 PM, gelazari [email protected] wrote:

Of course I am willing to contribute as long as we can do it together so
as to learn and at the same time improve the software for everyone. :)


Reply to this email directly or view it on GitHub
#18 (comment)
.[image: Web Bug from
https://github.com/notifications/beacon/ACEgB8s6AmW67nN4HEcXJTtjyz5TfJDSks5ns3h8gaJpZM4DhjT-.gif]

@demianw
Copy link
Owner

demianw commented Feb 17, 2015

True @mdesco ! I forgot!

Thanks for jumping in!

Demian Wassermann, PhD
[email protected]
Research Scientist
Athena Project Team
INRIA Sophia Antipolis - Méditerranée
2004 route des lucioles - FR-06902

@MarcCote
Copy link

Once in NiBabel, I will be happy to provide a patch to the TractQuerier so it can read any streamlines format. You can watch PR nipy/nibabel#243 for updates.

@gelazari
Copy link
Author

So, to sum up, by using the TractConverter to do the conversion .tck->.trk would be more than enough for using the tracts in Tract_querier, right?

@MarcCote
Copy link

Yes. Let me know how it goes.

@gelazari
Copy link
Author

Perfect. Thank you all @demianw @mdesco @MarcCote. I will let you know as soon as i can.

@gelazari
Copy link
Author

gelazari commented Mar 5, 2015

Results in track conversion from Mrtrix3 format .tck to .vtk are perfect. After the conversion, I check if the output is similar with the input with:
np.all([np.array_equal(trk_tracks, vtk_tracks) for trk_tracks, vtk_tracks in zip(trk_tracks, vtk_tracks])

And it's always good in my case.

@demianw
Copy link
Owner

demianw commented Mar 6, 2015

OK @gelazari . So you are proposing to directly incorporate this code into tract_querier?

@gelazari
Copy link
Author

gelazari commented Mar 6, 2015

i think that since code for conversion from one format to another exists, I find no reason for tract_querier not to incorporate direct Mrtrix (.tck) format reading and an option -o to specify the output the format of the output of the tracks. Of course it is not necessary but it would be nice, because all the necessary modules are up and running. What does @MarcCote think?

@MarcCote
Copy link

MarcCote commented Mar 6, 2015

I'm not sure if I understood correctly. You want to add code for loading tck directly in tract_querier instead of using a third party library (e.g. NiBabel or TractConverter)?

Personally, I think tract_querier should continue using NiBabel to load streamlines. Once my PR (nipy/nibabel#243) for supporting multiple streamlines file format is merged, it would be really easy to use. For example,

import nibabel as nib
fa = nib.load('fa.nii.gz')
streamlines = nib.streamlines.load('tractography.tck', ref=fa)

# Streamlines are in voxel space by default, send them to world space
streamlines = streamlines.to_world_space()

@demianw
Copy link
Owner

demianw commented Mar 9, 2015

I agree with @MarcCote . The issue with incorporating working code, is that the largest cost in code is not having a working version but doing the maintenance. As there's already a compatible project in the community handling this, NiBabel, which is already used in tract_querier. I think it's better to wait for Marc's PR to be accepted. (And btw, great work on that @MarcCote !)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants