Skip to content

Cortical thickness values skew to 0 #223

Description

@Jiajia-yj

@ntustison I used the antspynet.cortical_thickness(...) and the dkt = antspynet.desikan_killiany_tourville_labeling(...) to extract the ROI values from T1 weighted MRI, However, the median of the ROI values is lower than the normal range. I'm wondering if I need to set some threshold for the voxel values when get the ROI values?
The code I use is just the example code:
'''
import ants
import antspynet
import antstorch

t1 = ants.image_read(antspynet.get_antsxnet_data('mprage_hippmapp3r'))
kk = antspynet.cortical_thickness(t1, verbose=True)
ants.plot(t1, overlay=kk['thickness_image'], overlay_alpha=0.75)
'''
However, the cortical thickness value's Peak frequency is around 0.2-0.4 mm, which is very small and skewed to 0. This also happens when I preprocess the raw image from ADNI dataset. The code I used to preprocess the ADNI images is:
'''
# 2. Load MNI152 template and brain mask
# (Consider using res-01 if your raw data is 1mm isotropic)
# ----------------------------------------------------------------
template_path = "tpl-MNI152NLin2009cAsym_res-02_T1w.nii.gz"
mask_path = "tpl-MNI152NLin2009cAsym_res-02_desc-brain_mask.nii.gz"

template  = ants.image_read(template_path)
mni_mask  = ants.image_read(mask_path)
mni_brain = template * mni_mask          

# ----------------------------------------------------------------
# 3. Load raw T1 image and reorient to LPI
# ----------------------------------------------------------------
raw     = ants.image_read(input_path)
img_lpi = ants.reorient_image2(raw, orientation="LPI")

# ----------------------------------------------------------------
# 4. Cortical thickness estimation in NATIVE space  (ANTsPyNet)
# ----------------------------------------------------------------
print("  [Stage 4] Cortical thickness estimation (native space)...")
kk = antspynet.cortical_thickness(img_lpi, verbose=False)

thickness_native = kk["thickness_image"]
seg_native       = kk["segmentation_image"]   

# Binary brain mask derived from segmentation
brain_mask_native = ants.threshold_image(seg_native, low_thresh=1,
                                         high_thresh=None,
                                         inval=1, outval=0)

# Skull-stripped native-space T1
t1_brain_native = img_lpi * brain_mask_native

'''
Also, by using the DKT function, the ROI values are around 0.8, while the values performed by the platform (like ADNI) have a median around 2-3 mm, the code is listed below:
'''
# ----------------------------------------------------------------
# 5. DKT parcellation in NATIVE space (ANTsPyNet)
# ----------------------------------------------------------------
print(" [Stage 5] DKT parcellation (native space)...")
dkt = antspynet.desikan_killiany_tourville_labeling(
img_lpi,
do_lobar_parcellation=True,
version=1,
verbose=False)
dkt_labels = dkt["segmentation_image"]

# ----------------------------------------------------------------
# 6. Extract per-ROI cortical thickness statistics (FIXED ZERO-SKEW)
# ----------------------------------------------------------------
print("  [Stage 6] Computing cortical thickness per DKT ROI...")

# FIX: Intersect DKT labels with an explicit mask of where thickness > 0.
# This keeps non-cortical edge voxels from diluting your Mean/Sigma metrics.
thickness_positive_mask = ants.threshold_image(thickness_native, low_thresh=0.001,
                                               high_thresh=None, inval=1, outval=0)
valid_dkt_labels = dkt_labels * thickness_positive_mask

stats = ants.label_stats(thickness_native, valid_dkt_labels)
df    = pd.DataFrame(stats)
df    = df[df["LabelValue"] > 0].reset_index(drop=True)

csv_path = out("dkt_cortical_thickness.csv")
df.to_csv(csv_path, index=False)
print(f"  Saved → {csv_path}")

'''

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions