Giter Site home page Giter Site logo

brainlife / app-tractseg Goto Github PK

View Code? Open in Web Editor NEW
1.0 13.0 5.0 21.35 MB

Brainlife App for MIC-DKFZ/TractSeg. A tool for fast and accurate white matter bundle segmentation from Diffusion MRI using pretrained pytorch ML model.

Home Page: https://brainlife.io/app/5b82d7f4e2f4f800275e020f

License: MIT License

Dockerfile 20.10% Shell 41.30% Python 38.60%
analysis white-matter-segmentation

app-tractseg's Introduction

Abcdspec-compliant Run on Brainlife.io

app-tractseg

[Warning: only App versions >= 2.2 are currently maintained.]

Segment 72 white matter tracts.

Brainlife App for Automatic White Matter Bundle Segmentation using MIC-DKFZ/TractSeg. A tool for fast and accurate white matter bundle segmentation from Diffusion MRI.

TractSeg was developed by Jakob Wasserthal from Divison of Medical Image Computing at German Cancer Research Center (DKFZ). It uses pretrained 3D Fully Convolutional Neural Networks (FCNNs) to quickly identify human white matter tracts (bundles).

Reference

Plese refer to the official repository for more details: MIC-DKFZ/TractSeg.

Authors

Contributors

Project director

Funding Acknowledgement

brainlife.io is publicly funded and for the sustainability of the project it is helpful to Acknowledge the use of the platform. We kindly ask that you acknowledge the funding below in your publications and code reusing this code.

NSF-BCS-1734853 NSF-BCS-1636893 NSF-ACI-1916518 NSF-IIS-1912270 NIH-NIBIB-R01EB029272

Citation

We kindly ask that you cite the following articles when publishing papers and code using this code:

  1. Wasserthal, J., Neher, P., & Maier-Hein, K. H. (2018). TractSeg-Fast and accurate white matter tract segmentation. NeuroImage, 183, 239-253. https://doi.org/10.1016/j.neuroimage.2018.07.070
  2. Avesani, P., McPherson, B., Hayashi, S. et al. The open diffusion data derivatives, brain data upcycling via integrated publishing of derivatives and reproducible open cloud services. Sci Data 6, 69 (2019). https://doi.org/10.1038/s41597-019-0073-y

Running the App

On Brainlife.io

You can submit this App online at https://doi.org/10.25663/brainlife.app.186 via the “Execute” tab.

Input:
The dwi image in .nii format. TractSeg will generate CSD peaks from this dwi before running TOM tracking, Tractography, and Tractometry. The input dwi image must have the same "orientation" as the Human Connectome Project data (MNI space) (LEFT must be on the same side as LEFT of the HCP data). Alternatively, a peaks.nii.gz file can be given as input (App "TractSeg - from peaks" https://doi.org/10.25663/brainlife.app.684).

Optional inputs:

  • T1w images (registered to the dwi), required for cst_msmt_5tt option.
  • (work in progress) tensor image (registered to the dwi), required to run Tractometry on either FA, MD, RD, or AD instead that on the peak length (default).

Output:
The segmented white matter tracts.

Running locally

  1. git clone this repo.
  2. Inside the cloned directory, create config.json with something like the following content with paths to your input files:
{
"dwi": "testdata/dwi.nii.gz",
"bvecs": "testdata/dwi.bvecs",
"bvals": "testdata/dwi.bvals",
"preprocess": false,
"csd": "csd",
"nr_fibers": 2000,
"bundles": "",
"tractometry_input": "peak_length"
}
  1. Launch the App by executing main.
./main

Output

This App will generate four outputs:

  • a whole brain tractogram in .tck format, which includes all the segmented tracts (72 or less)
  • the segmented tracts in the white matter classification (wmc) format
  • a list of nifti volumes for each tract segments, containing the tract masks
  • a list of nifti volumes for each tract segments, containing the ending masks
  • a Tractseg output directory containing bundle_segmentations, endings_segmentations, Tractometry_peaks.csv, etc..
  • a tractmeasures.csv file corresponding to the Tractometry_peaks.csv file

Dependencies

This App only requires singularity to run.

MIT Copyright (c) 2020 brainlife.io The University of Texas at Austin and Indiana University, German Cancer Research Center (DKFZ), Division of Medical Image Computing (MIC).

app-tractseg's People

Contributors

francopestilli avatar giulia-berto avatar kitchell avatar soichih avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

app-tractseg's Issues

Expose --nr_fibers variable on brainlife interface

https://github.com/MIC-DKFZ/TractSeg/blob/ffc0c933824d92fe09e22d8f56e8541ec4ed9f5e/bin/Tracking#L76-L77

Would it be possible to add a mechanism to specify the requested number of fibers? The default of 2000 is actually kind of low, particularly for tracts that have wide fanning (e.g CST). I worry that, given the current setup of Brainlife / apps, this might require the creation of an entirely new app, but hopefully there's a less drastic way of achieving this.

Appropriate inputs to TractSeg

Hello Repo Colleagues,

I had done some test-driving of the TractSeg app and noticed a few issues.

First, the app doesn't reference that inputs to TractSeg should be ACPC aligned (I think other apps, like Classifyber and other apps note that).

Second, I think users should preprocess things before pushing things to TractSeg. From conversations with another brainlife user (Steven Meisler), TractSeg is likely expecting a

  • An MNI-oriented image, and
    -One that has info about peaks

Steve similarly suggested:

  1. Make sure your tractseg input (dwi image or peaks image) is correctly oriented to MNI. FSL has a command for this (fslreorient2std). You can also rigidly align using code on the tractseg website as long as you have your FA map calculated.
  2. Generate peaks yourself (e.g. via DIPY or MrTrix) and begin tractseg from there
  3. Download the brainlife tractseg repo and execute it on your computer/HPC, and you can script the process out and introduce a flip_peaks command if needed between steps.

I struggled a long time with troubleshooting, trying various gradient flips and other reorientation stuff, so now that I have it working happy to help if you continue hitting roadblocks! (edited)

I haven't tried to complete Peaks And Metrics dMRI processing, but it isn't clear to me if the compiled TractSeg app actually accepts the "appropriate" inputs? (I think it would be expecting NIFTI files and not a peaks.pam5 file from other brainlife apps). Hopefully, some of these pieces make sense and aid next versions of the app!

All the best,
Jamie.

"...T1w_acpc_dc_restore_brain.nii.gz": No such file or directory

Error encountered in recent run. Relevant error log as follows:

5ttgen: Generated scratch directory: /ocean/projects/dbs190008p/shayashi/prod/60495e1e2541c128a79b65f5/604a83fb7503892d3fe6166d/5ttgen-tmp-P87329/
mrinfo: [ERROR] cannot access file "/ocean/projects/dbs190008p/shayashi/prod/60495e1e2541c128a79b65f5/604a83fb7503892d3fe6166d/T1w_acpc_dc_restore_brain.nii.gz": No such file or directory
mrinfo: [ERROR] error opening image "/ocean/projects/dbs190008p/shayashi/prod/60495e1e2541c128a79b65f5/604a83fb7503892d3fe6166d/T1w_acpc_dc_restore_brain.nii.gz"

5ttgen: [ERROR] Could not access header information for image '/ocean/projects/dbs190008p/shayashi/prod/60495e1e2541c128a79b65f5/604a83fb7503892d3fe6166d/T1w_acpc_dc_restore_brain.nii.gz'
dwi2response:
dwi2response: Note that this script makes use of commands / algorithms that have relevant articles for citation. Please consult the help page (-help option) for more information.
dwi2response:
dwi2response: Generated scratch directory: /ocean/projects/dbs190008p/shayashi/prod/60495e1e2541c128a79b65f5/604a83fb7503892d3fe6166d/dwi2response-tmp-8553ZP/
dwi2response: Importing DWI data (/ocean/projects/dbs190008p/shayashi/prod/60495e1e2541c128a79b65f5/604a83fb7503892d3fe6166d/dwi.nii.gz)...
dwi2response: Importing mask (/ocean/projects/dbs190008p/shayashi/prod/60495e1e2541c128a79b65f5/604a83fb7503892d3fe6166d/tractseg_output/nodif_brain_mask.nii.gz)...
Command: mrconvert /ocean/projects/dbs190008p/shayashi/prod/60495e1e2541c128a79b65f5/604a83fb7503892d3fe6166d/tractseg_output/5TT.nii.gz /ocean/projects/dbs190008p/shayashi/prod/60495e1e2541c128a79b65f5/604a83fb7503892d3fe6166d/dwi2response-tmp-8553ZP/5tt.mif

dwi2response: [ERROR] mrconvert /ocean/projects/dbs190008p/shayashi/prod/60495e1e2541c128a79b65f5/604a83fb7503892d3fe6166d/tractseg_output/5TT.nii.gz /ocean/projects/dbs190008p/shayashi/prod/60495e1e2541c128a79b65f5/604a83fb7503892d3fe6166d/dwi2response-tmp-8553ZP/5tt.mif (msmt_5tt.py:53)
dwi2response: [ERROR] Information from failed command:
dwi2response:
mrconvert: [ERROR] cannot access file "/ocean/projects/dbs190008p/shayashi/prod/60495e1e2541c128a79b65f5/604a83fb7503892d3fe6166d/tractseg_output/5TT.nii.gz": No such file or directory
mrconvert: [ERROR] error opening image "/ocean/projects/dbs190008p/shayashi/prod/60495e1e2541c128a79b65f5/604a83fb7503892d3fe6166d/tractseg_output/5TT.nii.gz"
dwi2response:
dwi2response: [ERROR] For debugging, inspect contents of scratch directory: /ocean/projects/dbs190008p/shayashi/prod/60495e1e2541c128a79b65f5/604a83fb7503892d3fe6166d/dwi2response-tmp-8553ZP/
dwi2response: Scratch directory retained; location: /ocean/projects/dbs190008p/shayashi/prod/60495e1e2541c128a79b65f5/604a83fb7503892d3fe6166d/dwi2response-tmp-8553ZP/
===========]
dwi2fod: [ERROR] Unable to open numerical data text file "tractseg_output/RF_WM.txt": No such file or directory
dwi2fod: [ERROR] File "tractseg_output/RF_WM.txt" is not a valid response function file
dwi2fod: [ERROR] MSMT_CSD algorithm expects the first file in each argument pair to be an input response function file
sh2peaks: [ERROR] cannot access file "tractseg_output/WM_FODs.nii.gz": No such file or directory
sh2peaks: [ERROR] error opening image "tractseg_output/WM_FODs.nii.gz"
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/nibabel/loadsave.py", line 42, in load
stat_result = os.stat(filename)
FileNotFoundError: [Errno 2] No such file or directory: 'tractseg_output/peaks.nii.gz'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/TractSeg", line 417, in
main()
File "/usr/local/bin/TractSeg", line 255, in main
data_img = nib.load(peak_path)
File "/usr/local/lib/python3.7/site-packages/nibabel/loadsave.py", line 44, in load
raise FileNotFoundError(f"No such file or no access: '{filename}'")
FileNotFoundError: No such file or no access: 'tractseg_output/peaks.nii.gz'

real 13m31.503s
user 10m15.669s
sys 0m28.295s

Let me know if any additional information would be of use

Current App version doesn't save tractometry results

The current App version doesn't save tractometry results. I'd like to save it, however the output file Tractometry_subject1.csv does not comply with the definition of the neuro/tractmeasures datatype in BL. Options:

  • convert it to be compliant with the existing datatype, and assign the datatype tag tractseg
  • create a new datatype, e.g. tractseg/tractmeasures (and possibly an App to convert it to the neuro/tractmeasures datatype)
    Both versions could also be saved as output.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.