MIC-DKFZ / TractSeg

Automatic White Matter Bundle Segmentation
Apache License 2.0
221 stars 72 forks source link

Clinical tumor data #23

Closed LucSam closed 5 years ago

LucSam commented 5 years ago

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

wasserth commented 5 years ago

Did you try the steps described here: https://github.com/MIC-DKFZ/TractSeg#small-bundles-like-the-ca-and-fx-are-incomplete ? Those tend to make the segmentations more complete. What resolution and how many gradient directions does the dataset have? Did you make sure the peaks are flipped correctly by looking at them in mrview (Toosl->fixel plot)? You can also add the option --get_probabilities. Then you can choose the threshold yourself for creating binary masks from the model output. By choosing a lower threshold you can get more complete segmentations at the cost of some oversegmentation. If you can share some of the data (without preprocessing) I could also have a look at it and see what I get using my preprocessing pipeline.

wasserth commented 5 years ago

Did you rigidly move the images to MNI space?

LucSam commented 5 years ago

Yes, I used --bundle_specific_threshold and feeded the FA_MNI.nii.gz. Ok, very fine result now with flipped peaks. Thank you! Although before and now I get INFO: Detected that peaks have wrong orientation and automatically flipped them.

wasserth commented 5 years ago

Great that it works now! TractSeg is trying to automatically detect if the peaks have to be flipped. That is working correctly in most of the cases, but not all. So in the newest version of TractSeg (1.7.1) peaks are not flipped automatically anymore (because sometimes TractSeg gets it wrong). Only a warning is shown to the user telling him that TractSeg thinks that the peaks need to be flipped. Then the users has to do it manually and check it himself again.

LucSam commented 5 years ago

Ok, great, thanks again.. I'm encountering now a different problem, which I guess depends on the subsequent flipped peaks. If I want to perform tractometry with the FA_MNI.nii.gz file, I get out of bounds errors. I tried mrtransform FA_MNI.nii.gz -flip 1 FA_flipped.nii.gz but the problem remains.

wasserth commented 5 years ago

When you talk about FA_MNI.nii.gz to you mean the FA or the peaks? Flipping the FA does not make any sense. Only the peaks have to be flipped.

LucSam commented 5 years ago

Yes, with the flipped peaks Tractometry -i TOM_trackings/ -o Tractome try_tx.csv -e endings_segmentations/ -s ../../FA_MNI.nii.gz --tracking_format tck I now get the error: IndexError: index 90 is out of bounds for axis 0 with size 88

It must be related to the FA image somehow? I updated all segmentations with the newly flipped peaks.

wasserth commented 5 years ago

Do all of your images (the bundle segmentations, the tract orientation maps, brain mask and the FA) have the same spacing and dimensions?

LucSam commented 5 years ago

The segmentations,toms and mask do have the same dimensions, but not the FA images. How come? The only thing I changed was flipping the peaks.

Image:               "../../FA_MNI.nii.gz"
************************************************
  Dimensions:        145 x 174 x 145
  Voxel size:        1.25 x 1.25 x 1.25
  Data strides:      [ -1 2 3 ]
  Format:            NIfTI-1.1 (GZip compressed)
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1           0           0         -90
                               -0           1           0        -126
                               -0           0           1         -72
Image:               "TOM/AF_left.nii.gz"
************************************************
  Dimensions:        88 x 106 x 88 x 3
  Voxel size:        2.05 x 2.05 x 2.05 x 1
  Data strides:      [ -1 2 3 4 ]
  Format:            NIfTI-1.1 (GZip compressed)
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1           0           0      -88.35
                               -0           1           0        -126
                               -0           0           1         -72
Image:               "bundle_segmentations/AF_left.nii.gz"
************************************************
  Dimensions:        88 x 106 x 88
  Voxel size:        2.05 x 2.05 x 2.05
  Data strides:      [ -1 2 3 ]
  Format:            NIfTI-1.1 (GZip compressed)
  Data type:         signed 16 bit integer (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1           0           0      -88.35
                               -0           1           0        -126
                               -0           0           1         -72
Image:               "../../nodif_brain_mask.nii.gz"
************************************************
  Dimensions:        88 x 106 x 88
  Voxel size:        2.05 x 2.05 x 2.05
  Data strides:      [ -1 2 3 ]
  Format:            NIfTI-1.1 (GZip compressed)
  Data type:         signed 16 bit integer (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1           0           0      -88.35
                               -0           1           0        -126
                               -0           0           1         -72
Image:               "../my_peaks_flip_y.nii.gz"
************************************************
  Dimensions:        88 x 106 x 88 x 9
  Voxel size:        2.05 x 2.05 x 2.05 x 1
  Data strides:      [ -1 2 3 4 ]
  Format:            NIfTI-1.1 (GZip compressed)
  Data type:         32 bit float (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1           0           0      -88.35
                               -0           1           0        -126
                               -0           0           1         -72
wasserth commented 5 years ago

It seems like you used the FA_MNI.nii.gz image which is generated by TractSeg when using the option --preprocess. This image is having the dimensions of the MNI_FA_template image (1.25mm resolution). However your Diffusion image in MNI space has the same dimensions as your input image. Therefore the peaks and also the bundle segmentations also have the same resolution as the input image. This is the behaviour you normally want. The FA_MNI.nii.gz actually is only a temporary file used by TractSeg. It is a bit confusing because it has different dimensions than the other resulting files. You should ignore it. If you recalculate the FA (e.g. using the calc_FA script from TractSeg) using the Diffusion image (in MNI space) as input you should be fine. It has the same dimensions then as the bundle segmentations. Before the peak flipped you probably did not get any error because the segmentations were almost empty. But the different dimensions problem was already present at that point.

LucSam commented 5 years ago

Great, that works fine now, thanks! Where can we get an overview of those different scripts like calc_FA or flip_peaks, or are those the only two?

wasserth commented 5 years ago

If you look into the folder bin inside of the TractSeg repository you can see all available scripts. But normally only calc_FA, flip_peaks, TractSeg and Tractometry are of interest for most people.

LucSam commented 5 years ago

Hi, did something change in the preprocessing or processing steps? After we updated to 1.7.1 we get empty or interrupted tract segmentations in clinical cases which worked before. Furthermore, we have our own multishell data with AP-PA correction and 64 dirs per shell and 1.5mm voxel resolution which also results in non complete tract segmentations. We tested in multiple ways with flipping peaks, raw-diffusion inputs in both various subjects and patients as well as feeding our own calculated wm_fod's. Can you help, suggest hints or tips? In HCP data it still works perfectly fine.

wasserth commented 5 years ago

You can see all the changes for each version in the CHANGELOG.md file (https://github.com/MIC-DKFZ/TractSeg/blob/master/CHANGELOG.md). There is one change to the preprocessing in v1.7.1. Peaks are not automatically flipped anymore. You should see a warning message if TractSeg thinks the peaks need to be flipped. You have to flip them manually then. Does that solve your problem?

LucSam commented 5 years ago

Thanks for the changelog hint. However, after feeding various data - manually flipped and non-flipped, it seems to fail to provide non interrupted tract segmentations.

LucSam commented 5 years ago

Hi, we now downgraded to version 1.6. After we flip the peaks it works perfectly fine for our clinical data with version 1.6. Unfortunately we don't get similar nice results with 1.7.1. Peaks were flipped by flip_peaks -i peaks.nii.gz -o peaks_flipped.nii.gz -a y

wasserth commented 5 years ago

I did not experience such problems. It is hard to tell what might be the problem. If you send me the data of one subject where it works in 1.6 but fails in 1.7.1 I can have a look if I can reproduce the problem.

LucSam commented 5 years ago

ok thanks, we've sent it via wetransfer

wasserth commented 5 years ago

I had a look at the data. It is a bit tricky because it only works if you move it to MNI space (which you should always do) and flip it along the z dimension. TractSeg tells you to flip it along the x axis, but that is wrong. If there is a tumor in the brain TractSeg is getting it wrong quite often unfortunately. So you have to look at it manually in mrview (Tools->fixel plot) or MITK Diffusion to determine how you have to flip them so that it aligns properly with the Diffusion image. If you are not sure you can try all three options: Flip along x, y and z and see which one gives proper results. So you get good results (using v1.7.1) if you do the following with your data (--preprocess moves it to MNI space):

TractSeg -i Diffusion.nii.gz --raw_diffusion_input --preprocess 
flip_peaks -i tractseg_output/peaks.nii.gz -o tractseg_output/peaks_flipped_z.nii.gz -a z
TractSeg -i tractseg_output/peaks_flipped_z.nii.gz -o .
LucSam commented 5 years ago

Ok thank you very much! We used as well --preprocess but didn't think about flipping other axes... Thanks again!