CerebNet: run_prediction.py

Note

We recommend to run CerebNet with the standard run_fastsurfer.sh interfaces!

The CerebNet/run_prediction.py script enables the inference with CerebNet. In most situations, it will be called from run_fastsurfer.sh a direct call to CerebNet/run_prediction.py is not needed.

Segmentation

usage: CerebNet/run_prediction.py [-h] [--in_dir IN_DIR] [--tag SEARCH_TAG]
                                  [--csv_file CSV_FILE] [--sd OUT_DIR]
                                  [--sid SID] [--remove_suffix REMOVE_SUFFIX]
                                  [--t1 ORIG_NAME]
                                  [--conformed_name CONF_NAME]
                                  [--norm_name NORM_NAME]
                                  [--asegdkt_segfile PRED_NAME]
                                  [--cereb_segfile CEREB_SEGFILE]
                                  [--cereb_statsfile CEREB_STATSFILE]
                                  [--seg_log LOG_NAME] [--device DEVICE]
                                  [--viewagg_device VIEWAGG_DEVICE]
                                  [--threads THREADS]
                                  [--batch_size BATCH_SIZE] [--async_io]
                                  [--orientation {native,XXX,soft-XXX}]
                                  [--image_size IMAGE_SIZE]
                                  [--vox_size {1,1.0,none}]
                                  [--ckpt_ax CKPT_AX] [--ckpt_cor CKPT_COR]
                                  [--ckpt_sag CKPT_SAG]
                                  ...

Positional Arguments

opts

See CerebNet/config/cerebnet.py for additional options

Named Arguments

--in_dir

Directory in which input volume(s) are located. Optional, if full path is defined for –t1.

--tag

Search tag to process only certain subjects. If a single image should be analyzed, set the tag with its id. Default: processes all.

Default: *

--csv_file

Csv-file with subjects to analyze (alternative to –tag)

--sd

Directory in which evaluation results should be written. Will be created if it does not exist. Optional if full path is defined for –pred_name.

--sid

Optional: directly set the subject id to use. Can be used for single subject input. For multi-subject processing, use remove suffix if sid is not second to last element of input file passed to –t1

--remove_suffix

Optional: remove suffix from path definition of input file to yield correct subject name (e.g. /ses-x/anat/ for BIDS or /mri/ for FreeSurfer input). Default: do not remove anything.

Default: ''

--t1

Name of T1 full head MRI. Absolute path if single image else common image name. Default: mri/orig.mgz.

Default: 'mri/orig.mgz'

--conformed_name

Name under which the conformed input image will be saved, in the same directory as the segmentation (the input image is always conformed first, if it is not already conformed). The original input image is saved in the output directory as $id/mri/orig/001.mgz. Default: mri/orig.mgz.

Default: 'mri/orig.mgz'

--norm_name

Name under which the bias field corrected image is stored. Default: mri/norm.mgz.

Default: 'mri/norm.mgz'

--asegdkt_segfile, --aparc_aseg_segfile

Name of intermediate DL-based segmentation file (similar to aparc+aseg). When using FastSurfer, this segmentation is already conformed, since inference is always based on a conformed image. Absolute path if single image else common image name. Default: mri/aparc.DKTatlas+aseg.deep.mgz

Default: 'mri/aparc.DKTatlas+aseg.deep.mgz'

--cereb_segfile

Name under which segmentation will be saved. Default: mri/cerebellum.CerebNet.nii.gz.

Default: mri/cerebellum.CerebNet.nii.gz

--cereb_statsfile

Name under which the statsfield for the cerebellum will be saved. Default: None, do not calculate stats file. This option supports the special option ‘default’, which saves the stats file at stats/cerebellum.CerebNet.stats in the subject directory.

--seg_log

Absolute path to file in which run logs will be saved. If not set, logs will not be saved.

Default: ''

Advanced options

--device

Select device to run inference on: cpu, or cuda (= Nvidia gpu) or specify a certain gpu (e.g. cuda:1), Default: auto

Default: 'auto'

--viewagg_device

Define the device, where the view aggregation should be run. By default, the program checks if you have enough memory to run the view aggregation on the gpu (cuda). The total memory is considered for this decision. If this fails, or you actively overwrote the check with setting > –viewagg_device cpu <, view agg is run on the cpu. Equivalently, if you define > –viewagg_device cuda <, view agg will be run on the gpu (no memory check will be done).

Default: 'auto'

--threads

Number of threads to use (defaults to number of hardware threads: 4)

Default: 4

--batch_size

Batch size for inference. Default=1

Default: 1

--async_io

Allow asynchronous file operations (default: off). Note, this may impact the order of messages in the log, but speed up the segmentation specifically for slow file systems.

Default: False

--orientation

Possible choices: native, soft ras, soft rai, soft rps, soft rpi, soft las, soft lai, soft lps, soft lpi, soft rsa, soft rsp, soft ria, soft rip, soft lsa, soft lsp, soft lia, soft lip, soft ars, soft ari, soft als, soft ali, soft prs, soft pri, soft pls, soft pli, soft asr, soft asl, soft air, soft ail, soft psr, soft psl, soft pir, soft pil, soft sra, soft srp, soft sla, soft slp, soft ira, soft irp, soft ila, soft ilp, soft sar, soft sal, soft spr, soft spl, soft iar, soft ial, soft ipr, soft ipl, ras, rai, rps, rpi, las, lai, lps, lpi, rsa, rsp, ria, rip, lsa, lsp, lia, lip, ars, ari, als, ali, prs, pri, pls, pli, asr, asl, air, ail, psr, psl, pir, pil, sra, srp, sla, slp, ira, irp, ila, ilp, sar, sal, spr, spl, iar, ial, ipr, ipl

Select the target affine format for output, native: input defined by input image, soft-XXX (e.g. soft-lia): store as XXX, but do not interpolate, XXX (e.g. lia): force XXX, affine is only 0 or +-1. Default: lia (required by the surface pipeline).

Default: lia

--image_size

Select how the image should be conformed. A positive integer yields a cube of that size, ‘fov’ yields dimensions, so the field of view stays consistent, ‘auto’ yields a cube of dimensions fully containing the field of view (default).

Default: auto

--vox_size

Possible choices: 1, 1.0, none

Choose the voxelsize to process, CerebNet only supports 1 or ‘none’ to ignore the voxelsize.

Default: 1

--ckpt_ax

axial checkpoint to load

Default: /home/runner/work/FastSurfer/FastSurfer/src/checkpoints/CerebNet_axial_v1.0.0.pkl

--ckpt_cor

coronal checkpoint to load

Default: /home/runner/work/FastSurfer/FastSurfer/src/checkpoints/CerebNet_coronal_v1.0.0.pkl

--ckpt_sag

sagittal checkpoint to load

Default: /home/runner/work/FastSurfer/FastSurfer/src/checkpoints/CerebNet_sagittal_v1.0.0.pkl

Deep learning based tool for segmentation of cerebellar sub-regions.

The training and evaluation scripts of CerebNet are currently not part of the FastSurfer repository and are only available as incompatible stubs from the authors on request via email. The interface to realistic deformations can be found in :py:CerebNet.apply_warp.