Giter Club home page Giter Club logo

tractseg's Introduction

TractSeg

Alt text

Tool for fast and accurate white matter bundle segmentation from Diffusion MRI. It can create bundle segmentations, segmentations of the endregions of bundles and Tract Orientation Maps (TOMs). Moreover, it can do tracking on the TOMs creating bundle-specific tractogram and do Tractometry analysis on those.

The tool works very well for data similar to the Human Connectome Project. For other MRI datasets it works well for all bundles except for the Commissure Anterior (CA) and the Fornix (FX) which are incomplete sometimes.

TractSeg is the code for the following papers. Please cite the papers if you use it.

Brainlife

Table of contents

Install

TractSeg only runs on Linux and OSX. It works with Python >= 3.6.

Install Prerequisites

  • Pytorch
  • Mrtrix 3 (>= 3.0 RC3)
  • FSL (if you already have a brain mask and do not use the option --preprocess this is not needed)
  • xvfb (apt-get install xvfb) (only needed if you use plot_tractometry_results)

Install TractSeg

Latest stable version:

pip install TractSeg

NOTE: See CHANGELOG for (breaking) changes of each version

If you want to use Cython for Tracking (speedup 2x) then install via

pip install https://github.com/MIC-DKFZ/TractSeg/archive/cython_tracking.zip

Docker

You can also directly use TractSeg via Docker (contains all prerequisites).

sudo docker run -v /absolute/path/to/my/data/directory:/data \
-t wasserth/tractseg_container:master TractSeg -i /data/my_diffusion_file.nii.gz -o /data --raw_diffusion_input

On OSX you might have to increase the Docker memory limit from the default of 2GB to something like 7GB.

How to use

Simple example:

To segment the bundles on a Diffusion Nifti image run the following command. (Diffusion.bvals and Diffusion.bvecs have to be in the same directory as the input image.) (You can use the example image provided in this repository under examples.)

TractSeg -i Diffusion.nii.gz --raw_diffusion_input

This will create a folder tractseg_ouput inside of the same directory as your input file with one binary segmentation nifti image for each bundle.

NOTE: If results look bad you probably have to align your images to have the same orientation as MNI space. Moreover it should have isotropic spacing. See here for more details.

Custom input and output path:

TractSeg -i my/path/my_diffusion_image.nii.gz
         -o my/output/directory
         --bvals my/other/path/my.bvals
         --bvecs yet/another/path/my.bvec
         --raw_diffusion_input

Use --help to see all options.

Use existing peaks

To avoid generating the MRtrix CSD peaks every time you run TractSeg you can also provide them directly by skipping the option --raw_diffusion_input`.

TractSeg -i my/path/my_mrtrix_csd_peaks.nii.gz

Segment bundle start and end regions

Get segmentations of the regions were the bundles start and end (helpful for filtering fibers that do not run from start until end).

TractSeg -i peaks.nii.gz --output_type endings_segmentation

Create Tract Orientation Maps (TOMs)

For each bundle create a Tract Orientation Map (Wasserthal et al., Tract orientation mapping for bundle-specific tractography). This gives you one peak per voxel telling you the main orientation of the respective bundle at this voxel. Can be used for bundle-specific tracking later on.

TractSeg -i peaks.nii.gz --output_type TOM

NOTE: --output_type tract_segmentation and endings_segmentation has to be run first. Same input and output directories have to be used for all commands.

Peaks and streamlines can be visualized using for example MITK Diffusion.

NOTE: Peaks have to be flipped along the z-axis to be displayed correctly in MITK.

Create bundle-specific tractograms

Tracks on TOMs and only keeps fibers not leaving the bundle mask and starting and ending in the endpoint regions.

TractSeg -i peaks.nii.gz --output_type tract_segmentation
TractSeg -i peaks.nii.gz --output_type endings_segmentation
TractSeg -i peaks.nii.gz --output_type TOM 
Tracking -i peaks.nii.gz

Use bedpostX peaks instead of CSD peaks

TractSeg also works with bedpostX as input. You have to pass dyads1.nii.gz as input and TractSeg will automatically find all the other necessary bedpostX files (dyads2_thr0.05.nii.gz & dyads3_thr0.05.nii.gz. mean_f1-3samples will be used for scaling the peaks.). This only works if you did not change the default bedpostX file naming.

TractSeg -i dyads1.nii.gz

Show uncertainty map

Create map showing where the method is uncertain about its segmentation (uses monte carlo dropout: https://arxiv.org/abs/1506.02142)

TractSeg -i peaks.nii.gz --uncertainty

Perform Tractometry

See Documentation of Tractometry.

Extended Tutorial

Best pratices for standard usecases.
(You can also check out the tutorial from OHBM 2019 [OUTDATED].)

Track subset of bundles

You can specify to only track a subset of bundles.

Tracking -i peaks.nii.gz --bundles CST_right,CA,IFO_right

Bundle names

The following list shows the index of each extracted bundle in the output file (if using --single_output_file).

0: AF_left         (Arcuate fascicle)
1: AF_right
2: ATR_left        (Anterior Thalamic Radiation)
3: ATR_right
4: CA              (Commissure Anterior)
5: CC_1            (Rostrum)
6: CC_2            (Genu)
7: CC_3            (Rostral body (Premotor))
8: CC_4            (Anterior midbody (Primary Motor))
9: CC_5            (Posterior midbody (Primary Somatosensory))
10: CC_6           (Isthmus)
11: CC_7           (Splenium)
12: CG_left        (Cingulum left)
13: CG_right   
14: CST_left       (Corticospinal tract)
15: CST_right 
16: MLF_left       (Middle longitudinal fascicle)
17: MLF_right
18: FPT_left       (Fronto-pontine tract)
19: FPT_right 
20: FX_left        (Fornix)
21: FX_right
22: ICP_left       (Inferior cerebellar peduncle)
23: ICP_right 
24: IFO_left       (Inferior occipito-frontal fascicle) 
25: IFO_right
26: ILF_left       (Inferior longitudinal fascicle) 
27: ILF_right 
28: MCP            (Middle cerebellar peduncle)
29: OR_left        (Optic radiation) 
30: OR_right
31: POPT_left      (Parieto‐occipital pontine)
32: POPT_right 
33: SCP_left       (Superior cerebellar peduncle)
34: SCP_right 
35: SLF_I_left     (Superior longitudinal fascicle I)
36: SLF_I_right 
37: SLF_II_left    (Superior longitudinal fascicle II)
38: SLF_II_right
39: SLF_III_left   (Superior longitudinal fascicle III)
40: SLF_III_right 
41: STR_left       (Superior Thalamic Radiation)
42: STR_right 
43: UF_left        (Uncinate fascicle) 
44: UF_right 
45: CC             (Corpus Callosum - all)
46: T_PREF_left    (Thalamo-prefrontal)
47: T_PREF_right 
48: T_PREM_left    (Thalamo-premotor)
49: T_PREM_right 
50: T_PREC_left    (Thalamo-precentral)
51: T_PREC_right 
52: T_POSTC_left   (Thalamo-postcentral)
53: T_POSTC_right 
54: T_PAR_left     (Thalamo-parietal)
55: T_PAR_right 
56: T_OCC_left     (Thalamo-occipital)
57: T_OCC_right 
58: ST_FO_left     (Striato-fronto-orbital)
59: ST_FO_right 
60: ST_PREF_left   (Striato-prefrontal)
61: ST_PREF_right 
62: ST_PREM_left   (Striato-premotor)
63: ST_PREM_right 
64: ST_PREC_left   (Striato-precentral)
65: ST_PREC_right 
66: ST_POSTC_left  (Striato-postcentral)
67: ST_POSTC_right
68: ST_PAR_left    (Striato-parietal)
69: ST_PAR_right 
70: ST_OCC_left    (Striato-occipital)
71: ST_OCC_right

Use different tract definitions

TractSeg was also trained on the bundles provided by XTRACT. These bundles are slightly differently defined. They tend to be more specific but therefore also a bit less complete. Depending on your application this might be of interest for you. Using TractSeg instead of XTRACT has the advantage of being at least 10x faster. Please cite XTRACT if you use this.

NOTE: This is only supported for output type tract_segmentation and dm_regression.

TractSeg -i peaks.nii.gz --tract_definition xtract

Use python interface

import nibabel as nib
import numpy as np
from tractseg.python_api import run_tractseg
peaks = nib.load("tests/reference_files/peaks.nii.gz").get_fdata()
segmentation = run_tractseg(peaks)

Different tracking types

You can use different types of tracking:

  • "Probabilistic" tracking on TOM peaks [default].
    Tracking -i peaks.nii.gz
    Probabilistic means that at each step a small random factor will be added to the direction given by the TOM peaks. If not doing this on low resolution data it sometimes gets difficult finding fibers running from start to end and covering the whole bundle.

  • Probabilistic tracking on original FODs. Tracking -i WM_FODs.nii.gz --track_FODs iFOD2
    Is calling Mrtrix iFOD2 tracking internally. Does not use TOM peaks but the original FODs. The results will get filtered by the bundle mask and have to start and end in the endings masks.

Tracking formats

You can use the option --tracking_format to define the file format of the streamline files. tck is the most stable tracking format and recommended. trk might get displayed differently in different viewers.

NOTE: When calling Tractometry and plot_tractometry_results you have to set the same tracking format as was used in Tracking.

Aligning image to MNI space

For best results the input 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) and have isotropic spacing. If the image orientation and the gradient orientation of your data is the same as in examples/Diffusion.nii.gz you are fine. Otherwise you should use fslreorient2std or rigidly register your image to MNI space (the brains do not have to be perfectly aligned but must have the same LEFT/RIGHT orientation). You can use the following FSL commands to rigidly register your image to MNI space (uses the FA to calculate the transformation as this is more stable):

calc_FA -i Diffusion.nii.gz -o FA.nii.gz --bvals Diffusion.bvals --bvecs Diffusion.bvecs \
--brain_mask nodif_brain_mask.nii.gz

flirt -ref tractseg/tractseg/resources/MNI_FA_template.nii.gz -in FA.nii.gz \
-out FA_MNI.nii.gz -omat FA_2_MNI.mat -dof 6 -cost mutualinfo -searchcost mutualinfo

flirt -ref tractseg/tractseg/resources/MNI_FA_template.nii.gz -in Diffusion.nii.gz \
-out Diffusion_MNI.nii.gz -applyxfm -init FA_2_MNI.mat -dof 6
cp Diffusion.bvals Diffusion_MNI.bvals
rotate_bvecs -i Diffusion.bvecs -t FA_2_MNI.mat -o Diffusion_MNI.bvecs

To enforce isotropic spacing you can replace -applyxfm by -applyisoxfm <your_spacing>.

To move the results back to subject space you can use the following commands:

convert_xfm -omat MNI_2_FA.mat -inverse FA_2_MNI.mat  # invert transformation

flirt -ref FA.nii.gz -in my_bundle.nii.gz -out my_bundle_subject_space.nii.gz \
-applyxfm -init MNI_2_FA.mat -dof 6 -interp spline  # for TOM maps you have to use the command vecreg

fslmaths my_bundle_subject_space.nii.gz -thr 0.5 -bin my_bundle_subject_space.nii.gz  # float to binary 

The option --preprocess will automatically rigidly register the input image to MNI space, run TractSeg and then convert the output back to subject space. This only works for tract_segmentation and endings_segmentation. For TOMs and trackings you have to register you data manually to MNI space:

# in first step --raw_diffusion_input has to be used together with --preprocess
TractSeg -i Diffusion.nii.gz -o tractseg_output --output_type tract_segmentation --raw_diffusion_input --preprocess
# -o has to be set in all following step
TractSeg -i tractseg_output/peaks.nii.gz -o tractseg_output --output_type endings_segmentation --preprocess

NOTE: --preprocess does not work if you are using the option --csd_type csd_msmt_5tt, because the T1 image will not automatically be registered to MNI space

If you are not familiar with preprocessing of DWI images (e.g. correcting for artifacts) you can have a look at this preprocessing script.

FAQ

My output segmentation does not look like any bundle at all!

Make sure your input image is in MNI space. Even if the input image is in MNI space the Mrtrix peaks might still be flipped. In those cases you should view the peaks in mrview and make sure they have the proper orientation. Otherwise you might have to flip the sign along the x, y or z axis using the following command:

flip_peaks -i my_peaks.nii.gz -o my_peaks_flip_y.nii.gz -a y

My data has anisotropic spacing. Does it still work?

If the spacing is only slightly anisotropic (e.g. 1.9mm x 1.9mm x 2mm) it still works fine. If the spacing is heavily anisotropic (e.g. 1mm x 1mm x 2mm) results will be a lot better if you resample your image to isotropic spacing first.

Small bundles like the CA and FX are incomplete

You can use the following options to improve your results:
--super_resolution The input image is upsampled to 1.25mm resolution (the resolution TractSeg was trained on) and finally downsampled back to the original resolution. Using --super_resolution will output the image at 1.25mm. Especially if image resolution is low parts of the CA can get lost during downsampling.

Can I save the pretrained weights at a different location?

Per default the pretrained weights will be downloaded to and loaded from ~/.tractseg/. You can change this directory by adding weights_dir=/absolute/path_to_where/you_want_it to ~/.tractseg/config.txt in a new line (if the file does not exist yet you have to create it).
Normally the pretrained weights will automatically be downloaded in the background right when they are needed. In some cases you might want to download all of them at once. To do so you can simply run download_all_pretrained_weights and the weights will be download to ~/.tractseg/ or the location you specified in ~/.tractseg/config.txt.

Did I install the prerequisites correctly?

You can check if you installed Mrtrix correctly if you can run the following command on your terminal: dwi2response -help

You can check if you installed FSL correctly if you can run the following command on your terminal: bet -help

TractSeg uses these commands so they have to be available.

How can I install the latest master branch?

pip install https://github.com/MIC-DKFZ/TractSeg/archive/master.zip

Train your own model

TractSeg uses a pretrained model. You can also train your own model on your own data, however TractSeg is not optimised to make this convenient, as most people will use the pretrained model. The following guide is quite short and you might have problems following every step. Contact the author if you need help training your own model.

  1. Use your own data or download the data from Zenodo
  2. If you have streamlines you have to transform them to binary masks. You can use this script for that. (If you want to train a TOM model you have to create peak maps from the streamlines. This can be done by using the MITK Diffusion miniapp MitkFiberDirectionExtraction. See the following two issues for more details: 82, 92)
  3. Install TractSeg from local source code:
    git clone https://github.com/MIC-DKFZ/TractSeg.git
    pip install -e TractSeg
    
  4. Install BatchGenerators:
    git clone https://github.com/MIC-DKFZ/batchgenerators.git
    pip intall -e batchgenerators
    
  5. The folder structure of your training data should be the following:
    custom_path/HCP/subject_01/
          '-> mrtrix_peaks.nii.gz       (mrtrix CSD peaks;  shape: [x,y,z,9])
          '-> bundle_masks.nii.gz       (Reference bundle masks; shape: [x,y,z,nr_bundles])
    custom_path/HCP/subject_02/
          ...
    
  6. Preprocess the data using tractseg/data/preprocessing.py to remove all non-brain area (crop to brain bounding box). Adapt the data pathes in tractseg/data/preprocessing.py to fit your data (look for #todo: adapt inside of the file.)
  7. Adapt the file tractseg/config/custom/My_custom_experiment.py.
  8. Create a file ~/.tractseg/config.txt. This contains the path to your data directory working_dir=XXX, e.g. working_dir=custom_path.
  9. Adapt tractseg.data.dataset_specific_utils.get_bundle_names() with the bundles you use in your reference data.
  10. Adapt tractseg.data.dataset_specific_utils.get_labels_filename() with the names of your label files.
  11. Adapt tractseg.data.Subjects with the list of your subject IDs.
  12. Run ExpRunner --config My_custom_experiment
  13. custom_path/hcp_exp/My_custom_experiment contains the results

Docker

To build a docker container with all dependencies run the following command in project root:

sudo docker build -t tractseg_container -f Dockerfile_CPU .

NOTE: With docker the option --plot3D of the command plot_tractometry_results might not work.

Copyright

Copyright © German Cancer Research Center (DKFZ), Division of Medical Image Computing (MIC). Please make sure that your usage of this code is in compliance with the code license.

tractseg's People

Contributors

elder-mama avatar eliaskoromilas avatar magreiner avatar soichih avatar stavraspa avatar wasserth avatar

Stargazers

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

Watchers

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

tractseg's Issues

'move_streamlines' not found in dipy.tracking.utils

Hi,

After having to reset my PC, I installed TractSeg again (installation was successful). However, on trying to run some Tractometry codes, the following error comes up:

Traceback (most recent call last):
  File "/usr/bin/Tractometry", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/home/fsluser/Documents/TractSeg-1.9/bin/Tractometry", line 28, in <module>
    from dipy.tracking.utils import move_streamlines
ImportError: cannot import name 'move_streamlines'

I checked the file utils.py in python/site-packages/dipy/tracking/ and the function move_streamlines() is no longer in there. I was wondering what is happening here.

Question about the data for training my own model.

Hi, I have downloaded the HCP_105 data for training my own model.
For the second step, should I put these 144 bundle masks together to get the files named bundle_masks.nii.gz (Reference bundle masks; shape: [x,y,z,nr_bundles])?
What's more, for the third step, I don't know if the data has been preprocessed. Is whether I'm going to preprocess the data using tractseg/data/preprocessing.py to remove all non-brain area (crop to brain bounding box). Adapt the data pathes in tractseg/data/preprocessing.py to fit your data (look for #todo: adapt inside of the file.)

dwi2fod and sh2peaks are using all cpus.

Hi.
When I train my own model, I use this command TractSeg -i data.nii.gz -o tractseg_output --raw_diffusion_input --csd_type csd_msmt --brain_mask nodif_brain_mask.nii.gz --bvals bvals --bvecs bvecs to get peaks.
When it meets dwi2fod and sh2peaks command, I always use all cpus. Is this reasonable?
Is this the right way of training model to get the mrtrix_peaks.nii.gz (mrtrix CSD peaks; shape: [x,y,z,9])?

loss become minus when train my own model

Thanks for your work, and it works pretty well by using pretrained model. However, the loss become minus when I train my own model.

First, I generated the peak.nii.gz by using the command you provided, and converted the tract to volume, which is provided on Zenodo. Then I mated all bundles(72) into one 4D img.

After that, I adapted my_custom_experiment.py AND ~/.tractseg/config.txt .
Due to the HCP data, the following functions are not changed
tractseg.libs.DatasetUtils.scale_input_to_unet_shape()
tractseg.libs.exp_utils.get_bundle_names()
tractseg.libs.exp_utils.get_labels_filename()
tractseg.libs.Subjects

Here is my hyperparameters

{'BATCH_NORM': False,
'BATCH_SIZE': 47,
'BEST_EPOCH': 0,
'CALC_F1': True,
'CLASSES': 'All',
'CSD_RESOLUTION': 'LOW',
'CV_FOLD': 0,
'DATASET': 'HCP',
'DATASET_FOLDER': 'HCP',
'DATA_AUGMENTATION': False,
'DAUG_ELASTIC_DEFORM': True,
'DAUG_FLIP_PEAKS': False,
'DAUG_INFO': 'Elastic(90,120)(9,11) - Scale(0.9, 1.5) - CenterDist60 - '
'DownsampScipy(0.5,1) - Gaussian(0,0.05) - Rotate(-0.8,0.8)',
'DAUG_MIRROR': False,
'DAUG_NOISE': True,
'DAUG_RESAMPLE': True,
'DAUG_ROTATE': False,
'DAUG_SCALE': True,
'DIM': '2D',
'DROPOUT_SAMPLING': False,
'EPOCH_MULTIPLIER': 1,
'EXPERIMENT_TYPE': 'tract_segmentation',
'EXP_MULTI_NAME': '',
'EXP_NAME': 'my_custom_experiment',
'EXP_PATH': 'XXX/hcp_exp/my_custom_experiment_x2',
'FEATURES_FILENAME': 'peaks',
'FLIP_OUTPUT_PEAKS': True,
'GET_PROBS': False,
'INFO': '-',
'INPUT_DIM': (144, 144),
'KEEP_INTERMEDIATE_FILES': False,
'LABELS_FILENAME': 'bundle_masks',
'LABELS_FOLDER': 'bundle_masks',
'LEARNING_RATE': 0.001,
'LOAD_WEIGHTS': False,
'LOSS_FUNCTION': 'default',
'LOSS_WEIGHT': 1,
'LOSS_WEIGHT_LEN': -1,
'LR_SCHEDULE': False,
'MODEL': 'UNet_Pytorch',
'MULTI_PARENT_PATH': 'XXX/hcp_exp/',
'NORMALIZE_DATA': True,
'NORMALIZE_PER_CHANNEL': False,
'NR_CPUS': -1,
'NR_OF_CLASSES': 72,
'NR_OF_GRADIENTS': 9,
'NR_SLICES': 1,
'NUM_EPOCHS': 250,
'OPTIMIZER': 'Adamax',
'OUTPUT_MULTIPLE_FILES': False,
'PEAK_DICE_LEN_THR': 0.05,
'PEAK_DICE_THR': [0.95],
'PREDICT_IMG': False,
'PREDICT_IMG_OUTPUT': None,
'PRINT_FREQ': 20,
'RESET_LAST_LAYER': False,
'RESOLUTION': '1.25mm',
'SAVE_WEIGHTS': True,
'SEGMENT': False,
'SEG_INPUT': 'Peaks',
'SLICE_DIRECTION': 'y',
'TEST': False,
'TEST_TIME_DAUG': False,
'THRESHOLD': 0.5,
'TRACTSEG_DIR': 'tractseg_output',
'TRAIN': True,
'TRAINING_SLICE_DIRECTION': 'xyz',
'TYPE': 'single_direction',
'UNET_NR_FILT': 64,
'UPSAMPLE_TYPE': 'bilinear',
'USE_DROPOUT': False,
'USE_VISLOGGER': False,
'VERBOSE': True,
'WEIGHTS_PATH': '',
'WEIGHT_DECAY': 0}

To solve the bugs, I changed 2 lines

FIRST:
trainer.py 164
from

metrics = metric_utils.calculate_metrics(metrics, None, None, loss, f1=np.mean(f1), type=type,
                                                                 threshold=Config.THRESHOLD)

to

peak_f1_mean = np.array([s.item() for s in f1]).mean()
metrics = metric_utils.calculate_metrics(metrics, None, None, loss, f1=peak_f1_mean, type=type,
                                                                 threshold=Config.THRESHOLD)

for the error
'torch.dtype' object has no attribute 'type'

SECOND:
from

self.net = NetworkClass(n_input_channels=NR_OF_GRADIENTS, n_classes=self.Config.NR_OF_CLASSES,
                                n_filt=self.Config.UNET_NR_FILT, batchnorm=self.Config.BATCH_NORM,
                                dropout=self.Config.USE_DROPOUT, upsample=self.Config.UPSAMPLE_TYPE)

to

self.net = NetworkClass(n_input_channels=NR_OF_GRADIENTS, n_classes=self.Config.NR_OF_CLASSES,
                                n_filt=self.Config.UNET_NR_FILT, batchnorm=self.Config.BATCH_NORM,
                                dropout=self.Config.USE_DROPOUT)

for the error
TypeError: __init__() got an unexpected keyword argument 'upsample'

After these changes above, I can run, but the loss is minus

train Ep 0, Sp 940, loss -12.775692, t print 182.392s, t batch 9.12s
train Ep 0, Sp 1880, loss -444671.51571, t print 86.198s, t batch 4.31s
train Ep 0, Sp 2820, loss -2378428503.875, t print 87.207s, t batch 4.36s
train Ep 0, Sp 3760, loss -512482880699494.4, t print 86.612s, t batch 4.331s
train Ep 0, Sp 4700, loss -6.402550831420487e+18, t print 85.732s, t batch 4.287s

Is there anything that I missed or wrong?

No such file or no access: 'tractseg_output/peaks.nii.gz'

EDIT

Problem solved. It turns out that the bvals file I used wasn't called "data.bvals", and so mrconvert failed. Using the "--verbose" option let me to the correct error file, which made it all clear.

Dear Jakob (and other developers),

First of all, thanks for making this wonderful tool available for the community!

I'm using the latest version of TractSeg (1.9) in an anaconda3 environment on Ubuntu 18.04 (64bit). Usually I can run it with no problems on HCP data (7T diffusion), however now I use the following command:

TractSeg -i /path/to/dwi.nii.gz -o /path/to/outdir --raw_diffusion_input

and get the following FileNotFoundError:

No such file or no access: 'outdir/peaks.nii.gz'

And indeed, the peaks file is not being created.
Such an error was raised by another user in a closed issue, however I wasn't able to resolve it.

Do you have an idea what might cause this?
Many thanks,
Best,
Roey

Tractometry results

Dear Jakob,

First of all, thanks for this great tool!
Using the documentation, I was able to create bundles and extract FA values for most of my sample.
However, sometimes a subject does not have 1 bundle (for example, the ICP_right - "tract endings mask of ICP_right empty" ) and it does not seem like Tractometry can give me the .csv output with the 71 available. I'm not particularly interested in this bundle now, so I would rather use all the rest at this point.
Is there a way to do that?

Thanks!!
João Paulo

Not using GPU

I was able to run TractSeg successfully, but it didn't use our GPU available on our machine.

Here is the output

Creating brain mask...
Creating peaks (1 of 3)...
dwi2response: [ERROR] Output file './tractseg_output/response.txt' already exists (use -force to override)
Creating peaks (2 of 3)...
dwi2fod: [ERROR] output file "./tractseg_output/WM_FODs.mif" already exists (use -force option to force overwrite)
dwi2fod: [ERROR] error creating image "./tractseg_output/WM_FODs.mif"
Creating peaks (3 of 3)...
sh2peaks: [ERROR] output file "./tractseg_output/peaks.nii.gz" already exists (use -force option to force overwrite)
sh2peaks: [ERROR] error creating image "./tractseg_output/peaks.nii.gz"
Loading weights from: /.tractseg/pretrained_weights_tract_segmentation_v1.npz
Processing direction (1 of 3)
100%|########################################################################################| 144/144 [03:35<00:00,  1.49s/it]
Processing direction (2 of 3)
100%|########################################################################################| 144/144 [03:32<00:00,  1.47s/it]
Processing direction (3 of 3)
100%|########################################################################################| 144/144 [03:32<00:00,  1.47s/it]

real	11m40.197s
user	13m58.256s
sys	0m29.791s

I am running it through singularity with nvidia/cuda:9.0-cudnn7-runtime-ubuntu16.04 container, but other App that we run in similar manner can use our GPU just fine. I believe something needs to be reconfiguref for TractSeg for it to detect/use the GPU. How can I troubleshoot this?

Prestaging pretrained_weights_peak_regression_partX_v1.npz

Is there a way to prestage those pretrained_weights_peak_regression_partX_v1.npz files that gets loaded when I run with --output_type endings_segmentation? I am running TractSeg via singularity and singularity doesn't let me write to the container image (without going through some hoops) at runtime. It would make it easier if I could prestage those files just like other files that I am prestaging on Dockerfile.

RUN curl -SL -o /.tractseg/pretrained_weights_tract_segmentation_v2.npz https://zenodo.org/record/1410884/files/best_weights_ep274.npz?download=1 \
    && curl -SL -o /.tractseg/pretrained_weights_tract_segmentation_dropout_v2.npz https://zenodo.org/record/1414130/files/best_weights_ep407.npz?download=1 \
    && curl -SL -o /.tractseg/pretrained_weights_endings_segmentation_v3.npz https://zenodo.org/record/1409670/files/EndingsSeg_best_weights_ep234.npz?download=1 \
    && curl -SL -o /.tractseg/pretrained_weights_peak_regression_v2.npz https://zenodo.org/record/1419198/files/best_weights_ep125.npz?download=1 \
    && curl -SL -o /.tractseg/pretrained_weights_dm_regression_v1.npz https://zenodo.org/record/1409676/files/DmReg_best_weights_ep427.npz?download=1

I am hoping I could just add pretrained_weights_peak_regression files in the list above? Is that possible?

Faulty tracts when when feeding already calculated peaks and TOMs

Hi, we're encountering faulty tracks when we feed previously calculated peaks and segmentations, as seen in the attached image. We tested with both .trk and .tck formats.
If we enter the command to calculate all data from scratch it works fine, but it unfortunately has to create the peaks and toms again.
tractseg_error

cannot access file "/HCP105/599469/T1w/Diffusion/T1w_acpc_dc_restore_brain.nii.gz": No such file or directory

Hi.
When I run TractSeg -i Diffusion.nii.gz -o tractseg_output --raw_diffusion_input --csd_type csd_msmt_5tt --brain_mask nodif_brain_mask.nii.gz , the following error occurs.

(pytorch) qilu@user-SYS-7048GR-TR:/data1/qilu/HCP105/599469/T1w/Diffusion$ TractSeg -i Diffusion.nii.gz -o tractseg_output --raw_diffusion_input --csd_type csd_msmt_5tt --brain_mask nodif_brain_mask.nii.gz
Creating peaks (1 of 4)...
5ttgen:
5ttgen: Note that this script makes use of commands / algorithms that have relevant articles for citation; INCLUDING FROM EXTERNAL SOFTWARE PACKAGES. Please consult the help page (-help option) for more information.
5ttgen:
5ttgen: Generated temporary directory: /data1/qilu/HCP105/599469/T1w/Diffusion/5ttgen-tmp-O35FDC/
mrinfo: [ERROR] cannot access file "/data1/qilu/HCP105/599469/T1w/Diffusion/T1w_acpc_dc_restore_brain.nii.gz": No such file or directory
mrinfo: [ERROR] error opening image "/data1/qilu/HCP105/599469/T1w/Diffusion/T1w_acpc_dc_restore_brain.nii.gz"
5ttgen: [ERROR] Could not access header information for image '/data1/qilu/HCP105/599469/T1w/Diffusion/T1w_acpc_dc_restore_brain.nii.gz'
5ttgen: Contents of temporary directory kept, location: /data1/qilu/HCP105/599469/T1w/Diffusion/5ttgen-tmp-O35FDC/
Creating peaks (2 of 4)...
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 temporary directory: /data1/qilu/HCP105/599469/T1w/Diffusion/dwi2response-tmp-X8FTEU/
Command: mrconvert /data1/qilu/HCP105/599469/T1w/Diffusion/Diffusion.nii.gz /data1/qilu/HCP105/599469/T1w/Diffusion/dwi2response-tmp-X8FTEU/dwi.mif -strides 0,0,0,1 -fslgrad /data1/qilu/HCP105/599469/T1w/Diffusion/Diffusion.bvecs /data1/qilu/HCP105/599469/T1w/Diffusion/Diffusion.bvals
dwi2response:
dwi2response: [ERROR] Command failed: mrconvert /data1/qilu/HCP105/599469/T1w/Diffusion/Diffusion.nii.gz /data1/qilu/HCP105/599469/T1w/Diffusion/dwi2response-tmp-X8FTEU/dwi.mif -strides 0,0,0,1 -fslgrad /data1/qilu/HCP105/599469/T1w/Diffusion/Diffusion.bvecs /data1/qilu/HCP105/599469/T1w/Diffusion/Diffusion.bvals (dwi2response:86)
dwi2response: Output of failed command:
mrconvert: [ERROR] input file "/data1/qilu/HCP105/599469/T1w/Diffusion/Diffusion.bvecs" for option "-fslgrad" not found
dwi2response:
dwi2response: Script failed while executing the command: mrconvert /data1/qilu/HCP105/599469/T1w/Diffusion/Diffusion.nii.gz /data1/qilu/HCP105/599469/T1w/Diffusion/dwi2response-tmp-X8FTEU/dwi.mif -strides 0,0,0,1 -fslgrad /data1/qilu/HCP105/599469/T1w/Diffusion/Diffusion.bvecs /data1/qilu/HCP105/599469/T1w/Diffusion/Diffusion.bvals
dwi2response: For debugging, inspect contents of temporary directory: /data1/qilu/HCP105/599469/T1w/Diffusion/dwi2response-tmp-X8FTEU/
Creating peaks (3 of 4)...
dwi2fod: [ERROR] input file "Diffusion.bvecs" for option "-fslgrad" not found
Creating peaks (4 of 4)...
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 "/home/qilu/anaconda2/envs/pytorch/bin/TractSeg", line 382, in
main()
File "/home/qilu/anaconda2/envs/pytorch/bin/TractSeg", line 253, in main
data_img = nib.load(peak_path)
File "/home/qilu/anaconda2/envs/pytorch/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'

Do I need to change the file name to the following form?
image

Or is something wrong?
image

Clinical tumor data

Hi, I'm testing with a clinical data set of a tumor patient. I noticed that when feeding a preprocessed and upscaled Diffusion.nii.gz file and it's bvecs/bvals, the results are slightly better (after dwidenoise, mrdegibbs, dwipreproc, dwibiascorrect (ants), mrresize (1.25 voxel size) in the respective order).

Still, the bundle_segmentation files are partly empty or incomplete but not necessarily at the tumor location where one would assume interruption or difficulties.
Manually, fibers are traceable at the interrupted areas.

Can you provide a hint?
(I'll continue testing on different tumor patients.)
Best, Lucius

Command failed: mrconvert

I am seeing a strange error message when TractSeg runs dwi2response.

+ TractSeg -i dwi.nii.gz --raw_diffusion_input --csd_type csd_msmt_5tt --output_type tract_segmentation --keep_intermediate_files --postprocess -o .
INFO: font search path ['/usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data/fonts/ttf', '/usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data/fonts/afm', '/usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data/fonts/pdfcorefonts']
INFO: generated new fontManager
5ttgen: 
5ttgen: Note that this script makes use of commands / algorithms that have relevant articles for citation; INCLUDING FROM EXTERNAL SOFTWARE PACKAGES. Please consult the help page (-help option) for more information.
5ttgen: 
5ttgen: Generated temporary directory: /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/5ttgen-tmp-ANNWFJ/
Command:  mrconvert /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/T1w_acpc_dc_restore_brain.nii.gz /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/5ttgen-tmp-ANNWFJ/input.mif
5ttgen: Changing to temporary directory (/N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/5ttgen-tmp-ANNWFJ/)
5ttgen: [WARNING] Voxel size larger than expected for T1-weighted images ([1.25, 1.25, 1.25]); note that ACT does not require re-gridding of T1 image to DWI space, and indeed retaining the original higher resolution of the T1 image is preferable
Command:  mrconvert input.mif T1.nii -strides -1,+2,+3
Command:  fsl5.0-fast T1.nii
5ttgen: [WARNING] Generating 1mm isotropic T1 image for FIRST in hope of preventing failure, since input image is of lower resolution
Command:  mrresize T1.nii T1_1mm.nii -voxel 1.0 -interp sinc
Command:  fsl5.0-run_first_all -m none -s L_Accu,R_Accu,L_Caud,R_Caud,L_Pall,R_Pall,L_Puta,R_Puta,L_Thal,R_Thal -i T1_1mm.nii -o first -b
5ttgen: Generating partial volume images for SGM structures... [=======================================================]
Command:  mrmath mesh2voxel_L_Accu.mif mesh2voxel_R_Accu.mif mesh2voxel_L_Caud.mif mesh2voxel_R_Caud.mif mesh2voxel_L_Pall.mif mesh2voxel_R_Pall.mif mesh2voxel_L_Puta.mif mesh2voxel_R_Puta.mif mesh2voxel_L_Thal.mif mesh2voxel_R_Thal.mif sum - | mrcalc - 1.0 -min all_sgms.mif
Command:  mrthreshold T1_pve_2.nii.gz - -abs 0.001 | maskfilter - connect - -connectivity | mrcalc 1 - 1 -gt -sub remove_unconnected_wm_mask.mif -datatype bit
Command:  mrcalc T1_pve_0.nii.gz remove_unconnected_wm_mask.mif -mult csf.mif
Command:  mrcalc 1.0 csf.mif -sub all_sgms.mif -min sgm.mif
Command:  mrcalc 1.0 csf.mif sgm.mif -add -sub T1_pve_1.nii.gz T1_pve_2.nii.gz -add -div multiplier.mif
Command:  mrcalc multiplier.mif -finite multiplier.mif 0.0 -if multiplier_noNAN.mif
Command:  mrcalc T1_pve_1.nii.gz multiplier_noNAN.mif -mult remove_unconnected_wm_mask.mif -mult cgm.mif
Command:  mrcalc T1_pve_2.nii.gz multiplier_noNAN.mif -mult remove_unconnected_wm_mask.mif -mult wm.mif
Command:  mrcalc 0 wm.mif -min path.mif
Command:  mrcat cgm.mif sgm.mif wm.mif csf.mif path.mif - -axis 3 | mrconvert - combined_precrop.mif -strides +2,+3,+4,+1
Command:  mrmath combined_precrop.mif sum - -axis 3 | mrthreshold - - -abs 0.5 | mrcrop combined_precrop.mif result.mif -mask -
Command:  5ttcheck result.mif
Command:  mrconvert result.mif /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/tractseg_output/5TT.mif
5ttgen: Changing back to original directory (/N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc)
5ttgen: Deleting temporary directory /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/5ttgen-tmp-ANNWFJ/
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 temporary directory: /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/dwi2response-tmp-JCCNB0/
Command:  mrconvert /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/dwi.nii.gz /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/dwi2response-tmp-JCCNB0/dwi.mif -strides 0,0,0,1 -fslgrad /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/dwi.bvecs /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/dwi.bvals
dwi2response: 
dwi2response: [ERROR] Command failed: mrconvert /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/dwi.nii.gz /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/dwi2response-tmp-JCCNB0/dwi.mif -strides 0,0,0,1 -fslgrad /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/dwi.bvecs /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/dwi.bvals (dwi2response:86)
dwi2response: Output of failed command:
              mrconvert: uncompressing image "/N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/dwi.nii.gz"...  [==================================================]
dwi2response: 
dwi2response: Script failed while executing the command: mrconvert /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/dwi.nii.gz /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/dwi2response-tmp-JCCNB0/dwi.mif -strides 0,0,0,1 -fslgrad /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/dwi.bvecs /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/dwi.bvals
dwi2response: For debugging, inspect contents of temporary directory: /N/dc2/scratch/brlife/karst-workflows/5bc53b4549193400454aae1d/5bd09669d0414253317dfcbc/dwi2response-tmp-JCCNB0/

I am seeing this error on about 5% of jobs launched on various computing resources (across all HCP3T subjects). A strange thing is that, mrconvert seems to be suceeding with generating the dwi.mif.

screenshot from 2018-10-24 21-08-10

When I just run the "failing" command, it also successfully generate the dwi.mif. It's as if dwi2response script is incorrectly determining that the command is failing when in fact it's not.

I am not sure if this is really TractSeg issue or not, but since this issue only seems to happen when TractSeg runs it, I am hoping someone who might be having this issue could assist us.

wrong dimension segmentations (146x174x146x72)

Hi @wasserth,
I've noticed that the 4D .nii.gz segmentations output masks have dimensions (146x174x146x72). I'm using HCP data and TractSeg version v1.9. In the function scale_input_to_world_shape there is a scaling to those dimensions, while I guess it should be (145x174x145x72).
if resolution == "1.25mm":
if dataset == "HCP": # (144,144,144)
# no resize needed
return img_utils.pad_4d_image_left(img4d, np.array([1, 15, 1, 0]),
[146, 174, 146, img4d.shape[3]], pad_value=0) # (146, 174, 146, none)
Do you have an explanation for this?
Thank you!

FileNotFoundError

Hi, I'm new to using TractSeg. I tried to do bundle segmentation of the example provided by TractSeg as follow:

Mudathirs-MacBook-Pro:~ mudathirsalman$ ls examples
Diffusion.bvals Tests
Diffusion.bvecs example_output.nii.gz
Diffusion.nii.gz resources
Diffusion_mrtrix_peaks.nii.gz

But I got the following error:

Mudathirs-MacBook-Pro:/ mudathirsalman$ TractSeg -i /examples/Diffusion.nii.gz
Creating brain mask...

Error: input image /examples/Diffusion not valid

rm: /examples/tractseg_output/nodif_brain_mask.nii.gz: No such file or directory
mv: rename /examples/tractseg_output/nodif_brain_mask_mask.nii.gz to /examples/tractseg_output/nodif_brain_mask.nii.gz: No such file or directory
Creating peaks (1 of 3)...
Traceback (most recent call last):
File "/Users/mudathirsalman/mrtrix3/bin/dwi2response", line 80, in
app.makeTempDir()
File "/Users/mudathirsalman/mrtrix3/lib/mrtrix3/app.py", line 226, in makeTempDir
dir_path = dict.get('ScriptTmpDir', workingDir)
TypeError: descriptor 'get' requires a 'dict' object but received a 'str'
Creating peaks (2 of 3)...
dwi2fod: [ERROR] input file "/examples/Diffusion.bvecs" for option "-fslgrad" not found
Creating peaks (3 of 3)...
sh2peaks: [ERROR] failed to open key/value file "/examples/tractseg_output/WM_FODs.mif": No such file or directory
sh2peaks: [ERROR] error opening image "/examples/tractseg_output/WM_FODs.mif"
Traceback (most recent call last):
File "/Users/mudathirsalman/anaconda3/bin/TractSeg", line 109, in
data_img = nib.load(join(HP.PREDICT_IMG_OUTPUT, "peaks.nii.gz"))
File "/Users/mudathirsalman/anaconda3/lib/python3.6/site-packages/nibabel/loadsave.py", line 40, in load
raise FileNotFoundError("No such file: '%s'" % filename)
FileNotFoundError: No such file: '/examples/tractseg_output/peaks.nii.gz'

I checked FSL and MRtrix all are working fine. I wonder where was my mistake. Thanks

Tracking on Peaks or on FOD?

Dear TractSeg community,

I am using diffusion data with a b=1000 shell and 30 directions. On the tutorial, it is written (if I understood clearly) that for data with poor resolution, the Tracking command should be executed with its default behavior, i.e. tracking is performed on peaks, which i did. But I also tried Tracking with the --track_FODs iFOD2 option, i.e. tracking is performed on FOD.

On the image below, you can see the corticospinal tract with tracking performed on peaks on the left, and corticospinal tract with tracking performed on FOD on the right.

alt text

The FOD-tracking looks more... noisy? while it manages to capture fibers that look like they should belong to the CST (the lateral branch and the dorsal fibers of the tract are more complete), comparatively to the peaks-Tracking. For the latter method, it looks like the CST is incomplete.

Below is an image of the CST + AF with peaks-tracking on the left and FOD-tracking on the right.

alt text

As you can see, for peaks-tracking, these two tracts have little overlap (white voxels) comparatively to the FOD-tracking method.

Do you have any insights of what could I do to obtain what would appear as an ideal middle ground, i.e. a complete CST (i.e., FOD-tracking), but not too noisy (i.e., peaks-Tracking)?

I also have another dataset with high-resolution multishell data. In this case, which Tracking method should be preferred?

Thanks a lot for your help.

Hosting TractSeg on brainlife.io

@wasserth Jakob,

(I couldn't find your email address so I appologize in advance for posting it here!) As you might have noticed, I've been playing with TractSeg for the last few weeks and I am super impressed by what it can do! I've tested with a few of HCP dataset as well as some NKI data - both worked nicely!

I am actually a software engineer at Indiana University working for a NSF funded project called BrainLife and our platform allows researchers to publish algorithms as Apps and allows users to execute them on our compute resources. Apps can interface with other Apps developed by other researches through the use of registered datatypes to easily construct a workflow and explore new ways to use the algorithms.

I've registered an App on BrainLife here.

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

If you would signup on BrainLife, you will be able to run your App by visiting "Execute" tab via above URL.

I'd like to know if you have any concerns or questions about our platform and if you could let us publish your App through it. By having your App published on BrainLife, other users can discover and try your App with their own datasets, and take the output from your App and feed it to other registered Apps such as ..

This App can take tract masks and generate 3D volumes of the tracts and visualize them online (without having to download any software)

screenshot from 2018-08-30 12-04-28

The output from 3D tract surfaces can then used by other Apps such as

etc..

As you can see, users can quickly explore / compare different Apps on our platform and promote code reuse and sharing across different fields of science.

I hope you will be interested in Brainlife, and please feel free to contact me directly at [email protected], or on our slack channel I am looking forward to hearing from you!

Thank you,
Soichi

How can I get the bundle_masks.nii.gz?

If I want to train my own model, I need files named bundle_masks.nii.gz (Reference bundle masks; shape: [x,y,z,nr_bundles]). But I have only 144 independent bundle masks after running TractSeg. Should I put these 144 bundle masks together to get the shape: [x,y,z,nr_bundles]?

Tractometry in native space

First of all, thanks for this great tool!
One quick question. Following instructions as per https://github.com/MIC-DKFZ/TractSeg/blob/master/resources/Tractometry_documentation.md WITHOUT NORMALIZING TO MNI SPACE will still allow me to get the 20 nodes for each tract (in native space) in all my subjects.
AFQ defines the tracts in native space to ultimately 'project' the tract-profiles in MNI space (I guess). Is there a reason why you are suggesting to run the tractometry in MNI space for display purpose?
Thanks a lot!!
Amelia

Feed TOM for subsequent tracking

Hi, is it possible to perform tractography via --track or --only_track after the TOM segmentations have already been calculated by feeding existing TOM paths to the command?
We noticed that it shows errors since it generates a new tract_seg_output folder in which it can't find the TOMs because they are in a different output folder from a previous calculation.
With that option we could save time and wouldn't have to calculate the TOMs again.
Best, Lucius

--nr_cpus not used to run dwi2response

@wasserth Thank you for adding the --nr_cpus option (#13 (comment))

However, it looks like this option is not propagated to various commands that TractSeg runs internally. One such command that I noticed was the dwi2response.

dwi2response has the following option

  -nthreads number
     Use this number of threads in MRtrix multi-threaded applications (0
     disables multi-threading)

I believe nr_cpus option should be used to set this parameter?

.tck instead of .trk

Thank you very much for providing TractSeg.
Where exactly can I change the output format of the tractography files from .trk to .tck or add an additional .tck output to the existing .trk?

Since csd etc. is performed within mrtrix and all my other pipelines and workflows are using mrtrix, I would like to be able to stay within and use mrview for visualisation instead of trackvis.

The python script trk2tck.py outputs erroneous files, furthermore, I'd rather like to output a .tck file directly.
Thank you very much in advance, Lucius

Error: MultiThreadedAugmenter object is not an iterator.

Hi. I try to train the model using the first 11 HCP subjects. When I run ExpRunner --config My_custom_experiment, I meet the following error.
image

At first I thought there was a difference between python2 and python3 on the iterator. So I changed the __next__ function to next function. Then the error changed to this.
image

So how can I corrcet the first error or the second error?

No such file or no access: 'tractseg_output/peaks.nii.gz'

Hello!

I am trying to run TractSeg via singularity like the following

singularity exec -e docker://gkoehler90/tractseg TractSeg -i dwi.nii.gz

I have following files in my local directory.

hayashis@xps15:~/test/tractseg $ ls -lrt
total 1461344
-rw-r--r-- 1 hayashis hayashis       9507 Jun 25 13:26 dwi.bvecs
-rw-r--r-- 1 hayashis hayashis       1631 Jun 25 13:26 dwi.bvals
-rw-r--r-- 1 hayashis hayashis 1496386061 Jun 25 13:26 dwi.nii.gz

When I run it, I get following error messages.

Loading weights from: /home/hayashis/.tractseg/pretrained_weights_tract_segmentation_v1.npz
Creating brain mask...
sh: 1: bet: not found
rm: cannot remove 'tractseg_output/nodif_brain_mask.nii.gz': No such file or directory
mv: cannot stat 'tractseg_output/nodif_brain_mask_mask.nii.gz': No such file or directory
Creating peaks (1 of 3)...
sh: 1: dwi2response: not found
Creating peaks (2 of 3)...
sh: 1: dwi2fod: not found
Creating peaks (3 of 3)...
sh: 1: sh2peaks: not found
Traceback (most recent call last):
  File "/usr/local/bin/TractSeg", line 137, in <module>
    data_img = nib.load(join(HP.PREDICT_IMG_OUTPUT, "peaks.nii.gz"))
  File "/usr/local/lib/python2.7/dist-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'

On my current directory, I see an empty directory created with the name "tracseg_output".

hayashis@xps15:~/test/tractseg 1 ls -la
total 1461356
drwxrwxr-x  3 hayashis hayashis       4096 Jun 25 13:31 .
drwxrwxr-x 46 hayashis hayashis       4096 Jun 25 12:15 ..
-rw-r--r--  1 hayashis hayashis       1631 Jun 25 13:26 dwi.bvals
-rw-r--r--  1 hayashis hayashis       9507 Jun 25 13:26 dwi.bvecs
-rw-r--r--  1 hayashis hayashis 1496386061 Jun 25 13:26 dwi.nii.gz
drwxrwxr-x  2 hayashis hayashis       4096 Jun 25 13:31 tractseg_output
hayashis@xps15:~/test/tractseg $ ls -a tractseg_output/
.  ..

Am I running this in a wrong way?

UnpicklingError while loading the model with PyTorch

Hi,

I am trying to run the TractSeg project using the following command:
/NAS/tupac/renaud/softwares/TractSegmentation/TractSeg-master/examples$ TractSeg -i Diffusion.nii.gz --verbose

I am using Python 2.7 and installed pytorch from conda.

I get the following error:
Creating brain mask...
Creating peaks (1 of 3)...
Creating peaks (2 of 3)...
Creating peaks (3 of 3)...
Loading weights from: /home/renaud/.tractseg/pretrained_weights_tract_segmentation_v1.npz
Loading weights ... (/home/renaud/.tractseg/pretrained_weights_tract_segmentation_v1.npz)
Traceback (most recent call last):
File "/home/global/anaconda2/bin/TractSeg", line 122, in
bundle_specific_threshold=args.bundle_specific_threshold, get_probs=args.get_probabilities)
File "/home/global/anaconda2/lib/python2.7/site-packages/tractseg/TractSeg.py", line 123, in run_tractseg
model = BaseModel(HP)
File "/home/global/anaconda2/lib/python2.7/site-packages/tractseg/models/BaseModel.py", line 75, in init
self.create_network()
File "/home/global/anaconda2/lib/python2.7/site-packages/tractseg/models/BaseModel.py", line 265, in create_network
load_model(join(self.HP.EXP_PATH, self.HP.WEIGHTS_PATH))
File "/home/global/anaconda2/lib/python2.7/site-packages/tractseg/models/BaseModel.py", line 206, in load_model
PytorchUtils.load_checkpoint(path, unet=net)
File "/home/global/anaconda2/lib/python2.7/site-packages/tractseg/libs/PytorchUtils.py", line 34, in load_checkpoint
checkpoint = torch.load(path, map_location=lambda storage, loc: storage)
File "/home/global/anaconda2/lib/python2.7/site-packages/torch/serialization.py", line 358, in load
return _load(f, map_location, pickle_module)
File "/home/global/anaconda2/lib/python2.7/site-packages/torch/serialization.py", line 532, in _load
magic_number = pickle_module.load(f)
cPickle.UnpicklingError: invalid load key, '<'.

The model file exists and I have the following files in "tractseg_output" folder:
nodif_brain_mask.nii.gz
peaks.nii.gz
response.txt
WM_FODs.mif

Do you think I have an installation issue ?

Kindly let me know what I need to do so that I can use the model.

Renaud

Error: Can't plot tractometry results

Hi,

we received following error when trying to plot the tractometry results:

Traceback (most recent call last):
  File "<stdin>", line 16, in <module>
AttributeError: 'module' object has no attribute 'lineplot'

We changed plt.tight_layout() to plt.show() and installed seaborn 0.9.0 via pip install seaborn==0.9.0, which solved the problem.

Dipy dependence failure

Following the instructions (https://github.com/MIC-DKFZ/TractSeg/#install), I installed TractSeg and tried to run it, but could not because the current version of DiPy does not have the move_streamlines() function in dipy.tracking.utils. I tried to fix this by creating a new virtual environment without DiPy, but the installation of TractSect failed to download the required function from DiPy. This function is something that has been removed from the most recent release of DiPy. See below the error message I got after calling 'TractSeg' after installation.

Traceback (most recent call last):
File "/home/leevi/anaconda3/envs/tractseg/bin/TractSeg", line 38, in
from tractseg.libs import mrtrix
File "/home/leevi/anaconda3/envs/tractseg/lib/python3.7/site-packages/tractseg/libs/mrtrix.py", line 29, in
from tractseg.libs import tracking
File "/home/leevi/anaconda3/envs/tractseg/lib/python3.7/site-packages/tractseg/libs/tracking.py", line 9, in
from dipy.tracking.utils import move_streamlines
ImportError: cannot import name 'move_streamlines' from 'dipy.tracking.utils' (/home/leevi/anaconda3/envs/tractseg/lib/python3.7/site-packages/dipy/tracking/utils.py)

Is there something that I am missing?

could not broadcast input array from shape ..

I started seeing the following error message. I believe it was working fine before with the input data that I am testing with.

Traceback (most recent call last):
  File "/usr/local/bin/TractSeg", line 133, in <module>
    data, flip_done = ImgUtils.flip_peaks_to_correct_orientation_if_needed(data_img)
  File "/usr/local/lib/python2.7/dist-packages/tractseg/libs/ImgUtils.py", line 457, in flip_peaks_to_correct_orientation_if_needed
    peaks = ImgUtils.enfore_shape(peaks, target_shape=(91, 109, 91, 9))
  File "/usr/local/lib/python2.7/dist-packages/tractseg/libs/ImgUtils.py", line 410, in enfore_shape
    data_new[:data.shape[0], :data.shape[1], :data.shape[2]] = data
ValueError: could not broadcast input array from shape (90,108,90,288) into shape (90,108,90,9)

Has anything changed?

An RuntimeError occurred when I used python interface.

Hi.
When I used python interface, the RuntimeError occurred.

import nibabel as nib
import numpy as np
from tractseg.python_api import run_tractseg
peaks = nib.load("tests/reference_files/peaks.nii.gz").get_data()
segmentation = run_tractseg(peaks)

Loading weights from: /home/qilu/.tractseg/pretrained_weights_tract_segmentation_v2.npz
Traceback (most recent call last):
File "", line 1, in
File "tractseg/python_api.py", line 168, in run_tractseg
model = BaseModel(Config)
File "tractseg/models/base_model.py", line 116, in init
self.load_model(join(self.Config.EXP_PATH, self.Config.WEIGHTS_PATH))
File "tractseg/models/base_model.py", line 294, in load_model
pytorch_utils.load_checkpoint(path, unet=self.net)
File "tractseg/libs/pytorch_utils.py", line 36, in load_checkpoint
checkpoint = torch.load(path, map_location=lambda storage, loc: storage)
File "/home/qilu/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/serialization.py", line 368, in load
return _load(f, map_location, pickle_module)
File "/home/qilu/anaconda2/envs/pytorch/lib/python2.7/site-packages/torch/serialization.py", line 549, in _load
deserialized_objects[key]._set_from_file(f, offset, f_should_read_directly)
RuntimeError: unexpected EOF, expected 5801749 more bytes. The file might be corrupted.

How should I modify it?

Low cpu usage?

Hello!

I am running TractSeg with --nr_cpus 8. I've noticed that TractSeg doesn't even pass 200% cpu usage while it runs.

The following is the typical resource usage graph for app-tractseg

screenshot from 2018-12-06 18-59-32

I am wondering if --nr_cpus is not properly applied, or maybe we are not using this option right?

	TractSeg -i dwi.nii.gz --raw_diffusion_input \
		--csd_type $(jq -r .csd config.json) \
		--output_type tract_segmentation \
		--keep_intermediate_files \
		--postprocess \
		--nr_cpus 8 \
		-o . \
		$opts

https://github.com/brainlife/app-tractseg/blob/1.7.1/run.sh#L35

Please comment!

Full anatomical names of 72 tracts

Dear @wasserth and Klaus,

Great work. We have an implementation running quite swiftly on brainlife.io: https://doi.org/10.25663/bl.app.95

Many thanks to Jakob for the help with this given to @soichih

We are looking for a complete list of full anatomical names for the 72 tracts. I see in your paper and on the README file a list of acronyms. Would you please be kind and share with us full names for the tracts? I post here because this might be of help to the users.

Best regards,
Franco

Can't visualize generated .trk

We are having a trouble opening generated .trk files with tractvis. The .trk file loads but I don't see it displayed anywhere.

screenshot from 2018-10-08 20-34-05

track_vis command shows the volume dimension to be all-0

$ ./track_vis CA.trk -l 20

Reading CA.trk ...done
Number of tracks: 2000
Number of tracks to render: 2000
Number of line segments to render: 33812
Mean track length: 68.81 +/- 15.16 mm

Volume dimension: 0 0 0
Voxel size: 1.250 1.250 1.250
Can not load camera info from tmp.cam

I am wondering if affine information is properly stored on generated .trk files.

No complete tractogram file list

Hi, we updated to version 1.7.
After --track, tractography is just performed from ST_FO_left.tck to T_PAR_right.tck, the other tractograms are missing.
The command we used was:

foreach * : TractSeg -i IN/T1w/Diffusion_7T/tractseg_output/peaks.nii.gz -o IN/T1w/Diffusion_7T --output_type TOM --track --filter_tracking_by_endpoints --tracking_format tck --bundle_specific_threshold

TractSeg spends time generating "new fontManager"

I started testing the latest TractSeg 1.9.

I've noticed that TractSeg now spends few minutes generating "new fontManager".

INFO: font search path ['/usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data/fonts/ttf', '/usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data/fonts/afm', '/usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data/fonts/pdfcorefonts']
INFO: generated new fontManager

Iis there anyway to prerun this step to save time? Like.. can this step be done inside download_all_pretrained_weights ?

Erroneous tck format?

Hi,
with the command TractSeg -i peaks_flip_z.nii.gz --output_type TOM --track --only_track --filter_tracking_by_endpoints --super_resolution --tracking_format tck --bundle_specific_threshold
we receive now the error message:
mrview: [ERROR] invalid first line for key/value file "/media/bwgig/64F2-0B2C/S161/tractseg_output/TOM_trackings/AF_left.tck" (expected "mrtrix tracks")
The bundle segmentations, endings segmentations and TOMs look fine and the .tck files are not empty.
We are using Version 1.8.

Deleted wm_fods

If we use --output_type tract_segmentation TractSeg seems to delete previously written wm_fods. Is there another possibility to keep those without moving them to a different location before using --output_type tract_segmentation a second time? This would be helpful, since with our clinical data we sometimes need first to find the proper axis to flip which.

AFD - Tractometry careful consideration

Hi guys,

first of all, congrats on the great tool. Works flawlessly and runs nicely on most datasets I've tested so far. Handles standard and state-of-the-art data (e.g., Connectom generated data) pretty well (>5 shells).

I do however have a small comment/question for future users/devs. regarding the Tractometry option. I see that you provide the option to generate the peak length along the tract (which in some way is a discretized Apparent Fiber Density similar to FBA/AFD analysis in MRtrix).

The problem with the current Tractometry implementation is that each subject is processed independently and therefore the response function is unique to each participant (which is contradictory to the recommended steps for AFD). Typically, one has to take the average response function (or a single 1 and apply it to the whole group to generate the fods.). This will allow a correct comparison of the amplitudes between subjects (e.g. comparing oranges with oranges). Some other steps would, in theory, be needed as well (i.e. bias field correction on the data before giving it as input to TractSeg or mtnormalise the msmt-csd outputs of TractSeg).

As mentioned by Thijs on the MRtrix forums: "In a way, the response function is the unit of your FOD"

Maybe a word of caution on the wiki page would help future users!

Best,
Max

nibabel.py3k.filenotfounderror in docker

Hello,

I'm using Docker Toolbox for Windows 7 to access TractSeg. The command does not read the input file when using tractsegcontainer:master and gives errors same as this user when using tractsegcontainer:v1.4.

I am a bit stumped since I am using Docker (containing all pre-requisites) but still getting these errors.

Would be glad if you could help with this!

Output screens:

docker@default:~$ ls /home/docker/tractseg
dwi.bvals   dwi.bvecs   dwi.nii.gz
docker@default:~$
docker@default:~$ sudo docker run -v /home/docker/tractseg -t wasserth/tractseg
 _container:master TractSeg -i dwi.nii.gz --preprocess
INFO: font search path ['/usr/local/lib/python2.7/dist-packages/matplotlib/mpl-d
 ata/fonts/ttf', '/usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data/font
 s/afm', '/usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data/fonts/pdfcor
 efonts']
 INFO: generated new fontManager
 Traceback (most recent call last):
   File "/usr/local/bin/TractSeg", line 370, in <module>
     main()
   File "/usr/local/bin/TractSeg", line 252, in main
     data_img = nib.load(peak_path)
   File "/usr/local/lib/python2.7/dist-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: 'dwi.nii.gz'
 docker@default:~$

docker@default:~$ sudo docker run -v /home/docker/tractseg -t wasserth/tractseg
_container:v1.4 TractSeg -i dwi.nii.gz --preprocess
usage: TractSeg [-h] -i filepath [-o directory] [--output_multiple_files]
                [--csd_type csd|csd_msmt|csd_msmt_5tt]
                [--output_type tract_segmentation|endings_segmentation|TOM|dm_re
gression]
                [--bvals filename] [--bvecs filename] [--brain_mask filename]
                [--verbose] [--skip_peak_extraction]
                [--keep_intermediate_files] [--preview] [--flip]
                [--single_orientation] [--bundle_specific_threshold]
                [--get_probabilities] [--version]
TractSeg: error: unrecognized arguments: --preprocess
docker@default:~$
docker@default:~$ sudo docker run -v /home/docker/tractseg -t wasserth/tractseg
_container:v1.4 TractSeg -i dwi.nii.gz
Creating brain mask...

Error: input image dwi not valid

rm: cannot remove 'tractseg_output/nodif_brain_mask.nii.gz': No such file or dir
ectory
mv: cannot stat 'tractseg_output/nodif_brain_mask_mask.nii.gz': No such file or
directory
Creating peaks (1 of 3)...
dwi2response: [ERROR] Command failed: mrconvert /dwi.nii.gz - -strides 0,0,0,1 -
fslgrad /dwi.bvecs /dwi.bvals | dwiextract - /dwi2response-tmp-7QS2GT/dwi.mif -s
ingleshell -no_bzero (dwi2response:84)
dwi2response: Output of failed command:
              mrconvert: [ERROR] input file "/dwi.bvecs" for option "-fslgrad" n
ot found
              dwiextract: [ERROR] no filename supplied to standard input (broken
 pipe?)
              dwiextract: [ERROR] error opening image "-"
dwi2response: Script failed while executing the command: mrconvert /dwi.nii.gz -
 -strides 0,0,0,1 -fslgrad /dwi.bvecs /dwi.bvals | dwiextract - /dwi2response-tm
p-7QS2GT/dwi.mif -singleshell -no_bzero
dwi2response: For debugging, inspect contents of temporary directory: /dwi2respo
nse-tmp-7QS2GT/
Creating peaks (2 of 3)...
dwi2fod: [ERROR] input file "dwi.bvecs" for option "-fslgrad" not found
Creating peaks (3 of 3)...
sh2peaks: [ERROR] failed to open key/value file "tractseg_output/WM_FODs.mif": N
o such file or directory
sh2peaks: [ERROR] error opening image "tractseg_output/WM_FODs.mif"
Traceback (most recent call last):
  File "/usr/local/bin/TractSeg", line 113, in <module>
    data_img = nib.load(join(HP.PREDICT_IMG_OUTPUT, "peaks.nii.gz"))
  File "/usr/local/lib/python2.7/dist-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/peak
s.nii.gz'
docker@default:~$

Please do let me know if you need more information. Thanks!

Questions about Tractseg

Thanks a lot for this tool, it's just great!
I have a few dumb questions.

  1. I already did CSD estimation on my data with mrtrix's dwi2fod command. So I guess I need to convert the ODF images into peaks images with mrtrix's sh2peaks command?

I tried to generate the CSD peaks with TractSeg, but doing so gave the following error:

TractSeg -i diffusion.nii --bvals diffusion_bvals --bvecs diffusion_bvecs --raw_diffusion_input 
--preprocess --output_type tract_segmentation --csd_type csd

Creating brain mask...
Moving input to MNI space...
Creating brain mask...
Creating peaks (1 of 3)...

Traceback (most recent call last):
  File "/usr/local/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: '327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n327328 \n3

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 "//anaconda/lib/python3.6/site-packages/nibabel/loadsave.py", line 40, 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 "//anaconda/bin/TractSeg", line 303, in <module>
    main()
  File "//anaconda/bin/TractSeg", line 201, in main
    data_img = nib.load(peak_path)
  File "//anaconda/lib/python3.6/site-packages/nibabel/loadsave.py", line 42, in load
    raise FileNotFoundError("No such file or no access: '%s'" % filename)
FileNotFoundError: No such file or no access: 'tractseg_output/peaks.nii.gz'

So it seems to be caused by a mask generation error from mrtrix? As I already encountered issues on my data when using dwi2mask, I am now using masks computed with fsl bet.

  1. Are the two bits of code below performing the same thing, i.e. probabilistic tracking on TOM, or is there a difference?
TractSeg -i peaks.nii.gz --output_type TOM 
Tracking -i peaks.nii.gz

and

TractSeg -i peaks.nii.gz --output_type TOM --track --only_track

  1. Just to make sure: if i use the preprocess option, then I don't need to align my images with the MNI space before using TractSeg?

Thanks a lot.

TractSet for DSI

Dear TractSeg Developers:
Thanks for the wonderful new tool.
May I know if TractSeg is suitable for DSI? If so, any tweaks are needed?
Thanks.

Min

The question about batchgenerators and FlipVectorAxisTransform.

Hi.
I am training my model. And I have installed batchgenerators-0.19.4. But I can't install FlipVectorAxisTransform. The error is as follows.

Collecting FlipVectorAxisTransform
  ERROR: Could not find a version that satisfies the requirement FlipVectorAxisTransform (from versions: none)
ERROR: No matching distribution found for FlipVectorAxisTransform

How can I solve this problem?

Tractometry sampling

Hello,

Just wondering when tractometry code samples FA values along the tract, is this done is a pre-determined way? As in, is the sampling always done in anterior to posterior direction/ or superior-inferior?

The x-axis of the plot produced is 'position' - I was not quite clear how this maps to anatomical positions.

Thanks,

Surya

--preprocess fails with missing MNI template

I've installed TractSeg by doing

pip install https://github.com/MIC-DKFZ/TractSeg/archive/v1.5.zip

When I run TractSeg with --preprocess option, it fails with following error message.

Moving input to MNI space...
Image Exception : #22 :: ERROR: Could not open image /usr/local/lib/python2.7/dist-packages/tractseg/libs/../../examples/resources/MNI_FA_template
terminate called after throwing an instance of 'RBD_COMMON::BaseException'
Image Exception : #22 :: ERROR: Could not open image /usr/local/lib/python2.7/dist-packages/tractseg/libs/../../examples/resources/MNI_FA_template
terminate called after throwing an instance of 'RBD_COMMON::BaseException'

Is something wrong with the way TractSeg wheel is installed? I don't see "examples" directory under dist-packages directory.

hayashis@gpu1-pestillilab:/usr/local/lib/python2.7/dist-packages 2 ls -la examples
ls: cannot access 'examples': No such file or directory
hayashis@gpu1-pestillilab:/usr/local/lib/python2.7/dist-packages 2 ls -la tractseg/
total 48
drwxr-sr-x  6 hayashis hayashis 4096 Sep 26 16:00 .
drwxrwsr-x 74 hayashis hayashis 4096 Sep 26 17:10 ..
-rw-r--r--  1 hayashis hayashis 9516 Sep 26 16:00 TractSeg.py
-rw-r--r--  1 hayashis hayashis 6010 Sep 26 16:00 TractSeg.pyc
-rw-r--r--  1 hayashis hayashis    0 Sep 26 16:00 __init__.py
-rw-r--r--  1 hayashis hayashis  146 Sep 26 16:00 __init__.pyc
drwxr-sr-x  4 hayashis hayashis 4096 Sep 26 16:00 config
drwxr-sr-x  2 hayashis hayashis 4096 Sep 26 16:00 libs
drwxr-sr-x  4 hayashis hayashis 4096 Sep 26 16:00 models
drwxr-sr-x  2 hayashis hayashis 4096 Sep 26 16:00 tests

tutorial error

Hi, after following the tutorial we now receive following error after completion of the 4th step of loading the weights. We tried it on our ubuntu 16.04 LTS system as well as on a macbook pro with Mojave 10.14. It occurs after the 3rd command in the tutorial TractSeg -i tractseg_output/peaks.nii.gz -o . --output_type TOM --track --filter_tracking_by_endpoints. We used HCP data.

Tracking...
Traceback (most recent call last):
  File "/home/bwgig/anaconda2/bin/TractSeg", line 202, in <module>
    output_format=args.tracking_format)
  File "/home/bwgig/anaconda2/lib/python2.7/site-packages/tractseg/libs/Mrtrix.py", line 172, in track
    " -include " + tmp_dir + "/" + bundle + "_e.nii.gz" +
TypeError: cannot concatenate 'str' and 'NoneType' objects

Missing brain mask leads to a cryptic error message

Hi. I was trying to troubleshoot this error message.

Traceback (most recent call last):
  File "/usr/local/bin/TractSeg", line 196, in <module>
    output_format=args.tracking_format)
  File "/usr/local/lib/python2.7/dist-packages/tractseg/libs/Mrtrix.py", line 178, in track
    " -include " + tmp_dir + "/" + bundle + "_e.nii.gz" +
TypeError: cannot concatenate 'str' and 'NoneType' objects

For some reason, I had to set --brain_mask testdata/mask.nii.gz when I am running it with --track on one of our HPC system but works fine without it on Ubuntu 16 machine. (We are running via singularity so it shouldn't really matter..)

Even with --brain option set, TractSeg fails with OOM on our HCP system.

=>> PBS: job killed: vmem 289836974080 exceeded limit 68719476736

Here is the content of my testdata

hayashis@carbonate(h2):/N/dc2/scratch/hayashis/tractseg/testdata(master*) $ ls -lrt
total 1477428
-rwxr-xr-x 1 hayashis uits         26 Oct  8 09:41 makemask.sh
-rw-r--r-- 1 hayashis uits   13256170 Oct  8 09:42 t1.nii.gz
-rw-r--r-- 1 hayashis uits    3207305 Oct  8 09:42 mask.nii.gz
-rw-r--r-- 1 hayashis uits 1496386061 Oct  8 09:42 dwi.nii.gz
-rw-r--r-- 1 hayashis uits       9507 Oct  8 09:42 dwi.bvecs
-rw-r--r-- 1 hayashis uits       1631 Oct  8 09:42 dwi.bvals
lrwxrwxrwx 1 hayashis uits          9 Oct  8 13:35 T1w_acpc_dc_restore_brain.nii.gz -> t1.nii.gz

and I am running TractSeg with following options

TractSeg -i tractseg_output/peaks.nii.gz -o . --output_type TOM --track --filter_tracking_by_endpoints

No module named custom.My_custom_experiment

I'm sorry to bother you again.
When I training the model, I always encounter the following error.
image

I have completed the first to eighth steps. And In step 5, my file My_custom_experiment.py is in the path /home/qilu/anaconda2/lib/python2.7/site-packages/tractseg/experiments/custom/

Track specific bundles

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

No more --tracking_format ?

I used to be able to output tracking output in .tck format by seeging "--tracking_format tck" command line parameter, but this option doesn't seem to exist anymore.

TractSeg: error: unrecognized arguments: --output_format tck

Do I need to manually convert .trk output to .tck now? I am using version 1.9

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.