daducci / COMMIT

Linear framework to combine tractography and tissue micro-structure estimation with diffusion MRI
Other
43 stars 33 forks source link

Input tractograms #20

Closed atu1985000 closed 7 years ago

atu1985000 commented 7 years ago

Hi,

I am trying to run the COMMIT program using my data. But I have some questions with the input tractograms.

I found the description of main features of COMMIT: "Accepts and works with any input tractogram (i.e. set of fiber tracts)." And the example program and data showed the use of Trackvis ('.trk'). However, my tracking results were obtained by in-house code using MATLAB (.mat). Do i need to transfer .mat to .trk? Or, Could COMMIT load .mat file directly? It would be appreciated if you could offer some examples.

Thanks, .
Zhipeng Yang

barakovic commented 7 years ago

Hello, till now the COMMIT framework accepts in input only '.trk' files. In this case you need to convert '.mat' to '.trk'. "any input tractogram" is intended in the approach that you use to generate the tractogram, not the format.

Any format that is not '.trk', e.g. '.tck' '.fib' '.vtk', can't be loaded in COMMIT. Exist tools that convert from these formats to '.tck'. https://github.com/MarcCote/tractconverter

In your case, you should try to see if you can convert your format in the one of TrackVis.

Thank you,

Muhamed Barakovic

barakovic commented 7 years ago

Hello, the function that you are calling use the AMICO framework. I think you have installed an older version of COMMIT (maybe before November 2016?), but you are using the new version of AMICO, and some functions are not compatible. If you update COMMIT, the problem should be solved. In any case I would suggest to check the version of AMICO and to use the last one.

Hope this will fix your error.

Thank you,

Muhamed

atu1985000 commented 7 years ago

Thank you, I compared two version of core.py and found the difference.
This is amazing work. For the output results, could i get the optimal tractogram? The example code just save three comparments and error analysis result.

barakovic commented 7 years ago

Hello, till now we don't provide an output of the tractogram. However, if your are using the StickZeppelinBall model, here you can find a script in python that can generate your tractogram. This script will generate a tractogram of the streamlines with weights higher then your threshold.

# extract TRK with values higher then a threshold
import pickle
import nibabel as nib
import numpy as np

#input
threshold       = 0.01     #<== set here your threshold!
path_out        = 'CommitOutput'   # same of the demo
filename_output = path_out+'/dictionary_TRK_fibers_threshold_'+str(threshold)+'.trk' # where the .trk will be saved

#script
file = open(path_out+'/Results_StickZeppelinBall/results.pickle','rb')
object_file = pickle.load(file)
weight = object_file[2]

fib, trk_hdr = nib.trackvis.read( path_out+'/dictionary_TRK_fibers.trk' )

# generate a trk with the weight in the first scalar value
new_fib = []
new_hdr = trk_hdr.copy()

for i in range(trk_hdr['n_count']):
    if weight[i] >= threshold :
        new_fib.append((fib[i][0], np.ones((fib[i][0].shape[0],1))*weight[i], None))
new_hdr['scalar_name'][0] = 'weight'
nib.trackvis.write( filename_output , new_fib, new_hdr )

If you are running the demo this script will generate a tractogram in "CommitOutputdictionary_TRK_fibers_threshold_0.01.trk'"

If you open the new tractogram in TrackVis and you set scalar as color, you are able to see which streamlines have higher weights associated.

Hope this answer your question.

Muhamed

behnam12 commented 6 years ago

Hi

I want to use my tracking result, as a input tractogram input, stored in .mat format. It would be great for any hints to convert from .mat to .trk format.

Thank you Behnam

barakovic commented 6 years ago

Hello Benham, till now COMMIT uses only the following format for tractography: http://www.trackvis.org/docs/?subsect=fileformat You can try to write a converter from ".mat" to ".trk". You can potentially use python and nibabel, as is already installed in anaconda. If you find difficulties to write a converter you can send me an example of your format and I will try to write a script to adapt your format to the one used in TrackVis.

Cheers,

Muhamed