Skip to content

Conversation

valosekj
Copy link
Member

@valosekj valosekj commented Jun 25, 2025

Checklist

Description

While digging into sct_process_segmentation and the computation of AP and RL diameters in PR #4941, I was reminded of a past discussion about CSA measurements for the left and right sides (neuropoly/idea-projects#19).

Coincidentally, a clinician from Balgrist recently asked me whether it would be possible to assess the direction of cord compression—if the compression is dorsal (posterior) or ventral (anterior). Building on the debugging from PR #4941, this PR introduces four new quadrant-based CSA metrics: posterior right (red), anterior right (blue), posterior left (green), and anterior left (purple). These quadrants can then be aggregated into left-right or anterior-posterior halves.

image

(Note that although the sct_process_segmentation input is a binary mask, the CSA quadrant computation is done on a soft mask because we apply the angle correction; details: #4941 (comment))

How to test the PR

I'm using t2_compressed.nii.gz from sct_course_data (files attached below).

# Checkout to this branch and then run
sct_process_segmentation -i t2_compressed_seg.nii.gz -perslice 1 -vertfile t2_compressed_seg_labeled.nii.gz -normalize-PAM50 1 -o t2_compressed_csa_PAM50.csv

Then you can plot the CSA quadrants and left-right or anterior-posterior halves using generate_figure_PAM50_quadrant_measures.py (temporary script pushed to this PR):

generate_figure_PAM50_quadrant_measures.py -file t2_compressed_csa_PAM50.csv

As a sanity check, I'm overlaying MEAN(area) (in black), which is computed using existing code, with MEAN(area_total) (dashed yellow), which I compute by summing all four CSA quadrants.

Linked issues

Related to neuropoly/idea-projects#19 and #4282

Tagging @sandrinebedard

t2_compressed_seg_labeled.nii.gz
t2_compressed_seg.nii.gz

@valosekj valosekj added feature PR Category (used to generate the release changelog) sct_process_segmentation context: labels Jun 25, 2025
@valosekj
Copy link
Member Author

valosekj commented Jun 26, 2025

Adding symmetry calculation ((area1 - area2) / total_area) in recent commits.

I first added R-L and A-P symmetry (the middle and right subplots). But as the symmetry values are around zero (potentially because we are defining the R-L and A-P halves by skimage.regionprops using an elliptical approximation), I also added anterior RL symmetry and posterior RL symmetry (the left subplot).

cord_quadrant_tmp_fig_slice_024

WIP: I'm investigating the symmetry more

@sandrinebedard
Copy link
Member

@valosekj do you think it would be better if the spinal cord is symmetric that the value should be like of 1? Or like % of overlap?

Also, CSA may not reflect difference of shape on the R-L or A-P, we could also consider other metrics to compute symmetry

@valosekj valosekj added the experimental PR (do not merge) PR Category (used for PRs we do not want to merge) label Jun 27, 2025
@valosekj
Copy link
Member Author

@valosekj do you think it would be better if the spinal cord is symmetric that the value should be like of 1?

Good point! I actually implemented two types of calculations: symmetry from -1 to 1. And from 0 to 1. I think that with symmetry from 0 to 1, we cannot determine the laterality.

The symmetry can be computed in two ways:
1. Signed: (area1 - area2) / total_area
Returns values from -1 to 1, where:
- 0 indicates perfect symmetry
- Positive values indicate area1 dominance (typically left side)
- Negative values indicate area2 dominance (typically right side)
- The magnitude indicates the degree of asymmetry
2. Unsigned: 1 - |area1 - area2| / total_area
Returns values from 0 to 1, where:
- 1 indicates perfect symmetry
- 0 indicates complete asymmetry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experimental PR (do not merge) PR Category (used for PRs we do not want to merge) feature PR Category (used to generate the release changelog) sct_process_segmentation context:
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants