ANTsX / ANTs

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

Is there any algorithm available for spatial parcellation in ANTs? #1082

Closed sara-eb closed 3 years ago

sara-eb commented 4 years ago

Hi,

I am following a paper that they are using KMeans algorithm for spatial parcellation of knee MRIs,

I have used ANTs for constructing the cohort-specific knee MRIs, Then I used KMeans algorithm for clustering the positions (x,y,z) on the mask of the object of interest. My developed algorithm needs to be run on each cluster; however, what I realized that the results are not robust, which I think it is because of spatial parcellation error by using Kmeans algorithm available in python scikit-learn.

I have the following materials:

Question

  1. Does ANTs provide any algorithm for the spatial parcellation?

  2. If (1) is yes, could you please guide if there is any example codes?

Your expert opinion is really appreciate

ntustison commented 4 years ago

You should look at antsAtroposN4.sh which combines the Atropos and N4 programs into an easy to use script. Type antsAtroposN4.sh at the command line to see the help menu and start off with the "Required arguments."

sara-eb commented 4 years ago

@ntustison Thanks a lot for your suggestion, I tried to the sample code of AntsPy

Could I ask if my understanding is correct or not? This is what I am guessing in my specific problem, because each segment obtained from kmeans should show the same anatomical part in other subjects within the cohort (As the authors are showing in this image

  1. Loading the Template image and the label image of Template (T_Labels obtained from MALF) into antspy

    templateDirectory = './Template/T_template0.nii.gz'
    template = ants.image_read(templateDirectory, dimension = 3) # shape (160, 384, 384)  160 slices
  2. create the mask from T_Labels for the object of interest, for example I wanna cluster label 2

    labelDirectory = './T_Labels.nii.gz'
    T_Label = ants.image_read(labelDirectory, dimension = 3) #(160, 384, 384)
    T_Label[T_Label != 2] = 0
  3. Perform the following code:

    segs1 = ants.atropos(a=template, m='[0.2,1x1]', c='[2,0]', i='kmeans[40]', x=mask )
    *** IndexError: list index out of range

I want to cluster it into 40 regions

  1. Use the posterior probabilities obtained from Step 3, as priors to segment the test subjects using the command in Step 3. Is this correct? If yes, How to give these priors into the command? -p according to antsAtroposN4.sh is feeding the priors, but I am not familiar with commands in AntsPy. I followed your documentation but it is not a complete documentation.

Question:

Are the steps that I mentioned above applicable?

Could you please guide more on the command in AntsPy? How should I change -c and -m options? According to the command, c : number of segmentation class and -m: max. number of outer loop iterations between N4 and Atropos.

Should we do the N4 Bias correction again? because I have done N4 bias correction in the pre-processing step.

Thank you

sara-eb commented 4 years ago

@ntustison Thanks a lot for your suggestion, I tried to the sample code of AntsPy

Could I ask if my understanding is correct or not? This is what I am guessing in my specific problem, because each segment obtained from kmeans should show the same anatomical part in other subjects within the cohort (As the authors are showing in this image

  1. Loading the Template image and the label image of Template (T_Labels obtained from MALF) into antspy

    templateDirectory = './Template/T_template0.nii.gz'
    template = ants.image_read(templateDirectory, dimension = 3) # shape (160, 384, 384)  160 slices
  2. create the mask from T_Labels for the object of interest, for example I wanna cluster label 2

    labelDirectory = './T_Labels.nii.gz'
    T_Label = ants.image_read(labelDirectory, dimension = 3) #(160, 384, 384)
    T_Label[T_Label != 2] = 0
  3. Perform the following code:

    segs1 = ants.atropos(a=template, m='[0.2,1x1]', c='[2,0]', i='kmeans[40]', x=mask )
    *** IndexError: list index out of range

I want to cluster it into 40 regions

  1. Use the posterior probabilities obtained from Step 3, as priors to segment the test subjects using the command in Step 3. Is this correct? If yes, How to give these priors into the command? -p according to antsAtroposN4.sh is feeding the priors, but I am not familiar with commands in AntsPy. I followed your documentation but it is not a complete documentation.

Question:

Are the steps that I mentioned above applicable?

Could you please guide more on the command in AntsPy? How should I change -c and -m options? According to the command, c : number of segmentation class and -m: max. number of outer loop iterations between N4 and Atropos.

Should we do the N4 Bias correction again? because I have done N4 bias correction in the pre-processing step.

Thank you

ntustison commented 4 years ago

Take a look at this function which is a targeted adaptation of the antsAtroposN4.sh script for ANTsPy. It should help you get answers to your questions.

sara-eb commented 4 years ago

@ntustison thank you very much for your help. I ran the code on the cohort-specific template and the output for 40 cluster became like this. And also I had to comment the n4_bias_field_correction function in this line because of the error with this function.

I needed the parcels of regions. Is there any settings that I have missed?

Thank you

ntustison commented 4 years ago

LabelGeometryMeasures