Standardize analysis across subjects

If when using sct_extract_metric I specify - vert 1:3, metrics extraction will be limited to slices corresponding to those vertebral levels, regardless segmentation, right? I do not want to extract metrics from last slices, as segmentation stops or continues below certain vertebral levels according to the subject.
Thanks
Rosella

that’s right.

Thank you for your support. Do you think, basing on the qc segmentation results posted before, computing metrics between levels c1:c3 is ok?
Thanks
Rosella

my pleasure. It is difficult for me to say, because i don’t know, from these axial EPI data, what vertebral levels those slices cover.

that is exactely what I wanted to know, that is how to associate slices and vertebral levels .
best,
Rosella

in this discussion thread, we’ve discussed ways for you to label vertebral levels and use this information to extract metrics at specific levels. Let me know if something is unclear about the process.

OK , I already have created a file labels1_4.nii.gz by manually selecting labels at posterior tip of c1 and between c3 and c4. Do I have to overlay this file on my DKI image and segmentation mask in order to associate segmentation, slices and vertebral levels?
thanks,
Rosella

Lines 18-23 of your analysis script kurtosis_def.sh (3.2 KB) bring the template (incl. vertebral levels) in the space of the DWI data. This is a pretty fundamental question, which is covered in the SCT course as well as in the example batch_processing.sh script. I would advise you spend some time on the course material and script, to better understand how the analysis pipeline works. This will answer many of your concerns.

Best,
Julien

1 Like

just one more question, on a pretty different matter. After manual correction of segmentation, is there a way to display it as in qc results, in order to highlight the changes introduced?
thanks,
Rosella

just one more question, on a pretty different matter. After manual correction of segmentation, is there a way to display it as in qc results, in order to highlight the changes introduced?

Yes, you can run sct_qc with the input you want (i.e. manual and automatic segmentation).

1 Like

Running sct_qc gives me the following error:
sct_qc -i kurtosis_crop_moco_dwi_mean_seg-manual.nii.gz -p sct_deepseg_sc

--
Spinal Cord Toolbox (4.1.0)


>     *** Generate Quality Control (QC) html report ***
>     Traceback (most recent call last):
>       File "/home/rosella/sct_4.1.0/scripts/sct_qc.py", line 86, in <module>
>         main(arguments)
>       File "/home/rosella/sct_4.1.0/scripts/sct_qc.py", line 79, in main
>         process=args.p)
>       File "/home/rosella/sct_4.1.0/spinalcordtoolbox/reports/qc.py", line 564, in generate_qc
>         qcslice_type = qcslice.Axial([Image(fname_in1), Image(fname_seg)])
>       File "/home/rosella/sct_4.1.0/spinalcordtoolbox/image.py", line 256, in __init__
>         raise TypeError('Image constructor takes at least one argument.')
>     TypeError: Image constructor takes at least one argument.

This is getting out-of-scope for this thread (which is already very long).

Could you please open a new discussion thread, with a title specific to the issue you are experiencing with sct_qc. We will take it from there.

Thanks

1 Like

I have read both sct course and batch_processing.sh script. However, I can’t understand why in the script it creates labels and warps PAM50 atlas:

# Tips: for manual initialization of labeling by clicking at disc C2-C3, use flag -initc2
sct_label_vertebrae -i t2.nii.gz -s t2_seg.nii.gz -c t2 -qc "$SCT_BP_QC_FOLDER"
# Create labels at in the cord at C2 and C5 mid-vertebral levels
sct_label_utils -i t2_seg_labeled.nii.gz -vert-body 2,5 -o labels_vert.nii.gz
# Tips: you can also create labels manually using:
# sct_label_utils -i t2.nii.gz -create-viewer 2,5 -o labels_vert.nii.gz
# Register to template

but then extract diffusion metrics between slices 2 and 14:

# Compute FA within right and left lateral corticospinal tracts from slices 2 to 14 using weighted average method
sct_extract_metric -i dti_FA.nii.gz -z 2:14 -method wa -l 4,5 -o fa_in_cst.csv 

I still can’t understand how to find a correspondance between vertebral leves and slice number.
thanks,
Rosella

hi,
you need to specify to extract metrics at the desired vertebral levels (not the slices). E.g., to extract between C2 and C4:

sct_extract_metric -i dti_FA.nii.gz -vert 2:4 -method wa -l 4,5 -o fa_in_cst.csv 

I probably found a solution and updated my kurtosis_def.sh script.
Could you please give a quick check at my processing steps?
I remind that my aim is computing average DTI and DKI metrics along WM and GM in a bunch of subjects, along those vertebral levels where segmentation is good for all my subjects.
In order to do so, in my script I:

  1. cropped each image in the most similar way to reduce FOV the same way across subjects
  2. performed motion correction
  3. performed segmentation using deepseg and manually corrected those slices where segmentation was not good (apart from slices at the very beginning or bottom, where metrics are not supposed to be computed)
  4. manually created 2 labels at the posterior tip of the top of C1 vertebra and at C3-C4 disc on 3dT1 image, used as anatomical reference
  5. registered PAM50 template to each subject’s DKI image
  6. computed DTI and DKI maps over a dilated mask in order to account for partial volume effect
  7. multiplied segmentation mask with WM and GM labels for subsequent metric extraction only in slices where segmentation is ok
  8. metrics extraction along gm and wm between c1 and c3 (making sure vertebral levels are taken correctly as -vertfile is given as in input of sct_extract_metrics)
    kurtosis_def.sh (3.7 KB)

thank you very much,
Rosella

yes I already used this command but wanted to make sure those selected vertebral levels corresponded to slices where segmentation was good for every subject .
thanks
Rosella

as i already explained here, you cannot use both -f and -l.

here is the corrected script: kurtosis_def.sh (3.7 KB)

yes I already used this command but wanted to make sure those selected vertebral levels corresponded to slices where segmentation was good for every subject

the output csv includes a column for slices so you can check what slices were included.

also, as i explained here, the key is to provide a manually-corrected segmentation, so that regardless the slices that are selected, the extracted metrics will be computed in a region that you want them to be extracted from (i.e. even if the segmentation is “not good”, the fact that you correct it makes the extraction “good”).

ok. thank you
one more question: do you think this step is necessary?

multiplied segmentation mask with WM and GM labels for subsequent metric extraction only in slices where segmentation is ok

I haven’t seen anything similar in batch_processing.sh example
Moreover, what does it changes with or without specifying

-vertfile label/template/PAM50_levels.nii.gz in sct_extract_metric ?

thanks
Rosella

I am very surprised by your question. The purpose of this discussion thread is to specifically address your problem of “bad” segmentation. If you re-read this entire discussion thread, from the top, to the bottom, you will see that your question comes up again and again, with me trying to answer it again and again. I feel we are going in circle here, and that there is something fundamental in the analysis that is misunderstood.

as the usage says: you can specify a labeled segmentation (by default, it select: ./label/template/PAM50_levels.nii.gz)

I wrote my question in an improper way. I understood what you mean , but I simply was wandering why in example analysis script this need to compute metrics’ extraction only on segmentation mask has never raised.
Rosella