It depends what you would like to do with the brain still “attached” to the straightened spinal cord. If this is only for visual purpose (without any quantification on the spinal cord), there is the command
sct_flatten_sagittal, which aligns the cord in the medial sagittal plane. If this is of interest to you, we could easily modify the function to also align the cord in the coronal plane. However, no quantification should be done with such “flattening” method (because the inner structure of the cord is compromised).
If, however, you wish to perform quantifications, then my next question would be: why do you need to keep the brain on? Keeping it on raises all sorts of questions regarding the validity of the anatomical consistency at the interface between the unstraightened brain and the straightened spinal cord. If you wish to perform a brain-spine study, then I strongly suggest to preprocess the brain and the spine separately: register the brain to the MNI template and the cord to the PAM50 template. Given that the PAM50 template is within the same coordinate system as the MNI template, you will be able to process both the brain and the cord as a “single” volume. See this post for more details: How to merge MNI and PAM50 template?
If, for some reasons, you really need to keep the brain on the straightened spinal cord, then the example below shows how to do it:
# Download example data
sct_download_data -d sct_example_data
# Segment cord
sct_deepseg_sc -i t1.nii.gz -c t1 -qc qc
# We add a single label at the top of the FOV, located at the center of the upper most X,Y coordinate of the center of mass of the upper most part of the cord segmentation. Note: the numbers below were found "manually", but if this feature is desired we can easily add it in future versions of SCT.
sct_label_utils -i t1_seg.nii.gz -create-add 96,106,-1,1 -o t1_seg_top_vox.nii.gz
# Straighten spinal cord. The key here is to use the flag -xy-size with an appropriate value so the output straightened destination space can accommodate the inclusion of the brain.
sct_straighten_spinalcord -i t1.nii.gz -s t1_seg_top_vox.nii.gz -xy-size 192