Exemple #1
0
def handle_arg():
    """
    Handle command-line application arguments.
    """
    # :: Create Argument Parser
    arg_parser = argparse.ArgumentParser(
        description=__doc__,
        epilog=fmtm('v.{version} - {author}\n{license}', INFO),
        formatter_class=argparse.RawDescriptionHelpFormatter)
    # :: Add POSIX standard arguments
    arg_parser.add_argument(
        '--ver',
        '--version',
        version=fmt(
            '%(prog)s - ver. {version}\n{}\n{copyright} {author}\n{notice}',
            next(line for line in __doc__.splitlines() if line), **INFO),
        action='version')
    arg_parser.add_argument(
        '-v',
        '--verbose',
        action='count',
        default=D_VERB_LVL,
        help='increase the level of verbosity [%(default)s]')
    # :: Add additional arguments
    arg_parser.add_argument('-f',
                            '--force',
                            action='store_true',
                            help='force new processing [%(default)s]')
    arg_parser.add_argument('-d',
                            '--dir',
                            metavar='DIR',
                            default='.',
                            help='set working directory [%(default)s]')
    arg_parser.add_argument('-l',
                            '--delay',
                            metavar='X',
                            type=float,
                            default=60.0,
                            help='set checking interval in min [%(default)s]')
    arg_parser.add_argument(
        '-r',
        '--delay_var',
        metavar='DX',
        type=float,
        default=5,
        help='set random variance in the delay as percentage [%(default)s]')
    arg_parser.add_argument(
        '-m',
        '--max_count',
        metavar='NUM',
        type=int,
        default=0,
        help='maximum number of actions to be performed [%(default)s]')
    arg_parser.add_argument(
        '-c',
        '--cmd',
        metavar='EXECUTABLE',
        default=os.path.dirname(__file__) + '/dcm_analyze_dir.py {}',
        help='execute when finding a new dir with DICOMs [%(default)s]')
    return arg_parser
Exemple #2
0
def handle_arg():
    """
    Handle command-line application arguments.
    """
    # :: Define DEFAULT values
    # verbosity
    d_verbose = D_VERB_LVL
    # default input directory
    d_input_dir = '.'
    # default output directory
    d_output_dir = '.'
    # default method
    d_method = 'pydicom'
    # :: Create Argument Parser
    arg_parser = argparse.ArgumentParser(
        description=__doc__,
        epilog=fmtm('v.{version} - {author}\n{license}', INFO),
        formatter_class=argparse.RawDescriptionHelpFormatter)
    # :: Add POSIX standard arguments
    arg_parser.add_argument(
        '--ver',
        '--version',
        version=fmt(
            '%(prog)s - ver. {version}\n{}\n{copyright} {author}\n{notice}',
            next(line for line in __doc__.splitlines() if line), **INFO),
        action='version')
    arg_parser.add_argument(
        '-v',
        '--verbose',
        action='count',
        default=d_verbose,
        help='increase the level of verbosity [%(default)s]')
    # :: Add additional arguments
    arg_parser.add_argument('-f',
                            '--force',
                            action='store_true',
                            help='force new processing [%(default)s]')
    arg_parser.add_argument('-i',
                            '--in_dirpath',
                            metavar='DIR',
                            default=d_input_dir,
                            help='set input directory [%(default)s]')
    arg_parser.add_argument('-o',
                            '--out_dirpath',
                            metavar='DIR',
                            default=d_output_dir,
                            help='set output directory [%(default)s]')
    arg_parser.add_argument('-m',
                            '--method',
                            metavar='METHOD',
                            default=d_method,
                            help='set extraction method [%(default)s]')
    arg_parser.add_argument('-t',
                            '--type_ext',
                            action='store_true',
                            help='add type extension [%(default)s]')
    return arg_parser
Exemple #3
0
def handle_arg():
    """
    Handle command-line application arguments.
    """
    # :: Create Argument Parser
    arg_parser = argparse.ArgumentParser(
        description=__doc__,
        epilog=fmtm('v.{version} - {author}\n{license}', INFO),
        formatter_class=argparse.RawDescriptionHelpFormatter)
    # :: Add POSIX standard arguments
    arg_parser.add_argument(
        '--ver',
        '--version',
        version=fmt(
            '%(prog)s - ver. {version}\n{}\n{copyright} {author}\n{notice}',
            next(line for line in __doc__.splitlines() if line), **INFO),
        action='version')
    arg_parser.add_argument(
        '-v',
        '--verbose',
        action='count',
        default=D_VERB_LVL,
        help='increase the level of verbosity [%(default)s]')
    # :: Add additional arguments
    arg_parser.add_argument('-f',
                            '--force',
                            action='store_true',
                            help='force new processing [%(default)s]')
    arg_parser.add_argument('-i',
                            '--in_dirpath',
                            metavar='DIR',
                            default='.',
                            help='set input directory [%(default)s]')
    arg_parser.add_argument('-o',
                            '--out_dirpath',
                            metavar='DIR',
                            default='.',
                            help='set output directory [%(default)s]')
    arg_parser.add_argument('-b',
                            '--basename',
                            metavar='NAME',
                            default='{name}_{date}_{time}_{sys}',
                            help='set output directory [%(default)s]')
    arg_parser.add_argument('-m',
                            '--method',
                            metavar='METHOD',
                            default='pydicom',
                            help='set extraction method [%(default)s]')
    arg_parser.add_argument('-a',
                            '--file_format',
                            metavar='METHOD',
                            default='pdf',
                            help='set output format [%(default)s]')
    return arg_parser
Exemple #4
0
def handle_arg():
    """
    Handle command-line application arguments.
    """
    # :: Create Argument Parser
    arg_parser = argparse.ArgumentParser(
        description=__doc__,
        epilog=fmtm('v.{version} - {author}\n{license}', INFO),
        formatter_class=argparse.RawDescriptionHelpFormatter)
    # :: Add POSIX standard arguments
    arg_parser.add_argument(
        '--ver', '--version',
        version=fmt(
            '%(prog)s - ver. {version}\n{}\n{copyright} {author}\n{notice}',
            next(line for line in __doc__.splitlines() if line), **INFO),
        action='version')
    arg_parser.add_argument(
        '-v', '--verbose',
        action='count', default=D_VERB_LVL,
        help='increase the level of verbosity [%(default)s]')
    arg_parser.add_argument(
        '-q', '--quiet',
        action='store_true',
        help='override verbosity settings to suppress output [%(default)s]')
    # :: Add additional arguments
    arg_parser.add_argument(
        '-f', '--force',
        action='store_true',
        help='force new processing [%(default)s]')
    arg_parser.add_argument(
        '-i', '--in_dirpath', metavar='DIR',
        default='.',
        help='set input directory [%(default)s]')
    arg_parser.add_argument(
        '-o', '--out_dirpath', metavar='DIR',
        default='.',
        help='set output directory [%(default)s]')
    arg_parser.add_argument(
        '-n', '--name', metavar='STR',
        default='{name}_{date}_{time}_{sys}',
        help='set output directory [%(default)s]')
    arg_parser.add_argument(
        '-m', '--method', metavar='tlz|tgz|tbz2|7z|zip|txz',
        default='tlz',
        help='set compression method [%(default)s]')
    arg_parser.add_argument(
        '-k', '--keep',
        action='store_true',
        help='Keep DICOM sources after do_backup (and test). [%(default)s]')
    return arg_parser
Exemple #5
0
def handle_arg():
    """
    Handle command-line application arguments.
    """
    # :: Create Argument Parser
    arg_parser = argparse.ArgumentParser(
        description=__doc__,
        epilog=fmtm('v.{version} - {author}\n{license}', INFO),
        formatter_class=argparse.RawDescriptionHelpFormatter)
    # :: Add POSIX standard arguments
    arg_parser.add_argument(
        '--ver', '--version',
        version=fmt(
            '%(prog)s - ver. {version}\n{}\n{copyright} {author}\n{notice}',
            next(line for line in __doc__.splitlines() if line), **INFO),
        action='version')
    arg_parser.add_argument(
        '-v', '--verbose',
        action='count', default=D_VERB_LVL,
        help='increase the level of verbosity [%(default)s]')
    arg_parser.add_argument(
        '-q', '--quiet',
        action='store_true',
        help='override verbosity settings to suppress output [%(default)s]')
    # :: Add additional arguments
    arg_parser.add_argument(
        '-f', '--force',
        action='store_true',
        help='force new processing [%(default)s]')
    arg_parser.add_argument(
        '-i', '--in_dirpath', metavar='DIR',
        default='.',
        help='set input directory [%(default)s]')
    arg_parser.add_argument(
        '-o', '--out_dirpath', metavar='DIR',
        default='.',
        help='set output directory [%(default)s]')
    arg_parser.add_argument(
        '-m', '--method', metavar='copy|move|symlink|link',
        default='symlink',
        help='Move DICOM sources instead of copying [%(default)s]')
    arg_parser.add_argument(
        '-s', '--subpath',
        default='{study}/{name}_{date}_{time}_{sys}',
        help='Append DICOM-generated subpath to output [%(default)s]')
    arg_parser.add_argument(
        '-e', '--extra_subpath',
        default='dcm',
        help='Append static subpath to output [%(default)s]')
    return arg_parser
Exemple #6
0
def handle_arg():
    """
    Handle command-line application arguments.
    """
    # :: Create Argument Parser
    arg_parser = argparse.ArgumentParser(
        description=__doc__,
        epilog=fmtm('v.{version} - {author}\n{license}', INFO),
        formatter_class=argparse.RawDescriptionHelpFormatter)
    # :: Add POSIX standard arguments
    arg_parser.add_argument(
        '--ver',
        '--version',
        version=fmt(
            '%(prog)s - ver. {version}\n{}\n{copyright} {author}\n{notice}',
            next(line for line in __doc__.splitlines() if line), **INFO),
        action='version')
    arg_parser.add_argument(
        '-v',
        '--verbose',
        action='count',
        default=D_VERB_LVL,
        help='increase the level of verbosity [%(default)s]')
    # :: Add additional arguments
    arg_parser.add_argument('-f',
                            '--force',
                            action='store_true',
                            help='force new processing [%(default)s]')
    arg_parser.add_argument('-d',
                            '--dirpath',
                            metavar='DIR',
                            default='.',
                            help='set working directory [%(default)s]')
    arg_parser.add_argument(
        '-m',
        '--match',
        metavar='STR',
        default='{"_concat":"and","OperatorsName":"*****@*****.**"}',
        help='set a match in the DICOM information [%(default)s]')
    arg_parser.add_argument('-a',
                            '--action',
                            metavar='STR',
                            default='email+preprocess',
                            help='set action to perform [%(default)s]')
    return arg_parser
Exemple #7
0
def handle_arg():
    """
    Handle command-line application arguments.
    """
    # :: Create Argument Parser
    arg_parser = argparse.ArgumentParser(
        description=__doc__,
        epilog=fmtm('v.{version} - {author}\n{license}', INFO),
        formatter_class=argparse.RawDescriptionHelpFormatter)
    # :: Add POSIX standard arguments
    arg_parser.add_argument(
        '--ver',
        '--version',
        version=fmt(
            '%(prog)s - ver. {version}\n{}\n{copyright} {author}\n{notice}',
            next(line for line in __doc__.splitlines() if line), **INFO),
        action='version')
    arg_parser.add_argument(
        '-v',
        '--verbose',
        action='count',
        default=D_VERB_LVL,
        help='increase the level of verbosity [%(default)s]')
    # :: Add additional arguments
    arg_parser.add_argument('-d',
                            '--dirpath',
                            metavar='DIR',
                            default='.',
                            help='set working directory [%(default)s]')
    arg_parser.add_argument('-c',
                            '--dcm_info',
                            metavar='DIR',
                            default='{'
                            '"PatientID": null, '
                            '"PatientBirthDate": null, '
                            '"PatientName": null}',
                            help='set DICOM fields to update [%(default)s]')
    arg_parser.add_argument(
        '-b',
        '--backup_prefix',
        default=None,
        help='set prefix to be prepended to backup files [%(default)s]')
    return arg_parser
Exemple #8
0
def handle_arg():
    """
    Handle command-line application arguments.
    """
    # :: Create Argument Parser
    arg_parser = argparse.ArgumentParser(
        description=__doc__,
        epilog=fmtm('v.{version} - {author}\n{license}', INFO),
        formatter_class=argparse.RawDescriptionHelpFormatter)
    # :: Add POSIX standard arguments
    arg_parser.add_argument(
        '--ver',
        '--version',
        version=fmt(
            '%(prog)s - ver. {version}\n{}\n{copyright} {author}\n{notice}',
            next(line for line in __doc__.splitlines() if line), **INFO),
        action='version')
    arg_parser.add_argument(
        '-v',
        '--verbose',
        action='count',
        default=D_VERB_LVL,
        help='increase the level of verbosity [%(default)s]')
    # :: Add additional arguments
    arg_parser.add_argument('ui_mode',
                            nargs='?',
                            default='tui',
                            help='set UI mode [%(default)s]')
    arg_parser.add_argument('-f',
                            '--force',
                            action='store_true',
                            help='force new processing [%(default)s]')
    arg_parser.add_argument(
        '-c',
        '--config',
        metavar='FILE',
        default=CFG_FILENAME,
        help='set configuration file name/path [%(default)s]')
    return arg_parser
Exemple #9
0
def handle_arg():
    """
    Handle command-line application arguments.
    """
    # :: Create Argument Parser
    arg_parser = argparse.ArgumentParser(
        description=__doc__,
        epilog=fmtm('v.{version} - {author}\n{license}', INFO),
        formatter_class=argparse.RawDescriptionHelpFormatter)
    # :: Add POSIX standard arguments
    arg_parser.add_argument(
        '--ver',
        '--version',
        version=fmt(
            '%(prog)s - ver. {version}\n{}\n{copyright} {author}\n{notice}',
            next(line for line in __doc__.splitlines() if line), **INFO),
        action='version')
    arg_parser.add_argument(
        '-v',
        '--verbose',
        action='count',
        default=D_VERB_LVL,
        help='increase the level of verbosity [%(default)s]')
    # :: Add additional arguments
    arg_parser.add_argument('-f',
                            '--force',
                            action='store_true',
                            help='force new processing [%(default)s]')
    arg_parser.add_argument(
        '-s',
        '--summary',
        default=utl.D_SUMMARY + '.' + utl.EXT['json'],
        help='set expt. summary filepath (empty to skip) [%(default)s]')
    arg_parser.add_argument('-d',
                            '--dirpath',
                            metavar='DIR',
                            default='.',
                            help='set i/o directory path [%(default)s]')
    return arg_parser
Exemple #10
0
def handle_arg():
    """
    Handle command-line application arguments.
    """
    # :: Create Argument Parser
    arg_parser = argparse.ArgumentParser(
        description=__doc__,
        epilog=fmtm('v.{version} - {author}\n{license}', INFO),
        formatter_class=argparse.RawDescriptionHelpFormatter)
    # :: Add POSIX standard arguments
    arg_parser.add_argument(
        '--ver',
        '--version',
        version=fmt(
            '%(prog)s - ver. {version}\n{}\n{copyright} {author}\n{notice}',
            next(line for line in __doc__.splitlines() if line), **INFO),
        action='version')
    arg_parser.add_argument(
        '-v',
        '--verbose',
        action='count',
        default=D_VERB_LVL,
        help='increase the level of verbosity [%(default)s]')
    # :: Add additional arguments
    arg_parser.add_argument('-f',
                            '--force',
                            action='store_true',
                            help='force new processing [%(default)s]')
    arg_parser.add_argument('-i',
                            '--in_dirpath',
                            metavar='DIR',
                            default='.',
                            help='set input directory [%(default)s]')
    arg_parser.add_argument('-o',
                            '--out_dirpath',
                            metavar='DIR',
                            default='.',
                            help='set output directory [%(default)s]')
    arg_parser.add_argument(
        '-s',
        '--subpath',
        default=utl.TPL['acquire'],
        help='Append DICOM-generated subpath to output [%(default)s]')
    arg_parser.add_argument(
        '-n',
        '--niz_subpath',
        default=utl.ID['niz'],
        help='Sub-path for NIfTI extraction. Empty to skip [%(default)s]')
    arg_parser.add_argument(
        '-m',
        '--meta_subpath',
        default=utl.ID['meta'],
        help='Sub-path for META extraction. Empty to skip [%(default)s]')
    arg_parser.add_argument(
        '-p',
        '--prot_subpath',
        default=utl.ID['prot'],
        help='Sub-path for PROT extraction. Empty to skip [%(default)s]')
    arg_parser.add_argument(
        '-t',
        '--info_subpath',
        default=utl.ID['info'],
        help='Sub-path for INFO extraction. Empty to skip [%(default)s]')
    arg_parser.add_argument(
        '-r',
        '--report_subpath',
        default=utl.TPL['report'],
        help='Template for the report filename. Empty to skip [%(default)s]')
    arg_parser.add_argument(
        '-b',
        '--backup_subpath',
        default=utl.TPL['backup'],
        help='Template for the backup filename. Empty to skip [%(default)s]')
    return arg_parser