def _build_arg_parser(): p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawTextHelpFormatter) p.add_argument('in_sh', help='Path to the input file.') p.add_argument('out_sh', help='File name for averaged signal.') p.add_argument('--out_sym', default=None, help='Name of optional symmetric output. [%(default)s]') add_sh_basis_args(p) p.add_argument('--sphere', default='repulsion724', choices=sorted(SPHERE_FILES.keys()), help='Sphere used for the SH to SF projection. ' '[%(default)s]') p.add_argument('--sharpness', default=1.0, type=float, help='Specify sharpness factor to use for weighted average.' ' [%(default)s]') p.add_argument('--sigma', default=1.0, type=float, help='Sigma of the gaussian to use. [%(default)s]') add_verbose_arg(p) add_overwrite_arg(p) return p
def _build_arg_parser(): p = argparse.ArgumentParser(description=__doc__, epilog=EPILOG, formatter_class=argparse.RawTextHelpFormatter) p.add_argument('in_sh', help='Input SH image.') p.add_argument('--mask', default='', help='Optional mask.') # outputs p.add_argument('--cos_asym_map', default='', help='Output asymmetry map using cos similarity.') p.add_argument('--odd_power_map', default='', help='Output odd power map.') p.add_argument('--peaks', default='', help='Output filename for the extracted peaks.') p.add_argument('--peak_values', default='', help='Output filename for the extracted peaks values.') p.add_argument('--peak_indices', default='', help='Output filename for the generated peaks indices on ' 'the sphere.') p.add_argument('--nupeaks', default='', help='Output filename for the nupeaks file.') p.add_argument('--not_all', action='store_true', help='If set, only saves the files specified using the ' 'file flags [%(default)s].') p.add_argument('--at', dest='a_threshold', type=float, default='0.0', help='Absolute threshold on fODF amplitude. This ' 'value should be set to\napproximately 1.5 to 2 times ' 'the maximum fODF amplitude in isotropic voxels\n' '(ie. ventricles).\n' 'Use compute_fodf_max_in_ventricles.py to find the ' 'maximal value.\n' 'See [Dell\'Acqua et al HBM 2013] [%(default)s].') p.add_argument('--rt', dest='r_threshold', type=float, default='0.1', help='Relative threshold on fODF amplitude in percentage ' '[%(default)s].') p.add_argument('--sphere', default='symmetric724', choices=sorted(SPHERE_FILES.keys()), help='Sphere to use for peak directions estimation ' '[%(default)s].') add_processes_arg(p) add_sh_basis_args(p) add_overwrite_arg(p) return p
def add_sphere_arg(parser, symmetric_only=False, default='symmetric724'): spheres = sorted(SPHERE_FILES.keys()) if symmetric_only: spheres = [s for s in spheres if 'symmetric' in s] if 'symmetric' not in default: raise ValueError("Default cannot be {} if you only accept " "symmetric spheres.".format(default)) parser.add_argument('--sphere', choices=spheres, default=default, help='Dipy sphere; set of possible directions.')
def _build_arg_parser(): p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawTextHelpFormatter) # Positional arguments p.add_argument('in_bingham', help='Input SH image file.') # Window configuration options p.add_argument('--slice_index', type=int, help='Index of the slice to visualize along a given axis. ' 'Defaults to middle of volume.') p.add_argument('--win_dims', nargs=2, metavar=('WIDTH', 'HEIGHT'), default=(768, 768), type=int, help='The dimensions for the vtk window. [%(default)s]') p.add_argument('--interactor', default='trackball', choices={'image', 'trackball'}, help='Specify interactor mode for vtk window. ' '[%(default)s]') p.add_argument('--axis_name', default='axial', type=str, choices={'axial', 'coronal', 'sagittal'}, help='Name of the axis to visualize. [%(default)s]') p.add_argument('--silent', action='store_true', help='Disable interactive visualization.') p.add_argument('--output', help='Path to output file.') add_overwrite_arg(p) p.add_argument('--sphere', default='symmetric362', choices=sorted(SPHERE_FILES.keys()), help='Name of the sphere used to reconstruct SF. ' '[%(default)s]') p.add_argument('--color_per_lobe', action='store_true', help='Color each bingham distribution with a ' 'different color. [%(default)s]') return p
def _build_arg_parser(): p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawTextHelpFormatter) p.add_argument('in_sh', help='Path of the SH volume.') p.add_argument('out_sf', help='Name of the output SF file to save (bvals/bvecs will ' 'be automatically named when necessary).') # Sphere vs bvecs choice for SF directions = p.add_mutually_exclusive_group(required=True) directions.add_argument('--sphere', choices=sorted(SPHERE_FILES.keys()), help='Sphere used for the SH to SF projection. ') directions.add_argument( '--in_bvec', help="Directions used for the SH to SF projection.") p.add_argument('--dtype', default="float32", choices=["float32", "float64"], help="Datatype to use for SF computation and output array." "'[%(default)s]'") # Optional args for a DWI-like volume p.add_argument('--in_bval', help='b-value file, in FSL format, ' 'used to assign a b-value to the ' 'output SF and generate a `.bval` file.') p.add_argument('--in_b0', help='b0 volume to concatenate to the ' 'final SF volume.') p.add_argument('--out_bval', help="Optional output bval file.") p.add_argument('--out_bvec', help="Optional output bvec file.") p.add_argument('--b0_scaling', action="store_true", help="Scale resulting SF by the b0 image.") add_sh_basis_args(p) p.add_argument('--full_basis', action="store_true", help="If true, use a full basis for the input SH " "coefficients.") add_processes_arg(p) add_overwrite_arg(p) add_force_b0_arg(p) return p
def _build_arg_parser(): p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawTextHelpFormatter) p.add_argument('in_sh', help='Path to the input file.') p.add_argument('out_sh', help='File name for averaged signal.') p.add_argument('--out_asymmetry', default='asym_map.nii.gz', help='File name for asymmetry map. Can only be outputed' ' when the output SH basis is full. [%(default)s]') p.add_argument('--sh_order', default=8, type=int, help='SH order of the input. [%(default)s]') add_sh_basis_args(p) p.add_argument('--sphere', default='repulsion724', choices=sorted(SPHERE_FILES.keys()), help='Sphere used for the SH to SF projection. ' '[%(default)s]') p.add_argument('--sharpness', default=1.0, type=float, help='Specify sharpness factor to use for weighted average.' ' [%(default)s]') p.add_argument('--sigma', default=1.0, type=float, help='Sigma of the gaussian to use. [%(default)s]') p.add_argument('--out_sym', action='store_true', help='If set, saves output in symmetric SH basis.') add_verbose_arg(p) add_overwrite_arg(p) return p
def _build_arg_parser(): p = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawTextHelpFormatter) p.add_argument('in_sh', help='Path to the input file.') p.add_argument('out_sh', help='File name for averaged signal.') add_sh_basis_args(p) p.add_argument('--out_sym', default=None, help='Name of optional symmetric output. [%(default)s]') p.add_argument('--sphere', default='repulsion724', choices=sorted(SPHERE_FILES.keys()), help='Sphere used for the SH to SF projection. ' '[%(default)s]') p.add_argument('--sigma_angular', default=1.0, type=float, help='Standard deviation for angular distance.' ' [%(default)s]') p.add_argument('--sigma_spatial', default=1.0, type=float, help='Standard deviation for spatial distance.' ' [%(default)s]') p.add_argument('--sigma_range', default=1.0, type=float, help='Standard deviation for range filter.' ' [%(default)s]') p.add_argument('--use_gpu', action='store_true', help='Use GPU for computation.') add_verbose_arg(p) add_overwrite_arg(p) add_processes_arg(p) return p
def _build_arg_parser(): p = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter) p._optionals.title = 'Generic options' p.add_argument('sh_file', help='Spherical harmonic file. \n' '(isotropic resolution, nifti, see --basis).') p.add_argument('seed_file', help='Seeding mask (isotropic resolution, nifti).') p.add_argument('mask_file', help='Seeding mask(isotropic resolution, nifti).\n' + 'Tracking will stop outside this mask') p.add_argument('output_file', help='Streamline output file (must be trk or tck).') track_g = p.add_argument_group('Tracking options') track_g.add_argument( '--algo', default='prob', choices=['det', 'prob'], help='Algorithm to use (must be "det" or "prob"). [%(default)s]') track_g.add_argument('--step', dest='step_size', type=float, default=0.5, help='Step size in mm. [%(default)s]') track_g.add_argument( '--min_length', type=float, default=10., help='Minimum length of a streamline in mm. [%(default)s]') track_g.add_argument( '--max_length', type=float, default=300., help='Maximum length of a streamline in mm. [%(default)s]') track_g.add_argument( '--theta', type=float, help='Maximum angle between 2 steps. ["eudx"=60, det"=45, "prob"=20]') track_g.add_argument( '--sfthres', dest='sf_threshold', type=float, default=0.1, help='Spherical function relative threshold. [%(default)s]') add_sh_basis_args(track_g) seed_group = p.add_argument_group( 'Seeding options', 'When no option is provided, uses --npv 1.') seed_sub_exclusive = seed_group.add_mutually_exclusive_group() seed_sub_exclusive.add_argument('--npv', type=int, help='Number of seeds per voxel.') seed_sub_exclusive.add_argument('--nt', type=int, help='Total number of seeds to use.') p.add_argument('--sphere', choices=sorted(SPHERE_FILES.keys()), default='symmetric724', help='Set of directions to be used for tracking') out_g = p.add_argument_group('Output options') out_g.add_argument( '--compress', type=float, help='If set, will compress streamlines. The parameter\nvalue is the ' 'distance threshold. A rule of thumb\nis to set it to 0.1mm for ' 'deterministic\nstreamlines and 0.2mm for probabilitic ' 'streamlines.') out_g.add_argument('--seed', type=int, help='Random number generator seed.') add_overwrite_arg(out_g) log_g = p.add_argument_group('Logging options') add_verbose(log_g) return p
def _build_arg_parser(): p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawTextHelpFormatter) p._optionals.title = 'Generic options' p.add_argument('in_sh', help='Spherical harmonic file (.nii.gz) OR \n' 'peaks/evecs (.nii.gz) for EUDX tracking.') p.add_argument('in_seed', help='Seeding mask (.nii.gz).') p.add_argument('in_mask', help='Seeding mask (.nii.gz).\n' 'Tracking will stop outside this mask.') p.add_argument('out_tractogram', help='Tractogram output file (must be .trk or .tck).') track_g = p.add_argument_group('Tracking options') track_g.add_argument('--algo', default='prob', choices=['det', 'prob', 'eudx'], help='Algorithm to use [%(default)s]') track_g.add_argument('--step', dest='step_size', type=float, default=0.5, help='Step size in mm. [%(default)s]') track_g.add_argument('--min_length', type=float, default=10., help='Minimum length of a streamline in mm. ' '[%(default)s]') track_g.add_argument('--max_length', type=float, default=300., help='Maximum length of a streamline in mm. ' '[%(default)s]') track_g.add_argument('--theta', type=float, help='Maximum angle between 2 steps.\n' '["eudx"=60, "det"=45, "prob"=20]') track_g.add_argument('--sfthres', dest='sf_threshold', type=float, default=0.1, help='Spherical function relative threshold. ' '[%(default)s]') add_sh_basis_args(track_g) seed_group = p.add_argument_group( 'Seeding options', 'When no option is provided, uses --npv 1.') seed_sub_exclusive = seed_group.add_mutually_exclusive_group() seed_sub_exclusive.add_argument('--npv', type=int, help='Number of seeds per voxel.') seed_sub_exclusive.add_argument('--nt', type=int, help='Total number of seeds to use.') p.add_argument('--sphere', choices=sorted(SPHERE_FILES.keys()), default='symmetric724', help='Set of directions to be used for tracking.') out_g = p.add_argument_group('Output options') out_g.add_argument('--compress', type=float, help='If set, will compress streamlines.\n' 'The parameter value is the distance threshold.') out_g.add_argument('--seed', type=int, help='Random number generator seed.') add_overwrite_arg(out_g) out_g.add_argument('--save_seeds', action='store_true', help='If set, save the seeds used for the tracking \n ' 'in the data_per_streamline property.') log_g = p.add_argument_group('Logging options') add_verbose_arg(log_g) return p
def test_sphere_dtypes(): for sphere_name, sphere_path in SPHERE_FILES.items(): sphere_data = np.load(sphere_path) npt.assert_equal(sphere_data['vertices'].dtype, np.float64)
def _build_arg_parser(): parser = argparse.ArgumentParser( description='Dipy-based local tracking on fiber ODF (fODF)', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( 'type', choices=[DETERMINISTIC, PROBABILISTIC, EUDX], help='Tracking type (deterministic, probabilistic or EuDX based on ' 'fODF peaks)') parser.add_argument('sh_file', help='Spherical Harmonic file') parser.add_argument('seed_file', help='Seeding mask') parser.add_argument( 'mask_file', help='Tracking mask. Tracking will stop outside this mask') parser.add_argument('output_file', help='Streamline output file (TRK)') seed_group = parser.add_mutually_exclusive_group() seed_group.add_argument('--npv', default=5, type=int, help='Number of seeds per voxel') seed_group.add_argument('--nts', default=argparse.SUPPRESS, type=int, help='Total number of seeds. Replaces --npv') deviation_angle_group = parser.add_mutually_exclusive_group() deviation_angle_group.add_argument( '--theta', default=argparse.SUPPRESS, help='Maximum angle between 2 steps. [{}=45.0, {}=20.0, {}=60.0]' ''.format(DETERMINISTIC, PROBABILISTIC, EUDX)) deviation_angle_group.add_argument( '--curvature', type=float, default=argparse.SUPPRESS, help='Minimum radius of curvature R in mm. Replaces --theta') parser.add_argument('--step_size', default=0.5, type=float, help='Step size used for tracking') parser.add_argument('--sphere', choices=sorted(SPHERE_FILES.keys()), default='symmetric724', help='Set of directions to be used for tracking') parser.add_argument( '--basis', default='fibernav', choices=['mrtrix', 'fibernav'], help='Basis used for the spherical harmonic coefficients') parser.add_argument('--sf_thres', type=float, default=0.1, help='Spherical function relative threshold') parser.add_argument('--min_len', type=float, default=10, help='Minimum length of a streamline in mm') parser.add_argument('--max_len', type=float, default=300, help='Maximum length of a streamline in mm') parser.add_argument('--compress_streamlines', action='store_true', help='If set, compress streamlines on-the-fly') parser.add_argument( '--tolerance_error', type=float, default=0.1, help='Tolerance error in mm. A rule of thumb is to set it to 0.1mm ' 'for deterministic streamlines and 0.2mm for probabilitic ' 'streamlines.') parser.add_argument('--seed', type=int, default=None, help='Random number generator seed') add_overwrite_arg(parser) return parser