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

Track specific bundles #38

Closed
suryaR-15 opened this issue May 7, 2019 · 10 comments
Closed

Track specific bundles #38

suryaR-15 opened this issue May 7, 2019 · 10 comments

Comments

@suryaR-15
Copy link

Hi,

Just wondering if there is a way that I can use TractSeg to track only specific bundles, e.g. only the corpus callosum. I am studying the corpus callosum and it seems unnecessary to have to wait till the code has tracked all fibre bundles, to analyse just one tract.

Thanks,

Surya

@wasserth
Copy link
Collaborator

wasserth commented May 7, 2019

So far there is no option to only track a specific bundle. You could adapt line 132 in bin/Tracking and give it a list containing only the bundles you want to e.g. bundles = ['CC_1', 'CC_2', 'CC_3', 'CC_4', 'CC_5', 'CC_6', 'CC_7']

@suryaR-15
Copy link
Author

Thanks!

@suryaR-15 suryaR-15 reopened this May 7, 2019
@suryaR-15
Copy link
Author

Sorry, but I am completely new to this, so I have another question! How would you edit the bin/Tracking file in docker? I am assuming this is a file inside the docker container, but when I executed ls bin there was no file called Tracking.

@wasserth
Copy link
Collaborator

wasserth commented May 8, 2019

The file is here /usr/local/bin/Tracking. Not sure if it works if you just edit it, because this is not the original source file, but the location where it was installed to by pip.
And I guess if you change it this change will not be saved in the docker container after exiting from the interactive session.
So unfortunately with docker it is not that easy. To make it properly you would have to rebuild the docker container and in the dockerfile install your own modified TractSeg version instead of the official TractSeg.
Would be easier without docker. Just change the source code. Then do pip install -e . inside of the source directory.

@suryaR-15
Copy link
Author

Just wanted to point out a potential bug - I ran TractSeg on a VMware CentOS 7 system with all the pre-requisites installed. Tractseg gave an error:

`[fsluser@localhost tractseg]$ TractSeg -i dwi.nii.gz --raw_diffusion_input --preprocess --verbose
Creating brain mask...
Moving input to MNI space...
Creating brain mask...
Creating peaks (1 of 3)...
Traceback (most recent call last):
  File "/home/fsluser/mrtrix3/bin/dwi2response", line 102, in <module>
    if int(image.statistic('mask.mif', 'count', '-mask mask.mif')) == 0:
ValueError: invalid literal for int() with base 10: '236517  236517  236517  236517  236517  236517  236517  236517  236517  236517  236517  236517  236517  236517  236517  236517  236517  236517  236517  236517  236517  236517  236517  236517  236517  '
Creating peaks (2 of 3)...
dwi2fod: [ERROR] no data in matrix file "tractseg_output/response.txt"
dwi2fod: [ERROR] CSD algorithm expects second argument to be the input response function file
Creating peaks (3 of 3)...
sh2peaks: [ERROR] failed to open key/value file "tractseg_output/WM_FODs.mif": No such file or directory
sh2peaks: [ERROR] error opening image "tractseg_output/WM_FODs.mif"
Traceback (most recent call last):
  File "/usr/bin/TractSeg", line 303, in <module>
    main()
  File "/usr/bin/TractSeg", line 201, in main
    data_img = nib.load(peak_path)
  File "/usr/lib/python2.7/site-packages/nibabel/loadsave.py", line 42, in load
    raise FileNotFoundError("No such file or no access: '%s'" % filename)
nibabel.py3k.FileNotFoundError: No such file or no access: 'tractseg_output/peaks.nii.gz'

`
After finding this post on the Mrtrix forum, and responses to it, I was able to figure out what was happening. When running the TractSeg command, inside the dwi2response-tmp directory, files called dwi.mif and mask.mif are created. From what I understand, mask.mif is FSL-generated nodif_brain_mask.nii.gz copied. When I run mrstats:

[fsluser@localhost dwi2response-tmp-SXSIY2]$ mrstats dwi.mif -info
mrstats: [INFO] opening image "dwi.mif"...
mrstats: [INFO] image "dwi.mif" opened with dimensions 90x108x90x48, voxel spacing 2x2x2x7.2000000000000002, datatype Float32LE

[fsluser@localhost dwi2response-tmp-SXSIY2]$ mrstats mask.mif -info
mrstats: [INFO] opening image "mask.mif"...
mrstats: [INFO] image "mask.mif" opened with dimensions 90x108x90x55, voxel spacing 2x2x2x7.2000000000000002, datatype Bit

The dimensions of dwi.mif and mask.mif are different which might be causing the problem.

I commented out lines 87, 88, 95-99 in dwi2response, essentially forcing Mrtrix to generate its own mask.mif and that has solved the error.

However, due to memory errors, I wasn't able to run the complete TractSeg command and track specific bundles according to your suggestion above. On to that now!

@wasserth
Copy link
Collaborator

I was not able to reproduce this problem. When running on ubuntu 16.04 and using mrtrix 3.0 RC3 and fsl build 509 it works fine.

@suryaR-15
Copy link
Author

suryaR-15 commented May 13, 2019

I don't know if it has got anything to do with the fact that I'm running TractSeg on a virtual machine - it is the VMWare CentOS 7 installation that comes with FSL download; and with Mrtrix 3.0 RC3 as well.

@suryaR-15
Copy link
Author

The file is here /usr/local/bin/Tracking. Not sure if it works if you just edit it, because this is not the original source file, but the location where it was installed to by pip.
And I guess if you change it this change will not be saved in the docker container after exiting from the interactive session.
So unfortunately with docker it is not that easy. To make it properly you would have to rebuild the docker container and in the dockerfile install your own modified TractSeg version instead of the official TractSeg.
Would be easier without docker. Just change the source code. Then do pip install -e . inside of the source directory.

This works; I can now track just the corpus callosum. I also wanted to ask if there is a way to do something similar for the TractSeg command - while creating the endings_segmentations, bundle_segmentations etc.. Is there a way to segment just the corpus callosum? I have been looking at the code but couldn't figure it out. This is just to save time if possible since I plan to do some batch processing on a lot of images.

@wasserth
Copy link
Collaborator

TractSeg is segmenting all bundles / bundle-endings at the same time. Doing only one bundle would not reduce the runtime.

@suryaR-15
Copy link
Author

Ok, thanks!

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

No branches or pull requests

2 participants