dtiImportFibersMrtrix fails to parse track.tck header
Closed this issue · 8 comments
I am trying to run app-life on output track.tck generated by brain-life/app-dipy-tracking (multishell tractograph with CSA) app.
When I run LiFE, I get following error message.
{�Error using dtiImportFibersMrtrix (line 76)
Unable to parse header for file ../59a09712682fb20024ca9af8/track.tck
Error in fgRead (line 39)
fg = dtiImportFibersMrtrix(fgFile);
Error in feConnectomeInit (line 49)
fg = fgRead(fgFileName);
Error in life (line 10)
fe = feConnectomeInit(config.dwi, ...
Here is the header contained inside the output track.tck.
$ head ../59a09712682fb20024ca9af8/track.tck
mrtrix tracks
count: 0000272259
datatype: Float32LE
file: . 67
It's short, but the structure looks OK? It could be missing some parameters that LiFE needs?
The brain-life/app-dipy-tracking creates track.tck by doing following.
https://github.com/brain-life/app-dipy-tracking/blob/master/main.py#L108
tractogram = Tractogram(streamlines, affine_to_rasmm=affine)
save(tractogram, 'track.tck')
It am not sure if this issue needs to be fixed by the tractography app, or the .tck file header parser used by LiFE.
@ccaiafa @Garyfallidis Please comment.
Not clear idea what is happening. dtiImportFibersMrtrix is a VISTASOFT function, not part of LiFE.
@soichih This is actually a trick question. I do not think Dipy can save .tck files. @Garyfallidis (I just realized this is all within Python/Dipy, so it is relevant to you.)
@francopestilli Here is the nibabel method that app-dipy-tracking is using to save the .tck file
app-life app then tries to load the .tck using Vistasoft dtiImportFiberMrtrix() and it fails with the error message.
My hunch is that, dtiImportFiberMrtrix() is having trouble parsing the count
count: 0000272259
I think nibabel should output this in following format instead.
count: 272259
So I think this could be nibabel issue. OR.. vistasoft can be updated to trim the leading 0000 and be able to handle such format.
Actually, I was wrong about the count format. vistasoft can parse it just fine.
The real issue is that dtiImportFiberMrtrix() requires step_size field to be present in the header, but nibabel is not outputting this field (and it looks like that's the only field that's missing)
I will open an issue with nibabel to see if they can add this field.
Marc from nibabel says that step_size is an optional field, and I saw this issue was already addressed by Vistasoft (vistalab/vistasoft#164). They made it so that it assumes step_size to be 1 if it's not set, although I am not sure how safe that is..
Anyway, I just pulled the latest master branch of vistasoft, and tested it. I also just realized that, app-life needs dtiInit output (single shell) and app-dipy-tracking needs multi-shell dwi input.. So I can no longer run app-life against app-dipy-tracking output.
Do we need to make any in the code here?
No, I think everything should work fine as far as encode/app-life goes. I am recompiling the msa binary and docker container for app-life.