Exemplo n.º 1
0
def get_parser():
    parser = SCTArgumentParser(
        description=
        "Flatten the spinal cord such within the medial sagittal plane. Useful to make nice pictures. "
        "Output data has suffix _flatten. Output type is float32 (regardless of input type) to minimize "
        "loss of precision during conversion.")
    mandatory = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatory.add_argument('-i',
                           metavar=Metavar.file,
                           required=True,
                           help="Input volume. Example: t2.nii.gz")
    mandatory.add_argument(
        '-s',
        metavar=Metavar.file,
        required=True,
        help="Spinal cord segmentation or centerline. Example: t2_seg.nii.gz")
    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit.")
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    return parser
def get_parser():
    parser = SCTArgumentParser(
        description="Compute temporal SNR (tSNR) in fMRI time series.")
    mandatory = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatory.add_argument('-i',
                           metavar=Metavar.file,
                           required=True,
                           help="Input fMRI data. Example: fmri.nii.gz")
    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit.")
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )
    optional.add_argument(
        '-o',
        metavar=Metavar.file,
        help="tSNR data output file. Example: fmri_tsnr.nii.gz")

    return parser
Exemplo n.º 3
0
def get_parser():
    parser = SCTArgumentParser(
        description=
        'Display scatter plot of gradient directions from bvecs file.')
    mandatory = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatory.add_argument(
        '-bvec',
        metavar=Metavar.file,
        required=True,
        help="Input bvecs file. Example: bvecs.txt",
    )
    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit.")
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    return parser
def get_parser():
    parser = SCTArgumentParser(
        description='Concatenate bval files in time.'
    )

    mandatory = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatory.add_argument(
        "-i",
        nargs='+',
        required=True,
        help='List of the bval files to concatenate. Example: dmri_b700.bval dmri_b2000.bval',
        metavar=Metavar.file,
    )

    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument(
        "-h",
        "--help",
        action="help",
        help="Show this help message and exit")
    optional.add_argument(
        "-o",
        help='Output file with bvals merged. Example: dmri_b700_b2000_concat.bval',
        metavar=Metavar.file)
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help="Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode")

    return parser
def get_parser():
    parser = SCTArgumentParser(
        description='Transpose bvecs file (if necessary) to get nx3 structure.'
    )

    mandatory = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatory.add_argument('-bvec',
                           metavar=Metavar.file,
                           required=True,
                           help="Input bvecs file. Example: bvecs.txt")
    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit.")
    optional.add_argument(
        '-o',
        metavar=Metavar.file,
        default='',
        help=
        "Output bvecs file. By default, input file is overwritten. Example: bvecs_t.txt"
    )
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    return parser
def get_parser():
    parser = SCTArgumentParser(
        description=
        'Compute SNR using methods described in [Dietrich et al., Measurement of'
        ' signal-to-noise ratios in MR images: Influence of multichannel coils, parallel '
        'imaging, and reconstruction filters. J Magn Reson Imaging 2007; 26(2): 375-385].'
    )

    mandatoryArguments = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatoryArguments.add_argument(
        '-i',
        required=True,
        help=
        '4D data to compute the SNR on (along the 4th dimension). Example: b0s.nii.gz',
        metavar=Metavar.file)

    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit")
    optional.add_argument(
        '-m',
        help=
        'Binary (or weighted) mask within which SNR will be averaged. Example: dwi_moco_mean_seg.nii.gz',
        metavar=Metavar.file,
        default='')
    optional.add_argument(
        '-method',
        help='R|Method to use to compute the SNR:\n'
        ' diff (default): Substract two volumes (defined by -vol) and estimate noise variance within the ROI (flag -m is required).\n'
        ' mult: Estimate noise variance over time across volumes specified with -vol.',
        choices=('diff', 'mult'),
        default='diff')
    optional.add_argument(
        '-vol',
        help=
        'Volumes to compute SNR from. Separate with "," (Example: -vol 0,1), or select range '
        'using ":" (Example: -vol 2:50). By default, all volumes in series are selected.',
        metavar=Metavar.str,
        default='')
    optional.add_argument('-r',
                          type=int,
                          help='Remove temporary files.',
                          default=1,
                          choices=(0, 1))
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    return parser
def get_parser():
    parser = SCTArgumentParser(
        description=
        'Compute Maximum Spinal Cord Compression (MSCC) as in: Miyanji F, Furlan JC, Aarabi B, Arnold PM, '
        'Fehlings MG. Acute cervical traumatic spinal cord injury: MR imaging findings correlated with '
        'neurologic outcome--prospective study with 100 consecutive patients. Radiology 2007;243(3):820-'
        '827.')

    mandatoryArguments = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatoryArguments.add_argument(
        '-di',
        type=float,
        required=True,
        help=
        'Anteroposterior cord distance (in mm) at the level of maximum injury. Example: 6.85',
        metavar=Metavar.float,
    )
    mandatoryArguments.add_argument(
        '-da',
        type=float,
        required=True,
        help=
        'Anteroposterior cord distance (in mm) at the nearest normal level above the level of injury.',
        metavar=Metavar.float,
    )
    mandatoryArguments.add_argument(
        '-db',
        type=float,
        required=True,
        help=
        'Anteroposterior cord distance (in mm) at the nearest normal level below the level of injury.',
        metavar=Metavar.float,
    )

    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit")
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    return parser
def get_parser():
    parser = SCTArgumentParser(
        description='Compute magnetization transfer ratio (MTR). Output is given in percentage.'
    )

    mandatoryArguments = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatoryArguments.add_argument(
        '-mt0',
        required=True,
        help='Image without MT pulse (MT0)',
        metavar=Metavar.float,
    )
    mandatoryArguments.add_argument(
        '-mt1',
        required=True,
        help='Image with MT pulse (MT1)',
        metavar=Metavar.float,
    )

    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument(
        "-thr",
        type=float,
        help="Threshold to clip MTR output values in case of division by small number. This implies that the output image"
             "range will be [-thr, +thr]. Default: 100.",
        default=100
    )
    optional.add_argument(
        "-h",
        "--help",
        action="help",
        help="Show this help message and exit"
    )
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help="Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )
    optional.add_argument(
        '-o',
        help='Path to output file.',
        metavar=Metavar.str,
        default=os.path.join('.', 'mtr.nii.gz')
    )
    return parser
def get_parser():
    parser = SCTArgumentParser(description='Calculate b-value (in mm^2/s).')

    mandatory = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatory.add_argument(
        "-g",
        type=float,
        required=True,
        help="Amplitude of diffusion gradients (in mT/m). Example: 40",
        metavar=Metavar.float,
    )
    mandatory.add_argument(
        "-b",
        type=float,
        required=True,
        help=
        "Big delta: time between both diffusion gradients (in ms). Example: 40",
        metavar=Metavar.float,
    )
    mandatory.add_argument(
        "-d",
        type=float,
        required=True,
        help=
        "Small delta: duration of each diffusion gradient (in ms). Example: 30",
        metavar=Metavar.float,
    )

    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit")
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    return parser
def get_parser():
    parser = SCTArgumentParser(
        description=
        'Display scatter plot of gradient directions from bvecs file.')
    mandatory = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatory.add_argument(
        '-bvec',
        metavar=Metavar.file,
        required=True,
        help="Input bvecs file. Example: bvecs.txt",
    )
    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit.")

    return parser
Exemplo n.º 11
0
def get_parser():
    parser = SCTArgumentParser(
        description='Convert image file to another type.')

    mandatoryArguments = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatoryArguments.add_argument(
        "-i",
        required=True,
        help='File input. Example: data.nii.gz',
        metavar=Metavar.file,
    )
    mandatoryArguments.add_argument(
        "-o",
        required=True,
        help='File output (indicate new extension). Example: data.nii',
        metavar=Metavar.str,
    )

    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit")
    optional.add_argument(
        "-squeeze",
        type=int,
        help='Sueeze data dimension (remove unused dimension)',
        required=False,
        choices=(0, 1),
        default=1)
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    return parser
def get_parser():
    parser = SCTArgumentParser(
        description=
        'Concatenate bvec files in time. You can either use bvecs in lines or columns. '
        'N.B.: Return bvecs in lines. If you need it in columns, please use '
        'sct_dmri_transpose_bvecs afterwards.')

    mandatory = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatory.add_argument(
        "-i",
        nargs='+',
        required=True,
        help=
        'List of the bvec files to concatenate. Example: dmri_b700.bvec dmri_b2000.bvec',
        metavar=Metavar.file,
    )

    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit")
    optional.add_argument(
        "-o",
        metavar=Metavar.file,
        help=
        'Output file with bvecs concatenated. Example: dmri_b700_b2000_concat.bvec'
    )
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    return parser
Exemplo n.º 13
0
def get_parser():
    # initialize parameters
    # TODO: create a class ParamFmriMoco which inheritates from ParamMoco
    param_default = ParamMoco(group_size=1, metric='MeanSquares', smooth='0')

    # parser initialisation
    parser = SCTArgumentParser(
        description=
        "Motion correction of fMRI data. Some robust features include:\n"
        "  - group-wise (-g)\n"
        "  - slice-wise regularized along z using polynomial function (-p)\n"
        "    (For more info about the method, type: isct_antsSliceRegularizedRegistration)\n"
        "  - masking (-m)\n"
        "  - iterative averaging of target volume\n"
        "\n"
        "The outputs of the motion correction process are:\n"
        "  - the motion-corrected fMRI volumes\n"
        "  - the time average of the corrected fMRI volumes\n"
        "  - a time-series with 1 voxel in the XY plane, for the X and Y motion direction (two separate "
        "files), as required for FSL analysis.\n"
        "  - a TSV file with the slice-wise average of the motion correction for XY (one file), that "
        "can be used for Quality Control.\n")

    mandatory = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatory.add_argument('-i',
                           metavar=Metavar.file,
                           required=True,
                           help="Input data (4D). Example: fmri.nii.gz")
    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit.")
    optional.add_argument(
        '-g',
        metavar=Metavar.int,
        type=int,
        help="Group nvols successive fMRI volumes for more robustness.")
    optional.add_argument(
        '-m',
        metavar=Metavar.file,
        help=
        "Binary mask to limit voxels considered by the registration metric.")
    optional.add_argument(
        '-param',
        metavar=Metavar.list,
        type=list_type(',', str),
        help=
        f"R|Advanced parameters. Assign value with \"=\"; Separate arguments with \",\".\n"
        f"  - poly [int]: Degree of polynomial function used for regularization along Z. For no regularization "
        f"set to 0. Default={param_default.poly}.\n"
        f"  - smooth [mm]: Smoothing kernel. Default={param_default.smooth}.\n"
        f"  - iter [int]: Number of iterations. Default={param_default.iter}.\n"
        f"  - metric {{MI, MeanSquares, CC}}: Metric used for registration. Default={param_default.metric}.\n"
        f"  - gradStep [float]: Searching step used by registration algorithm. The higher the more deformation "
        f"allowed. Default={param_default.gradStep}.\n"
        f"  - sampling [None or 0-1]: Sampling rate used for registration metric. "
        f"Default={param_default.sampling}.\n"
        f"  - numTarget [int]: Target volume or group (starting with 0). Default={param_default.num_target}.\n"
        f"  - iterAvg [int]: Iterative averaging: Target volume is a weighted average of the "
        f"previously-registered volumes. Default={param_default.iterAvg}.\n")
    optional.add_argument('-ofolder',
                          metavar=Metavar.folder,
                          action=ActionCreateFolder,
                          default='./',
                          help="Output path.")
    optional.add_argument('-x',
                          choices=['nn', 'linear', 'spline'],
                          default='linear',
                          help="Final interpolation.")
    optional.add_argument('-r',
                          metavar=Metavar.int,
                          type=int,
                          choices=[0, 1],
                          default=1,
                          help="Remove temporary files. O = no, 1 = yes")
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    return parser
Exemplo n.º 14
0
def get_parser():
    parser = SCTArgumentParser(
        description='Compute Diffusion Tensor Images (DTI) using dipy.')

    mandatory = parser.add_argument_group("MANDATORY ARGMENTS")
    mandatory.add_argument(
        "-i",
        required=True,
        help='Input 4d file. Example: dmri.nii.gz',
        metavar=Metavar.file,
    )
    mandatory.add_argument(
        "-bval",
        required=True,
        help='Bvals file. Example: bvals.txt',
        metavar=Metavar.file,
    )
    mandatory.add_argument(
        "-bvec",
        required=True,
        help='Bvecs file. Example: bvecs.txt',
        metavar=Metavar.file,
    )

    optional = parser.add_argument_group("OPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit")
    optional.add_argument(
        '-method',
        help='Type of method to calculate the diffusion tensor:\n'
        ' standard: Standard equation [Basser, Biophys J 1994]\n'
        ' restore: Robust fitting with outlier detection [Chang, MRM 2005]',
        default='standard',
        choices=('standard', 'restore'))
    optional.add_argument("-evecs",
                          type=int,
                          help='Output tensor eigenvectors and eigenvalues.',
                          default=0,
                          choices=(0, 1))
    optional.add_argument(
        '-m',
        metavar=Metavar.file,
        help=
        'Mask used to compute DTI in for faster processing. Example: mask.nii.gz'
    )
    optional.add_argument('-o',
                          help='Output prefix.',
                          metavar=Metavar.str,
                          required=False,
                          default='dti_')
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    return parser
Exemplo n.º 15
0
def get_parser():
    parser = SCTArgumentParser(
        description='Utility function to denoise images. (Return the denoised image and also the difference '
                    'between the input and the output.)'
    )

    mandatory = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatory.add_argument(
        "-i",
        default=None,
        required=True,
        help="Input NIFTI image to be denoised. Example: image_input.nii.gz",
        metavar=Metavar.file,
    )

    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument(
        "-h",
        "--help",
        action="help",
        help="Show this help message and exit")
    optional.add_argument(
        "-p",
        help='Type of assumed noise distribution. Default is: Rician.',
        required=False,
        choices=("Rician", "Gaussian"),
        default="Rician")
    optional.add_argument(
        "-d",
        type=int,
        help="Threshold value for what to be considered as noise. "
             "The standard deviation of the noise is calculated for values below this limit. "
             "Not relevant if -std value is precised. Default is 80.",
        metavar=Metavar.int,
        required=False,
        default="80")
    optional.add_argument(
        "-std",
        type=float,
        help="Standard deviation of the noise. "
             "If not specified, it is calculated using a background of point of values "
             "below the threshold value (parameter d).",
        metavar=Metavar.float)
    optional.add_argument(
        "-o",
        help="Name of the output NIFTI image.",
        metavar=Metavar.str,
        default=None)
    optional.add_argument(
        "-r",
        help="Remove temporary files. Specify 0 to get access to temporary files.",
        type=int,
        choices=(0, 1),
        default=1)
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help="Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode")

    return parser
Exemplo n.º 16
0
def get_parser():
    parser = SCTArgumentParser(
        description=
        'Spinal Cord Gray Matter (GM) Segmentation using deep dilated convolutions. The contrast of the '
        'input image must be similar to a T2*-weighted image: WM dark, GM bright and CSF bright. '
        'Reference: Perone CS, Calabrese E, Cohen-Adad J. Spinal cord gray matter segmentation using deep '
        'dilated convolutions. Sci Rep 2018;8(1):5966.')

    mandatory = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatory.add_argument(
        "-i",
        required=True,
        help="Image filename to segment (3D volume). Example: t2s.nii.gz.",
        metavar=Metavar.file)

    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit")
    optional.add_argument(
        "-o",
        help="Output segmentation file name. Example: sc_gm_seg.nii.gz",
        metavar=Metavar.file,
        default=None)
    misc = parser.add_argument_group('\nMISC')
    misc.add_argument(
        '-qc',
        help=
        "The path where the quality control generated content will be saved.",
        metavar=Metavar.str,
        default=None)
    misc.add_argument(
        '-qc-dataset',
        help=
        'If provided, this string will be mentioned in the QC report as the dataset the process was run on',
        metavar=Metavar.str)
    misc.add_argument(
        '-qc-subject',
        help=
        'If provided, this string will be mentioned in the QC report as the subject the process was run on',
        metavar=Metavar.str)
    misc.add_argument("-m",
                      help="Model to use (large or challenge). "
                      "The model 'large' will be slower but "
                      "will yield better results. The model "
                      "'challenge' was built using data from "
                      "the following challenge: goo.gl/h4AVar.",
                      choices=('large', 'challenge'),
                      default='large')
    misc.add_argument(
        "-thr",
        type=float,
        help=
        'Threshold to apply in the segmentation predictions, use 0 (zero) to disable it. Example: 0.999',
        metavar=Metavar.float,
        default=0.999)
    misc.add_argument("-t",
                      help="Enable TTA (test-time augmentation). "
                      "Better results, but takes more time and "
                      "provides non-deterministic results.",
                      metavar='')
    misc.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    return parser
Exemplo n.º 17
0
def get_parser():
    parser = SCTArgumentParser(
        description="Tools to crop an image. Either via command line or via a Graphical User Interface (GUI). See "
                    "example usage at the end.",
        epilog="EXAMPLES:\n"
               "- To crop an image using the GUI (this does not allow to crop along the right-left dimension):\n"
               "sct_crop_image -i t2.nii.gz -g 1\n\n"
               "- To crop an image using a binary mask:\n"
               "sct_crop_image -i t2.nii.gz -m mask.nii.gz\n\n"
               "- To crop an image using a reference image:\n"
               "sct_crop_image -i t2.nii.gz -ref mt1.nii.gz\n\n"
               "- To crop an image by specifying min/max (you don't need to specify all dimensions). In the example "
               "below, cropping will occur between x=5 and x=60, and between z=5 and z=zmax-1\n"
               "sct_crop_image -i t2.nii.gz -xmin 5 -xmax 60 -zmin 5 -zmax -2\n\n"
    )

    mandatoryArguments = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatoryArguments.add_argument(
        '-i',
        required=True,
        help="Input image. Example: t2.nii.gz",
        metavar=Metavar.file,
    )

    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument(
        '-h',
        '--help',
        action='help',
        help="Show this help message and exit")
    optional.add_argument(
        '-o',
        help="Output image. By default, the suffix '_crop' will be added to the input image.",
        metavar=Metavar.str,
    )
    optional.add_argument(
        '-g',
        type=int,
        help="0: Cropping via command line | 1: Cropping via GUI. Has priority over -m.",
        choices=(0, 1),
        default=0,
    )
    optional.add_argument(
        '-m',
        help="Binary mask that will be used to extract bounding box for cropping the image. Has priority over -ref.",
        metavar=Metavar.file,
    )
    optional.add_argument(
        '-ref',
        help="Image which dimensions (in the physical coordinate system) will be used as a reference to crop the "
             "input image. Only works for 3D images. Has priority over min/max method.",
        metavar=Metavar.file,
    )
    optional.add_argument(
        '-xmin',
        type=int,
        default=0,
        help="Lower bound for cropping along X.",
        metavar=Metavar.int,
    )
    optional.add_argument(
        '-xmax',
        type=int,
        default=-1,
        help="Higher bound for cropping along X. Setting '-1' will crop to the maximum dimension (i.e. no change), "
             "'-2' will crop to the maximum dimension minus 1 slice, etc.",
        metavar=Metavar.int,
    )
    optional.add_argument(
        '-ymin',
        type=int,
        default=0,
        help="Lower bound for cropping along Y.",
        metavar=Metavar.int,
    )
    optional.add_argument(
        '-ymax',
        type=int,
        default=-1,
        help="Higher bound for cropping along Y. Follows the same rules as xmax.",
        metavar=Metavar.int,
    )
    optional.add_argument(
        '-zmin',
        type=int,
        default=0,
        help="Lower bound for cropping along Z.",
        metavar=Metavar.int,
    )
    optional.add_argument(
        '-zmax',
        type=int,
        default=-1,
        help="Higher bound for cropping along Z. Follows the same rules as xmax.",
        metavar=Metavar.int,
    )
    optional.add_argument(
        '-b',
        type=int,
        default=None,
        help="If this flag is declared, the image will not be cropped (i.e. the dimension will not change). Instead, "
             "voxels outside the bounding box will be set to the value specified by this flag. For example, to have "
             "zeros outside the bounding box, use: '-b 0'",
        metavar=Metavar.int,
    )
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help="Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode")

    return parser
Exemplo n.º 18
0
def get_parser():
    parser = SCTArgumentParser(
        description=
        'Compute SNR using methods described in [Dietrich et al., Measurement of'
        ' signal-to-noise ratios in MR images: Influence of multichannel coils, parallel '
        'imaging, and reconstruction filters. J Magn Reson Imaging 2007; 26(2): 375-385].'
    )
    mandatoryArguments = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatoryArguments.add_argument(
        '-i',
        required=True,
        help="Image to compute the SNR on. (Example: b0s.nii.gz)\n"
        "- For '-method diff' and '-method mult', the image must be 4D, as SNR will be computed "
        "along the 4th dimension.\n"
        "- For '-method single', the image can either be 3D or 4D. If a 4D image is passed, a specific "
        "3D volume should be specified using the '-vol' argument.",
        metavar=Metavar.file)
    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit")
    optional.add_argument(
        '-m',
        help=
        'Binary (or weighted) mask within which SNR will be averaged. Example: dwi_moco_mean_seg.nii.gz',
        metavar=Metavar.file,
        default='')
    optional.add_argument(
        '-m-noise',
        help=
        "Binary (or weighted) mask within which noise will be calculated. Only valid for '-method single'.",
        metavar=Metavar.file,
        default='')
    optional.add_argument(
        '-method',
        help='Method to use to compute the SNR (default: diff):\n'
        "  - diff: Substract two volumes (defined by -vol) and estimate noise variance within the ROI "
        "(flag '-m' is required). Requires a 4D volume.\n"
        "  - mult: Estimate noise variance over time across volumes specified with '-vol'. Requires a 4D volume.\n"
        "  - single: Compute the mean signal in the mask specified by '-m' and estimate the noise variance in a "
        "mask specified by '-m-noise'. If the noise mask is in the background (air), the noise variance needs to "
        "be corrected for Rayleigh distribution (set '-rayleigh 1'). If the noise mask is located in a "
        "region with high signal (eg: tissue), noise distribution can be assumed Gaussian and there is no need to "
        "correct for Rayleigh distribution (use '-rayleigh 0'). This implementation corresponds to the SNRstdv "
        "in the Dietrich et al. article. Uses a 3D or a 4D volume. If a 4D volume is input, the volume to "
        "compute SNR on is specified by '-vol'.",
        choices=('diff', 'mult', 'single'),
        default='diff')
    optional.add_argument(
        '-vol',
        help=
        "Volumes to compute SNR from. Separate with ',' (Example: '-vol 0,1'), or select range "
        "using ':' (Example: '-vol 2:50'). If this argument is not passed:\n"
        "  - For '-method mult', all volumes will be used.\n"
        "  - For '-method diff', the first two volumes will be used.\n"
        "  - For '-method single', the first volume will be used.",
        metavar=Metavar.str,
        default='')
    optional.add_argument(
        '-rayleigh',
        type=int,
        help=
        "Correct for Rayleigh distribution. It is recommended to always use this correction for the 'diff' method "
        "and to use it with the 'single' method in case the noise mask is taken in a region with low SNR (e.g., "
        "the air). ",
        default=1,
        choices=(0, 1))
    optional.add_argument('-r',
                          type=int,
                          help='Remove temporary files.',
                          default=1,
                          choices=(0, 1))
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )
    optional.add_argument('-o',
                          metavar=Metavar.str,
                          type=str,
                          default=None,
                          help="File name to write the computed SNR to.")
    return parser
def get_parser():
    parser = SCTArgumentParser(
        description=
        "Concatenate b=0 scans with DWI time series and update the bvecs and bvals files.\n\n"
        "Example 1: Add two b=0 file at the beginning and one at the end of the DWI time series:\n"
        ">> sct_dmri_concat_b0_and_dwi -i b0-1.nii b0-2.nii dmri.nii b0-65.nii -bvec bvecs.txt -bval "
        "bvals.txt -order b0 b0 dwi b0 -o dmri_concat.nii -obval bvals_concat.txt -obvec "
        "bvecs_concat.txt\n\n"
        "Example 2: Concatenate two DWI series and add one b=0 file at the beginning:\n"
        ">> sct_dmri_concat_b0_and_dwi -i b0-1.nii dmri1.nii dmri2.nii -bvec bvecs1.txt bvecs2.txt -bval "
        "bvals1.txt bvals2.txt -order b0 dwi dwi -o dmri_concat.nii -obval bvals_concat.txt -obvec "
        "bvecs_concat.txt")
    mandatory = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatory.add_argument(
        '-i',
        nargs='+',
        required=True,
        help=
        "Input 4d files, separated by space, listed in the right order of concatenation. Example: b0.nii dmri1.nii dmri2.nii",
        metavar=Metavar.file,
    )
    mandatory.add_argument(
        '-bval',
        nargs='+',
        required=True,
        help="Bvals file(s). Example: bvals.txt",
        metavar=Metavar.file,
    )
    mandatory.add_argument(
        '-bvec',
        nargs='+',
        required=True,
        help="Bvecs file(s). Example: bvecs.txt",
        metavar=Metavar.file,
    )
    mandatory.add_argument(
        '-order',
        nargs='+',
        required=True,
        help=
        "Order of b=0 and DWI files entered in flag '-i', separated by space. Example: b0 dwi dwi",
        choices=['b0', 'dwi'],
    )
    mandatory.add_argument(
        '-o',
        required=True,
        help="Output 4d concatenated file. Example: b0_dmri_concat.nii",
        metavar=Metavar.file,
    )
    mandatory.add_argument(
        '-obval',
        required=True,
        help="Output concatenated bval file. Example: bval_concat.txt",
        metavar=Metavar.file,
    )
    mandatory.add_argument(
        '-obvec',
        required=True,
        help="Output concatenated bvec file. Example: bvec_concat.txt",
        metavar=Metavar.file,
    )

    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument(
        '-h',
        '--help',
        action='help',
        help="Show this help message and exit",
    )
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    return parser
Exemplo n.º 20
0
def get_parser():
    parser = SCTArgumentParser(
        description="Anisotropic resampling of 3D or 4D data.")

    mandatory = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatory.add_argument(
        '-i',
        metavar=Metavar.file,
        required=True,
        help=
        "Image to segment. Can be 3D or 4D. (Cannot be 2D) Example: dwi.nii.gz"
    )

    resample_types = parser.add_argument_group(
        "\nTYPE OF THE NEW SIZE INPUT: with a factor of resampling, in mm or in number of voxels\n"
        "Please choose only one of the 3 options")
    resample_types.add_argument(
        '-f',
        metavar=Metavar.str,
        help=
        "R|Resampling factor in each dimensions (x,y,z). Separate with 'x'. Example: 0.5x0.5x1\n"
        "For 2x upsampling, set to 2. For 2x downsampling set to 0.5")
    resample_types.add_argument(
        '-mm',
        metavar=Metavar.str,
        help=
        "New resolution in mm. Separate dimension with 'x'. Example: 0.1x0.1x5"
    )
    resample_types.add_argument(
        '-vox',
        metavar=Metavar.str,
        help=
        "Resampling size in number of voxels in each dimensions (x,y,z). Separate with 'x'."
    )

    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit.")
    optional.add_argument(
        '-ref',
        metavar=Metavar.file,
        help=
        "Reference image to resample input image to. Uses world coordinates.")
    optional.add_argument('-x',
                          choices=['nn', 'linear', 'spline'],
                          default='linear',
                          help="Interpolation method.")
    optional.add_argument(
        '-o',
        metavar=Metavar.file,
        help="Output file name. Example: dwi_resampled.nii.gz")
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    return parser
Exemplo n.º 21
0
def get_parser():
    parser = SCTArgumentParser(
        description=
        'Utility function to denoise diffusion MRI images. Return the denoised image and also the difference '
        'between the input and the output.The Patch2Self denoising algorithm is based on self-supervised denoising via statistical independence of noise, as described in the following publications:\n'
        '\n'
        '- Fadnavis et al. Patch2Self: Denoising Diffusion MRI with Self-supervised Learning. NeurIPS, 2020, Vol. 33. (https://arxiv.org/abs/2011.01355)\n'
        '- Schilling et al. Patch2Self denoising of diffusion MRI in the cervical spinal cord improves intra-cord contrast, '
        'signal modelling, repeatability, and feature conspicuity. medRxiv, 2021. (https://doi.org/10.1101/2021.10.04.21264389)\n'
        '\n'
        'The implementation is based on DIPY (https://dipy.org/documentation/1.4.1./examples_built/denoise_patch2self/#example-denoise-patch2self)'
    )

    mandatory = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatory.add_argument(
        "-i",
        default=None,
        required=True,
        help="Input NIfTI image to be denoised. Example: image_input.nii.gz",
        metavar=Metavar.file,
    )
    mandatory.add_argument(
        "-b",
        default=None,
        required=True,
        help="Input bvals file corresponding to the NIfTI file to be denoised."
        " Example: filename.bval",
        metavar=Metavar.file,
    )

    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit")
    optional.add_argument(
        "-model",
        help=
        'Type of regression model used for self-supervised training within Patch2Self.',
        required=False,
        choices=("ols", "ridge", "lasso"),
        default="ols")
    optional.add_argument(
        "-radius",
        help=
        "Patch Radius used to generate p-neighbourhoods within Patch2Self. Notes:\n"
        "- A radius of '0' will use 1x1x1 p-neighbourhoods, a radius of '1' will use "
        "3x3x3 p-neighbourhoods, and so on.\n"
        "- For ansiotropic patch sizes, provide a comma-delimited list of 3 integers. "
        "(e.g. '-radius 0,1,0'). For isotropic patch sizes, provide a single int value "
        "(e.g. '-radius 0').",
        metavar=Metavar.int,
        required=False,
        default="0")
    optional.add_argument("-o",
                          help="Name of the output NIFTI image.",
                          metavar=Metavar.str,
                          default=None)
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    return parser
Exemplo n.º 22
0
def get_parser():

    # initialize parameters
    param_default = ParamMoco(is_diffusion=True,
                              group_size=3,
                              metric='MI',
                              smooth='1')

    parser = SCTArgumentParser(
        description=
        "Motion correction of dMRI data. Some of the features to improve robustness were proposed in Xu et "
        "al. (http://dx.doi.org/10.1016/j.neuroimage.2012.11.014) and include:\n"
        "  - group-wise (-g)\n"
        "  - slice-wise regularized along z using polynomial function (-param). For more info about the "
        "method, type: isct_antsSliceRegularizedRegistration\n"
        "  - masking (-m)\n"
        "  - iterative averaging of target volume\n")

    mandatory = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatory.add_argument('-i',
                           metavar=Metavar.file,
                           required=True,
                           help="Diffusion data. Example: dmri.nii.gz")
    mandatory.add_argument('-bvec',
                           metavar=Metavar.file,
                           required=True,
                           help='Bvecs file. Example: bvecs.txt')

    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit.")
    optional.add_argument(
        '-bval',
        metavar=Metavar.file,
        default=param_default.fname_bvals,
        help='Bvals file. Example: bvals.nii.gz',
    )
    optional.add_argument(
        '-bvalmin',
        type=float,
        metavar=Metavar.float,
        default=param_default.bval_min,
        help=
        'B-value threshold (in s/mm2) below which data is considered as b=0. Example: 50.0',
    )
    optional.add_argument(
        '-g',
        type=int,
        metavar=Metavar.int,
        default=param_default.group_size,
        help=
        'Group nvols successive dMRI volumes for more robustness. Example: 2',
    )
    optional.add_argument(
        '-m',
        metavar=Metavar.file,
        default=param_default.fname_mask,
        help=
        'Binary mask to limit voxels considered by the registration metric. Example: dmri_mask.nii.gz',
    )
    optional.add_argument(
        '-param',
        metavar=Metavar.list,
        type=list_type(',', str),
        help=
        f"R|Advanced parameters. Assign value with \"=\", and separate arguments with \",\".\n"
        f"  - poly [int]: Degree of polynomial function used for regularization along Z. For no regularization "
        f"set to 0. Default={param_default.poly}.\n"
        f"  - smooth [mm]: Smoothing kernel. Default={param_default.smooth}.\n"
        f"  - metric {{MI, MeanSquares, CC}}: Metric used for registration. Default={param_default.metric}.\n"
        f"  - gradStep [float]: Searching step used by registration algorithm. The higher the more deformation "
        f"allowed. Default={param_default.gradStep}.\n"
        f"  - sample [None or 0-1]: Sampling rate used for registration metric. "
        f"Default={param_default.sampling}.\n")
    optional.add_argument('-x',
                          choices=['nn', 'linear', 'spline'],
                          default=param_default.interp,
                          help="Final interpolation.")
    optional.add_argument('-ofolder',
                          metavar=Metavar.folder,
                          action=ActionCreateFolder,
                          default=param_default.path_out,
                          help="Output folder. Example: dmri_moco_results/")
    optional.add_argument("-r",
                          choices=('0', '1'),
                          default=param_default.remove_temp_files,
                          help="Remove temporary files. 0 = no, 1 = yes")
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )
    return parser
Exemplo n.º 23
0
def get_parser():
    parser = SCTArgumentParser(
        description='Compute MTsat and T1map. '
        'Reference: Helms G, Dathe H, Kallenberg K, Dechent P. High-resolution maps of magnetization '
        'transfer with inherent correction for RF inhomogeneity and T1 relaxation obtained from 3D FLASH '
        'MRI. Magn Reson Med 2008;60(6):1396-1407.')

    mandatoryArguments = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatoryArguments.add_argument(
        "-mt",
        required=True,
        help="Image with MT_ON",
        metavar=Metavar.file,
    )
    mandatoryArguments.add_argument(
        "-pd",
        required=True,
        help="Image PD weighted (typically, the MT_OFF)",
        metavar=Metavar.file,
    )
    mandatoryArguments.add_argument(
        "-t1",
        required=True,
        help="Image T1-weighted",
        metavar=Metavar.file,
    )

    optional = parser.add_argument_group('\nOPTIONAL ARGUMENTS')
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit")
    optional.add_argument(
        "-trmt",
        help=
        "TR [in ms] for mt image. By default, will be fetch from the json sidecar (if it exists).",
        type=float,
        metavar=Metavar.float,
    )
    optional.add_argument(
        "-trpd",
        help=
        "TR [in ms] for pd image. By default, will be fetch from the json sidecar (if it exists).",
        type=float,
        metavar=Metavar.float,
    )
    optional.add_argument(
        "-trt1",
        help=
        "TR [in ms] for t1 image. By default, will be fetch from the json sidecar (if it exists).",
        type=float,
        metavar=Metavar.float,
    )
    optional.add_argument(
        "-famt",
        help=
        "Flip angle [in deg] for mt image. By default, will be fetch from the json sidecar (if it exists).",
        type=float,
        metavar=Metavar.float,
    )
    optional.add_argument(
        "-fapd",
        help=
        "Flip angle [in deg] for pd image. By default, will be fetch from the json sidecar (if it exists).",
        type=float,
        metavar=Metavar.float,
    )
    optional.add_argument(
        "-fat1",
        help=
        "Flip angle [in deg] for t1 image. By default, will be fetch from the json sidecar (if it exists).",
        type=float,
        metavar=Metavar.float,
    )
    optional.add_argument("-b1map",
                          help="B1 map",
                          metavar=Metavar.file,
                          default=None)
    optional.add_argument("-omtsat",
                          metavar=Metavar.str,
                          help="Output file for MTsat",
                          default="mtsat.nii.gz")
    optional.add_argument("-ot1map",
                          metavar=Metavar.str,
                          help="Output file for T1map",
                          default="t1map.nii.gz")
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    return parser
Exemplo n.º 24
0
def get_parser():
    parser = SCTArgumentParser(
        description="Utility functions for label images."
    )

    req_group = parser.add_argument_group("\nREQUIRED I/O")
    req_group.add_argument(
        '-i',
        metavar=Metavar.file,
        required=True,
        help="Input image (Required) Example: t2_labels.nii.gz"
    )

    io_group = parser.add_argument_group("\nOPTIONAL I/O")

    io_group.add_argument(
        '-o',
        metavar=Metavar.file,
        default='labels.nii.gz',
        help=("Output image. Note: Only some label utilities create an output image. Example: t2_labels.nii.gz")
    )

    io_group.add_argument(
        '-ilabel',
        metavar=Metavar.file,
        help="File that contain labels that you want to correct. It is possible to add new points with this option. "
             "Use with -create-viewer. Example: t2_labels_auto.nii.gz"
    )

    functions = parser.add_argument_group("\nLABEL FUNCTIONS")
    func_group = functions.add_mutually_exclusive_group(required=True)

    func_group.add_argument(
        '-add',
        metavar=Metavar.int,
        type=int,
        help="Add value to all labels. Value can be negative."
    )

    func_group.add_argument(
        '-create',
        metavar=Metavar.list,
        type=list_type(':', Coordinate),
        help="Create labels in a new image. List labels as: x1,y1,z1,value1:x2,y2,z2,value2. "
             "Example: 12,34,32,1:12,35,33,2"
    )

    func_group.add_argument(
        '-create-add',
        metavar=Metavar.list,
        type=list_type(':', Coordinate),
        help="Same as '-create', but add labels to the input image instead of creating a new image. "
             "Example: 12,34,32,1:12,35,33,2"
    )

    func_group.add_argument(
        '-create-seg',
        metavar=Metavar.list,
        type=list_type(':', list_type(',', int)),
        help="R|Create labels on a cord segmentation (or centerline) image defined by '-i'. Each label should be "
             "specified using the form 'v1,v2' where 'v1' is value of the slice index along the inferior-superior "
             "axis, and 'v2' is the value of the label. Separate each label with ':'. \n"
             "Example: '-create-seg 5,1:14,2:23,3' adds three labels at the axial slices 5, 14, and 23 (starting from "
             "the most inferior slice)."
    )

    func_group.add_argument(
        '-create-seg-mid',
        metavar=Metavar.int,
        type=int,
        help="R|Similar to '-create-seg'. This option takes a single label value, and will automatically select the "
             "mid-point slice in the inferior-superior direction (so there is no need for a slice index).\n"
             "This is useful for when you have centered the field of view of your data at a specific location. "
             "For example, if you already know that the C2-C3 disc is centered in the I-S direction, then "
             "you can enter '-create-seg-mid 3' for that label. This saves you the trouble of having to manually "
             "specify a slice index using '-create-seg'."
    )

    func_group.add_argument(
        '-create-viewer',
        metavar=Metavar.list,
        help="Manually label from a GUI a list of labels IDs. Provide a comma-separated list "
             "containing individual values and/or intervals. Example: '-create-viewer 1:4,6,8' "
             "will allow you to add labels [1,2,3,4,6,8] using the GUI."
    )

    func_group.add_argument(
        '-cubic-to-point',
        action="store_true",
        help="Compute the center-of-mass for each label value."
    )

    func_group.add_argument(
        '-disc',
        metavar=Metavar.file,
        help="Create an image with regions labelized depending on values from reference"
    )

    func_group.add_argument(
        '-display',
        action="store_true",
        help="Display all labels (i.e. non-zero values)."
    )
    func_group.add_argument(
        '-increment',
        action="store_true",
        help="Takes all non-zero values, sort them along the inverse z direction, and attributes the values "
             "1, 2, 3, etc."
    )
    func_group.add_argument(
        '-vert-body',
        metavar=Metavar.list,
        type=list_type(',', int),
        help="R|From vertebral labeling, create points that are centered at the mid-vertebral levels. Separate "
             "desired levels with ','. Example: 3,8\n"
             "To get all levels, enter 0."
    )

    func_group.add_argument(
        '-vert-continuous',
        action="store_true",
        help="Convert discrete vertebral labeling to continuous vertebral labeling.",
    )
    func_group.add_argument(
        '-MSE',
        metavar=Metavar.file,
        help="Compute Mean Square Error between labels from input and reference image. Specify reference image here."
    )
    func_group.add_argument(
        '-remove-reference',
        metavar=Metavar.file,
        help="Remove labels from input image (-i) that are not in reference image (specified here)."
    )
    func_group.add_argument(
        '-remove-sym',
        metavar=Metavar.file,
        help="Remove labels from input image (-i) and reference image (specified here) that don't match. You must "
             "provide two output names separated by ','."
    )
    func_group.add_argument(
        '-remove',
        metavar=Metavar.list,
        type=list_type(',', int),
        help="Remove labels of specific value (specified here) from reference image."
    )
    func_group.add_argument(
        '-keep',
        metavar=Metavar.list,
        type=list_type(',', int),
        help="Keep labels of specific value (specified here) from reference image."
    )

    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument(
        "-h",
        "--help",
        action="help",
        help="Show this help message and exit."
    )

    optional.add_argument(
        '-msg',
        metavar=Metavar.str,
        help="Display a message to explain the labeling task. Use with -create-viewer"
    )

    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help="Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    optional.add_argument(
        '-qc',
        metavar=Metavar.folder,
        action=ActionCreateFolder,
        help="The path where the quality control generated content will be saved."
    )

    optional.add_argument(
        '-qc-dataset',
        metavar=Metavar.str,
        help="If provided, this string will be mentioned in the QC report as the dataset the process was run on."
    )

    optional.add_argument(
        '-qc-subject',
        metavar=Metavar.str,
        help="If provided, this string will be mentioned in the QC report as the subject the process was run on."
    )

    return parser
def get_parser():
    parser = SCTArgumentParser(
        description=
        'Utility function to denoise images. Return the denoised image and also the difference '
        'between the input and the output. The denoising algorithm is based on the Non-local means'
        'methods (Pierrick Coupe, Jose Manjon, Montserrat Robles, Louis Collins. “Adaptive Multiresolution '
        'Non-Local Means Filter for 3D MR Image Denoising” IET Image Processing, Institution of '
        'Engineering and Technology, 2011). The implementation is based on Dipy (https://dipy.org/).'
    )

    mandatory = parser.add_argument_group("\nMANDATORY ARGUMENTS")
    mandatory.add_argument(
        "-i",
        default=None,
        required=True,
        help="Input NIFTI image to be denoised. Example: image_input.nii.gz",
        metavar=Metavar.file,
    )

    optional = parser.add_argument_group("\nOPTIONAL ARGUMENTS")
    optional.add_argument("-h",
                          "--help",
                          action="help",
                          help="Show this help message and exit")
    optional.add_argument(
        "-p",
        help='Type of assumed noise distribution. Default is: Rician.',
        required=False,
        choices=("Rician", "Gaussian"),
        default="Rician")
    optional.add_argument(
        "-d",
        type=int,
        help="Threshold value for what to be considered as noise. "
        "The standard deviation of the noise is calculated for values below this limit. "
        "Not relevant if -std value is precised. Default is 80.",
        metavar=Metavar.int,
        required=False,
        default="80")
    optional.add_argument(
        "-std",
        type=float,
        help="Standard deviation of the noise. "
        "If not specified, it is calculated using a background of point of values "
        "below the threshold value (parameter d).",
        metavar=Metavar.float)
    optional.add_argument("-o",
                          help="Name of the output NIFTI image.",
                          metavar=Metavar.str,
                          default=None)
    optional.add_argument(
        "-r",
        help=
        "Remove temporary files. Specify 0 to get access to temporary files.",
        type=int,
        choices=(0, 1),
        default=1)
    optional.add_argument(
        '-v',
        metavar=Metavar.int,
        type=int,
        choices=[0, 1, 2],
        default=1,
        # Values [0, 1, 2] map to logging levels [WARNING, INFO, DEBUG], but are also used as "if verbose == #" in API
        help=
        "Verbosity. 0: Display only errors/warnings, 1: Errors/warnings + info messages, 2: Debug mode"
    )

    return parser