When generating QC report for function sct_label_utils, the image is cropped (while it should not):

here is the original image, indicating that it has indeed been cropped by the QC report:

To reproduce:
data (internal): duke/temp/sebeda/test1_30_sub/files_test_qc
syntax:
~
sct_qc -i sub-1002358_T1w_RPI_r_gradcorr.nii.gz -s sub-1002358_T1w_RPI_r_gradcorr_labels-manual.nii.gz -p sct_label_utils -qc qc
~
SCT version: git-jca/3044-ants-sampling-770e37f8b25f3283ede65eb171501f55bf5416e5
I have access to duke now. I'm going to take a look at this shortly. :slightly_smiling_face:
I was able to reproduce the error, and I have a rough idea where the problem is.
The problem is present inside reports/slice.py : Sagittal.single(). (This is the function that gets called to produce the image matrix.) Specifically, this line:
When I run the command in this issue and set a breakpoint here, index = {list: 208} [104, 104, 104, 104 ...]. In other words, index is used to take 208 rows of data, each from slice 104. But, the image data matrix is actually of size 256x256, so index is missing 48 rows.
To quickly test this theory, if I manually change index to be index = {list: 256} [104, 104, 104, 104 ...], then continue with the rest of the script, the expected image is produced:

My next step is to inspect the get_center_spit function to figure out why the 48 rows are missing in the first place. :sweat_smile:
Ah! The data files ('sub-1002358_T1w_RPI_r_gradcorr.nii.gz', 'sub-1002358_T1w_RPI_r_gradcorr_labels-manual.nii.gz') are of size [208, 256, 256].
These images get re-oriented from RPI to SAL (i.e. [208, 256, 256] -> [256, 256, 208]) here:
Then, inside get_center_spit:
image.data.shape[2] refers to the RL dimension (208). But, the function is supposed to be returning index = [int] * n_SI:
Since we assume SAL orientation, to index the SI dimension properly, I think the fix is as simple as this:
```diff
# If mask only has one label (e.g., in sct_detect_pmj), return the repmat of the R-L index (assuming SAL orient)
elif np.argwhere(image.data).shape[0] == 1:
- return [np.argwhere(image.data)[0][2]] * image.data.shape[2]
+ return [np.argwhere(image.data)[0][2]] * image.data.shape[0]