Closed sara-eb closed 3 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."
@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
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
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
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
-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 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
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
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
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
-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
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.
@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?
How to get the cluster centers from the outputs?
dict_keys(['segmentation_image', 'probability_images', 'processed_image'])
How to use these posterior probabilities for clustering the test subjects?
Thank you
LabelGeometryMeasures
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
Does ANTs provide any algorithm for the spatial parcellation?
If (1) is yes, could you please guide if there is any example codes?
Your expert opinion is really appreciate