def get_parser(): # parser initialisation parser = Parser(__file__) # # initialize parameters # param = Param() # param_default = Param() # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Transpose bvecs file (if necessary) to get nx3 structure.') parser.add_option(name='-bvec', type_value='file', description='Input bvecs file.', mandatory=True, example='bvecs.txt') parser.add_option(name='-i', type_value='file', description='Input bvecs file.', mandatory=False, example='bvecs.txt', deprecated_by='-bvec') parser.add_option(name='-o', type_value='file_output', description='Output bvecs file. By default input file is overwritten.', mandatory=False, example='bvecs_t.txt') parser.add_option(name='-v', type_value='multiple_choice', description="""Verbose. 0: nothing. 1: basic. 2: extended.""", mandatory=False, default_value='1', example=['0', '1', '2']) return parser
def get_parser(): # parser initialisation parser = Parser(__file__) parser.usage.set_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.' ) parser.add_option( name='-di', type_value='float', description= 'Anteroposterior cord distance at the level of maximum injury', mandatory=True, example=6.85) parser.add_option( name='-da', type_value='float', description= 'Anteroposterior cord distance at the nearest normal level above the level of injury', mandatory=True, example=7.65) parser.add_option( name='-db', type_value='float', description= 'Anteroposterior cord distance at the nearest normal level below the level of injury', mandatory=True, example=7.02) parser.add_option(name="-h", type_value=None, description="Display this help", mandatory=False) return parser
def get_parser(): parser = Parser(__file__) parser.usage.set_description('Quality Control Viewer') parser.add_option(name='-folder', type_value='folder', mandatory=True, description='The root folder of the generated QC data') return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Crash and integrity testing for functions of the Spinal Cord Toolbox. Internet connection is required for downloading testing data.') parser.add_option(name="-f", type_value="str", description="Test this specific script (do not add extension).", mandatory=False, example='sct_propseg') parser.add_option(name="-d", type_value="multiple_choice", description="Download testing data.", mandatory=False, default_value=param.download, example=['0', '1']) parser.add_option(name="-p", type_value="folder", description='Path to testing data. NB: no need to set if using "-d 1"', mandatory=False, default_value=param.path_data) parser.add_option(name="-r", type_value="multiple_choice", description='Remove temporary files.', mandatory=False, default_value='1', example=['0', '1']) return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description('''This program automatically detect the spinal cord in a MR image and output a centerline of the spinal cord.''') parser.add_option(name="-i", type_value="file", description="input image.", mandatory=True, example="t2.nii.gz") parser.add_option(name="-t", type_value="multiple_choice", description="type of image contrast, t2: cord dark / CSF bright ; t1: cord bright / CSF dark", mandatory=True, example=['t1', 't2']) parser.usage.addSection("General options") parser.add_option(name="-v", type_value="multiple_choice", description="1: display on, 0: display off (default)", mandatory=False, example=["0", "1"], default_value="1") parser.add_option(name="-h", type_value=None, description="display this help", mandatory=False) return parser
def get_parser(): """ :return: Returns the parser with the command line documentation contained in it. """ #param = Param() # Initialize the parser parser = Parser(__file__) parser.usage.set_description('''Identification and estimation of noise in the diffusion signal, implemented by the Dipy software project (http://nipy.org/dipy/), based on the PIESNO method: Koay C.G., E. Ozarslan, C. Pierpaoli. Probabilistic Identification and Estimation of Noise (PIESNO): A self-consistent approach and its applications in MRI. JMR, 199(1):94-103, 2009.''') parser.add_option(name='-i', type_value='file', description='Input file', mandatory=True, example='data_highQ.nii') parser.add_option(name='-dof', type_value='int', description='Degree of freedom of the noise distribution. Corresponds to the number of antenna for an acquisition without parallel imaging with sum of squares combination. Otherwise, dof is close to 1.', mandatory=False, default_value='1', example='1') parser.add_option(name="-o", type_value='file_output', description='Output file.', mandatory=False, example='noise_mask.nii.gz') parser.add_option(name='-h', type_value=None, description='Display this help.', mandatory=False) return parser
def get_parser(): param_default = Param() parser = Parser(__file__) parser.usage.set_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.""") parser.add_option(name='-i', type_value='image_nifti', description='Input volume.', mandatory=True, example='t2.nii.gz') parser.add_option(name='-s', type_value='image_nifti', description='Spinal cord segmentation or centerline.', mandatory=True, example='t2_seg.nii.gz') parser.add_option(name='-v', type_value='multiple_choice', description='0: no verbose (default), 1: min verbose, 2: verbose + figures', mandatory=False, example=['0', '1', '2'], default_value=str(param_default.verbose)) parser.add_option(name='-h', type_value=None, description='Display this help', mandatory=False) return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Concatenate transformations. This function is a wrapper for isct_ComposeMultiTransform (ANTs). N.B. Order of input warping fields is important. For example, if you want to concatenate: A->B and B->C to yield A->C, then you have to input warping fields like that: A->B,B->C.') parser.add_option(name="-d", type_value="file", description="Destination image.", mandatory=True, example='mt.nii.gz') parser.add_option(name="-w", type_value=[[','], 'file'], description='List of affine matrix or warping fields separated with "," N.B. if you want to use the inverse matrix, add "-" before matrix file name.', mandatory=True, example='warp_template2anat.nii.gz,warp_anat2mt.nii.gz') parser.add_option(name="-o", type_value="file_output", description='Name of output warping field.', mandatory=False, example='warp_template2mt.nii.gz') parser.add_option(name="-v", type_value='multiple_choice', description="verbose: 0 = nothing, 1 = classic, 2 = expended", mandatory=False, example=['0', '1', '2'], default_value='1') return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description( "Concatenate transformations. This function is a wrapper for isct_ComposeMultiTransform (ANTs). N.B. Order of input warping fields is important. For example, if you want to concatenate: A->B and B->C to yield A->C, then you have to input warping fields like that: A->B,B->C." ) parser.add_option( name="-d", type_value="file", description="Destination image.", mandatory=True, example="mt.nii.gz" ) parser.add_option( name="-w", type_value=[[","], "file"], description='List of affine matrix or warping fields separated with "," N.B. if you want to use the inverse matrix, add "-" before matrix file name. N.B. You should NOT use "-" with warping fields (only with matrices). If you want to use an inverse warping field, then input it directly (e.g., warp_template2anat.nii.gz instead of warp_anat2template.nii.gz) ', mandatory=True, example="warp_template2anat.nii.gz,warp_anat2mt.nii.gz", ) parser.add_option( name="-o", type_value="file_output", description="Name of output warping field.", mandatory=False, example="warp_template2mt.nii.gz", ) parser.add_option( name="-v", type_value="multiple_choice", description="verbose: 0 = nothing, 1 = classic, 2 = expended", mandatory=False, example=["0", "1", "2"], default_value="1", ) return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Display scatter plot of gradient directions from bvecs file.') parser.add_option(name='-bvec', type_value='file', description='bvecs file.', mandatory=True, example='bvecs.txt') return parser
def get_parser(): # Initialize parser parser = Parser(__file__) # Mandatory arguments parser.usage.set_description("") parser.add_option(name="-a", type_value=None, description="If provided, compile with sudo.", mandatory=False) return parser
def get_parser(): # parser initialisation parser = Parser(__file__) # # initialize parameters # param = Param() # param_default = Param() # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Transpose bvecs file (if necessary) to get nx3 structure.') parser.add_option(name="-i", type_value="file", description="Input bvecs file.", mandatory=True, example="bvecs.txt") parser.add_option(name="-o", type_value="file_output", description="Output bvecs file. By default input file is overwritten.", mandatory=False, example="bvecs_t.txt") parser.add_option(name="-v", type_value="multiple_choice", description="""Verbose. 0: nothing. 1: basic. 2: extended.""", mandatory=False, default_value='1', example=['0', '1', '2']) return parser
def get_parser(): # parser initialisation parser = Parser(__file__) # initialize parameters param = Param() param_default = Param() # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Convert image file to another type.') parser.add_option(name="-i", type_value="file", description="File input", mandatory=True, example='data.nii.gz') parser.add_option(name="-o", type_value="file_output", description="File output (indicate new extension)", mandatory=True, example=['data.nii']) parser.add_option(name="-squeeze", type_value='multiple_choice', description='Sueeze data dimension (remove unused dimension).', mandatory=False, example=['0', '1'], default_value='1') return parser
def get_parser(): # parser initialisation parser = Parser(__file__) # initialize parameters param = Param() param_default = Param() # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Concatenate data.') parser.add_option(name="-i", type_value=[[','], "file"], description='Multiple files separated with ",".', mandatory=True, example="data1.nii.gz,data2.nii.gz") parser.add_option(name="-o", type_value="file_output", description="Output file", mandatory=True, example=['data_concat.nii.gz']) parser.add_option(name="-dim", type_value="multiple_choice", description="""Dimension for concatenation.""", mandatory=True, example=['x', 'y', 'z', 't']) return parser
def get_parser(): # parser initialisation parser = Parser(__file__) # initialize parameters param = Param() param_default = Param() # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Split data. By default, output files will have suffix "_0000", "_0002", etc.') parser.add_option(name="-i", type_value="file", description="Input file.", mandatory=True, example="data.nii.gz") parser.add_option(name="-dim", type_value="multiple_choice", description="""Dimension for split.""", mandatory=False, default_value='t', example=['x', 'y', 'z', 't']) parser.add_option(name="-suffix", type_value="str", description="""Output suffix.""", mandatory=False, default_value='_', example='_') return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Concatenate bval files in time.') parser.add_option(name="-i", type_value=[[','], 'file'], description="List of the bval files to concatenate.", mandatory=True, example="dmri_b700.bval,dmri_b2000.bval") parser.add_option(name="-o", type_value="file_output", description='Output file with bvals merged.', mandatory=False, example='dmri_b700_b2000_concat.bval') return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Concatenate bvec files in time. You can either use bvecs in lines or columns.\nN.B.: Return bvecs in lines. If you need it in columns, please use sct_dmri_transpose_bvecs afterwards.') parser.add_option(name="-i", type_value=[[','], 'file'], description="List of the bvec files to concatenate.", mandatory=True, example="dmri_b700.bvec,dmri_b2000.bvec") parser.add_option(name="-o", type_value="file_output", description='Output file with bvecs concatenated.', mandatory=False, example='dmri_b700_b2000_concat.bvec') return parser
def get_parser(): parser = Parser(__file__) parser.usage.set_description('''Download binaries from the web.''') parser.add_option( name="-d", type_value="multiple_choice", description="Name of the dataset.", mandatory=True, example=[ 'sct_example_data', 'sct_testing_data', 'course_hawaii17', 'course_paris18', 'course_london19', 'sct_course-beijing19', 'PAM50', 'MNI-Poly-AMU', 'gm_model', 'optic_models', 'pmj_models', 'binaries_debian', 'binaries_centos', 'binaries_osx', 'deepseg_gm_models', 'deepseg_sc_models', 'deepseg_lesion_models', 'c2c3_disc_models' ]) parser.add_option( name="-v", type_value="multiple_choice", description="Verbose. 0: nothing. 1: basic. 2: extended.", mandatory=False, default_value=1, example=['0', '1', '2']) parser.add_option( name="-o", type_value="folder_creation", description="path to save the downloaded data", mandatory=False) parser.add_option( name="-h", type_value=None, description="Display this help", mandatory=False) return parser
def get_data_or_scalar(argument, data_in): """ Get data from list of file names (scenario 1) or scalar (scenario 2) :param argument: list of file names of scalar :param data_in: if argument is scalar, use data to get shape :return: 3d or 4d numpy array """ if argument.replace('.', '').isdigit(): # so that it recognize float as digits too # build data2 with same shape as data data_out = data_in[:, :, :] * 0 + float(argument) else: # parse file name and check integrity parser2 = Parser(__file__) parser2.add_option(name='-i', type_value=[[','], 'file']) list_fname = parser2.parse(['-i', argument]).get('-i') data_out = get_data(list_fname) return data_out
def get_data_or_scalar(argument, data_in): """ Get data from list of file names (scenario 1) or scalar (scenario 2) :param argument: list of file names of scalar :param data_in: if argument is scalar, use data to get np.shape :return: 3d or 4d numpy array """ # try to convert argument in float try: # build data2 with same shape as data data_out = data_in[:, :, :] * 0 + float(argument) # if conversion fails, it should be a file except: # parse file name and check integrity parser2 = Parser(__file__) parser2.add_option(name='-i', type_value=[[','], 'file']) list_fname = parser2.parse(['-i', argument]).get('-i') data_out = get_data(list_fname) return data_out
def get_parser(): parser = Parser(__file__) parser.usage.set_description('''Download binaries from the web.''') parser.add_option( name="-d", type_value="multiple_choice", description="Name of the dataset.", mandatory=True, example=[ 'sct_example_data', 'sct_testing_data', 'course_hawaii17', 'course_paris18', 'course_london19', 'PAM50', 'MNI-Poly-AMU', 'gm_model', 'optic_models', 'pmj_models', 'binaries_debian', 'binaries_centos', 'binaries_osx', 'deepseg_gm_models', 'deepseg_sc_models', 'deepseg_lesion_models', 'c2c3_disc_models' ]) parser.add_option( name="-v", type_value="multiple_choice", description="Verbose. 0: nothing. 1: basic. 2: extended.", mandatory=False, default_value=1, example=['0', '1', '2']) parser.add_option( name="-o", type_value="folder_creation", description="path to save the downloaded data", mandatory=False) parser.add_option( name="-h", type_value=None, description="Display this help", mandatory=False) return parser
def get_parser(): parser = Parser(__file__) parser.usage.set_description('Volume Viewer') parser.add_option(name="-i", type_value=[[','], 'file'], description="Images to display.", mandatory=True, example="anat.nii.gz") parser.add_option(name='-mode', type_value='multiple_choice', description='Display mode.' '\nviewer: standard three-window viewer.' '\naxial: one-window viewer for manual centerline.\n', mandatory=False, default_value='viewer', example=['viewer', 'axial']) parser.add_option(name='-param', type_value=[[':'], 'str'], description='Parameters for visualization. ' 'Separate images with \",\". Separate parameters with \":\".' '\nid: number of image in the "-i" list' '\ncmap: image colormap' '\ninterp: image interpolation. Accepts: [\'nearest\' | \'bilinear\' | \'bicubic\' | \'spline16\' | ' '\'spline36\' | \'hanning\' | \'hamming\' | \'hermite\' | \'kaiser\' | ' '\'quadric\' | \'catrom\' | \'gaussian\' | \'bessel\' | \'mitchell\' | ' '\'sinc\' | \'lanczos\' | \'none\' |]' '\nvmin:' '\nvmax:' '\nvmean:' '\nperc: ', mandatory=False, example=['cmap=red:vmin=0:vmax=1', 'cmap=grey']) parser.add_option(name="-v", type_value="multiple_choice", description="""Verbose. 0: nothing. 1: basic. 2: extended.""", mandatory=False, default_value='0', example=['0', '1', '2']) return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description( 'Check the installation and environment variables of the' ' toolbox and its dependencies.') parser.add_option(name="-c", description="Complete test.", mandatory=False) parser.add_option(name="-log", description="Generate log file.", mandatory=False) parser.add_option(name="-l", type_value=None, description="Generate log file.", deprecated_by="-log", mandatory=False) return parser
def get_parser(): # parser initialisation parser = Parser(__file__) # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Convert image file to another type.') parser.add_option(name="-i", type_value="file", description="File input", mandatory=True, example='data.nii.gz') parser.add_option(name="-o", type_value="file_output", description="File output (indicate new extension)", mandatory=True, example=['data.nii']) parser.add_option(name="-squeeze", type_value='multiple_choice', description='Sueeze data dimension (remove unused dimension).', mandatory=False, example=['0', '1'], default_value='1') return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Check the installation and environment variables of the toolbox and its dependences.') parser.add_option(name="-c", description="Complete test.", mandatory=False) parser.add_option(name="-log", description="Generate log file.", mandatory=False) parser.add_option(name="-l", type_value=None, description="Generate log file.", deprecated_by="-log", mandatory=False) return parser
def get_parser(): parser = Parser(__file__) parser.usage.set_description('Compute temporal SNR (tSNR) in fMRI time series.') parser.add_option(name='-i', type_value='file', description='fMRI data', mandatory=True, example='fmri.nii.gz') parser.add_option(name='-v', type_value='multiple_choice', description='verbose', mandatory=False, default_value='1', example=['0', '1']) parser.add_option(name='-o', type_value='file_output', description='tSNR data output file', mandatory=False, example='fmri_tsnr.nii.gz') return parser
def get_parser(): # parser initialisation parser = Parser(__file__) parser.usage.set_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.') parser.add_option(name='-di', type_value='float', description='Anteroposterior cord distance at the level of maximum injury', mandatory=True, example=6.85) parser.add_option(name='-da', type_value='float', description='Anteroposterior cord distance at the nearest normal level above the level of injury', mandatory=True, example=7.65) parser.add_option(name='-db', type_value='float', description='Anteroposterior cord distance at the nearest normal level below the level of injury', mandatory=True, example=7.02) parser.add_option(name="-h", type_value=None, description="Display this help", mandatory=False) return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Calculate b-value (in mm^2/s).') parser.add_option(name="-g", type_value="float", description="Amplitude of diffusion gradients (in mT/m)", mandatory=True, example='40') parser.add_option(name="-b", type_value="float", description="Big delta: time between both diffusion gradients (in ms)", mandatory=True, example='40') parser.add_option(name="-d", type_value="float", description="Small delta: duration of each diffusion gradient (in ms)", mandatory=True, example='30') return parser
def get_parser(): # parser initialisation parser = Parser(__file__) # initialize parameters param = Param() param_default = Param() # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Convert image file to another type.') parser.add_option(name="-i", type_value="file", description="File input", mandatory=True, example='data.nii.gz') parser.add_option(name="-o", type_value="file_output", description="File output (indicate new extension)", mandatory=True, example=['data.nii']) return parser
def get_parser(): # parser initialisation parser = Parser(__file__) parser.usage.set_description('''Download dataset from the web.''') parser.add_option(name="-d", type_value="multiple_choice", description="Name of the dataset.", mandatory=True, example=['sct_example_data', 'sct_testing_data', 'PAM50']) parser.add_option(name="-v", type_value="multiple_choice", description="""Verbose. 0: nothing. 1: basic. 2: extended.""", mandatory=False, example=['0', '1', '2']) parser.add_option(name="-h", type_value=None, description="Display this help", mandatory=False) return parser
def get_parser(): # parser initialisation parser = Parser(__file__) # initialize parameters param = Param() param_default = Param() # Initialize the parser parser = Parser(__file__) parser.usage.set_description( 'Copy NIFTI header from source to destination.') parser.add_option(name="-i", type_value="file", description="Source file.", mandatory=True, example="src.nii.gz") parser.add_option(name="-d", type_value="file", description="Destination file.", mandatory=True, example='dest.nii.gz') return parser
def get_parser(): # Initialize parser parser = Parser(__file__) # Mandatory arguments parser.usage.set_description("") parser.add_option(name="-f", type_value="multiple_choice", description="Library to compile.", mandatory=False, example=['dipy', 'denoise']) parser.add_option(name="-a", type_value=None, description="If provided, compile with sudo.", mandatory=False) return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description( 'Concatenate bvec files in time. You can either use bvecs in lines or columns.\nN.B.: Return bvecs in lines. If you need it in columns, please use sct_dmri_transpose_bvecs afterwards.' ) parser.add_option(name="-i", type_value=[[','], 'file'], description="List of the bvec files to concatenate.", mandatory=True, example="dmri_b700.bvec,dmri_b2000.bvec") parser.add_option(name="-o", type_value="file_output", description='Output file with bvecs concatenated.', mandatory=False, example='dmri_b700_b2000_concat.bvec') return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description('This function inverts the image intensity using the maximum intensity in the image and 0.') parser.add_option(name="-i", type_value="file", description="Image to invert.", mandatory=True, example="my_image.nii.gz") parser.add_option(name="-o", type_value="file_output", description="output image.", mandatory=False, example="output_image.nii.gz", default_value="inverted_image.nii.gz") return parser
def get_parser(): # parser initialisation parser = Parser(__file__) # initialize parameters param = Param() param_default = Param() # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Copy NIFTI header from source to destination.') parser.add_option(name="-i", type_value="file", description="Source file.", mandatory=True, example="src.nii.gz") parser.add_option(name="-d", type_value="file", description="Destination file.", mandatory=True, example='dest.nii.gz') return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Segmentation of the white and gray matter.' ' The segmentation is based on a multi-atlas method that uses a dictionary of pre-segmented gray matter images (already included in SCT) and finds the most similar images for identifying the gray matter using label fusion approach. The model used by this method contains: a template of the white/gray matter segmentation along the cervical spinal cord, and a PCA reduced space to describe the variability of intensity in that template.' ' This method was inspired from [Asman et al., Medical Image Analysis 2014] and features the following additions:\n' '- possibility to add information from vertebral levels for improved accuracy\n' '- intensity normalization of the image to segment (allows the segmentation of any kind of contrast)\n' '- pre-registration based on non-linear transformations') parser.add_option(name="-i", type_value="file", description="Image to segment", mandatory=True, example='t2star.nii.gz') parser.add_option(name="-s", type_value="file", description="Spinal cord segmentation", mandatory=True, example='sc_seg.nii.gz') parser.usage.addSection('SEGMENTATION OPTIONS') parser.add_option(name="-vertfile", type_value="str", description='Labels of vertebral levels used as prior for the segmentation. This could either be an image (e.g., label/template/PAM50_levels.nii.gz) or a text file that specifies "slice,level" at each line. Example:\n' "0,3\n" "1,3\n" "2,4\n" "3,4\n" "4,4\n", mandatory=False, default_value=ParamSeg().fname_level) parser.add_option(name="-vert", mandatory=False, deprecated_by='-vertfile') parser.add_option(name="-l", mandatory=False, deprecated_by='-vertfile') parser.add_option(name="-denoising", type_value='multiple_choice', description="1: Adaptative denoising from F. Coupe algorithm, 0: no WARNING: It affects the model you should use (if denoising is applied to the target, the model should have been computed with denoising too)", mandatory=False, default_value=int(ParamData().denoising), example=['0', '1']) parser.add_option(name="-normalization", type_value='multiple_choice', description="Normalization of the target image's intensity using median intensity values of the WM and the GM, recomended with MT images or other types of contrast than T2*", mandatory=False, default_value=int(ParamData().normalization), example=['0', '1']) parser.add_option(name="-p", type_value='str', description="Registration parameters to register the image to segment on the model data. Use the same format as for sct_register_to_template and sct_register_multimodal.", mandatory=False, default_value=ParamData().register_param, example='step=1,type=seg,algo=centermassrot,metric=MeanSquares,smooth=2,iter=1:step=2,type=seg,algo=columnwise,metric=MeanSquares,smooth=3,iter=1:step=3,type=seg,algo=bsplinesyn,metric=MeanSquares,iter=3') parser.add_option(name="-w-levels", type_value='float', description="Weight parameter on the level differences to compute the similarities", mandatory=False, default_value=ParamSeg().weight_level, example=2.0) parser.add_option(name="-w-coordi", type_value='float', description="Weight parameter on the euclidean distance (based on images coordinates in the reduced sapce) to compute the similarities ", mandatory=False, default_value=ParamSeg().weight_coord, example=0.005) parser.add_option(name="-thr-sim", type_value='float', description="Threshold to select the dictionary slices most similar to the slice to segment (similarities are normalized to 1)", mandatory=False, default_value=ParamSeg().thr_similarity, example=0.6) parser.add_option(name="-model", type_value="folder", description="Path to the computed model", mandatory=False, example='/home/jdoe/gm_seg_model/') parser.usage.addSection('\nOUTPUT OPTIONS') parser.add_option(name="-res-type", type_value='multiple_choice', description="Type of result segmentation : binary or probabilistic", mandatory=False, default_value=ParamSeg().type_seg, example=['bin', 'prob']) parser.add_option(name="-ratio", type_value='multiple_choice', description="Compute GM/WM CSA ratio by slice or by vertebral level (average across levels). For no computation of ratio, set to 0.", mandatory=False, default_value=ParamSeg().ratio, example=['0', 'slice', 'level']) parser.add_option(name="-ofolder", type_value="folder_creation", description="Output folder", mandatory=False, default_value=ParamSeg().path_results, example='gm_segmentation_results/') parser.usage.addSection('\nQC OPTIONS') parser.add_option(name="-ref", type_value="file", description="Compute DICE coefficient, Hausdorff's and median distances between output segmentation and gold-standard segmentation specified here", mandatory=False, example='manual_gm_seg.nii.gz') parser.usage.addSection('\nMISC') parser.add_option(name='-qc', type_value='multiple_choice', description='Output images for quality control.', mandatory=False, example=['0', '1'], default_value=str(int(ParamSeg().qc))) parser.add_option(name="-r", type_value="multiple_choice", description='Remove temporary files.', mandatory=False, default_value=str(int(Param().rm_tmp)), example=['0', '1']) parser.add_option(name="-v", type_value='multiple_choice', description="Verbose: 0 = nothing, 1 = classic, 2 = expended", mandatory=False, example=['0', '1', '2'], default_value=str(Param().verbose)) return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Merge images to the same space') parser.add_option(name="-i", type_value=[[','], 'file'], description="Input images", mandatory=True) parser.add_option(name="-d", type_value='file', description="Destination image", mandatory=True) parser.add_option( name="-w", type_value=[[','], 'file'], description= "List of warping fields from input images to destination image", mandatory=True) parser.add_option( name="-x", type_value='str', description= "interpolation for warping the input images to the destination image", mandatory=False, default_value=Param().interp) parser.add_option(name="-o", type_value='file_output', description="Output image", mandatory=False, default_value=Param().fname_out) ''' parser.add_option(name="-ofolder", type_value="folder_creation", description="Output folder", mandatory=False) ''' parser.usage.addSection('MISC') parser.add_option(name="-r", type_value="multiple_choice", description='Remove temporary files.', mandatory=False, default_value=str(int(Param().rm_tmp)), example=['0', '1']) parser.add_option( name="-v", type_value='multiple_choice', description="Verbose: 0 = nothing, 1 = classic, 2 = expended", mandatory=False, example=['0', '1', '2'], default_value=str(Param().verbose)) return parser
print 'Warning: the distance between label ' + str(i) + '[' + str(coordinates_input[i].x) + ',' + str(coordinates_input[i].y) + ',' + str( coordinates_input[i].z) + ']=' + str(coordinates_input[i].value) + ' and label ' + str(i+1) + '[' + str( coordinates_input[i+1].x) + ',' + str(coordinates_input[i+1].y) + ',' + str(coordinates_input[i+1].z) + ']=' + str( coordinates_input[i+1].value) + ' is larger than ' + str(max_dist) + '. Distance=' + str(dist) #======================================================================================================================= # Start program #======================================================================================================================= if __name__ == "__main__": # initialize parameters param = Param() param_default = Param() # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Utility function for labels.') parser.add_option(name="-i", type_value="file", description="labels or image to create labels on. Must be 3D.", mandatory=True, example="t2_labels.nii.gz") parser.add_option(name="-o", type_value="file_output", description="output volume.", mandatory=False, example="t2_labels_cross.nii.gz", default_value="labels.nii.gz") parser.add_option(name="-t", type_value="str", description="""process:\ncross: create a cross. Must use flag "-c"\nremove: remove labels. Must use flag "-r"\ndisplay-voxel: display all labels in file\ncreate: create labels. Must use flag "-x" to list labels\nadd: add label to an existing image (-i).\nincrement: increment labels from top to bottom (in z direction, suppose RPI orientation)\nMSE: compute Mean Square Error between labels input and reference input "-r"\ncubic-to-point: transform each volume of labels into a discrete single voxel label. """,
def get_parser(): # initialize default param param_default = Param() # Initialize the parser parser = Parser(__file__) parser.usage.set_description( 'Perform manipulations on images (e.g., pad, change space, split along dimension). Inputs can be a number, a 4d image, or several 3d images separated with ","' ) parser.add_option( name="-i", type_value=[[','], 'file'], description= "Input file(s). If several inputs: separate them by a coma without white space.\n", mandatory=True, example="data.nii.gz") parser.add_option(name="-o", type_value='file_output', description='Output file.', mandatory=False, example='data_pad.nii.gz') parser.usage.addSection('\nImage operations:') parser.add_option( name="-pad", type_value="str", description='Pad 3D image. Specify padding as: "x,y,z" (in voxel)', mandatory=False, example='0,0,1') parser.add_option( name="-pad-asym", type_value="str", description= 'Pad 3D image with asymmetric padding. Specify padding as: "x_i,x_f,y_i,y_f,z_i,z_f" (in voxel)', mandatory=False, example='0,0,5,10,1,1') parser.add_option( name="-split", type_value="multiple_choice", description= 'Split data along the specified dimension. The suffix _DIM+NUMBER will be added to the intput file name.', mandatory=False, example=['x', 'y', 'z', 't']) parser.add_option( name="-concat", type_value="multiple_choice", description='Concatenate data along the specified dimension', mandatory=False, example=['x', 'y', 'z', 't']) parser.add_option( name='-remove-vol', type_value=[[','], 'int'], description= 'Remove specific volumes from a 4d volume. Separate with ","', mandatory=False, example='0,5,10') parser.add_option( name='-keep-vol', type_value=[[','], 'int'], description= 'Keep specific volumes from a 4d volume (remove others). Separate with ","', mandatory=False, example='1,2,3,11') parser.add_option(name='-type', type_value='multiple_choice', description='Change file type', mandatory=False, example=[ 'uint8', 'int16', 'int32', 'float32', 'complex64', 'float64', 'int8', 'uint16', 'uint32', 'int64', 'uint64' ]) parser.usage.addSection('\nHeader operations:') parser.add_option( name="-copy-header", type_value="file", description= 'Copy the header of the source image (specified in -i) to the destination image (specified here)', mandatory=False, example='data_dest.nii.gz') parser.usage.addSection("\nOrientation operations: ") parser.add_option(name="-getorient", description='Get orientation of the input image', mandatory=False) parser.add_option( name="-setorient", type_value="multiple_choice", description= 'Set orientation of the input image (only modifies the header).', mandatory=False, example= 'RIP LIP RSP LSP RIA LIA RSA LSA IRP ILP SRP SLP IRA ILA SRA SLA RPI LPI RAI LAI RPS LPS RAS LAS PRI PLI ARI ALI PRS PLS ARS ALS IPR SPR IAR SAR IPL SPL IAL SAL PIR PSR AIR ASR PIL PSL AIL ASL' .split()) parser.add_option( name="-setorient-data", type_value="multiple_choice", description= 'Set orientation of the input image\'s data (does NOT modify the header, but the data). Use with care !', mandatory=False, example= 'RIP LIP RSP LSP RIA LIA RSA LSA IRP ILP SRP SLP IRA ILA SRA SLA RPI LPI RAI LAI RPS LPS RAS LAS PRI PLI ARI ALI PRS PLS ARS ALS IPR SPR IAR SAR IPL SPL IAL SAL PIR PSR AIR ASR PIL PSL AIL ASL' .split()) parser.usage.addSection( "\nMulti-component operations on ITK composite warping fields:") parser.add_option( name='-mcs', description= 'Multi-component split: Split ITK warping field into three separate displacement fields. The suffix _X, _Y and _Z will be added to the input file name.', mandatory=False) parser.add_option( name='-omc', description= 'Multi-component merge: Merge inputted images into one multi-component image. Requires several inputs.', mandatory=False) parser.usage.addSection("\nWarping field operations:") parser.add_option( name='-display-warp', description='Create a grid and deform it using provided warping field.', mandatory=False) parser.usage.addSection("\nMisc") parser.add_option( name="-v", type_value="multiple_choice", description="""Verbose. 0: nothing. 1: basic. 2: extended.""", mandatory=False, default_value=param_default.verbose, example=['0', '1', '2']) return parser
def get_parser(): # initialize parameters param_default = ParamMoco(is_diffusion=True, group_size=3, metric='MI', smooth='1') # Initialize the parser parser = Parser(__file__) parser.usage.set_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') parser.add_option(name='-i', type_value='file', description='Diffusion data', mandatory=True, example='dmri.nii.gz') parser.add_option(name='-bvec', type_value='file', description='Bvecs file', mandatory=True, example='bvecs.nii.gz') parser.add_option(name='-bval', type_value='file', description='Bvals file', mandatory=False, example='bvals.nii.gz') parser.add_option( name='-bvalmin', type_value='float', description= 'B-value threshold (in s/mm2) below which data is considered as b=0.', mandatory=False, example='50') parser.add_option( name='-g', type_value='int', description='Group nvols successive dMRI volumes for more robustness.', mandatory=False, default_value=param_default.group_size, example=['2']) parser.add_option( name='-m', type_value='file', description= 'Binary mask to limit voxels considered by the registration metric.', mandatory=False, example=['dmri_mask.nii.gz']) parser.add_option( name='-param', type_value=[[','], 'str'], description= "Advanced parameters. Assign value with \"=\"; Separate arguments with \",\"\n" "poly [int]: Degree of polynomial function used for regularization along Z. For no regularization set to 0. Default=" + param_default.poly + ".\n" "smooth [mm]: Smoothing kernel. Default=" + param_default.smooth + ".\n" "metric {MI, MeanSquares, CC}: Metric used for registration. Default=" + param_default.metric + ".\n" "gradStep [float]: Searching step used by registration algorithm. The higher the more deformation allowed. Default=" + param_default.gradStep + ".\n" "sample [None or 0-1]: Sampling rate used for registration metric. Default=" + param_default.sampling + ".\n", mandatory=False) parser.add_option(name='-x', type_value='multiple_choice', description='Final Interpolation.', mandatory=False, default_value=param_default.interp, example=['nn', 'linear', 'spline']) parser.add_option(name='-ofolder', type_value='folder_creation', description='Output folder', mandatory=False, default_value=param_default.path_out, example='dmri_moco_results/') parser.usage.addSection('MISC') parser.add_option(name="-r", type_value="multiple_choice", description='Remove temporary files.', mandatory=False, default_value='1', example=['0', '1']) parser.add_option( name="-v", type_value='multiple_choice', description="verbose: 0 = nothing, 1 = classic, 2 = expended", mandatory=False, example=['0', '1', '2'], default_value='1') return parser
def get_parser(): # Initialize parser param_default = Param() parser = Parser(__file__) # Mandatory arguments parser.usage.set_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.") parser.add_option(name='-i', type_value='image_nifti', description='Diffusion data', mandatory=True, example='dmri.nii.gz') parser.add_option(name='-bvec', type_value='file', description='bvecs file', mandatory=True, example='bvecs.txt') # Optional arguments parser.add_option(name='-a', type_value='multiple_choice', description='average b=0 and DWI data.', mandatory=False, example=['0', '1'], default_value=str(param_default.average)) parser.add_option(name='-bval', type_value='file', description='bvals file. Used to identify low b-values (in case different from 0).', mandatory=False) parser.add_option(name='-bvalmin', type_value='float', description='B-value threshold (in s/mm2) below which data is considered as b=0.', mandatory=False, example='50') parser.add_option(name='-ofolder', type_value='folder_creation', description='Output folder.', mandatory=False, default_value='./') parser.add_option(name='-v', type_value='multiple_choice', description='Verbose.', mandatory=False, example=['0', '1'], default_value=str(param_default.verbose)) parser.add_option(name='-r', type_value='multiple_choice', description='remove temporary files.', mandatory=False, example=['0', '1'], default_value=str(param_default.remove_temp_files)) return parser
def get_parser(): param = Param() # Initialize the parser parser = Parser(__file__) parser.usage.set_description( 'Compute Diffusion Tensor Images (DTI) using dipy.') parser.add_option(name="-i", type_value="file", description="Input 4d file.", mandatory=True, example="dmri.nii.gz") parser.add_option(name="-bval", type_value="file", description="Bvals file.", mandatory=True, example="bvals.txt") parser.add_option(name="-bvec", type_value="file", description="Bvecs file.", mandatory=True, example="bvecs.txt") parser.add_option( name='-method', type_value='multiple_choice', description= 'Type of method to calculate the diffusion tensor:\nstandard: Standard equation [Basser, Biophys J 1994]\nrestore: Robust fitting with outlier detection [Chang, MRM 2005]', mandatory=False, default_value='standard', example=['standard', 'restore']) parser.add_option( name="-evecs", type_value="multiple_choice", description="""To output tensor eigenvectors, set to 1.""", mandatory=False, default_value='0', example=['0', '1']) parser.add_option( name='-m', type_value='file', description='Mask used to compute DTI in for faster processing.', mandatory=False, example='mask.nii.gz') parser.add_option(name='-o', type_value='str', description='Output prefix.', mandatory=False, default_value='dti_') parser.add_option( name="-v", type_value="multiple_choice", description="""Verbose. 0: nothing. 1: basic. 2: extended.""", mandatory=False, default_value=str(param.verbose), example=['0', '1', '2']) return parser
def get_parser(): """Initialize the parser.""" parser = Parser(__file__) parser.usage.set_description( """MS lesion Segmentation using convolutional networks. \n\nReference: C Gros, B De Leener, et al. Automatic segmentation of the spinal cord and intramedullary multiple sclerosis lesions with convolutional neural networks (2018). arxiv.org/abs/1805.06349""" ) parser.add_option(name="-i", type_value="image_nifti", description="input image.", mandatory=True, example="t1.nii.gz") parser.add_option( name="-c", type_value="multiple_choice", description= "type of image contrast. \nt2: T2w scan with isotropic or anisotropic resolution. \nt2_ax: T2w scan with axial orientation and thick slices. \nt2s: T2*w scan with axial orientation and thick slices.", mandatory=True, example=['t2', 't2_ax', 't2s']) parser.add_option( name="-centerline", type_value="multiple_choice", description= "Method used for extracting the centerline.\nsvm: automatic centerline detection, based on Support Vector Machine algorithm.\ncnn: automatic centerline detection, based on Convolutional Neural Network.\nviewer: semi-automatic centerline generation, based on manual selection of a few points using an interactive viewer, then approximation with NURBS.\nmanual: use an existing centerline by specifying its filename with flag -file_centerline (e.g. -file_centerline t2_centerline_manual.nii.gz).\n", mandatory=False, example=['svm', 'cnn', 'viewer', 'manual'], default_value="svm") parser.add_option( name="-file_centerline", type_value="image_nifti", description= "Input centerline file (to use with flag -centerline manual).", mandatory=False, example="t2_centerline_manual.nii.gz") parser.add_option( name="-brain", type_value="multiple_choice", description= "indicate if the input image is expected to contain brain sections:\n1: contains brain section\n0: no brain section.\nTo indicate this parameter could speed the segmentation process. Note that this flag is only effective with -centerline cnn.", mandatory=False, example=["0", "1"], default_value="1") parser.add_option(name="-ofolder", type_value="folder_creation", description="output folder.", mandatory=False, example="My_Output_Folder/", default_value="") parser.add_option(name="-r", type_value="multiple_choice", description="remove temporary files.", mandatory=False, example=['0', '1'], default_value='1') parser.add_option(name="-v", type_value="multiple_choice", description="1: display on, 0: display off (default)", mandatory=False, example=["0", "1"], default_value="1") parser.add_option(name='-igt', type_value='image_nifti', description='File name of ground-truth segmentation.', mandatory=False) return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) # initialize default parameters param_default = Param() parser.usage.set_description( 'Smooth the spinal cord along its centerline. Steps are:\n' '1) Spinal cord is straightened (using centerline),\n' '2) a Gaussian kernel is applied in the superior-inferior direction,\n' '3) then cord is de-straightened as originally.\n') parser.add_option(name="-i", type_value="file", description="Image to smooth", mandatory=True, example='data.nii.gz') parser.add_option(name="-s", type_value="file", description="Spinal cord centerline or segmentation", mandatory=True, example='data_centerline.nii.gz') parser.add_option(name="-c", type_value=None, description="Spinal cord centerline or segmentation", mandatory=False, deprecated_by='-s') parser.add_option( name="-smooth", type_value="int", description="Sigma of the smoothing Gaussian kernel (in mm).", mandatory=False, default_value=3, example='2') parser.add_option( name='-param', type_value=[[','], 'str'], description= "Advanced parameters. Assign value with \"=\"; Separate params with \",\"\n" "algo_fitting {hanning,nurbs}: Algorithm for curve fitting. For more information, see sct_straighten_spinalcord. Default=" + param_default.algo_fitting + ".\n", mandatory=False) parser.usage.addSection('MISC') parser.add_option(name="-r", type_value="multiple_choice", description='Remove temporary files.', mandatory=False, default_value='1', example=['0', '1']) parser.add_option( name="-v", type_value='multiple_choice', description="verbose: 0 = nothing, 1 = classic, 2 = expended", mandatory=False, example=['0', '1', '2'], default_value='1') return parser
def get_parser(paramregmulti=None): # Initialize the parser if paramregmulti is None: step0 = Paramreg(step='0', type='im', algo='syn', metric='MI', iter='0', shrink='1', smooth='0', gradStep='0.5', slicewise='0', dof='Tx_Ty_Tz_Rx_Ry_Rz') # only used to put src into dest space step1 = Paramreg(step='1', type='im') paramregmulti = ParamregMultiStep([step0, step1]) parser = Parser(__file__) parser.usage.set_description('This program co-registers two 3D volumes. The deformation is non-rigid and is ' 'constrained along Z direction (i.e., axial plane). Hence, this function assumes ' 'that orientation of the destination image is axial (RPI). If you need to register ' 'two volumes with large deformations and/or different contrasts, it is recommended to ' 'input spinal cord segmentations (binary mask) in order to achieve maximum robustness.' ' The program outputs a warping field that can be used to register other images to the' ' destination image. To apply the warping field to another image, use ' 'sct_apply_transfo') parser.add_option(name="-i", type_value="file", description="Image source.", mandatory=True, example="src.nii.gz") parser.add_option(name="-d", type_value="file", description="Image destination.", mandatory=True, example="dest.nii.gz") parser.add_option(name="-iseg", type_value="file", description="Segmentation source.", mandatory=False, example="src_seg.nii.gz") parser.add_option(name="-dseg", type_value="file", description="Segmentation destination.", mandatory=False, example="dest_seg.nii.gz") parser.add_option(name="-ilabel", type_value="file", description="Labels source.", mandatory=False) parser.add_option(name="-dlabel", type_value="file", description="Labels destination.", mandatory=False) parser.add_option(name='-initwarp', type_value='file', description='Initial warping field to apply to the source image.', mandatory=False) parser.add_option(name='-initwarpinv', type_value='file', description='Initial inverse warping field to apply to the destination image (only use if you wish to generate the dest->src warping field).', mandatory=False) parser.add_option(name="-m", type_value="file", description="Mask that can be created with sct_create_mask to improve accuracy over region of interest. " "This mask will be used on the destination image.", mandatory=False, example="mask.nii.gz") parser.add_option(name="-o", type_value="file_output", description="Name of output file.", mandatory=False, example="src_reg.nii.gz") parser.add_option(name='-owarp', type_value="file_output", description="Name of output forward warping field.", mandatory=False) parser.add_option(name="-param", type_value=[[':'], 'str'], description="Parameters for registration. Separate arguments with \",\". Separate steps with \":\".\n" "step: <int> Step number (starts at 1, except for type=label).\n" "type: {im, seg, imseg, label} type of data used for registration. Use type=label only at step=0.\n" "algo: Default=" + paramregmulti.steps['1'].algo + "\n" " translation: translation in X-Y plane (2dof)\n" " rigid: translation + rotation in X-Y plane (4dof)\n" " affine: translation + rotation + scaling in X-Y plane (6dof)\n" " syn: non-linear symmetric normalization\n" " bsplinesyn: syn regularized with b-splines\n" " slicereg: regularized translations (see: goo.gl/Sj3ZeU)\n" " centermass: slicewise center of mass alignment (seg only).\n" " centermassrot: slicewise center of mass and rotation alignment using method specified in 'rot_method'\n" " columnwise: R-L scaling followed by A-P columnwise alignment (seg only).\n" "slicewise: <int> Slice-by-slice 2d transformation. Default=" + paramregmulti.steps['1'].slicewise + "\n" "metric: {CC,MI,MeanSquares}. Default=" + paramregmulti.steps['1'].metric + "\n" "iter: <int> Number of iterations. Default=" + paramregmulti.steps['1'].iter + "\n" "shrink: <int> Shrink factor (only for syn/bsplinesyn). Default=" + paramregmulti.steps['1'].shrink + "\n" "smooth: <int> Smooth factor (in mm). Note: if algo={centermassrot,columnwise} the smoothing kernel is: SxSx0. Otherwise it is SxSxS. Default=" + paramregmulti.steps['1'].smooth + "\n" "laplacian: <int> Laplacian filter. Default=" + paramregmulti.steps['1'].laplacian + "\n" "gradStep: <float> Gradient step. Default=" + paramregmulti.steps['1'].gradStep + "\n" "deformation: ?x?x?: Restrict deformation (for ANTs algo). Replace ? by 0 (no deformation) or 1 (deformation). Default=" + paramregmulti.steps['1'].deformation + "\n" "init: Initial translation alignment based on:\n" " geometric: Geometric center of images\n" " centermass: Center of mass of images\n" " origin: Physical origin of images\n" "poly: <int> Polynomial degree of regularization (only for algo=slicereg). Default=" + paramregmulti.steps['1'].poly + "\n" "filter_size: <float> Filter size for regularization (only for algo=centermassrot). Default=" + str(paramregmulti.steps['1'].filter_size) + "\n" "smoothWarpXY: <int> Smooth XY warping field (only for algo=columnwize). Default=" + paramregmulti.steps['1'].smoothWarpXY + "\n" "pca_eigenratio_th: <int> Min ratio between the two eigenvalues for PCA-based angular adjustment (only for algo=centermassrot and rot_method=pca). Default=" + paramregmulti.steps['1'].pca_eigenratio_th + "\n" "dof: <str> Degree of freedom for type=label. Separate with '_'. Default=" + paramregmulti.steps['0'].dof + "\n" + paramregmulti.steps['1'].rot_method + "\n" "rot_method {pca, hog, pcahog}: rotation method to be used with algo=centermassrot. pca: approximate cord segmentation by an ellipse and finds it orientation using PCA's eigenvectors; hog: finds the orientation using the symmetry of the image; pcahog: tries method pca and if it fails, uses method hog. If using hog or pcahog, type should be set to imseg.", mandatory=False, example="step=1,type=seg,algo=slicereg,metric=MeanSquares:step=2,type=im,algo=syn,metric=MI,iter=5,shrink=2") parser.add_option(name="-identity", type_value="multiple_choice", description="just put source into destination (no optimization).", mandatory=False, default_value='0', example=['0', '1']) parser.add_option(name="-z", type_value="int", description="""size of z-padding to enable deformation at edges when using SyN.""", mandatory=False, default_value=Param().padding) parser.add_option(name="-x", type_value="multiple_choice", description="""Final interpolation.""", mandatory=False, default_value='linear', example=['nn', 'linear', 'spline']) parser.add_option(name="-ofolder", type_value="folder_creation", description="Output folder", mandatory=False, example='reg_results/') parser.add_option(name='-qc', type_value='folder_creation', description='The path where the quality control generated content will be saved', default_value=None) parser.add_option(name='-qc-dataset', type_value='str', description='If provided, this string will be mentioned in the QC report as the dataset the process was run on', ) parser.add_option(name='-qc-subject', type_value='str', description='If provided, this string will be mentioned in the QC report as the subject the process was run on', ) parser.add_option(name="-r", type_value="multiple_choice", description="""Remove temporary files.""", mandatory=False, default_value='1', example=['0', '1']) parser.add_option(name="-v", type_value="multiple_choice", description="""Verbose.""", mandatory=False, default_value='1', example=['0', '1', '2']) return parser
def get_parser(): # Initialize parser parser = Parser(__file__) # Mandatory arguments parser.usage.set_description( 'Tools to crop an image. Either through command line or GUI') parser.add_option(name="-i", type_value="image_nifti", description="input image.", mandatory=True, example="t2.nii.gz") parser.add_option( name="-g", type_value="multiple_choice", description="1: use the GUI to crop, 0: use the command line to crop", mandatory=False, example=['0', '1'], default_value='0') # Command line mandatory arguments parser.usage.addSection("\nCOMMAND LINE RELATED MANDATORY ARGUMENTS") parser.add_option( name="-o", type_value="file_output", description= "output image. This option is REQUIRED for the command line execution", mandatory=False, example=['t1', 't2']) # Optional arguments section parser.add_option(name="-v", type_value="multiple_choice", description="1: display on, 0: display off (default)", mandatory=False, example=['0', '1'], default_value='1') parser.add_option(name="-h", type_value=None, description="Displays help", mandatory=False) # GUI optional argument parser.usage.addSection("\nGUI RELATED OPTIONAL ARGUMENTS") parser.add_option(name="-r", type_value="multiple_choice", description="Remove temporary files. Default = 1", mandatory=False, example=['0', '1']) # Command line optional arguments parser.usage.addSection("\nCOMMAND LINE RELATED OPTIONAL ARGUMENTS") parser.add_option(name="-m", type_value="file", description="cropping around the mask", mandatory=False) parser.add_option( name="-start", type_value=[[','], 'float'], description="start slices, ]0,1[: percentage, 0 & >1: slice number", mandatory=False, example="40,30,5") parser.add_option( name="-end", type_value=[[','], 'float'], description= "end slices, ]0,1[: percentage, 0: last slice, >1: slice number, <0: last slice - value", mandatory=False, example="60,100,10") parser.add_option( name="-dim", type_value=[[','], 'int'], description="dimension to crop, from 0 to n-1, default is 1", mandatory=False, example="0,1,2") parser.add_option( name="-shift", type_value=[[','], 'int'], description="adding shift when used with mask, default is 0", mandatory=False, example="10,10,5") parser.add_option( name="-b", type_value="float", description= "replace voxels outside cropping region with background value. \n" "If both the -m and the -b flags are used : the image is croped \"exactly\" around the mask with a background (and not around a rectangle area including the mask). the shape of the image isn't change.", mandatory=False) parser.add_option( name="-bmax", type_value=None, description= "maximize the cropping of the image (provide -dim if you want to specify the dimensions)", mandatory=False) parser.add_option( name="-ref", type_value="file", description= "crop input image based on reference image (works only for 3D images)", mandatory=False, example="ref.nii.gz") parser.add_option(name="-mesh", type_value="file", description="mesh to crop", mandatory=False) parser.add_option(name="-rof", type_value="multiple_choice", description="remove output file created when cropping", mandatory=False, default_value='0', example=['0', '1']) parser.add_option( name="-bzmax", type_value=None, description= "maximize the cropping of the image (provide -dim if you want to specify the dimensions)", deprecated_by="-bmax", mandatory=False) return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description( 'Compute the Hausdorff\'s distance between two binary images which can be thinned (ie skeletonized)' 'If only one image is inputted, it will be only thinned') parser.add_option( name="-i", type_value="file", description="First Image on which you want to find the skeleton", mandatory=True, example='t2star_manual_gmseg.nii.gz') parser.add_option( name="-d", type_value="file", description="Second Image on which you want to find the skeleton", mandatory=False, default_value=None, example='t2star_manual_gmseg.nii.gz') parser.add_option( name="-r", type_value=None, description="Second Image on which you want to find the skeleton", mandatory=False, deprecated_by='-d') parser.add_option( name="-thinning", type_value="multiple_choice", description= "Thinning : find the skeleton of the binary images using the Zhang-Suen algorithm (1984) and use it to compute the hausdorff's distance", mandatory=False, default_value=1, example=['0', '1']) parser.add_option( name="-t", type_value=None, description= "Thinning : find the skeleton of the binary images using the Zhang-Suen algorithm (1984) and use it to compute the hausdorff's distance", deprecated_by="-thinning", mandatory=False) parser.add_option(name="-resampling", type_value="float", description="pixel size in mm to resample to", mandatory=False, default_value=0.1, example=0.5) parser.add_option(name="-o", type_value="file_output", description="Name of the output file", mandatory=False, default_value='hausdorff_distance.txt', example='my_hausdorff_dist.txt') parser.add_option( name="-v", type_value="int", description="verbose: 0 = nothing, 1 = classic, 2 = expended", mandatory=False, default_value=0, example='1') return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description( 'Extraction of grey level co-occurence matrix (GLCM) texture features from an image within a given mask. The textures features are those defined in the sckit-image implementation: http://scikit-image.org/docs/dev/api/skimage.feature.html#greycoprops. This function outputs one nifti file per texture metric (' + ParamGLCM().feature + ') and per orientation called fnameInput_feature_distance_angle.nii.gz. Also, a file averaging each metric across the angles, called fnameInput_feature_distance_mean.nii.gz, is output.' ) parser.add_option(name="-i", type_value="file", description="Image to analyze.", mandatory=True, example='t2.nii.gz') parser.add_option(name="-m", type_value="file", description="Image mask (e.g., lesion, spinal cord).", mandatory=True, example='t2_seg.nii.gz') parser.add_option( name="-feature", type_value="str", description= "List of GLCM texture features (separate arguments with \",\").", mandatory=False, default_value=ParamGLCM().feature, example="energy,contrast") parser.add_option( name="-distance", type_value="int", description= "Distance offset for GLCM computation, in pixel (suggested distance values between 1 and 5).", mandatory=False, default_value=ParamGLCM().distance, example=1) parser.add_option( name="-angle", type_value="str", description= "List of angles for GLCM computation, separate arguments with \",\", in degrees (suggested distance values between 0 and 179).", mandatory=False, default_value=ParamGLCM().angle, example='0,90') parser.add_option( name="-dim", type_value='multiple_choice', description= "Compute the texture on the axial (ax), sagittal (sag) or coronal (cor) slices.", mandatory=False, default_value=Param().dim, example=['ax', 'sag', 'cor']) parser.add_option(name="-ofolder", type_value="folder_creation", description="Output folder.", mandatory=False, default_value=Param().path_results, example='/my_texture/') parser.add_option(name="-igt", type_value="image_nifti", description="File name of ground-truth texture metrics.", mandatory=False) parser.add_option(name="-r", type_value="multiple_choice", description="Remove temporary files.", mandatory=False, default_value=str(int(Param().rm_tmp)), example=['0', '1']) parser.add_option( name="-v", type_value='multiple_choice', description="Verbose: 0 = nothing, 1 = classic, 2 = expended.", mandatory=False, example=['0', '1', '2'], default_value=str(Param().verbose)) return parser
def get_parser(): # parser initialisation parser = Parser(__file__) # initialize parameters param_default = Param() parser.usage.set_description("""Motion correction of fMRI data. Some robust features include: - group-wise (-g) - slice-wise regularized along z using polynomial function (-p) For more info about the method, type: isct_antsSliceRegularizedRegistration - masking (-m) - iterative averaging of target volume""") parser.add_option(name='-i', type_value='image_nifti', description='4D data', mandatory=True, example='fmri.nii.gz') parser.add_option(name='-g', type_value='int', description='Group nvols successive fMRI volumes for more robustness.', mandatory=False, default_value=param_default.group_size) parser.add_option(name='-m', type_value='image_nifti', description='Binary mask to limit voxels considered by the registration metric.', mandatory=False) parser.add_option(name='-param', type_value=[[','], 'str'], description="Advanced parameters. Assign value with \"=\"; Separate arguments with \",\"\n" "poly [int]: Degree of polynomial function used for regularization along Z. For no regularization set to 0. Default=" + param_default.poly + ".\n" "smooth [mm]: Smoothing kernel. Default=" + param_default.smooth + ".\n" "iter [int]: Number of iterations. Default=" + param_default.iter + ".\n" "metric {MI, MeanSquares, CC}: Metric used for registration. Default=" + param_default.metric + ".\n" "gradStep [float]: Searching step used by registration algorithm. The higher the more deformation allowed. Default=" + param_default.gradStep + ".\n" "sampling [0-1]: Sampling rate used for registration metric. Default=" + param_default.sampling + ".\n" "numTarget [int]: Target volume or group (starting with 0). Default=" + param_default.num_target + ".\n" "iterAvg [int]: Iterative averaging: Target volume is a weighted average of the previously-registered volumes. Default=" + str(param_default.iterAvg) + ".\n", mandatory=False) parser.add_option(name='-ofolder', type_value='folder_creation', description='Output path.', mandatory=False, default_value='./') parser.add_option(name="-x", type_value="multiple_choice", description="""Final interpolation.""", mandatory=False, default_value='linear', example=['nn', 'linear', 'spline']) parser.add_option(name="-r", type_value="multiple_choice", description="""Remove temporary files.""", mandatory=False, default_value='1', example=['0', '1']) parser.add_option(name="-v", type_value="multiple_choice", description="""Verbose.""", mandatory=False, default_value='1', example=['0', '1', '2']) return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Create mask along z direction.') parser.add_option( name='-i', type_value='file', description= 'Image to create mask on. Only used to get header. Must be 3D.', mandatory=True, example='data.nii.gz') parser.add_option( name='-p', type_value=[[','], 'str'], description='Process to generate mask.\n' 'coord: X,Y coordinate of center of mask. E.g.: coord,20x15\n' 'point: volume that contains a single point. E.g.: point,label.nii.gz\n' 'center: mask is created at center of FOV.\n' 'centerline: volume that contains centerline or segmentation. E.g.: centerline,t2_seg.nii.gz', mandatory=True, default_value=param_default.process, example=['centerline,data_centerline.nii.gz']) parser.add_option( name='-m', type_value=None, description='Process to generate mask and associated value.\n' ' coord: X,Y coordinate of center of mask. E.g.: coord,20x15' ' point: volume that contains a single point. E.g.: point,label.nii.gz' ' center: mask is created at center of FOV. In that case, "val" is not required.' ' centerline: volume that contains centerline. E.g.: centerline,my_centerline.nii', mandatory=False, deprecated_by='-p') parser.add_option( name='-size', type_value='str', description= 'Size of the mask in the axial plane, given in pixel (ex: 35) or in millimeter (ex: 35mm). If shape=gaussian, size corresponds to "sigma"', mandatory=False, default_value=param_default.size, example=['45']) parser.add_option( name='-s', type_value=None, description= 'Size in voxel. Odd values are better (for mask to be symmetrical). If shape=gaussian, size corresponds to "sigma"', mandatory=False, deprecated_by='-size') parser.add_option(name='-f', type_value='multiple_choice', description='Shape of the mask.', mandatory=False, default_value=param_default.shape, example=param.shape_list) parser.add_option(name='-o', type_value='file_output', description='Name of output mask.', mandatory=False, example=['data.nii']) parser.add_option(name="-r", type_value="multiple_choice", description='Remove temporary files.', mandatory=False, default_value='1', example=['0', '1']) parser.add_option( name="-v", type_value='multiple_choice', description="verbose: 0 = nothing, 1 = classic, 2 = expended", mandatory=False, example=['0', '1', '2'], default_value='1') return parser
def get_parser(): # parser initialisation parser = Parser(__file__) parser.usage.set_description('''This program automatically detect the spinal cord in a MR image and output a centerline of the spinal cord.''') parser.add_option(name="-i", type_value="file", description="input image.", mandatory=True, example="t2.nii.gz") parser.add_option(name="-seg", type_value="file", description="Segmentation or centerline of the spinal cord.", mandatory=True, example="t2_seg.nii.gz") parser.add_option(name="-t", type_value="multiple_choice", description="Image contrast: t2: cord dark / CSF bright ; t1: cord bright / CSF dark", mandatory=True, example=["t1", "t2"]) # parser.add_option(name="-seg", # type_value="file", # description="input image.", # mandatory=True, # example="segmentation.nii.gz") parser.add_option(name="-v", type_value="multiple_choice", description="""Verbose. 0: nothing. 1: basic. 2: extended.""", mandatory=False, default_value=param.verbose, example=['0', '1', '2']) parser.add_option(name="-h", type_value=None, description="display this help", mandatory=False) return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) # initialize default parameters param_default = Param() parser.usage.set_description('Smooth the spinal cord along its centerline. Steps are:\n' '1) Spinal cord is straightened (using centerline),\n' '2) a Gaussian kernel is applied in the superior-inferior direction,\n' '3) then cord is de-straightened as originally.\n') parser.add_option(name="-i", type_value="file", description="Image to smooth", mandatory=True, example='data.nii.gz') parser.add_option(name="-s", type_value="file", description="Spinal cord centerline or segmentation", mandatory=True, example='data_centerline.nii.gz') parser.add_option(name="-c", type_value=None, description="Spinal cord centerline or segmentation", mandatory=False, deprecated_by='-s') parser.add_option(name="-smooth", type_value=[[','], 'float'], description='Sigma (standard deviation) of the smoothing Gaussian kernel (in mm). For isotropic ' 'smoothing you only need to specify a value (e.g. 2). For anisotropic smoothing ' 'specify a value for each axis, separated with a comma. The order should follow axes ' 'Right-Left, Antero-Posterior, Superior-Inferior (e.g.: 1,1,3). For no smoothing, set ' 'value to 0.', mandatory=False, default_value=[0, 0, 3]) parser.add_option(name='-param', type_value=[[','], 'str'], description="Advanced parameters. Assign value with \"=\"; Separate params with \",\"\n" "algo_fitting {bspline, polyfit}: Algorithm for curve fitting. For more information, see sct_straighten_spinalcord. Default="+ param_default.algo_fitting + ".\n", mandatory=False) parser.usage.addSection('MISC') parser.add_option(name="-r", type_value="multiple_choice", description='Remove temporary files.', mandatory=False, default_value='1', example=['0', '1']) parser.add_option(name="-v", type_value='multiple_choice', description="verbose: 0 = nothing, 1 = classic, 2 = expended", mandatory=False, example=['0', '1', '2'], default_value='1') return parser
def get_parser(): # Initialize the parser parser = Parser(__file__) parser.usage.set_description( 'Detection of the Ponto-Medullary Junction (PMJ).\n' ' This method is machine-learning based and adapted for T1w-like or T2w-like images.\n' ' If the PMJ is detected from the input image, a nifti mask is output ("*_pmj.nii.gz")\n' ' with one voxel (value=50) located at the predicted PMJ position.\n' ' If the PMJ is not detected, nothing is output.') parser.add_option(name="-i", type_value="file", description="input image.", mandatory=True, example="t2.nii.gz") parser.add_option( name="-c", type_value="multiple_choice", description= "type of image contrast, if your contrast is not in the available options (t1, t2), use t1 (cord bright / CSF dark) or t2 (cord dark / CSF bright)", mandatory=True, example=["t1", "t2"]) parser.add_option( name="-s", type_value="file", description= "SC segmentation or centerline mask. Provide this mask helps the detection of the PMJ by indicating the position of the SC in the Right-to-Left direction.", mandatory=False, example="t2_seg.nii.gz") parser.add_option(name="-ofolder", type_value="folder_creation", description="Output folder", mandatory=False, example="My_Output_Folder/") parser.add_option( name='-qc', type_value='folder_creation', description= 'The path where the quality control generated content will be saved', default_value=None) parser.add_option( name="-igt", type_value="image_nifti", description="File name of ground-truth PMJ (single voxel).", mandatory=False) parser.add_option(name="-r", type_value="multiple_choice", description="Remove temporary files.", mandatory=False, default_value="1", example=["0", "1"]) parser.add_option( name="-v", type_value='multiple_choice', description="Verbose: 0 = nothing, 1 = classic, 2 = expended", mandatory=False, example=["0", "1", "2"], default_value="1") return parser