ANTsX / ANTs

Advanced Normalization Tools (ANTs)
Apache License 2.0
1.19k stars 380 forks source link

antsCorticalThickness #624

Closed xiaojunZJU closed 5 years ago

xiaojunZJU commented 6 years ago

Dear, In these two weeks, I am trying best to figure out the whole processing of antsCorticalThickness. Because I am medical graduate, I can not fully understand computer science. Would you please help me check my procedures? First, I directly used OASIS template+priors (downloaded from your website) to run antsCorticalThickness by inputing my T1 data. Meanwhile, I constructed specific template for my own data set by using antsMultivariateTemplateConstruction.sh. Then, I used antsCorticalThickness to cook priors for my constructed template by using OASIS template+priors. Finally, I tested the antsCorticalThickness for my T1 data by using my constructed template. Then, I compared the cortical thickness maps between two methods and found that the results were different in some details and both have their own advantages. In summary, which method do you suggest? Second, I read your paper "Large-scale evaluation of ANTs and FreeSurfer cortical thickness measurements" for many times. In order to get regional cortical thickness, I want to extract cortical thickness according to DKT 31 atlas. However, DKT 31 atlas is in the OASIS template space, I can not extract the cortical thickness directly. I tried antsRegistrationSyn to register OASIS template to my T1 native space and warped (using antsApplyTransform) the DKT 31 atlas to the native space. Unfortunately, the atlas for native T1 data is not well overlapped with my cortical thickness map. In summary, I am wondering whether my methods are right or not. And do you have any expertise suggestions for my purposes? Now, I am running antsCorticalThickness to segment all my T1 data. Next step, and a very important step, is to extract cortical features. I have no idea about this currently. Would you please help me solve this? Thank you so much! Looking forward to your reply.

All the best, Xiaojun

xiaojunZJU commented 6 years ago

By the way, in order to obtain regional cortical thickness, I used antsJointLabelFusion.sh (antsJointLabelFusion.sh -d 3 -o malf -t N001_BrainSegmentation0N4.nii.gz -g T_template0.nii.gz -l OASIS-TRT-20_jointfusion_DKT31_CMA_labels_in_OASIS-30_v2.nii.gz). Finally, the results reported as "at least two warped images/labels in joint label fusion". I am confused. Please help me. Thank you!

Xiaojun

ntustison commented 6 years ago

It sounds like you have a number of issues you would like addressed. Let's just take them one at a time. What's the first thing with which you'd like help?

xiaojunZJU commented 6 years ago

Yes, thanks! I summary my questions here:

  1. can I just use the OASIS template+priors to do antsCorticalThickness.sh in my own data instead of my constructed template by using antsMultivariateTemplateConstruction.sh?
  2. Would you please teach me how to get thickness information of each brain region labelled by DKT 31 template downloaded from http://mindboggle.info/data.html? Previously, I used registration and inverse transformation methods to get labels for my individual antsThickness data, but the outcome was not overlapped exactly. Looking forward to your reply. Thank you again.

xiaojun

ntustison commented 6 years ago
  1. can I just use the OASIS template+priors to do antsCorticalThickness.sh in my own data instead of my constructed template by using antsMultivariateTemplateConstruction.sh?

Yes. We also have four other templates which you might want to consider. Just make sure a template which best matches your data.

  1. Would you please teach me how to get thickness information of each brain region labelled by DKT 31 template downloaded from http://mindboggle.info/data.html? Previously, I used registration and inverse transformation methods to get labels for my individual antsThickness data, but the outcome was not overlapped exactly. Looking forward to your reply. Thank you again.

Can you post your results so I can assess the outcome overlap?

xiaojunZJU commented 6 years ago

atlas_on_corticalthickness Hi, Please help me review the figures (underlay is CorticalThickness map, and overlay is transformed DKT atlas).. For registration, I used antsRegistrationSyn to register the OASIS T_tempalte0. nii.gz to the individual N4 corrected T1 image (generated from antsCorticalThickness). Then I used antsApplyTransform to transform the DKT atlas to the cortical thickness map. Finally I got the result showing above.

ntustison commented 6 years ago

You mention trying joint label fusion but were confused. Can you elaborate?

xiaojunZJU commented 6 years ago

jlf_results

CODES.txt Thank you for your help. I run a JLF again in my data. Please help me review the figres (upper left: warped T_template; upper right: individual N4_T1 image; left Lower: warped labels on warped T_template; right lower: warped labels on NC001_corticalThickness).. The results seem worse than using antsRegistrationSyn & antsApplyTransform (I showed earlier)... In case of my error in typing function. I attached the function in the .txt file. I know these probably are basic question. Please help me out.

Xiaojun

xiaojunZJU commented 6 years ago

I think above outcome is resulting from bad coregistration between T_template and individual N4 T1 image.. Would you have any suggestion for me to correct it and get a exact coregistration?

ntustison commented 6 years ago

You're not using it correctly. The error message is self-explanatory. Please see here for a simple example.

xiaojunZJU commented 6 years ago

I know this example and tested in my computer. But, this example is designed for generating labels in the target (T_template) by using the obtained labels of several individual subjects. The purpose I want to do is just opposite, to generate individual labels by using labels in template. Would you please specify the mistake I made? I am confused.

ntustison commented 6 years ago

No mistake. It's just not the best route for propagating labels to a target image. I would suggest you use multiple atlases with joint label fusion to get you what you want.

xiaojunZJU commented 6 years ago

Thank you. Multiple atlases would be helpful. I can try now. But, for the labels, I only have DKT 31 labels... Would you please suggest me some available resources including atlases and corresponding labels?

ntustison commented 6 years ago

I use the DKT protocol as well but with 20 labeled OASIS data sets I downloaded from Arno's Mindboggle page. I'm guessing he doesn't make those available anymore. Sorry, but I don't know of any other resources off the top of my head.

xiaojunZJU commented 6 years ago

No problem. May I ask how would you obtain cortical thickness information of each Brain Region in native antsCorticalThickness map space? Like in the paper "Large-scale evaluation of ANTs and FreeSurfer cortical thickness measurements", you calculated the thickness from each DKT region.

xiaojunZJU commented 6 years ago

Because I want to get cortical thickness information of a set of brain regions as features. Please help me solve it.

ntustison commented 6 years ago

This is all described in the paper. I used the DKT protocol with the 20 labeled OASIS data sets I downloaded from Arno's Mindboggle page. I used that atlas data and JLF to propagate the DKT labels to the native space of each individual subject. I then calculated the mean thickness values in each region.

xiaojunZJU commented 6 years ago

That is cool. If I understand right, there are 20 3D-data with 20 corresponding labels available in Mindboggle page. I just downloaded the DKT label map only. Would you please share me the link to download all 20 labeled data?

All the best, xiaojun

xiaojunZJU commented 6 years ago

malf Good morning! I downloaded the 20 OASIS labeled brains and used them to do antsJointLabelFusion.sh. Above is the result which has a better overlap compared with earlier one (by using antsRegistration methods). However, for this result, the labels in the occipital lobe I have marked is not well overlapped. May I have your further suggestions? codes: antsJointLabelFusion.sh -d 3 -x or -t NC001_BrainSegmentation0N4.nii.gz -p posteriors%02d/nii/gz - g OASIS_altals -l OASIS_label (* 20) Looking forward to your reply.

xiaojun

ntustison commented 6 years ago

That doesn't look correct neither does your command line call. Are you sure you didn't have any errors ? Also, can you post your input data?

xiaojunZJU commented 6 years ago

n4_brain oasis_1_t1 labels oasis_1_labels oasis_1_weigthed Hi, above is the input T1 image. The total code is: sudo $ANTSPATH/antsJointLabelFusion.sh -d 3 -x or -c 2 -j 8 -o NC001_malf -t NC001BrainSegmentation0N4.nii.gz -p NC001_malf_posterior%02d.nii.gz -g OASIS_1_t1weighted.nii.gz -l OASIS_1_labels.nii.gz -g OASIS_2_t1weighted.nii.gz -l OASIS_2_labels.nii.gz -g OASIS_3_t1weighted.nii.gz -l OASIS_3_labels.nii.gz .... I input 20 OASIS data in total.

ntustison commented 6 years ago

I meant to make the actual .nii.gz available so I can run it locally.

xiaojunZJU commented 6 years ago

Would you please give me your email? I could send T1 image to you. Thank you!

xiaojunZJU commented 6 years ago

NC001.zip I found I could attach the data. Please download and help me check the data. Thank you very much!

ntustison commented 6 years ago

This is what I'm getting.

dktLabels.nii.gz

# /usr/bin/sh

atlasDir=/Users/ntustison/Data/Public/OASIS-TRT-20/

command="antsJointLabelFusion.sh -d 3 -t antsBrainExtractionBrain.nii.gz -x or -o dkt -q 1" 

for i in {1..20}; 
  do
    command="${command} -g ${atlasDir}Volumes/OASIS-TRT-20-${i}_brain.nii.gz"
    command="${command} -l ${atlasDir}Labels/OASIS-TRT-20-${i}_DKT31_CMA_labels.nii.gz"
  done

 $command
xiaojunZJU commented 6 years ago

Thank you so much! I find that you were using "-t antsBrainExtractionBrain.nii.gz". Is this file with skull-scalped brain? Because automatically, by using antsCorticalThickness.sh, there is no skull-scalped T1 image generated. As I understand, I need to use the generated "BrainExtractionMask.nii.gz" and "BrainSegmentation90N4.nii.gz" by antsCorticalThickness.sh to obtain a skull-scalped brain. Right? I know it is a basic question, thank you for your help in advance.

All the best, xiaojun

ntustison commented 6 years ago

'Yes' to both questions.

xiaojunZJU commented 6 years ago

Yes! Thank you for hundreds times! I will try your suggestions.

xiaojunZJU commented 6 years ago

Thank you for your previous help. And the antsJointLabelFusion.sh does work well now. Recently, I have done further analysis. May I ask a couple of questions more?

  1. I found the labels constructed by using antsJointLabelFusion.sh were amazingly nice. But, some small regions are not labeled. So, do you think manual revisions for the labels in native space should be appropriately applied by using ITKSNAP toolbox?

  2. After finishing labeling, I can run LabelGeometryMeasures to get the regional cortex information, and afterwards, I can use the extracted values to do statistics, am I right?

Thank you in advance.

All the best, xiaojun

ntustison commented 6 years ago

I found the labels constructed by using antsJointLabelFusion.sh were amazingly nice. But, some small regions are not labeled. So, do you think manual revisions for the labels in native space should be appropriately applied by using ITKSNAP toolbox?

Sure, if you your application requires it. But that's something you ultimately have to judge.

After finishing labeling, I can run LabelGeometryMeasures to get the regional cortex information, and afterwards, I can use the extracted values to do statistics, am I right?

Yes, you can use that program to get stuff like volumes and surface areas. To get cortical thickness values, you need to use ImageMath ... LabelStats .... However, if you want to look at the regional cortical thickness values, be sure you look at the how the JLF map and non-zero cortical thickness values align as you only want to include those non-zero values in your regional averaging.

xiaojunZJU commented 6 years ago

Thank you so much! Today, I suffered another question. When I run $ANTSPATH/antsJointLabelFusion.sh, the "sudo" is necessary or an error would happen as below.

" FILE /home/xiaojun/ANTs/ScriptsANTSpexec.sh DOES NOT EXIST -- OR -- IS NOT EXECUTABLE !!! /home/xiaojun/ANTs/Scripts/antsJointLabelFusion.sh will terminate.

if the file is not executable, please change its permissions.

FILE /home/xiaojun/ANTs/ScriptswaitForSGEQJobs.pl DOES NOT EXIST -- OR -- IS NOT EXECUTABLE !!! /home/xiaojun/ANTs/Scripts/antsJointLabelFusion.sh will terminate.

if the file is not executable, please change its permissions.

FILE /home/xiaojun/ANTs/ScriptswaitForXGridJobs.pl DOES NOT EXIST -- OR -- IS NOT EXECUTABLE !!! /home/xiaojun/ANTs/Scripts/antsJointLabelFusion.sh will terminate.

if the file is not executable, please change its permissions.

FILE /home/xiaojun/ANTs/ScriptswaitForPBSQJobs.pl DOES NOT EXIST -- OR -- IS NOT EXECUTABLE !!! /home/xiaojun/ANTs/Scripts/antsJointLabelFusion.sh will terminate.

if the file is not executable, please change its permissions. missing helper script"

But, you know, I am using matlab to loop this code.. So that, every time I need to input my password to start the code. Actually, when I run antsCorticalThickness.sh, there is not needing to add "sudo" in front of "$ANTSPATH/antsCorticalThickness.sh". Would you please give me some suggestions?

Thanks, Xiaojun

ntustison commented 6 years ago

You didn’t follow the installation directions correctly. Please see here specifically the parts about Scripts and setting the path.

xiaojunZJU commented 6 years ago

Yes. The truth is, I copied the files in the ants/bin to ANTs/Scripts... And all the tests mentioned in the website you suggested above worked. However, the antsJointLabelFusion.sh should be run with "sudo $ANTSPATH"... I don't know why.. Would you please give me some detailed suggestions?

image image

The second picture is about antsJointLabelFusion.sh....

xiaojunZJU commented 6 years ago

2 1

Hi, Good Morning, I am wondering that is there someone else suffering same question. Now, I figure it out by add "/" in the appropriate place (please check the above figures) of antsJointLabelFusion.sh. Probably, may I have your expertise suggestions that whether it is right or not by revising path in this way?

cookpa commented 6 years ago

You'll probably have an easier time if you install ANTs according to the instructions here

https://github.com/ANTsX/ANTs/wiki/Compiling-ANTs-on-Linux-and-Mac-OS

See the section on copying scripts and setting ANTSPATH.

xiaojunZJU commented 6 years ago

Thank you! Currently, my data are being processed. I will change it to the latest version strictly according to your suggestion.

xiaojunZJU commented 6 years ago

Dear, I have finished all my data processing. When I checked each results of antCorticalThickness, I found more than 10 subjects with failed segmentation. Would you please help me solve this? I attached the raw T1 image and the results I get. The code I am using is as following: "$ANTSPATH/antsCorticalThickness.sh -d 3 -a /home/xiaojun/Downloads/GE750_SEGMENTATION/ANTS_CorticalThickness/T1_raw_data_co/NC065.nii -e /home/xiaojun/Downloads/GE750_SEGMENTATION/ANTS_CorticalThickness/Template/T_template0.nii.gz -t /home/xiaojun/Downloads/GE750_SEGMENTATION/ANTS_CorticalThickness/Template/T_template0_BrainCerebellum.nii.gz -m /home/xiaojun/Downloads/GE750_SEGMENTATION/ANTS_CorticalThickness/Template/T_template0_BrainCerebellumProbabilityMask.nii.gz -f /home/xiaojun/Downloads/GE750_SEGMENTATION/ANTS_CorticalThickness/Template/T_template0_BrainCerebellumExtractionMask.nii.gz -p /home/xiaojun/Downloads/GE750_SEGMENTATION/ANTS_CorticalThickness/Template/priors%d.nii.gz -o /home/xiaojun/Downloads/GE750_SEGMENTATION/ANTS_CorticalThickness/ACT_191sub/NC065/NC065" Looking forward to your reply.

Best, xiaojun

dataExample.zip

xiaojunZJU commented 6 years ago

Of note, I attached the data of NC018, the code is for NC065... I am sorry for the inconsistence.

xiaojunZJU commented 6 years ago

And another question is that, antsCorticalThickness reported error during processing in NC065...But I don't know what the error is. I run all my data in a matlab loop.. so the code used here is same to the above post. Exactly, above code is for processing NC065 data. And it is also used in other subjects with different prefix. Thank you in advance.

All best, xiaojun

NC065_data.zip

xiaojunZJU commented 6 years ago

I am sorry I have a number of questions... After sufficiently searching for relevant answers posted by you, I found a process before calculating LabelGeometryMeasures. That is shown here https://github.com/ANTsX/ANTs/issues/589 (After joint label fusion, I mask out the zero thickness voxels in the label regions and then calculate the mean thickness values in those masked labeled regions.). Would you please tell me how to mask out the zero thickness voxels in the label regions? Thank you so much!

stnava commented 6 years ago

Miccai is happening So it will take some time for answers to arrive .... Thank you for your patience

On Thu, Sep 13, 2018 at 7:00 PM xiaojunZJU notifications@github.com wrote:

I am sorry I have a number of questions... After sufficiently searching for relevant answers posted by you, I found a process before calculating LabelGeometryMeasures. That is shown here #589 https://github.com/ANTsX/ANTs/issues/589 (After joint label fusion, I mask out the zero thickness voxels in the label regions and then calculate the mean thickness values in those masked labeled regions.). Would you please tell me how to mask out the zero thickness voxels in the label regions? Thank you so much!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ANTsX/ANTs/issues/624#issuecomment-421178873, or mute the thread https://github.com/notifications/unsubscribe-auth/AATyfnOP5a76HZWv6XcTvac9pVC3mLSFks5uauODgaJpZM4V8yjv .

--

brian

ntustison commented 6 years ago

Okay, I didn't see it in your above messages but which template set are you using?

xiaojunZJU commented 6 years ago

Thank you for your reply. Yesterday, I tried to fix the problem. Previously, I used OASIS template and 12 subjects failed (as shown before). And I tried to use IXI template then the failed subjects data were successfully segmented. After carefully checking, I found the main question is the brain extraction. Hopefully following information would be helpful for you and other researchers love ANTs as me. When I realized the question was the brain extraction during the processing of antsCorticalThickness.sh, I independently did antsBrainExtraction in the 'failed' data and it can be successfully done (using -m ProbabilityMask -f ExtractionMask, -f is necessary to get the right brain extraction). But I don't know how to apply the independently extracted brain mask to antsCorticalThickness.

Currently, I figured out the segmentation, and Labeling joint is under processing. Thank you! For further feature extraction, I have a couple questions: (1) Would you please tell me how to mask out the zero thickness voxels in the label regions? And do you suggest to mask out that during LabelGeometryMeasures? Since LabelGeometryMeasures is calculated on labels, some voxels in the labels are beyond the cerebral cortex. I think they should be masked out. (2) By using ImageMath ... LabelStats..., I got some features, e.g. mass, volume and count. As I can see, no feature is straightly referred to CORTICAL THICKNESS. I know it is very basic question. However, this is the first time I calculate cortical thickness, would you please specify these features for me? And I also used LabelGeometryMeasures to calculate the surfer area, which could be directly seen as the title.... And further, I think total intracranial volume (TIV) should be regressed out during inter-group comparisons, would you please suggest a function to calculate TIV?

ntustison commented 6 years ago

Yes, we talk about the importance of matching the characteristics of the template with the cohort to avoid these types of problems.

(1) Would you please tell me how to mask out the zero thickness voxels in the label regions? And do you suggest to mask out that during LabelGeometryMeasures? Since LabelGeometryMeasures is calculated on labels, some voxels in the labels are beyond the cerebral cortex. I think they should be masked out.

$ ThresholdImage 3 ${corticalThicknessImage} ${corticalThicknessMask} 0 0 0 1
$ ImageMath 3 ${corticalThicknessMask} m ${corticalThicknessMask} ${labelImage}
$ LabelGeometryMeasures 3 ${corticalThicknessImage} ${corticalThicknessMask}

(2) By using ImageMath ... LabelStats..., I got some features, e.g. mass, volume and count. As I can see, no feature is straightly referred to CORTICAL THICKNESS. I know it is very basic question. However, this is the first time I calculate cortical thickness, would you please specify these features for me? And I also used LabelGeometryMeasures to calculate the surfer area, which could be directly seen as the title.... And further, I think total intracranial volume (TIV) should be regressed out during inter-group comparisons, would you please suggest a function to calculate TIV?

The only question I understand was how to calculate TIV and we don't have a specific tool to do that although we'll often substitute the total brain volume in our regression equations.

xiaojunZJU commented 6 years ago

Because cortical thickness extraction is the last step for me to do research, does someone know the meanings of the "mass, volume and count"? Or is there any tutorial to tell me these?

The only question I understand was how to calculate TIV and we don't have a specific tool to do that although we'll often substitute the total brain volume in our regression equations.

Yes, TIV is commonly regressed out... So, would you please teach me how will you calculate TIV? And normalize the cortical thickness and surface area?

xiaojunZJU commented 6 years ago

Hi, how is it going with MICCAI? I masked out the zeros in the DKT_label image.. But as a result, there are some extra voxels of non-brain tissue. Do you have any idea to further mask out them? test Thank you!

All the best, xiaojun

ntustison commented 6 years ago

Please post the original DKT image, the modified DKT image, and the cortical thickness image somewhere where I can look at them myself. And tell me what axial slice you've posted above.

xiaojunZJU commented 6 years ago

ACT.zip Thank you! Please find my data in the link. I attached several files that you may need.

All the best, xiaojun

xiaojunZJU commented 6 years ago

My main concerning is about the signal from cerebral meninges, especially adjacent to occipital lobes. I think that might be due to the signal of cerebral meninges are too similar to the grey matter and, though the brain extraction performed by ANTs is very nice, there is still some non-brain tissue included. Therefore, may I ask is there any method to fix this? Yesterday, I tried my best to mask out them by using the probability maps of grey matter and CSF... But failed, my poor mathematics....

ntustison commented 6 years ago

Yeah, this goes back all the way to the brain extraction and segmentation steps. You might want to try -q 0 to attempt to get a better initialization for those steps.

xiaojunZJU commented 6 years ago

So.. May I ask is there any other method to fix this? Actually, processing more than 300 subjects will take a very long time...