Issue with update of qc report

Hi,

Running the labelling step and shape-based analysis, the qc report (html file) does not seem to update. I still have only the line corresponding to the segmentation.

Please see below for the full log. Thank you for the help,
Best,
Nabila

sct_label_vertebrae -i t2.nii.gz -s t2_seg.nii.gz -c t2 -qc /Users/fwlab_nb/qc_singleSubj

--

Creating temporary folder (/var/folders/bb/tkk0kp15763g75kpdjyr_rg40000gn/T/sct_2024-12-09_17-00-44_label-vertebrae_oy2fmpws)

Copying input data to tmp folder...

Straighten spinal cord...

**Reusing existing warping field which seems to be valid**

cp /Users/fwlab_nb/sct_course_data/single_subject/data/t2/straightening.cache straightening.cache

cp /Users/fwlab_nb/sct_course_data/single_subject/data/t2/warp_curve2straight.nii.gz warp_curve2straight.nii.gz

cp /Users/fwlab_nb/sct_course_data/single_subject/data/t2/warp_straight2curve.nii.gz warp_straight2curve.nii.gz

cp /Users/fwlab_nb/sct_course_data/single_subject/data/t2/straight_ref.nii.gz straight_ref.nii.gz

Resample to 0.5mm isotropic...

load data...

Apply straightening to segmentation...

File /private/var/folders/bb/tkk0kp15763g75kpdjyr_rg40000gn/T/sct_2024-12-09_17-00-44_label-vertebrae_oy2fmpws/segmentation_straight.nii already exists. Will overwrite it.

Create label to identify disc...

Creating temporary folder...

Creating temporary folder (/var/folders/bb/tkk0kp15763g75kpdjyr_rg40000gn/T/sct_2024-12-09_17-00-47_detect-c2c3_9emqvo0n)

Image header specifies datatype 'float32', but array is of type 'int16'. Header metadata will be overwritten to use 'int16'.

Image header specifies datatype 'int16', but array is of type 'float64'. Header metadata will be overwritten to use 'float64'.

Run C2-C3 detector...

Image header specifies datatype 'float32', but array is of type 'uint8'. Header metadata will be overwritten to use 'uint8'.

C2-C3 detected...

Remove temporary files...

rm -rf /var/folders/bb/tkk0kp15763g75kpdjyr_rg40000gn/T/sct_2024-12-09_17-00-47_detect-c2c3_9emqvo0n

File /var/folders/bb/tkk0kp15763g75kpdjyr_rg40000gn/T/sct_2024-12-09_17-00-44_label-vertebrae_oy2fmpws/labelz.nii.gz already exists. Will overwrite it.

And apply straightening to label...

Get z and disc values from straight label...

.. [308, 3]

Look for template...

Path template: /Users/fwlab_nb/sct_6.5/data/PAM50

Open template and vertebral levels...

Disc values from template: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]

Z-values for each disc: [984, 938, 907, 870, 833, 800, 769, 735, 692, 646, 600, 551, 500, 449, 396, 342, 289, 231, 168, 105, 39]

Distances between discs (in voxel): [46.0, 31.0, 37.0, 37.0, 33.0, 31.0, 34.0, 43.0, 46.0, 46.0, 49.0, 51.0, 51.0, 53.0, 54.0, 53.0, 58.0, 63.0, 63.0, 66.0]

Detect intervertebral discs...

Current disc: 2 (z=308). Direction: superior

.. Peak found: z=-3 (correlation = 0.5731065903895622)

Current disc: 1 (z=336). Direction: superior

.. correcting factor: 1.0

.. Switching to inferior direction.

Current disc: 3 (z=271). Direction: inferior

.. Peak found: z=-1 (correlation = 0.4609616422279576)

.. correcting factor: 0.972972972972973

Current disc: 4 (z=234). Direction: inferior

.. Peak found: z=-1 (correlation = 0.49005321018819764)

.. correcting factor: 0.981981981981982

Current disc: 5 (z=201). Direction: inferior

.. Peak found: z=-2 (correlation = 0.5298939824797383)

.. correcting factor: 0.9940622440622441

Current disc: 6 (z=168). Direction: inferior

.. Peak found: z=0 (correlation = 0.6480323638269871)

.. correcting factor: 0.9952497952497954

Current disc: 7 (z=134). Direction: inferior

.. Peak found: z=3 (correlation = 0.5134397586952049)

.. correcting factor: 0.981335613688555

Current disc: 8 (z=95). Direction: inferior

.. Peak found: z=1 (correlation = 0.5087236005179484)

.. correcting factor: 0.9773574363177647

Current disc: 9 (z=51). Direction: inferior

.. Peak found: z=4 (correlation = 0.4946196737508683)

.. correcting factor: 0.9666008002563049

Current disc: 10 (z=11). Direction: inferior

.. Peak found: z=5 (correlation = 0.4957669456823823)

.. correcting factor: 0.9534036098896623

Adding top disc based on adjusted template distance: #0

.. approximate distance: 44

Un-straighten labeling...

Cleaning labeled segmentation:

removing labeled voxels outside segmentation...

Done cleaning.

File /private/var/folders/bb/tkk0kp15763g75kpdjyr_rg40000gn/T/sct_2024-12-09_17-00-44_label-vertebrae_oy2fmpws/segmentation_labeled.nii already exists. Will overwrite it.

Label discs...

Un-straighten labeled discs...

Creating temporary folder (/var/folders/bb/tkk0kp15763g75kpdjyr_rg40000gn/T/sct_2024-12-09_17-00-51_apply-transfo-3d-label_26z_3u4q)

File segmentation_labeled_disc.nii already exists. Will overwrite it.

Generate output files...

File /Users/fwlab_nb/sct_course_data/single_subject/data/t2/t2_seg_labeled.nii.gz already exists. Deleting it..

File created: /Users/fwlab_nb/sct_course_data/single_subject/data/t2/t2_seg_labeled.nii.gz

File /Users/fwlab_nb/sct_course_data/single_subject/data/t2/t2_seg_labeled_discs.nii.gz already exists. Deleting it..

File created: /Users/fwlab_nb/sct_course_data/single_subject/data/t2/t2_seg_labeled_discs.nii.gz

File /Users/fwlab_nb/sct_course_data/single_subject/data/t2/straightening.cache already exists. Deleting it..

mv /var/folders/bb/tkk0kp15763g75kpdjyr_rg40000gn/T/sct_2024-12-09_17-00-44_label-vertebrae_oy2fmpws/straightening.cache /Users/fwlab_nb/sct_course_data/single_subject/data/t2/straightening.cache

File created: /Users/fwlab_nb/sct_course_data/single_subject/data/t2/straightening.cache

File /Users/fwlab_nb/sct_course_data/single_subject/data/t2/warp_curve2straight.nii.gz already exists. Deleting it..

mv /var/folders/bb/tkk0kp15763g75kpdjyr_rg40000gn/T/sct_2024-12-09_17-00-44_label-vertebrae_oy2fmpws/warp_curve2straight.nii.gz /Users/fwlab_nb/sct_course_data/single_subject/data/t2/warp_curve2straight.nii.gz

File created: /Users/fwlab_nb/sct_course_data/single_subject/data/t2/warp_curve2straight.nii.gz

File /Users/fwlab_nb/sct_course_data/single_subject/data/t2/warp_straight2curve.nii.gz already exists. Deleting it..

mv /var/folders/bb/tkk0kp15763g75kpdjyr_rg40000gn/T/sct_2024-12-09_17-00-44_label-vertebrae_oy2fmpws/warp_straight2curve.nii.gz /Users/fwlab_nb/sct_course_data/single_subject/data/t2/warp_straight2curve.nii.gz

File created: /Users/fwlab_nb/sct_course_data/single_subject/data/t2/warp_straight2curve.nii.gz

File /Users/fwlab_nb/sct_course_data/single_subject/data/t2/straight_ref.nii.gz already exists. Deleting it..

mv /var/folders/bb/tkk0kp15763g75kpdjyr_rg40000gn/T/sct_2024-12-09_17-00-44_label-vertebrae_oy2fmpws/straight_ref.nii.gz /Users/fwlab_nb/sct_course_data/single_subject/data/t2/straight_ref.nii.gz

File created: /Users/fwlab_nb/sct_course_data/single_subject/data/t2/straight_ref.nii.gz

Remove temporary files...

rm -rf /var/folders/bb/tkk0kp15763g75kpdjyr_rg40000gn/T/sct_2024-12-09_17-00-44_label-vertebrae_oy2fmpws

*** Generating Quality Control (QC) html report ***
/Users/fwlab_nb/qc_singleSubj/single_subject/data/t2/sct_label_vertebrae/2024_12_09_170053.824301/background_img.png
Traceback (most recent call last):
  File "/Users/fwlab_nb/sct_6.5/spinalcordtoolbox/scripts/sct_label_vertebrae.py", line 507, in <module>
    main(sys.argv[1:])
  File "/Users/fwlab_nb/sct_6.5/spinalcordtoolbox/scripts/sct_label_vertebrae.py", line 498, in main
    generate_qc(fname_in, fname_seg=labeled_seg_file, args=argv, path_qc=os.path.abspath(path_qc),
  File "/Users/fwlab_nb/sct_6.5/spinalcordtoolbox/reports/qc.py", line 632, in generate_qc
    qc_image._make_QC_image_for_3d_volumes(img, mask, plane, imgs_to_generate)
  File "/Users/fwlab_nb/sct_6.5/python/envs/venv_sct/lib/python3.9/contextlib.py", line 126, in __exit__
    next(self.gen)
  File "/Users/fwlab_nb/sct_6.5/spinalcordtoolbox/reports/qc2.py", line 130, in create_qc_entry
    path_index_html = refresh_qc_entries.main(path_qc)
  File "/Users/fwlab_nb/sct_6.5/spinalcordtoolbox/reports/assets/_assets/py/refresh_qc_entries.py", line 42, in main
    json_data.append(json.load(file))
  File "/Users/fwlab_nb/sct_6.5/python/envs/venv_sct/lib/python3.9/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/Users/fwlab_nb/sct_6.5/python/envs/venv_sct/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/Users/fwlab_nb/sct_6.5/python/envs/venv_sct/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Users/fwlab_nb/sct_6.5/python/envs/venv_sct/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)
fwlab_nb@Mac t2 % sct_process_segmentation -i t2_seg.nii.gz -vert 3:4 -vertfile t2_seg_labeled.nii.gz
-o csa_c3c4.csv

Hi @Nab30,

Does this issue happen every time? (For example, if you were to remove the old qc_singleSubj folder, then re-run the commands, do you get the same error?)

If you don’t get the error again, then maybe it was just a one-off glitch.

However, if you can get this error to happen consistently, would you be able to zip up your qc_singleSubj folder and upload it to the forum? That way I can look at the specific files to identify what is causing the error.

Kind regards,
Joshua

I tried deleting the qc_singleSubj folder and indeed it works now.

Does it mean that I have to run each step in a separate folder for the error not to happen ?

Definitely not! The QC report is designed to have many different entries (so that you can quickly QC an entire dataset, for example).

If the error occurs again, after you run a second command, then something is definitely wrong. Please feel free to put the qc_singleSubj into a .zip and upload it to the forum, and I’ll be happy to take a look. :slight_smile:

Thank you kindly,
Joshua

It appears to be a one-time error. It did not happen when I run the subsequent commands!

Thank you Joshua,
Best,
Nabila

1 Like