DTI Brain Mask Including Non-Brain Tissue

Dear Slicer community,

I’m using slicer 4.10.1.
I first converted my nii.gz DWI file to .nrrd using DWIConvert. After that, I create a brain mask using “Diffusion Brain Masking”. But the resulting mask includes a lot of non-brain tissue (skull, soft tissue). My b-values are 0 and 1000, changing the b-value threshold doesnt help. How can I approach this?

Cheers
Melanie

If you can share a screenshot that can help us see if the brain mask is as expected or not. Is your data working correctly otherwise? Can you estimate tensors and perform tractography? The main use of the brain mask is often for tractography such as UKF, which also uses thresholds to stop tractography. Is that how you plan to use the brain mask?

3dslicer_brainmask
Thanks for the fast response :slight_smile:
This is the brain mask. The tensor estimation works, the FA and V1 maps look also reasonable. It just calculates these parameters for non-brain voxels as well. (looks similar for many subjects)
For now, I dont want to do tractography, but maybe later. At first, I want to register the DTI image to a T1 image, for which I need the brainmask. Then I want to do a segmentation using the T1 image with help of the diffusion directions.

I agree with you that this does not look as expected. Have you tried fiddling with any parameters in an “advanced” or similar section of the module?

Which advanced settings do you mean? This is what the module looks like to me: Unbenannt

Thanks. I had thought I remembered something else. One more question. How does the output baseline image look? The method is using this image to compute the mask. If it is very noisy or has some issue, that could lead a mask issue.

baselinevolume
This is the baseline volume. The surrounding tissue is displayed quite bright, the original data (b0) looks like this as well. I dont know if this might be the reason. I tried it once with motion and eddy current corrected dwi images from FSL, and once with the raw data, both create the same brainmask.

I also tried using the brain mask generated by FSL for the tensor estimation. But this results in an error due to a wrong coordinate space (the nii.gz dwi image is shifted when imported to .nrrd in DWIConvert, so that the transformation matrices dont match anymore). If you know a way how I can use this other brainmask, that would be fine as well.

It’s possible the mask process is challenged by the bright spots in the skull/scalp area. First try to read your mask using regular Slicer loading instead of dwiconvert. If that doesn’t help, in the slicer nightly version we have a new dcm2nii module available through the extension manager. If you are able to download the nightly and try this module (intended to replace dwiconvert) it may function better. Please keep us posted on your progress with this.

I loaded the FSL mask regularly anyway, DWIconvert only works for the “real” dwi image. For masks, eigenvectoror or fractional anisotropy maps, the import produces an error. So the dwi image is shifted during import, not the mask. (but I have to use the import for the data because the FSL data is otherwise not recognized as DTI format). I’ll try the nightly version, and will keep you posted, thank you!:slight_smile:

Great thank you for keeping us posted. Note that today’s nightly may not have all extensions available due to internal upload issues (we are migrating to a better server soon I think):
http://slicer.cdash.org/index.php?project=SlicerPreview

I downloaded the nightly version from the website (18.04), but I cant find the extension dcm2nii. Is this the extension name or is it a module within an extension, or did I download the wrong nightly :thinking:?

You did it right. This webpage shows the status of the nightly builds
http://slicer.cdash.org/index.php?project=SlicerPreview

On Mac there is an upload error due to internal server problems the team is working on. On Windows there is a new build issue. It seems Linux has not built yet, so later this morning. What operating system are you using?

grafik I’m using Windows, but it says that the latest one is 18.04.

Most likely dcm2nii was not available then. We just fixed build issues but apparently there is a new one on Windows now.

If you’d just like to test the conversion you can try to run dcm2niix outside of slicer. The most recent version of this software can output nrrd/nhdr format.

Or you can wait a few days and check back. Or you can try eroding and dilating the brain mask you have and some manual editing.

What is your use case/goal and time frame?

Hey!
I converted the DICOMS to .nrrd format using dcm2niix. I used the flag -z with different n/3/y/i because I didnt know if slicer would be able to read zipped files. (if I convert to compressed files I get a .raw.gz, and a .nhdr file; if I convert to non-compressed file, I get a .nrrd, without .nhdr).
Slicer does not recognize the .raw.gz file, so I used the un-compressed .nrrd.
If I load that, it looks like this:
grafik
The T1 image looks similar. Do you know what I did wrong here?
command: dcm2niix -e y -z n dicompath

I’m a PhD student and want to work on segmentations of the hypothalamus in tumor patients, for which I also want to use the diffusion vectors. The goal at the moment is to align the T2 and diffusion image to the T1, then I can start with the segmentations (I would like to start the segmentations at some time during the next month).

Ohh, sorry. I found my mistake. I now used the raw.gz and .nhdr files converted with dcm2niix, which produce correct images. Still, the resulting brain mask looks like the one I had previously (including skull and eyes etc.).

Hi try converting your good mask using dcm2nii. I think that was the goal, to import both using the same pipeline, to see if they align. However it’s possible you need to use image registration (for example T2 to baseline from dMRI) then apply that transform to the mask, then resample. I don’t know if the mask started out aligned to the dMRI or not. So whether it’s a conversion or registration issue is not yet clear to me. Let us know how this goes.

Hmm, I’m not sure what you mean. The “good” mask was created with FSL, is therefore in .nii.gz format.
I dont think I can convert .nii.gz files to .nrrd with dcm2nii, but only DICOM to .nrrd. The .nii.gz files are aligned, but after converting the data to .nrrd, the mask doesnt fit anymore. I now checked whether registration of DTI and T1 works with the baseline image that I got, and this seems alright. So I can do the segmentation anyways :slight_smile:

But to get rid of signal outside the brain for tractography, maybe I could use my T1 image (it’s skullstripped) as mask? I would have to mask the DTI tensor image (cant use the Diffusion Brain Masking-Module because the DWI data is not registered to the T1, only to the DTI data and the DWI baseline image).
Is something like this possible?

You can use any mask if it’s exactly registered to the baseline and has the exact same voxel dimensions. This requires registration then resampling. Try googling resample 3DSlicer and searching this forum/tutorials for more information on exact steps. For resampling you want nearest neighbor since it’s a mask volume (don’t want to average neighboring voxels).

Sorry, I think I’m confused now…:smiley:

  1. I created a baseline volume using Diffusion Brain Masking
  2. I created the tensor data using the baseline volume (over the whole image, not restricted to the brain)
  3. I registered the DTI image and Baseline image to the structural (T1) image using General Registration and Resample DTI Volume.
  4. I created a mask from the T1 image (after registration, because only then it matches the baseline image)

Now I want to apply this mask to the DTI.

What I tried:
I cannot use a mask created with the baseline image (neither in Diffusion Brain Masking, nor in Segment Editor), since this includes nonbrain tissue (probably brightness issue).
What I could do is to manually edit the baseline-mask in the segment editor slice by slice until only brain is left, to put that into Diffusion Brain Masking before Tensor estimation. But I would have to do this for 70 subjects, and I wont do that because it’s incredibly time consuming.

I can also not register the DWI data to the T1 image before tensor estimation to be able to use the T1 mask “regularly” within Diffusion Brain Masking.
(at least not using General Registration + Resample DTI volume/Resample Scalar/Vector/DWI, because the Registration step does not allow DWI).

So my questions are:
Is there either
a way to delete values in the DTI volume outside of a mask after tensor estimation?
or
a module for registering the DWI volume to the T1 image before Diffusion Brain Masking?

I couldnt find anything about that in the forum or on the website. Maybe it’s obvious and I just dont get it.:sweat_smile: