def handle_arg(): """ Handle command-line application arguments. """ # :: Create Argument Parser arg_parser = argparse.ArgumentParser( description=__doc__, epilog='v.{} - {}\n{}'.format( INFO['version'], INFO['author'], INFO['license']), 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 # nothing here yet! # avoid mandatory arguments whenever possible arg_parser.add_argument( '-m', '--mode', nargs=2, default=('t1', 'tr'), help='set display/calculation mode [%(default)s]') return arg_parser
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('--t1', metavar='X', type=float, default=1000, help='set the T1 value in ms [%(default)s]') arg_parser.add_argument('--tr', metavar='X', type=float, default=100, help='set the TR value in ms [%(default)s]') arg_parser.add_argument('--fa', metavar='X', type=float, default=None, help='set the FA value in deg [%(default)s]') return arg_parser
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('-d', '--dir', metavar='DIR', default='.', help='set working directory [%(default)s]') arg_parser.add_argument('-e', '--extradir', metavar='FOLDER', default='nifti', help='set output subdirectory [%(default)s]') return arg_parser
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( '-n', '--name', metavar='NAME', default=None, choices=AVAILABLES, help='playground selection (from: %(choices)s) [%(default)s]') return arg_parser
def handle_arg(): """ Handle command-line application arguments. """ # :: Create Argument Parser arg_parser = argparse.ArgumentParser( description=__doc__, epilog='v.{} - {}\n{}'.format(INFO['version'], INFO['author'], INFO['license']), 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( '-i', '--indirect', action='store_true', help='use acquisition params instead of sequence params [%(default)s]') return arg_parser
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('-d', '--dirpath', metavar='DIR', default='.', help='set working directory [%(default)s]') arg_parser.add_argument('-n', '--val_name', metavar='NAME', default=None, help='set values name ( [%(default)s]') arg_parser.add_argument('-a', '--val_interval', metavar=('MIN', 'MAX'), type=float, nargs=2, default=None, help='set interval of values [%(default)s]') arg_parser.add_argument('-u', '--val_units', metavar='UNITS', default=None, help='set units for values [%(default)s]') arg_parser.add_argument('-m', '--mask_filepath', metavar='FILE', default=None, help='set exact mask file [%(default)s]') arg_parser.add_argument( '--reg_ref_ext', metavar='FILE_EXT', default=pml.EXT['reg_ref'], help='file extension of registration reference flag [%(default)s]') arg_parser.add_argument( '--corr_ref_ext', metavar='FILE_EXT', default=pml.EXT['corr_ref'], help='file extension of correlation reference flag [%(default)s]') arg_parser.add_argument( '--tmp_dir', metavar='SUBDIR', default='tmp', help='subdirectory where to store temporary files [%(default)s]') arg_parser.add_argument( '--reg_dir', metavar='SUBDIR', default='reg', help='subdirectory where to store registration files [%(default)s]') arg_parser.add_argument( '--msk_dir', metavar='SUBDIR', default='msk', help='subdirectory where to store masking files [%(default)s]') arg_parser.add_argument( '--cmp_dir', metavar='SUBDIR', default='cmp', help='subdirectory where to store comparing files [%(default)s]') arg_parser.add_argument( '--fig_dir', metavar='SUBDIR', default='fig', help='subdirectory where to store figures [%(default)s]') return arg_parser
def plot(fig, params=None, title=TITLE.split(':')[1].strip()): axs = fig.subplots(1, 1, squeeze=False, sharex='row', sharey='row') te = params['te'] = np.linspace(params['te_start'], params['te_stop'], params['te_num']) params['rest_tissue_m0'] = _normalize_qty(params, 'rest_', '_m0') params['actv_tissue_m0'] = _normalize_qty(params, 'actv_', '_m0') rest = group_params('rest', params) actv = group_params('actv', params) both = group_params('both', params) if params['mode'] == 'No MT': both['mtr'] = dict(arterial=0.0, capillary=0.0, venous=0.0, tissue=0.0) ss_rest = signals_perfusion(rest['m0'], rest['t1'], rest['t2s'], params['fa'], params['tr'], params['te'], rest['perfusion'], both['mtr'], both['wc']) ss_actv = signals_perfusion(actv['m0'], actv['t1'], actv['t2s'], params['fa'], params['tr'], params['te'], actv['perfusion'], both['mtr'], both['wc']) ds = ss_actv - ss_rest if params['mode'] == 'Difference': mtoff = dict(arterial=0.0, capillary=0.0, venous=0.0, tissue=0.0) ss_rest_mtoff = signals_perfusion(rest['m0'], rest['t1'], rest['t2s'], params['fa'], params['tr'], params['te'], rest['perfusion'], mtoff, both['wc']) ss_actv_mtoff = signals_perfusion(actv['m0'], actv['t1'], actv['t2s'], params['fa'], params['tr'], params['te'], actv['perfusion'], mtoff, both['wc']) ds_mton = ds ds_mtoff = ss_actv_mtoff - ss_rest_mtoff ds = ds_mtoff - ds_mton ds_tot = np.sum(ds, axis=0) if params['mode'] == 'Difference': te_i = np.argmin(np.abs(ds_tot)) te_name = 'Zero Crossing' title = 'Difference Signal Variation upon Activation' else: te_i = np.argmax(ds_tot) te_name = 'Optimal' title = 'Signal Variation upon Activation' colors = dict( arterial='#cc3333', capillary='#cc66cc', venous='#3333cc', tissue='#33cc33', ) ax = axs[0, 0] for j, name in enumerate(COMPARTMENTS): if params['show_' + name]: ax.plot(te, ds[j], label=name.title(), color=colors[name]) if params['show_total']: ax.plot(te, ds_tot, label='Total', color='#000000') if params['show_opt']: ax.axvline(x=te[te_i], color='#999999', linestyle='dashed') title += fmt( '\n' + te_name + ' $T_{{E}} = {:.1f}\\pm{:.1f}\\;\\mathrm{{ms}}$', te[te_i], te[1] - te[0]) params['tes_meas'] = [params[f'te{i}_meas'] for i in range(1, 4)] for te_meas in params['tes_meas']: ax.axvline(x=te_meas, color='#cccccc', linestyle='dotted') ax.set_title(title) ax.legend() ax.set_ylabel('$\\Delta S$ / arb. units') ax.set_xlabel('$T_E$ / ms') if params['y_min'] != params['y_max']: ax.set_ylim([params['y_min'], params['y_max']])
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_filepaths', metavar=('MAG_FILE', 'PHS_FILE'), nargs=2, default=('mag_coils.nii.gz', 'phs_coils.nii.gz'), help='set input magnitude and phase filepaths [%(default)s]') arg_parser.add_argument( '-o', '--out_filepaths', metavar=('MAG_FILE', 'PHS_FILE'), nargs=2, default=('mag.nii.gz', 'phs.nii.gz'), help='set output magnitude and phase filepaths [%(default)s]') arg_parser.add_argument( '-p', '--q_filepath', metavar='FILE', default=None, help='set output quality metric filepath [%(default)s]') arg_parser.add_argument('-m', '--method', metavar='STR', default='block_adaptive_iter', help=' [%(default)s]') arg_parser.add_argument( '-mk', '--method_kws', metavar='STR', default=None, help='Additional keyword parameters for the method [%(default)s]') arg_parser.add_argument('-c', '--compression', metavar='STR', default='compress_svd', help=' [%(default)s]') arg_parser.add_argument( '-ck', '--compression_kws', metavar='STR', default=None, help='Additional keyword parameters for the compression [%(default)s]') arg_parser.add_argument( '-a', '--coil_axis', metavar='N', default=-1, help='Axis along which the single coils are stored [%(default)s]') arg_parser.add_argument( '-s', '--split_axis', metavar='N', default=None, help='Axis along which input shall be split [%(default)s]') return arg_parser
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', '--input', metavar='DIR', default='.', help='set input directory [%(default)s]') arg_parser.add_argument('-o', '--output', metavar='DIR', default='.', help='set output directory [%(default)s]') arg_parser.add_argument( '-r', '--recursive', action='store_true', help='Force descending into subdirectories [%(default)s]') arg_parser.add_argument('-e', '--meta_subpath', metavar='DIR', default=pmc.META_EXT, help='set extra input subdirectory [%(default)s]') arg_parser.add_argument('-a', '--data_subpath', metavar='DIR', default='nii', help='set extra input subdirectory [%(default)s]') arg_parser.add_argument( '-m', '--method', metavar='METHOD', default='generic', help='set computation target and method [%(default)s]') arg_parser.add_argument( '-n', '--options', metavar='OPTS', default='{}', help='set JSON-formatted options dictionary [%(default)s]') return arg_parser
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', '--input', metavar='FILE', default=None, required=True, help='set input filepath [%(default)s]') arg_parser.add_argument('-o', '--output', metavar='FILE', default=None, help='set output filepath [%(default)s]') arg_parser.add_argument( '-s', '--smoothing', metavar='SIGMA', type=float, default=0.0, help='value of Gaussian smoothing\'s sigma [%(default)s]') arg_parser.add_argument('-a', '--threshold', metavar='METHOD|X', default='otsu', help='thresholding method or value [%(default)s]') arg_parser.add_argument('-A', '--threshold_opts', metavar='JSON', default='{"bins":"sqrt"}', help='comparison directive [%(default)s]') arg_parser.add_argument('-c', '--comparison', metavar='">"|">="|"<"|"<="|"="|"!="', default='>', help='comparison directive [%(default)s]') arg_parser.add_argument( '-e', '--erosion_iter', metavar='N', type=int, default=0, help='number of postprocess binary erosion iterations [%(default)s]') arg_parser.add_argument( '-d', '--dilation_iter', metavar='N', type=int, default=0, help='number of postprocess binary dilation iterations [%(default)s]') arg_parser.add_argument('-t', '--dtype', metavar='TYPE', default='int', help='data type of the output [%(default)s]') return arg_parser