NIRALUser / DTIPlayground

An integrated framework for DWI Image QC and processing
MIT License
12 stars 2 forks source link

The error from 2.MaskCreation in Autotract #68

Open funckjose1999 opened 1 month ago

funckjose1999 commented 1 month ago

Hi,

Sorry that I posted AutoTract-related issue into the dtiplayground forum, but hopefully there might be someone who can help me with the problem.

When I am running AutoTract, the final results from classification are wrong. For example, in the folder IFOF, IFOF fiber file is not included in those big-size files, with maybe fornix being the file with biggest size in IFOF folder. Additionally, when I loaded the nrrd file of IFOF from classifiation/extarcted_fibers and IFOF.nrrd file in the 3.PostProcess folder to Slicer, there were no IFOF-like fiber showing but a mixture of some other fibers.

Therefore, I checked files in 4 big folders, and then I found the WMmask.nrrd is not correct. The problem might be originated from the otsuFA.nrrd to otsuFAeroded.nrrd. otsuFA.nrrd looks fine but for the eroded one, it should be wrong, which did not look like a white matter mask.

I am posting this issue to ask if there will be any advice on the problem and I am very looking forward to your reply.

Thanks.

styner commented 1 month ago

Hi, yes, this is not really a dtiplayground related issue. Although, we are in the process of integrating the successor of AutoTract into dtiplayground this fall (with significantly better performance).

With respect to the problem here, this sounds like an incorrect white matter mask, which is auto-generated via an otsu-based threshold on the FA image (which is know not to be perfect). I suggest that you create a white matter mask (e.g. via itksnap or 3D slicer) and provide it to AutoTract. Hope this helps, Martin

funckjose1999 commented 1 month ago

Hi, yes, this is not really a dtiplayground related issue. Although, we are in the process of integrating the successor of AutoTract into dtiplayground this fall (with significantly better performance).

With respect to the problem here, this sounds like an incorrect white matter mask, which is auto-generated via an otsu-based threshold on the FA image (which is know not to be perfect). I suggest that you create a white matter mask (e.g. via itksnap or 3D slicer) and provide it to AutoTract. Hope this helps, Martin

Thanks, Martin.

Well, I am trying to generate the white matter mask with DTI-TK, with the command: BinaryThresholdImageFilter tensor_fa.nii.gz wm.nii.gz 0 0.2 0 1. However, I am still not entirely sure if this way can be the proper way to create white matter mask. Would you mind giving me more advice on how to create white matter mask with itkSNAP or Slicer? I have already got the final atlas from DTI Atlas Builder in dtiplaygroud.

Thank you. Appreciate any help from you.

funckjose1999 commented 1 month ago

Hi, yes, this is not really a dtiplayground related issue. Although, we are in the process of integrating the successor of AutoTract into dtiplayground this fall (with significantly better performance).

With respect to the problem here, this sounds like an incorrect white matter mask, which is auto-generated via an otsu-based threshold on the FA image (which is know not to be perfect). I suggest that you create a white matter mask (e.g. via itksnap or 3D slicer) and provide it to AutoTract. Hope this helps, Martin

Hey Martin,

I created white matter mask through segment editor and segmentation via Slicer using FA image in the final atlas after DTI Atlas Builder. I put this white matter mask into GUI of autotract, but still the process started to create a new WM mask and overwrite the input one, which turned out to be a dilated wrong white matter mask.

Creation of WM mask - Step 1... dtiprocess --dti_image FinalAtlasDTI_float.nrrd -f /2.MaskCreation/FAimage.nrrd

Creation of WM mask - Step 2... ImageMath /2.MaskCreation/FAimage.nrrd -otsu -outfile /2.MaskCreation/otsuFA.nrrd

Creation of WM mask - Step 3... ImageMath /2.MaskCreation/otsuFA.nrrd -outfile /2.MaskCreation/otsuFAeroded.nrrd -erode 2,1

Creation of WM mask - Step 4... ImageMath /2.MaskCreation/otsuFAeroded.nrrd -outfile WMmask.nrrd -dilate 3,1

The location of white matter mask is my own WMmask's input location which is not in the 2.MaskCreation folder. otsuFAeroded.nrrd does not look okay from my perspective, and also bad for the final white matter mask being generated during the process. My original input white matter mask has been overwritten.

I am not sure if this is the wrong process when inputting self-customized white matter mask in autotract. If not, do you know what is the problem with it?

Thank you very much for your help.

styner commented 1 month ago
  1. Providing it in the GUI of AutoTract as the optional WM mask is the correct way. But, make sure it is not a filename that overlaps with any output filenames of AutoTract (it might get overwritten otherwise), e.g. call it MyWMMask.nrrd . Is your won input mask called differently from any AutoTract outputs?
  2. It could be that it will always create a WM mask whether you provide one or not. It should use the one you provided though.
  3. Try to provide both WM and CSF masks and see whether that will stop the tool from computing the masks
funckjose1999 commented 1 month ago
  1. Providing it in the GUI of AutoTract as the optional WM mask is the correct way. But, make sure it is not a filename that overlaps with any output filenames of AutoTract (it might get overwritten otherwise), e.g. call it MyWMMask.nrrd . Is your won input mask called differently from any AutoTract outputs?
  2. It could be that it will always create a WM mask whether you provide one or not. It should use the one you provided though.
  3. Try to provide both WM and CSF masks and see whether that will stop the tool from computing the masks

Hi Martin,

Thanks for the reply.

  1. I changed the file name to myxxmask, but still the auto-generated one overwrote the file in my own input location I provided in the GUI.
  2. I am not sure if I provide my own one, whether the process still erode and dilate the one I provided?
  3. I tried to input both masks with myxxmask.nrrd, but the tool overwrote both of them.

I checked the MaskCreation.py file in the generated script folder, and found that though there were my own WM mask and CSF mask, the process of creation still started. I am not sure if this would be the problem.

Thank you!

Best, Yunyou

styner commented 1 month ago

Yeah, this clearly is a bug and needs to be addressed. A possible way around is to hack the main script to skip the MaskCreation. You could comment out by adding '#' to MaskCreation.run() => #MaskCreation.run()

funckjose1999 commented 1 month ago

Yeah, this clearly is a bug and needs to be addressed. A possible way around is to hack the main script to skip the MaskCreation. You could comment out by adding '#' to MaskCreation.run() => #MaskCreation.run()

Thanks, it solved the problem. I successfully inserted WM mask and CSF mask generated by myself. However, the output files of AutoTract are still not good. The output fibres (ILF, IFOF and the splenium of CC) are far more sparse than reference tracts (as the following figure) after I cleaned with the output files in post process folder. When I checked the classification folder, I found left and right IFOF are not one of the files with largest size. The output file of left ILF is lacking in the classification folder. Therefore, I am not sure if this problem originated from AutoTract itself? (or maybe I will reconsider my final atlas as the input file being bad).

cleaned_tracts

Thank you!!

styner commented 1 month ago

Looking at your cleaned tracts in the picture, those look all fine (the ILF is a bit sparse and seems to end a bit early in the temporal pole region). You mentioned that the left ILF is missing from the classification, but it is in the picture that you attached, so I am a bit confused.

Also, if you want to create denser tracts, you can also adjust the seed spacing in the autotract parameters (smaller spacing, e.g. 0.75)

funckjose1999 commented 1 month ago

Looking at your cleaned tracts in the picture, those look all fine (the ILF is a bit sparse and seems to end a bit early in the temporal pole region). You mentioned that the left ILF is missing from the classification, but it is in the picture that you attached, so I am a bit confused.

Also, if you want to create denser tracts, you can also adjust the seed spacing in the autotract parameters (smaller spacing, e.g. 0.75)

Thanks very much for the quick response. Sorry that I didn't clarify the situation better. The above figure is the cleaned tracts by myself using the output files of ILF, IFOF and the splenium of CC in post process folder rather than classification folder. The following figure is the tracts from classification folder without manual cleaning. classified

As you can see, left ILF has been lacking because I didn't find the file in the classification folder. For left and right IFOF, they look more sparse than the above one.

Also, Thank you for your advice on changing the parameter. It turned out to be denser in those tracts, though the left and right IFOF are still not one of the largest files in classification folder and left ILF is still missing. I will try to clean them from the output files in the postprocess folder.