Perlevel data not in accordance with perslice data

Hi,
I calculate csa data by using “sct_process_segmentation -i t2s_seg.nii.gz -vert 3:7 -perlevel 1 -o csa_level.csv” and “sct_process_segmentation -i t2s_seg.nii.gz -vert 3:7 -perslice 1 -o csa_level.csv” respectively, every variant of perlevel data but sumlength equals average data of perslice in correspondant vert. Is it correct? I doubt if I misunderstand the definition of sumlength, would anybody illustrate the position with diagrams to me?csa_perlevel_perslice.xlsx (10.7 KB)

Hi,

Trying to reproduce your bug in a transparent and reproducible manner:

Processing data:

# Using SCT v4.3 on OSX
# Download example data
sct_download_data -d sct_example_data
cd sct_example_data/t2
# Segment cord
sct_deepseg_sc -i t2.nii.gz -c t2
# Label vertebrae
sct_label_vertebrae -i t2.nii.gz -s t2_seg.nii.gz -c t2
# Create labels
sct_label_utils -i t2_seg_labeled.nii.gz -vert-body 3,7 -o labels.nii.gz
# Register to template
sct_register_to_template -i t2.nii.gz -s t2_seg.nii.gz -l labels.nii.gz 
# Warp template
sct_warp_template -d t2.nii.gz -w warp_template2anat.nii.gz -a 0
# Compute CSA using perslice and perlevel
sct_process_segmentation -i t2_seg.nii.gz -vert 3:7 -perslice 1 -o csa_perslice.csv
sct_process_segmentation -i t2_seg.nii.gz -vert 3:7 -perlevel 1 -o csa_perlevel.csv

Computing statistics::
Download this script: compare_sumlength.py (519 Bytes)
Then run:

# Activate SCT's Python
source $SCT_DIR/python/etc/profile.d/conda.sh
conda activate venv_sct
# Extract length value for level C7 for perlevel and perslice, and display results
python compare_sumlength.py

Results:

sumlength_perlevel: 17.052485864785886
sumlength_perslice: 17.052485864785883

As you can see, both sumlengths match (at reasonable precision level).

So, I am not sure what you did and how you analyzed your data, but if you provide me with a transparent and fully-reproducible example so I can reproduce your bug, I will be able to help.

Best,
Julien

Yes,Both sumlengths match well as soon as I understand the concept of sumlength. sumlength of a vertlevel equals total sumlength perslice, not average of them.
Thanks.

1 Like