### Model Installation Examples Source: https://spinalcordtoolbox.com/stable/user_section/command-line/deepseg/tumor_edema_cavity_t1_t2.html Examples for installing models using custom URLs and running the segmentation on a T2 image. ```bash sct_deepseg tumor_edema_cavity_t1_t2 -install -custom-url CUSTOM_URL ``` ```bash sct_deepseg tumor_edema_cavity_t1_t2 -i t2.nii.gz ``` -------------------------------- ### Install model with custom URL and run segmentation Source: https://spinalcordtoolbox.com/stable/user_section/command-line/deepseg/gm_wm_exvivo_t2.html Examples showing how to install a specific model version using a custom URL and how to run the segmentation on an input file. ```bash sct_deepseg gm_wm_exvivo_t2 -install -custom-url CUSTOM_URL ``` ```bash sct_deepseg gm_wm_exvivo_t2 -i t2.nii.gz ``` -------------------------------- ### Install custom model and segment image Source: https://spinalcordtoolbox.com/stable/user_section/command-line/deepseg/lesion_ms_axial_t2.html Two example commands: one installs a custom model version using -custom-url, and the other segments an input image with -i. ```bash sct_deepseg lesion_ms_axial_t2 -install -custom-url CUSTOM_URL ``` ```bash sct_deepseg lesion_ms_axial_t2 -i t2.nii.gz ``` -------------------------------- ### Example sct_deepseg spinalcord commands Source: https://spinalcordtoolbox.com/stable/user_section/command-line/deepseg/spinalcord.html Example commands: install a specific model version using -custom-url, and segment an image with -i. ```bash sct_deepseg spinalcord -install -custom-url CUSTOM_URL ``` ```bash sct_deepseg spinalcord -i t2.nii.gz ``` -------------------------------- ### View help and usage examples for sct_deepseg Source: https://spinalcordtoolbox.com/stable/user_section/command-line/all_tools.html Shows the help message and lists available tasks. The examples demonstrate how to view help for a specific task, install a task, and segment an image with a task. ```bash sct_deepseg -h ``` ```bash sct_deepseg spinalcord -h ``` ```bash sct_deepseg gm_mouse_t1 -install ``` ```bash sct_deepseg lesion_ms -i cMRI3712.nii.gz ``` -------------------------------- ### Install a specific model version with -custom-url Source: https://spinalcordtoolbox.com/stable/user_section/command-line/deepseg/lesion_ms_mp2rage.html Example command to install a specific model version using the -custom-url option. ```bash sct_deepseg lesion_ms_mp2rage -install -custom-url CUSTOM_URL ``` -------------------------------- ### Run the SCT installation script Source: https://spinalcordtoolbox.com/stable/user_section/installation/apptainer.html Execute the installation script to set up the container. You can perform a basic installation or include specific DeepSeg tasks. ```bash ./install_sct_containered_{sct_version}.sh ``` ```bash ./install_sct_containered_{sct_version}.sh spinalcord tumor_t2 ``` -------------------------------- ### Install X11 Utilities Source: https://spinalcordtoolbox.com/stable/user_section/installation/linux.html Install xauth and x11-xserver-utils on the host machine to support GUI redirection. ```bash sudo apt install xauth x11-xserver-utils ``` -------------------------------- ### Run SCT Installer Script Source: https://spinalcordtoolbox.com/stable/user_section/installation/linux.html Navigate to the download directory and execute the SCT installation script. ```bash cd ~/Downloads bash install_sct-_linux.sh ``` -------------------------------- ### Optional argument examples Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_dmri_moco.html Examples of file inputs for optional arguments. ```text bvals.txt ``` ```text dmri_mask.nii.gz ``` -------------------------------- ### Install SCT in Docker Source: https://spinalcordtoolbox.com/stable/user_section/installation/linux.html Commands to pull the Ubuntu image, install dependencies, clone the SCT repository, and install the toolbox. ```bash sudo docker pull ubuntu:22.04 sudo docker run -it ubuntu:22.04 apt update apt install git bzip2 curl gcc git libdbus-1-3 libgl1-mesa-glx libglib2.0-0 libxkbcommon-x11-0 libxrender1 git clone --branch 7.0 https://github.com/spinalcordtoolbox/spinalcordtoolbox.git sct cd sct ./install_sct -iy source /root/.bashrc sct_testing sudo docker ps -a sudo docker commit /ubuntu:ubuntu22.04 ``` -------------------------------- ### Install Ubuntu via WSL Source: https://spinalcordtoolbox.com/stable/user_section/installation/windows.html Execute this command in an administrator PowerShell to install the default Ubuntu distribution. ```powershell wsl --install ``` -------------------------------- ### Install Spinal Cord Toolbox Source: https://spinalcordtoolbox.com/stable/index.html Execute the installation script on macOS or Linux systems. ```bash ./install_sct ``` -------------------------------- ### Install sc_lumbar_t2 model Source: https://spinalcordtoolbox.com/stable/user_section/tutorials/registration-to-template/lumbar-registration/lumbar-segmentation.html Run this command to install the sc_lumbar_t2 model if it is not already installed. ```bash sct_deepseg sc_lumbar_t2 -install ``` -------------------------------- ### Mandatory argument examples Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_dmri_moco.html Examples of file inputs for mandatory arguments. ```text dmri.nii.gz ``` ```text bvecs.txt ``` -------------------------------- ### Expected installation warnings Source: https://spinalcordtoolbox.com/stable/user_section/installation/windows.html These warnings are expected due to the lack of a default GUI environment in WSL. ```text Check if figure can be opened with matplotlib.......[FAIL] (Using non-GUI backend 'agg') Check if figure can be opened with PyQt.............[FAIL] ($DISPLAY not set on X11-supporting system) ``` -------------------------------- ### JSON configuration example for sct_run_batch Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_run_batch.html Example JSON configuration file for sct_run_batch. All arguments use underscores instead of dashes. The exclude_list can exclude entire subjects or individual sessions. ```json { "path_data" : "~/sct_data", "path_output" : "~/pipeline_results", "script" : "nature_paper_analysis.sh", "jobs" : -1, "exclude_list" : ["sub-01/ses-01", "sub-02", "ses-03"] } ``` -------------------------------- ### Install GCC via Homebrew Source: https://spinalcordtoolbox.com/stable/user_section/installation/mac.html Install GCC using Homebrew if it is not already present on your system. ```bash brew install gcc ``` -------------------------------- ### Install GCC on Debian/Ubuntu Source: https://spinalcordtoolbox.com/stable/user_section/installation/linux.html Install the GNU Compiler Collection using the apt package manager. ```bash apt install gcc ``` -------------------------------- ### Install SCT with pip for user Source: https://spinalcordtoolbox.com/stable/user_section/installation/mac.html Install SCT in-place using pip for the current user when not using a virtual environment. ```bash pip install --user -e . ``` -------------------------------- ### Install system dependencies in Ubuntu Source: https://spinalcordtoolbox.com/stable/user_section/installation/windows.html Update the package list and install required software packages for SCT. ```bash sudo apt-get update && sudo apt-get upgrade -y sudo apt-get -y install gcc unzip python3-pip python3 psmisc net-tools git gfortran libjpeg-dev ``` -------------------------------- ### Install NumPy Source: https://spinalcordtoolbox.com/stable/user_section/installation/linux.html Install the required numpy dependency. ```bash pip install numpy ``` -------------------------------- ### Install model with custom URL Source: https://spinalcordtoolbox.com/stable/user_section/command-line/deepseg/gm_mouse_t1.html Installs a specific version of a model by providing the URL of the .zip asset from the model's Releases page. ```bash sct_deepseg gm_mouse_t1 -install -custom-url CUSTOM_URL ``` -------------------------------- ### YAML configuration example for sct_run_batch Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_run_batch.html Example YAML configuration file for sct_run_batch. All arguments use underscores instead of dashes. The exclude_list can exclude entire subjects or individual sessions. Quotes are optional for strings in YAML but omitting them may cause parse errors. ```yaml path_data : "~/sct_data" path_output : "~/pipeline_results" script : "nature_paper_analysis.sh" jobs : -1 exclude_list : ["sub-01/ses-01", "sub-02", "ses-03"] # this will exclude ses-01 for sub-01, all sessions for sub-02 and ses-03 for all subjects ``` -------------------------------- ### Run the batch processing script Source: https://spinalcordtoolbox.com/stable/user_section/getting-started.html Launches the SCT batch processing example script, which downloads example data and runs a typical multi-parametric MRI analysis. The script is located at $SCT_DIR/batch_processing.sh. ```bash $SCT_DIR/batch_processing.sh ``` -------------------------------- ### Install SCT in Ubuntu Docker Container Source: https://spinalcordtoolbox.com/stable/user_section/installation/windows.html Commands to pull the Ubuntu image, install dependencies, clone the SCT repository, and commit the container state. ```bash # Start from Powershell or the Command Prompt docker pull ubuntu:22.04 # Launch interactive mode (command-line inside container) docker run -it ubuntu:22.04 # Now, inside Docker container, install dependencies apt update apt install git bzip2 curl gcc git libdbus-1-3 libgl1-mesa-glx libglib2.0-0 libxkbcommon-x11-0 libxrender1 # Note for above: libdbus-1-3, libgl1-mesa-glx, libglib2.0-0, libxkbcommon-x11-0, libxrender1 are required by PyQt # Install SCT (you can change 7.0 for the version of your choice) git clone --branch 7.0 https://github.com/spinalcordtoolbox/spinalcordtoolbox.git sct cd sct ./install_sct -iy source /root/.bashrc # Test SCT sct_testing # Save the state of the container as a docker image. # Back on the Host machine, open a new terminal and run: docker ps -a # list all containers (to find out the container ID) # specify the ID, and also choose a name to use for the docker image, such as "sct_v7.0" docker commit /ubuntu:ubuntu22.04 ``` -------------------------------- ### Install custom model with sct_deepseg spine Source: https://spinalcordtoolbox.com/stable/user_section/command-line/deepseg/spine.html Installs a specific version of a model by providing the URL to the .zip asset from the model's Releases page. Use with -install to install that version. ```bash sct_deepseg spine -install -custom-url CUSTOM_URL ``` -------------------------------- ### Install GCC on CentOS/RedHat Source: https://spinalcordtoolbox.com/stable/user_section/installation/linux.html Install the GNU Compiler Collection using the yum package manager. ```bash yum -y install gcc ``` -------------------------------- ### Example parameter configuration with centermassrot and columnwise algorithms Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_register_multimodal.html Shows a parameter string where the columnwise algorithm is applied after a translation and rotation using the centermassrot algorithm, both using the MeanSquares metric. ```text -param step=1,type=seg,algo=centermassrot,metric=MeanSquares: step=2,type=seg,algo=columnwise,metric=MeanSquares ``` -------------------------------- ### batch_processing.sh source script Source: https://spinalcordtoolbox.com/stable/user_section/getting-started.html The full source of the batch_processing.sh script. It sets up environment variables, downloads example data, and runs the analysis. It includes options to prevent re-downloading (SCT_BP_DOWNLOAD=0), specify a QC folder (SCT_BP_QC_FOLDER), and skip QC removal (SCT_BP_NO_REMOVE_QC). The script aborts on error and installs the sct_deepseg model. ```bash #!/bin/bash # # Example of commands to process multi-parametric data of the spinal cord. # # Please note that this batch script has a lot of redundancy and should not # be used as a pipeline for regular processing. For example, there is no need # to process both t1 and t2 to extract CSA values. # # For information about acquisition parameters, see: https://osf.io/wkdym/ # N.B. The parameters are set for these type of data. With your data, parameters # might be slightly different. # # Usage: # # [option] ./batch_processing.sh # # Prevent (re-)downloading sct_example_data: # SCT_BP_DOWNLOAD=0 ./batch_processing.sh # # Specify quality control (QC) folder (Default is ~/qc_batch_processing): # SCT_BP_QC_FOLDER=/user/toto/my_qc_folder ./batch_processing.sh # Abort on error set -ve # For full verbose, uncomment the next line # set -x # Fetch OS type if uname -a | grep -i darwin > /dev/null 2>&1; then # OSX open_command="open" elif uname -a | grep -i linux > /dev/null 2>&1; then # Linux open_command="xdg-open" fi # Check if users wants to use his own data if [[ -z "$SCT_BP_DOWNLOAD" ]]; then SCT_BP_DOWNLOAD=1 fi # QC folder if [[ -z "$SCT_BP_QC_FOLDER" ]]; then SCT_BP_QC_FOLDER=$(pwd)/"qc_example_data" fi # Remove QC folder if [ -z "$SCT_BP_NO_REMOVE_QC" ] && [ -d "$SCT_BP_QC_FOLDER" ]; then echo "Removing $SCT_BP_QC_FOLDER folder." rm -rf "$SCT_BP_QC_FOLDER" fi # get starting time: start=$(date +%s) # download example data if [[ "$SCT_BP_DOWNLOAD" == "1" ]]; then sct_download_data -d sct_example_data fi # Enter our data directory cd "$SCT_DIR/data/sct_example_data" # install the sct_deepseg model this script will use later sct_deepseg spinalcord -install ``` -------------------------------- ### Install SCT via Pip Source: https://spinalcordtoolbox.com/stable/user_section/installation/linux.html Install SCT in editable mode, either within a virtual environment or the base environment. ```bash pip install -e . ``` ```bash pip install --user -e . ``` -------------------------------- ### Install DeepSeg tasks post-installation Source: https://spinalcordtoolbox.com/stable/user_section/installation/apptainer.html Update an existing sct.sif file to include additional DeepSeg tasks by running the provided installation script. ```bash ./install_deepseg_task.sh spinalcord t2_tumor ``` -------------------------------- ### Example: segment a single image Source: https://spinalcordtoolbox.com/stable/user_section/command-line/deepseg/gm_sc_7t_t2star.html Example command that segments the input image t2.nii.gz using the gm_sc_7t_t2star model. ```bash sct_deepseg gm_sc_7t_t2star -i t2.nii.gz ``` -------------------------------- ### List WSL distributions Source: https://spinalcordtoolbox.com/stable/user_section/installation/windows.html Check the installed distributions and their current WSL version. ```powershell wsl --list --verbose ``` -------------------------------- ### Custom step=1 parameters for -param argument Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_register_to_template.html Recommended starting parameters for the -param argument when customizing step=1 for rootlet-based registration. Use these as a base and adjust as needed. ```text step=1,type=rootlet,algo=bsplinesyn,metric=CC,iter=6x6x3,shrink=8x4x2,smooth=0x0x0,slicewise=0,deformation=0x0x1,gradStep=0.1 ``` -------------------------------- ### Check SCT Dependencies Source: https://spinalcordtoolbox.com/stable/user_section/installation/linux.html Verify that GUI dependencies like PyQT and matplotlib are correctly installed. ```bash sct_check_dependencies ``` -------------------------------- ### Install SCT with pip in virtualenv Source: https://spinalcordtoolbox.com/stable/user_section/installation/mac.html Install SCT in-place using pip when working within a virtual environment. ```bash pip install -e . ``` -------------------------------- ### Navigate to dMRI data directory Source: https://spinalcordtoolbox.com/stable/user_section/tutorials/diffusion-weighted-mri/before-starting.html Navigate to the dMRI data directory before starting the tutorial. Replace {PATH_TO_DOWNLOADED_DATA} with the actual path to the downloaded data. ```bash cd {PATH_TO_DOWNLOADED_DATA}/single_subject/data/dmri/ ``` -------------------------------- ### Input data argument example Source: https://spinalcordtoolbox.com/stable/user_section/command-line/all_tools.html Example of the mandatory input data argument for the sct_fmri_moco command. ```text fmri.nii.gz ``` -------------------------------- ### Install FSLeyes Source: https://spinalcordtoolbox.com/stable/user_section/installation/windows.html Commands to create a conda environment for FSLeyes and create a symbolic link for global access. ```bash source ${SCT_DIR}/python/etc/profile.d/conda.sh conda create -c conda-forge -p ~/fsleyes_env fsleyes -y sudo ln -s ~/fsleyes_env/bin/fsleyes /usr/local/bin/fsleyes ``` -------------------------------- ### Generate QC reports Source: https://spinalcordtoolbox.com/stable/user_section/command-line/all_tools.html Examples of generating QC reports for different SCT processing functions. ```bash sct_qc -i t2.nii.gz -s t2_seg.nii.gz -p sct_deepseg_sc sct_qc -i t2.nii.gz -s t2_pmj.nii.gz -p sct_detect_pmj sct_qc -i t2.nii.gz -s t2_seg_labeled.nii.gz -p sct_label_vertebrae sct_qc -i t2.nii.gz -s t2_seg.nii.gz -p sct_deepseg_sc -qc-dataset mydata -qc-subject sub-45 sct_qc -i t2.nii.gz -s t2_seg.nii.gz -d t2_lesion.nii.gz -p sct_deepseg_lesion -plane axial ``` -------------------------------- ### sct_label_utils -project-centerline example Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_label_utils.html Example command for projecting labels onto a spinal cord segmentation or centerline using -project-centerline. ```bash sct_label_utils -i spinalcord.nii.gz -project-centerline labels.nii.gz ``` -------------------------------- ### Crop image using reference image Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_crop_image.html Example command using a reference image's dimensions to crop the input image. ```bash sct_crop_image -i t2.nii.gz -ref mt1.nii.gz ``` -------------------------------- ### Check GCC version Source: https://spinalcordtoolbox.com/stable/user_section/installation/mac.html Verify if the Gnu Compiler Collection is installed on your system. ```bash gcc --version ``` -------------------------------- ### Source bashrc Source: https://spinalcordtoolbox.com/stable/user_section/installation/windows.html Apply the environment changes after installation. ```bash source ~/.bashrc ``` -------------------------------- ### Crop image using binary mask Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_crop_image.html Example command using a binary mask to define the cropping bounding box. ```bash sct_crop_image -i t2.nii.gz -m mask.nii.gz ``` -------------------------------- ### Crop image with binary mask and margin Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_crop_image.html Example command using a binary mask with a margin of 5 voxels on each side in the x and y directions only. ```bash sct_crop_image -i t2.nii.gz -m mask.nii.gz -dilate 5x5x0 ``` -------------------------------- ### Install Rosetta 2 for Apple silicon Source: https://spinalcordtoolbox.com/stable/user_section/installation/mac.html Run this command in Terminal to install Rosetta 2 if your Mac uses Apple silicon (M1, M2, M3, etc.). ```bash softwareupdate --install-rosetta ``` -------------------------------- ### Example parameter configuration for multi-step registration Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_register_multimodal.html Shows a recommended multi-step registration parameter string combining segmentation-based and image-based steps with increasing transformation complexity. Uses MeanSquares metric for segmentations and Mutual Information (MI) for different contrasts. ```text -param step=1,type=seg,algo=slicereg,metric=MeanSquares: step=2,type=seg,algo=affine,metric=MeanSquares,gradStep=0.2: step=3,type=im,algo=syn,metric=MI,iter=5,shrink=2 ``` -------------------------------- ### Include subjects or sessions via -include-list Source: https://spinalcordtoolbox.com/stable/user_section/command-line/all_tools.html Examples of using the -include-list flag to specify subjects or sessions for processing. ```bash -include-list sub-001 sub-002 ``` ```bash -include-list sub-001/ses-01 ses-02 ``` -------------------------------- ### Crop image by specifying min/max bounds Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_crop_image.html Example command cropping the image along specific dimensions using min/max bounds. Here, cropping occurs between x=5 and x=60, and between z=5 and z=zmax-1. ```bash sct_crop_image -i t2.nii.gz -xmin 5 -xmax 60 -zmin 5 -zmax -2 ``` -------------------------------- ### Segment an image with sct_deepseg lesion_ms_mp2rage Source: https://spinalcordtoolbox.com/stable/user_section/command-line/deepseg/lesion_ms_mp2rage.html Example command to segment a single image file using the lesion_ms_mp2rage model. ```bash sct_deepseg lesion_ms_mp2rage -i t2.nii.gz ``` -------------------------------- ### sct_deepseg gm_wm_exvivo_t2 usage help Source: https://spinalcordtoolbox.com/stable/user_section/command-line/deepseg/gm_wm_exvivo_t2.html Displays the command-line usage syntax and available arguments for the tool. ```bash usage: sct_deepseg gm_wm_exvivo_t2 [-i [ ...]] [-o ] [-install] [-custom-url CUSTOM_URL [CUSTOM_URL ...]] [-thr ] [-largest {0,1}] [-fill-holes {0,1}] [-remove-small REMOVE_SMALL [REMOVE_SMALL ...]] [-qc ] [-qc-dataset ] [-qc-subject ] [-qc-plane ] [-qc-seg ] [-h] [-v ] [-r {0,1}] ``` -------------------------------- ### Crop image using GUI Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_crop_image.html Example command using the graphical user interface to crop an image. This method does not allow cropping along the right-left dimension. ```bash sct_crop_image -i t2.nii.gz -g 1 ``` -------------------------------- ### Display sct_register_multimodal help Source: https://spinalcordtoolbox.com/stable/user_section/command-line/all_tools.html View the usage instructions and available arguments for the tool. ```bash sct_register_multimodal -h ``` -------------------------------- ### Navigate to the multi_subject directory Source: https://spinalcordtoolbox.com/stable/user_section/tutorials/analysis-pipelines-with-sct/before-starting.html Use this command in a terminal to change into the tutorial's working directory. Replace {PATH_TO_DOWNLOADED_DATA} with the actual path where you downloaded the data. ```bash cd {PATH_TO_DOWNLOADED_DATA}/multi_subject ``` -------------------------------- ### Register template to subject with -ref subject Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_register_to_template.html Use the -ref subject parameter to register the template to the subject, skipping the straightening procedure. This example includes custom -param settings for centermassrot and columnwise algorithms. ```bash sct_register_to_template -i data.nii.gz -s data_seg.nii.gz -l data_labels.nii.gz -ref subject -param step=1,type=seg,algo=centermassrot,smooth=0:step=2,type=seg,algo=columnwise,smooth=0,smoothWarpXY=2 ``` -------------------------------- ### Display sct_register_to_template help Source: https://spinalcordtoolbox.com/stable/user_section/command-line/all_tools.html Displays the usage and available arguments for the command. ```bash sct_register_to_template -h ``` -------------------------------- ### sct_maths usage help Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_maths.html Displays the command-line usage, available flags, and options for the sct_maths tool. ```bash usage: sct_maths -i -o [-volumewise {0,1}] [-add [...]] [-sub [...]] [-mul [...]] [-div [...]] [-mean {x,y,z,t}] [-rms {x,y,z,t}] [-std {x,y,z,t}] [-bin ] [-slicewise-mean {0,1,2}] [-otsu ] [-adap ] [-otsu-median ] [-percent ] [-thr ] [-uthr ] [-dilate ] [-erode ] [-shape {square,cube,disk,ball}] [-dim {0,1,2}] [-smooth ] [-laplacian ] [-denoise DENOISE] [-mi ] [-minorm ] [-corr ] [-symmetrize {0,1,2}] [-type {uint8,int16,int32,float32,complex64,float64,int8,uint16,uint32,int64,uint64}] [-h] [-v ] ``` -------------------------------- ### Display sct_straighten_spinalcord help Source: https://spinalcordtoolbox.com/stable/user_section/command-line/all_tools.html Run the help command to view usage instructions and available arguments for the tool. ```bash sct_straighten_spinalcord -h ``` -------------------------------- ### Verify GUI Dependencies Source: https://spinalcordtoolbox.com/stable/user_section/installation/windows.html Commands to prepare the runtime directory and verify GUI dependencies within the container. ```bash mkdir /tmp/runtime-root sct_check_dependencies ``` -------------------------------- ### sct_resample usage help Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_resample.html Displays the command-line usage syntax and available arguments for the sct_resample tool. ```bash usage: sct_resample -i [-f ] [-mm ] [-vox ] [-ref ] [-x {nn,linear,spline}] [-o ] [-h] [-v ] ``` -------------------------------- ### Navigate to fMRI data directory Source: https://spinalcordtoolbox.com/stable/user_section/tutorials/processing-fmri-data/before-starting.html Use this command to change into the fMRI data directory after downloading the tutorial data. Replace {PATH_TO_DOWNLOADED_DATA} with the actual path to the downloaded data. ```bash cd {PATH_TO_DOWNLOADED_DATA}/single_subject/data/fmri/ ``` -------------------------------- ### Command-line usage Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_register_to_template.html Full usage statement for sct_register_to_template, showing all available options and arguments. ```bash usage: sct_register_to_template -i -s [-s-template-id ] [-l ] [-ldisc ] [-lspinal ] [-lrootlet ] [-ofolder ] [-t ] [-c {t1,t2,t2s}] [-ref {template,subject}] [-param ] [-centerline-algo {polyfit,bspline,linear,nurbs}] [-centerline-smooth ] [-qc ] [-qc-dataset ] [-qc-subject ] [-h] [-v ] [-r {0,1}] ``` -------------------------------- ### Navigate to the T2* data directory Source: https://spinalcordtoolbox.com/stable/user_section/tutorials/gray-matter-segmentation/improving-registration-with-gm-seg/before-starting.html Change the current working directory to the location of the T2* data files required for the tutorial. ```bash cd {PATH_TO_DOWNLOADED_DATA}/single_subject/data/t2s/ ``` -------------------------------- ### Run Docker with X11 Redirection Source: https://spinalcordtoolbox.com/stable/user_section/installation/windows.html Command to launch the container with environment variables configured for GUI support. ```bash docker run -it --rm -e DISPLAY=: -e XDG_RUNTIME_DIR=/tmp/runtime-root /ubuntu:ubuntu22.04 ``` -------------------------------- ### sct_process_segmentation usage help Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_process_segmentation.html Displays the command-line usage syntax and available flags for sct_process_segmentation. ```bash usage: sct_process_segmentation -i [-o ] [-append ] [-z ] [-perslice ] [-vert ] [-vertfile ] [-discfile ] [-perlevel ] [-angle-corr ] [-centerline ] [-centerline-algo {polyfit,bspline,linear,nurbs}] [-centerline-smooth ] [-centerline-exclude-missing ] [-pmj ] [-pmj-distance ] [-pmj-extent ] [-anat ] [-normalize [ ...]] [-normalize-PAM50 ] [-qc ] [-qc-image ] [-qc-dataset ] [-qc-subject ] [-h] [-v ] [-r {0,1}] ``` -------------------------------- ### sct_run_batch help command Source: https://spinalcordtoolbox.com/stable/user_section/command-line/all_tools.html Displays the usage information and available options for the sct_run_batch tool. ```bash sct_run_batch -h ``` -------------------------------- ### Configure XQuartz for GUI Redirection Source: https://spinalcordtoolbox.com/stable/user_section/installation/mac.html Command to allow X11 connections from the local host in XQuartz. ```bash xhost + 127.0.0.1 ``` -------------------------------- ### Open QC report on Linux Source: https://spinalcordtoolbox.com/stable/overview/concepts/inspecting-results-qc-fsleyes.html Sample terminal output on Linux showing the command to open the QC report in a browser. ```bash # Sample output (Linux) after running the SCT script Use the following command to see the results in a browser: xdg-open "qc_folder/index.html" ``` -------------------------------- ### sct_deepseg tumor_t2 Source: https://spinalcordtoolbox.com/stable/user_section/command-line/deepseg/tumor_t2.html Command-line tool for segmenting tumors in T2-weighted images. Supports multiple input files, model installation, and various post-processing options. ```APIDOC ## sct_deepseg tumor_t2 ### Description Segments tumors in T2-weighted MRI images using deep learning models. Supports multiple input files, model installation, and various post-processing options. ### Usage ``` sct_deepseg tumor_t2 [-i [ ...]] [-o ] [-install] [-custom-url CUSTOM_URL [CUSTOM_URL ...]] [-thr ] [-largest {0,1}] [-fill-holes {0,1}] [-remove-small REMOVE_SMALL [REMOVE_SMALL ...]] [-qc ] [-qc-dataset ] [-qc-subject ] [-qc-plane ] [-qc-seg ] [-h] [-v ] [-r {0,1}] ``` ### Parameters #### Input/Output - **-i** (file) - Required - Image filename(s) to segment. If segmenting multiple files, separate filenames with a space. - **-o** (str) - Optional - Output file name. The chosen filename will be used as a base name, and model-specific suffixes will be added to the end depending on the type of output (e.g. '_cord.nii.gz', '_gm.nii.gz', etc.). #### Tasks - **-install** (flag) - Optional - Install models that are required for specified task. Default: `False`. - **-custom-url** (str) - Optional - URL(s) pointing to the `.zip` asset for a model release. This option can be used with `-install` to install a specific version of a model. To use this option, navigate to the 'Releases' page of the model, find release you wish to install, and right-click + copy the URL of the `.zip` listed under 'Assets'. Example: `sct_deepseg tumor_t2 -install -custom-url CUSTOM_URL` `sct_deepseg tumor_t2 -i t2.nii.gz`. #### Parameters - **-thr** (float) - Optional - Binarize segmentation with specified threshold. Set to 0 for no thresholding (i.e., soft segmentation). Default value is '[0.5, 0.5]', and was chosen by experimentation (more info at https://github.com/sct-pipeline/deepseg-threshold). - **-largest** (int) - Optional - Possible choices: 0, 1. Keep the largest connected object from each output segmentation; if not set, all objects are kept. Default: `0`. - **-fill-holes** (int) - Optional - Possible choices: 0, 1. If set, small holes in the segmentation will be filled in automatically. Default: `0`. - **-remove-small** (str) - Optional - Minimal object size to keep with unit (mm3 or vox). A single value can be provided or one value per prediction class. Single value example: 1mm3, 5vox. Multiple values example: 10 20 10vox (remove objects smaller than 10 voxels for class 1 and 3, and smaller than 20 voxels for class 2). #### Misc Arguments - **-qc** (folder) - Optional - The path where the quality control generated content will be saved. - **-qc-dataset** (str) - Optional - If provided, this string will be mentioned in the QC report as the dataset the process was run on. - **-qc-subject** (str) - Optional - If provided, this string will be mentioned in the QC report as the subject the process was run on. - **-qc-plane** (str) - Optional - Possible choices: Axial, Sagittal. Plane of the output QC. If Sagittal, it is highly recommended to provide the `-qc-seg` option, as it will ensure the output QC is cropped to a reasonable field of view. Default: `'Axial'`. - **-qc-seg** (file) - Optional - Segmentation file to use for cropping the QC. This option is useful when you want to QC a region that is different from the output segmentation. For example, it might be useful to provide a dilated cord segmentation to expand the QC field of view. If `-qc-seg` is not provided, the default behavior will depend on the value of `-qc-plane`: 'Axial': Without '-qc-seg', a sensible crop radius between 15-40 vox will be automatically used, depending on the resolution and segmentation type. 'Sagittal': Without '-qc-seg', the full image will be displayed by default. (For very large images, this may cause a crash, so using `-qc-seg` is highly recommended.) - **-v** (int) - Optional - Possible choices: 0, 1, 2. Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode. Default: `1`. - **-r** (int) - Optional - Possible choices: 0, 1. Remove temporary files. Default: `1`. ### Example ``` sct_deepseg tumor_t2 -i t2.nii.gz ``` ``` -------------------------------- ### Run Docker with X11 Forwarding Source: https://spinalcordtoolbox.com/stable/user_section/installation/linux.html Launch the container with privileged access and X11 display forwarding enabled. ```bash sudo docker run -it --rm --privileged -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix /ubuntu:ubuntu22.04 ``` -------------------------------- ### Process included files using bash syntax Source: https://spinalcordtoolbox.com/stable/user_section/command-line/all_tools.html Example of using bash conditional logic to process specific files when using the -include-yml flag. ```bash # check if FILE_T2 is in the list of included files FILE_T2="$SUBJECT"_T2w.nii.gz if [[ " $INCLUDE_FILES " =~ " $FILE_T2 " ]]; then # process file only if it is included FILE_T2_SEG="$SUBJECT"_T2w_seg.nii.gz sct_deepseg spinalcord $FILE_T2 -o $FILE_T2_SEG fi ``` -------------------------------- ### Register subject to template using default settings Source: https://spinalcordtoolbox.com/stable/user_section/command-line/all_tools.html Performs the standard registration process using the input image, segmentation, and labels. ```bash sct_register_to_template -i data.nii.gz -s data_seg.nii.gz -l data_labels.nii.gz ``` -------------------------------- ### Transform displacement field to FSL warps Source: https://spinalcordtoolbox.com/stable/user_section/command-line/all_tools.html Example syntax for converting SCT warping fields to FSL format and applying them using FSL's applywarp. ```bash sct_image -i WARP_SRC2DEST -to-fsl IM_SRC (IM_DEST) -o WARP_FSL ``` ```bash applywarp -i IM_SRC -r IM_DEST -w WARP_FSL --abs -o IM_SRC2DEST ``` -------------------------------- ### Open Quality Control Report Source: https://spinalcordtoolbox.com/stable/user_section/getting-started.html Command to launch the Quality Control (QC) report index file in the default web browser. ```bash echo "To open Quality Control (QC) report on a web-browser, run the following:" echo "$open_command $SCT_BP_QC_FOLDER/index.html" ``` -------------------------------- ### Set WSL version to 1 Source: https://spinalcordtoolbox.com/stable/user_section/installation/windows.html Convert a specific distribution to WSL version 1. Replace 'Ubuntu' with your distribution name if different. ```powershell wsl --set-version Ubuntu 1 ``` -------------------------------- ### Display sct_qc help Source: https://spinalcordtoolbox.com/stable/user_section/command-line/all_tools.html Displays the help message and usage information for the sct_qc command. ```bash sct_qc -h ``` -------------------------------- ### sct_dice_coefficient usage Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_dice_coefficient.html Shows the command-line usage for sct_dice_coefficient, including all options. Note that indexing starts at 0, and using -1 for a size sets it to the full image extent. ```bash usage: sct_dice_coefficient -i -d [-2d-slices {0,1,2}] [-b ] [-bmax {0,1}] [-bzmax {0,1}] [-bin {0,1}] [-o ] [-h] [-v ] [-r {0,1}] ``` -------------------------------- ### sct_dmri_separate_b0_and_dwi Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_dmri_separate_b0_and_dwi.html Command-line tool to separate b=0 and diffusion-weighted images from a diffusion dataset. Output files get suffixes _b0 and _dwi appended to the input file name. ```APIDOC ## sct_dmri_separate_b0_and_dwi ### Description Separate b=0 and DW images from diffusion dataset. The output files will have a suffix (_b0 and _dwi) appended to the input file name. ### Usage ``` sct_dmri_separate_b0_and_dwi -i -bvec [-a {0,1}] [-bval ] [-bvalmin ] [-ofolder ] [-h] [-v ] [-r {0,1}] ``` ### Arguments #### Mandatory Arguments - **-i** (file) - Required - Diffusion data. Example: `dmri.nii.gz` - **-bvec** (file) - Required - Bvecs file. Example: `bvecs.txt` #### Optional Arguments - **-a** (choice: 0, 1) - Optional - Average b=0 and DWI data. 0 = no, 1 = yes. Default: `1` - **-bval** (file) - Optional - bvals file. Used to identify low b-values (in case different from 0). Example: `bvals.txt`. Default: `''` - **-bvalmin** (float) - Optional - B-value threshold (in s/mm2) below which data is considered as b=0. Example: `50.0` - **-ofolder** (folder) - Optional - Output folder. Default: `'.'` #### Miscellaneous Arguments - **-v** (choice: 0, 1, 2) - Optional - Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode. Default: `1` - **-r** (choice: 0, 1) - Optional - Remove temporary files. Default: `1` ### Notes - The output files will have suffixes `_b0` and `_dwi` appended to the input file name. - Use `-h` to display help. ``` -------------------------------- ### sct_deepseg gm_mouse_t1 Source: https://spinalcordtoolbox.com/stable/user_section/command-line/deepseg/gm_mouse_t1.html Command-line tool to segment gray matter in mouse T1-weighted images. It supports multiple input files, model installation, and various segmentation post-processing options. ```APIDOC ## sct_deepseg gm_mouse_t1 ### Description Segments gray matter in mouse T1-weighted images using deep learning models. Supports multiple input files, model installation, and various post-processing options. ### Usage ``` sct_deepseg gm_mouse_t1 [-i [ ...]] [-o ] [-install] [-custom-url CUSTOM_URL [CUSTOM_URL ...]] [-thr ] [-largest {0,1}] [-fill-holes {0,1}] [-remove-small REMOVE_SMALL [REMOVE_SMALL ...]] [-qc ] [-qc-dataset ] [-qc-subject ] [-qc-plane ] [-qc-seg ] [-h] [-v ] [-r {0,1}] ``` ### Parameters #### Input/Output - **-i** (file list) - Required - Image filename(s) to segment. If segmenting multiple files, separate filenames with a space. - **-o** (string) - Optional - Output file name. The chosen filename will be used as a base name, and model-specific suffixes will be added to the end depending on the type of output (e.g., '_cord.nii.gz', '_gm.nii.gz', etc.). #### Tasks - **-install** (flag) - Optional - Install models that are required for specified task. Default: False. - **-custom-url** (string list) - Optional - URL(s) pointing to the .zip asset for a model release. Can be used with -install to install a specific version of a model. Example: `sct_deepseg gm_mouse_t1 -install -custom-url CUSTOM_URL` #### Parameters - **-thr** (float) - Optional - Binarize segmentation with specified threshold. Set to 0 for no thresholding (i.e., soft segmentation). Default value is '[0.0]'. - **-largest** (choice: 0, 1) - Optional - Keep the largest connected object from each output segmentation; if not set, all objects are kept. Default: 0. - **-fill-holes** (choice: 0, 1) - Optional - If set, small holes in the segmentation will be filled in automatically. Default: 0. - **-remove-small** (string list) - Optional - Minimal object size to keep with unit (mm3 or vox). A single value can be provided or one value per prediction class. Example: 1mm3, 5vox. Multiple values example: 10 20 10vox. #### Misc Arguments - **-qc** (folder) - Optional - The path where the quality control generated content will be saved. - **-qc-dataset** (string) - Optional - If provided, this string will be mentioned in the QC report as the dataset the process was run on. - **-qc-subject** (string) - Optional - If provided, this string will be mentioned in the QC report as the subject the process was run on. - **-qc-plane** (choice: Axial, Sagittal) - Optional - Plane of the output QC. If Sagittal, it is highly recommended to provide the -qc-seg option. Default: 'Axial'. - **-qc-seg** (file) - Optional - Segmentation file to use for cropping the QC. If not provided, default behavior depends on -qc-plane. - **-v** (choice: 0, 1, 2) - Optional - Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode. Default: 1. - **-r** (choice: 0, 1) - Optional - Remove temporary files. Default: 1. ### Examples ``` sct_deepseg gm_mouse_t1 -i t2.nii.gz sct_deepseg gm_mouse_t1 -install -custom-url CUSTOM_URL ``` ``` -------------------------------- ### sct_detect_compression usage syntax Source: https://spinalcordtoolbox.com/stable/user_section/command-line/sct_detect_compression.html Displays the command-line usage pattern and available arguments for the sct_detect_compression tool. ```bash usage: sct_detect_compression -s -discfile [-num-of-slices ] [-angle-corr ] [-o ] [-h] [-v ] ``` -------------------------------- ### Check method information Source: https://spinalcordtoolbox.com/stable/user_section/command-line/all_tools.html Displays detailed information about the slice-wise regularized registration method. ```bash isct_antsSliceRegularizedRegistration ``` -------------------------------- ### sct_deepseg sc_canal_t2 Source: https://spinalcordtoolbox.com/stable/user_section/command-line/deepseg/sc_canal_t2.html Segments the spinal cord and canal from T2-weighted images. This command accepts input image filenames and various options to control segmentation, model installation, and quality control. ```APIDOC ## sct_deepseg sc_canal_t2 ### Description Segments the spinal cord and canal from T2-weighted images. The command accepts one or more input image filenames and provides options for model installation, segmentation post-processing, and quality control. ### Usage ``` sct_deepseg sc_canal_t2 [-i [ ...]] [-o ] [-install] [-custom-url CUSTOM_URL [CUSTOM_URL ...]] [-largest {0,1}] [-fill-holes {0,1}] [-remove-small REMOVE_SMALL [REMOVE_SMALL ...]] [-qc ] [-qc-dataset ] [-qc-subject ] [-qc-plane ] [-qc-seg ] [-h] [-v ] [-r {0,1}] [-test-time-aug] ``` ### Parameters #### Input/Output - **-i** (file list) - Required - Image filename(s) to segment. If segmenting multiple files, separate filenames with a space. - **-o** (str) - Optional - Output file name. The chosen filename will be used as a base name, and model-specific suffixes will be added to the end depending on the type of output (e.g., '_cord.nii.gz', '_gm.nii.gz', etc.). #### Tasks - **-install** (flag) - Optional - Install models that are required for specified task. Default: False. - **-custom-url** (URL list) - Optional - URL(s) pointing to the `.zip` asset for a model release. This option can be used with `-install` to install a specific version of a model. To use this option, navigate to the 'Releases' page of the model, find the release you wish to install, and right-click + copy the URL of the `.zip` listed under 'Assets'. Example: `sct_deepseg sc_canal_t2 -install -custom-url CUSTOM_URL` `sct_deepseg sc_canal_t2 -i t2.nii.gz`. #### Parameters - **-largest** (int, choices: 0, 1) - Optional - Keep the largest connected object from each output segmentation; if not set, all objects are kept. Default: 0. - **-fill-holes** (int, choices: 0, 1) - Optional - If set, small holes in the segmentation will be filled in automatically. Default: 0. - **-remove-small** (string list) - Optional - Minimal object size to keep with unit (mm3 or vox). A single value can be provided or one value per prediction class. Single value example: 1mm3, 5vox. Multiple values example: 10 20 10vox (remove objects smaller than 10 voxels for class 1 and 3, and smaller than 20 voxels for class 2). - **-test-time-aug** (flag) - Optional - Perform test-time augmentation (TTA) by flipping the input image along all axes and averaging the resulting predictions. Note: The time it takes to run the model will increase due to the additional predictions. Default: False. #### Misc Arguments - **-qc** (folder) - Optional - The path where the quality control generated content will be saved. - **-qc-dataset** (str) - Optional - If provided, this string will be mentioned in the QC report as the dataset the process was run on. - **-qc-subject** (str) - Optional - If provided, this string will be mentioned in the QC report as the subject the process was run on. - **-qc-plane** (str, choices: Axial, Sagittal) - Optional - Plane of the output QC. If Sagittal, it is highly recommended to provide the `-qc-seg` option, as it will ensure the output QC is cropped to a reasonable field of view. Default: 'Axial'. - **-qc-seg** (file) - Optional - Segmentation file to use for cropping the QC. This option is useful when you want to QC a region that is different from the output segmentation. For example, it might be useful to provide a dilated cord segmentation to expand the QC field of view. If `-qc-seg` is not provided, the default behavior will depend on the value of `-qc-plane`: 'Axial': Without '-qc-seg', a sensible crop radius between 15-40 vox will be automatically used, depending on the resolution and segmentation type. 'Sagittal': Without '-qc-seg', the full image will be displayed by default. (For very large images, this may cause a crash, so using `-qc-seg` is highly recommended.) - **-v** (int, choices: 0, 1, 2) - Optional - Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode. Default: 1. - **-r** (int, choices: 0, 1) - Optional - Remove temporary files. Default: 1. ### Examples ``` sct_deepseg sc_canal_t2 -i t2.nii.gz ``` ``` sct_deepseg sc_canal_t2 -install -custom-url CUSTOM_URL ``` ```