Lesion analysis outputs

Hi SCT team, I have been using the sct_analyze_lesion function and have a couple of related questions:

  1. Can the “ROI Occupied by lesion” and “Lesion distribution” output data be calculated -perslice, or is it limited to vertebral segments?

  2. I am interested in calcuating the volume of my lesion within specific spinal cord regions. I am currently calculating volume of lesion within each template by multiplying the “%occupied by lesion” value of my lesion by the volume of the template/atlas of interest. I am using the sct_process_segmentation to calculate the volumes of the atlas/templates of interest. For example, I can determine that 0.5% of gm is occupied by my lesion at C6 and that the gm volume at C6 is x. I then have to multiply these values and manually do this calculation at each vertebral level and for each lesion. Is there a faster way??

Thanks!

Hi @jtalbott,

  1. AFAIK it is currently not possible (@Charley_Gros?). But this is a great idea, so I’ve opened a new feature request. It shouldn’t be too complicated to implement. Alternatively, you could use the approach shown below.

  2. A faster way would be to multiply your lesion mask with the atlas of interest and then compute perslice/perlevel statistics. Below is an example (which also addresses the previous question):

# This script assumes that the PAM50 atlas was warped and the output folder is ./label (which is the default)
# Here, the lesion file is called "lesion.nii.gz". You will need to adapt with your actual file name.

# List of labels to compute the lesion statistics from
LABELS=(30 31)

# Range of vertebral levels to compute the lesion statistics from
LEVELS="2:5"

for label in ${LABELS[@]}; do
  # Multiply lesion mask by specific atlas tract
  sct_maths -i lesion.nii.gz -mul label/atlas/PAM50_atlas_${label}.nii.gz -o lesion_${label}.nii.gz
  # Compute slicewise statistics on lesion mask within this specific tract
  # P.S. We don't use angle correction because of the normalization below (i.e. same result, but we save time)
  sct_process_segmentation -i lesion_${label}.nii.gz -angle-corr 0 -o csa_perslice_lesion_${label}.csv
  # Compute slicewise statistics on the specific atlas (for normalization purpose)
  sct_process_segmentation -i label/atlas/PAM50_atlas_${label}.nii.gz -angle-corr 0 -o csa_perslice_atlas_${label}.csv
  # Compute levelwise statistics on lesion mask within this specific tract
  # P.S. We don't use angle correction because of the normalization below (i.e. same result, but we save time)
  sct_process_segmentation -i lesion_${label}.nii.gz -vert $LEVELS -perlevel 1 -angle-corr 0 -o csa_perlevel_lesion_${label}.csv
  # Compute levelwise statistics on the specific atlas (for normalization purpose)
  sct_process_segmentation -i label/atlas/PAM50_atlas_${label}.nii.gz -vert $LEVELS -perlevel 1 -angle-corr 0 -o csa_perlevel_atlas_${label}.csv
done

You can download the script here: compute_lesion_statistics.sh (1.5 KB)

This script will output csv files per lesion (within each ROI) and per ROI, so you can then perform normalization (e.g. slicewise normalization of CSA(lesion_ROI)/CSA(ROI)). This can of course be automatized with a simple Python script (happy to help).

Cheers,
Julien

1 Like

Brilliant! Thank you Julien. I’ll try your suggested approach which I’m sure will work.

Thank again!

1 Like

Script works perfectly! Sorry, but two quick followup questions:

  1. Is there a way to use combined labels in this script. For example, I tried “LABELS=(0:29)” for white matter in the label definitions line of the script but this didn’t seem to work. As a workaround, I copy/pasted the wm template from the template folder to the atlas folder and renamed it with a number. This seems to work, but I was wondering if there is an alternative solution.

  2. Do area calculations in the sct_process_segmentation output account for the fractional pixel values or does every pixel >0.0 get counted equally in the area calculation?

Thanks again!

Jason

great questions!

Is there a way to use combined labels in this script. For example, I tried “LABELS=(0:29)” for white matter in the label definitions line of the script but this didn’t seem to work. As a workaround, I copy/pasted the wm template from the template folder to the atlas folder and renamed it with a number. This seems to work, but I was wondering if there is an alternative solution.

ah! i was waiting for that one :wink: What you suggest is a reasonable thing to do if you want to keep everything within the same loop. Alternatively you can create additional lines of code (outside the for loop) specific to the WM and GM atlas but it’s a bit ugly. However I would choose values “51” and “52” respectively for the WM and GM, just to be consistent with the naming of these ROIs in sct_extract_metric

Do area calculations in the sct_process_segmentation output account for the fractional pixel values or does every pixel >0.0 get counted equally in the area calculation?

sct_process_segmentation does account for soft mask in the calculation of CSA, i.e., a voxel with value 0.5 will count for 0.5 of the CSA calculation. For full disclosure here is the line of code that computes the CSA.

Thank you!!