本文整理汇总了Python中msct_parser.Parser类的典型用法代码示例。如果您正苦于以下问题:Python Parser类的具体用法?Python Parser怎么用?Python Parser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_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='-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
示例2: get_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
示例3: get_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
示例4: get_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
示例5: get_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
示例6: get_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
示例7: get_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
示例8: get_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
示例9: get_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
示例10: get_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
示例11: get_data_or_scalar
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
示例12: get_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
示例13: get_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',
'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
示例14: get_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
示例15: get_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