Exemplo n.º 1
0
def _build_arg_parser():
    p = argparse.ArgumentParser(description=__doc__,
                                formatter_class=argparse.RawTextHelpFormatter)

    p.add_argument('in_lesion',
                   help='Binary mask of the lesion(s) (.nii.gz).')
    p.add_argument('out_json',
                   help='Output file for lesion information (.json).')
    p1 = p.add_mutually_exclusive_group()
    p1.add_argument('--bundle',
                    help='Path of the bundle file (.trk).')
    p1.add_argument('--bundle_mask',
                    help='Path of the bundle binary mask (.nii.gz).')
    p1.add_argument('--bundle_labels_map',
                    help='Path of the bundle labels map (.nii.gz).')

    p.add_argument('--min_lesion_vol', type=float, default=7,
                   help='Minimum lesion volume in mm3 [%(default)s].')
    p.add_argument('--out_lesion_atlas', metavar='FILE',
                   help='Save the labelized lesion(s) map (.nii.gz).')
    p.add_argument('--out_lesion_stats', metavar='FILE',
                   help='Save the lesion-wise volume measure (.json).')
    p.add_argument('--out_streamlines_stats', metavar='FILE',
                   help='Save the lesion-wise streamline count (.json).')

    add_json_args(p)
    add_overwrite_arg(p)
    add_reference_arg(p)

    return p
def _build_args_parser():
    p = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                description=DESCRIPTION,
                                epilog=EPILOG)

    p.add_argument('moving_tractogram', help='Path of the moving tractogram.')

    p.add_argument('static_tractogram', help='Path of the target tractogram.')

    add_reference_arg(p, 'moving_tractogram')

    add_reference_arg(p, 'static_tractogram')

    p.add_argument('--out_name',
                   default='transformation.npy',
                   help='Filename of the transformation matrix, \n'
                   'the registration type will be appended as a suffix,\n'
                   '[<out_name>_<affine/rigid>.npy]')

    p.add_argument('--only_rigid',
                   action='store_true',
                   help='Will only use a rigid transformation, '
                   'uses affine by default.')

    p.add_argument('--amount_to_load',
                   type=int,
                   default=250000,
                   help='Amount of streamlines to load for each tractogram \n'
                   'using lazy load. [%(default)s]')

    add_overwrite_arg(p)

    add_verbose_arg(p)

    return p
def _build_arg_parser():
    p = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                description=__doc__)

    p.add_argument('in_bundle', help='Path of the input bundle.')

    p.add_argument('min_distance',
                   type=float,
                   help='Distance threshold for 2 streamlines to be '
                   'considered similar (mm).')

    p.add_argument('out_bundle', help='Path of the output tractography file')

    p.add_argument('--clustering_thr',
                   type=float,
                   default=6,
                   help='Clustering threshold for QB/QBx (mm), during '
                   'the first approximation [%(default)s].')
    p.add_argument('--min_cluster_size',
                   type=int,
                   default=5,
                   help='Minimum cluster size for the first iteration '
                   '[%(default)s].')
    p.add_argument('--convergence',
                   type=int,
                   default=100,
                   help='Streamlines count difference threshold to stop '
                   're-running the algorithm [%(default)s].')

    add_reference_arg(p)
    add_processes_arg(p)
    add_overwrite_arg(p)
    add_verbose_arg(p)

    return p
Exemplo n.º 4
0
def _build_arg_parser():
    p = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawTextHelpFormatter)
    p.add_argument('in_bundles', nargs='+',
                   help='Path of the input bundles.')
    p.add_argument('out_json',
                   help='Path of the output json file.')
    p.add_argument('--streamline_dice', action='store_true',
                   help='Compute streamline-wise dice coefficient.\n'
                        'Tractograms must be identical [%(default)s].')
    p.add_argument('--bundle_adjency_no_overlap', action='store_true',
                   help='If set, do not count zeros in the average BA.')
    p.add_argument('--disable_streamline_distance', action='store_true',
                   help='Will not compute the streamlines distance \n'
                        '[%(default)s].')
    p.add_argument('--single_compare',
                   help='Compare inputs to this single file.')
    p.add_argument('--keep_tmp', action='store_true',
                   help='Will not delete the tmp folder at the end.')
    p.add_argument('--ratio', action='store_true',
                   help='Compute overlap and overreach as a ratio over the\n'
                        'reference tractogram in a Tractometer-style way.\n'
                        'Can only be used if also using the `single_compare` '
                        'option.')

    add_processes_arg(p)
    add_reference_arg(p)
    add_json_args(p)
    add_overwrite_arg(p)

    return p
Exemplo n.º 5
0
def _build_arg_parser():
    p = argparse.ArgumentParser(description=__doc__,
                                formatter_class=argparse.RawTextHelpFormatter)

    p.add_argument('in_tractogram',
                   help='Tractogram filename.\n'
                   'Path of the input tractogram or bundle.')
    p.add_argument('dist_thresh',
                   type=float,
                   help='Last QuickBundlesX threshold in mm. Typically \n'
                   'the value are between 10-20mm.')
    p.add_argument('output_clusters_dir',
                   help='Path to the clusters directory.')

    p.add_argument('--nb_points',
                   type=int,
                   default='20',
                   help='Streamlines will be resampled to have this '
                   'number of points [%(default)s].')
    p.add_argument('--output_centroids',
                   help='Output tractogram filename.\n'
                   'Format must be readable by the Nibabel API.')

    add_reference_arg(p)
    add_overwrite_arg(p)

    return p
Exemplo n.º 6
0
def _build_arg_parser():
    p = argparse.ArgumentParser(description=__doc__,
                                formatter_class=argparse.RawTextHelpFormatter)

    p.add_argument('in_tractogram',
                   help='Tractogram filename. Format must be one of \n'
                   'trk, tck, vtk, fib, dpy.')
    p.add_argument('out_tractogram',
                   help='Output filename. Format must be one of \n'
                   'trk, tck, vtk, fib, dpy.')

    p.add_argument('--cut_invalid',
                   action='store_true',
                   help='Cut invalid streamlines rather than removing them.\n'
                   'Keep the longest segment only.')
    p.add_argument('--remove_single_point',
                   action='store_true',
                   help='Consider single point streamlines invalid.')
    p.add_argument(
        '--remove_overlapping_points',
        action='store_true',
        help='Consider streamlines with overlapping points invalid.')

    add_reference_arg(p)
    add_overwrite_arg(p)

    return p
def _build_arg_parser():
    p = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                description=__doc__)
    p.add_argument('in_tractogram',
                   help='Tractogram input file name.')
    p.add_argument('out_tractogram',
                   help='Output tractogram without loops.')
    p.add_argument('--looping_tractogram',
                   help='If set, saves detected looping streamlines.')
    p.add_argument('--qb', action='store_true',
                   help='If set, uses QuickBundles to detect\n' +
                        'outliers (loops, sharp angle turns).\n' +
                        'Should mainly be used with bundles. '
                        '[%(default)s]')
    p.add_argument('--threshold', default=8., type=float,
                   help='Maximal streamline to bundle distance\n' +
                        'for a streamline to be considered as\n' +
                        'a tracking error. [%(default)s]')
    p.add_argument('-a', dest='angle', default=360, type=float,
                   help='Maximum looping (or turning) angle of\n' +
                        'a streamline in degrees. [%(default)s]')

    add_overwrite_arg(p)

    add_reference_arg(p)

    return p
def _build_args_parser():
    p = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                description='Filter streamlines by length.')
    p.add_argument('in_tractogram', help='Streamlines input file name.')
    p.add_argument('out_tractogram', help='Streamlines output file name.')
    p.add_argument('--minL',
                   default=0.,
                   type=float,
                   help='Minimum length of streamlines. [%(default)s]')
    p.add_argument('--maxL',
                   default=np.inf,
                   type=float,
                   help='Maximum length of streamlines. [%(default)s]')
    p.add_argument('--no_empty',
                   action='store_true',
                   help='Do not write file if there is no streamline.')
    p.add_argument('--display_counts',
                   action='store_true',
                   help='Print streamline count before and after filtering')

    add_reference_arg(p)
    add_overwrite_arg(p)
    add_verbose_arg(p)
    add_json_args(p)

    return p
Exemplo n.º 9
0
def _build_arg_parser():
    p = argparse.ArgumentParser(description=__doc__,
                                formatter_class=argparse.RawTextHelpFormatter)

    p.add_argument('in_bundles', nargs='+',
                   help='List of the clusters filename.')
    p.add_argument('out_accepted',
                   help='Filename of the concatenated accepted clusters.')
    p.add_argument('out_rejected',
                   help='Filename of the concatenated rejected clusters.')

    p.add_argument('--out_accepted_dir',
                   help='Directory to save all accepted clusters separately.')
    p.add_argument('--out_rejected_dir',
                   help='Directory to save all rejected clusters separately.')

    p.add_argument('--min_cluster_size', type=int, default=1,
                   help='Minimum cluster size for consideration [%(default)s].'
                        'Must be at least 1.')
    p.add_argument('--background_opacity', type=float, default=0.1,
                   help='Opacity of the background streamlines.'
                        'Keep low between 0 and 0.5 [%(default)s].')
    p.add_argument('--background_linewidth', type=float, default=1,
                   help='Linewidth of the background streamlines [%(default)s].')
    p.add_argument('--clusters_linewidth', type=float, default=1,
                   help='Linewidth of the current cluster [%(default)s].')

    add_reference_arg(p)
    add_overwrite_arg(p)
    add_verbose_arg(p)

    return p
def _build_arg_parser():
    p = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                description=__doc__)
    p.add_argument('in_bundle',
                   help='Fiber bundle file to compute the bundle profiles on.')
    p.add_argument('in_metrics',
                   nargs='+',
                   help='Metric(s) on which to compute the bundle profiles.')

    g = p.add_mutually_exclusive_group()
    g.add_argument('--in_centroid',
                   help='If provided it will be used to make sure all '
                   'streamlines go in the same direction. \n'
                   'Also, number of points per streamline will be '
                   'set according to centroid.')
    g.add_argument('--nb_pts_per_streamline',
                   type=int,
                   default=20,
                   help='If centroid not provided, resample each streamline to'
                   ' this number of points [%(default)s].')

    add_json_args(p)
    add_reference_arg(p)
    add_overwrite_arg(p)
    return p
Exemplo n.º 11
0
def _build_arg_parser():
    p = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                description=__doc__)

    p.add_argument('moving_tractogram',
                   help='Path of the tractogram to be transformed.')
    p.add_argument('target_file',
                   help='Path of the reference file (trk or nii).')
    p.add_argument('deformation',
                   help='Path of the file containing deformation field.')
    p.add_argument('out_tractogram',
                   help='Output filename of the transformed tractogram.')

    invalid = p.add_mutually_exclusive_group()
    invalid.add_argument('--remove_invalid', action='store_true',
                         help='Remove the streamlines landing out of the '
                              'bounding box.')
    invalid.add_argument('--keep_invalid', action='store_true',
                         help='Keep the streamlines landing out of the '
                              'bounding box.')

    add_overwrite_arg(p)
    add_reference_arg(p)

    return p
Exemplo n.º 12
0
def _build_arg_parser():
    p = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                description=__doc__)
    p.add_argument('in_tractogram', help='Tractogram input file name.')
    p.add_argument('out_tractogram', help='Output tractogram file name.')
    p.add_argument('--minU',
                   default=0.5,
                   type=float,
                   help='Min ufactor value. [%(default)s]')
    p.add_argument('--maxU',
                   default=1.0,
                   type=float,
                   help='Max ufactor value. [%(default)s]')

    p.add_argument('--remaining_tractogram',
                   help='If set, saves remaining streamlines.')
    p.add_argument('--no_empty',
                   action='store_true',
                   help='Do not write file if there is no streamline.')
    p.add_argument('--display_counts',
                   action='store_true',
                   help='Print streamline count before and after filtering.')

    add_overwrite_arg(p)
    add_reference_arg(p)
    add_json_args(p)

    return p
def _build_arg_parser():
    p = argparse.ArgumentParser(
        description=__doc__, formatter_class=argparse.RawTextHelpFormatter)

    p.add_argument('in_bundle',
                   help='Fiber bundle file to compute statistics on.')
    p.add_argument('in_label_map',
                   help='Label map (.npz) of the corresponding fiber bundle.')
    p.add_argument('in_distance_map',
                   help='Distance map (.npz) of the corresponding bundle/'
                        'centroid streamline.')
    p.add_argument('in_metrics', nargs='+',
                   help='Nifti file to compute statistics on. Probably some '
                        'tractometry measure(s) such as FA, MD, RD, ...')

    p.add_argument('--density_weighting', action='store_true',
                   help='If set, weight statistics by the number of '
                        'streamlines passing through each voxel.')
    p.add_argument('--distance_weighting', action='store_true',
                   help='If set, weight statistics by the inverse of the '
                        'distance between a streamline and the centroid.')
    p.add_argument('--out_json',
                   help='Path of the output json file. If not given, json '
                        'formatted stats are simply printed.')

    add_overwrite_arg(p)
    add_reference_arg(p)
    add_json_args(p)
    return p
Exemplo n.º 14
0
def _build_arg_parser():
    p = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                description=__doc__)

    p.add_argument('in_hdf5',
                   help='Path of the tractogram to be transformed.')
    p.add_argument('in_target_file',
                   help='Path of the reference target file (.trk or .nii).')
    p.add_argument('in_transfo',
                   help='Path of the file containing the 4x4 \n'
                        'transformation, matrix (.txt, .npy or .mat).')
    p.add_argument('out_hdf5',
                   help='Output tractogram filename (transformed data).')

    p.add_argument('--inverse', action='store_true',
                   help='Apply the inverse linear transformation.')
    p.add_argument('--in_deformation',
                   help='Path to the file containing a deformation field.')

    invalid = p.add_mutually_exclusive_group()
    invalid.add_argument('--cut_invalid', action='store_true',
                         help='Cut invalid streamlines rather than removing '
                              'them.\nKeep the longest segment only.\n'
                              'By default, invalid streamline are removed.')

    add_reference_arg(p)
    add_overwrite_arg(p)

    return p
Exemplo n.º 15
0
def _build_arg_parser():
    p = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                description=__doc__)

    p.add_argument('in_bundles', nargs='+', help='Input bundles filename.')

    p.add_argument('--ratio_streamlines',
                   type=float,
                   default=0.5,
                   help='Minimum vote to be considered for streamlines '
                   '[%(default)s].')
    p.add_argument('--ratio_voxels',
                   type=float,
                   default=0.5,
                   help='Minimum vote to be considered for voxels'
                   ' [%(default)s].')

    p.add_argument('--same_tractogram',
                   action='store_true',
                   help='All bundles need to come from the same tractogram,\n'
                   'will generate a voting for streamlines too.')
    p.add_argument('--output_prefix',
                   default='voting_',
                   help='Output prefix, [%(default)s].')

    add_reference_arg(p)
    add_overwrite_arg(p)

    return p
Exemplo n.º 16
0
def _build_arg_parser():
    p = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawTextHelpFormatter)
    p.add_argument('in_bundles', nargs='+',
                   help='Path of the input bundles.')
    p.add_argument('out_json',
                   help='Path of the output json file.')

    p.add_argument('--streamline_dice', action='store_true',
                   help='Streamlines-wise Dice coefficient will be computed \n'
                        'Tractograms must be identical [%(default)s].')
    p.add_argument('--disable_streamline_distance', action='store_true',
                   help='Will not compute the streamlines distance \n'
                        '[%(default)s].')
    p.add_argument('--single_compare',
                   help='Compare inputs to this single file.')
    p.add_argument('--keep_tmp', action='store_true',
                   help='Will not delete the tmp folder at the end.')

    add_processes_arg(p)
    add_reference_arg(p)
    add_json_args(p)
    add_overwrite_arg(p)

    return p
Exemplo n.º 17
0
def _build_arg_parser():
    p = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawTextHelpFormatter)
    p.add_argument('in_bundle',
                   help='Input path of the tractography file.')
    p.add_argument('out_bundle',
                   help='Output path of the uniformized file.')

    method = p.add_mutually_exclusive_group(required=True)
    method.add_argument('--axis', choices=['x', 'y', 'z'],
                        help='Match endpoints of the streamlines along this axis.\n'
                        'SUGGESTION: Commissural = x, Association = y, '
                        'Projection = z')
    method.add_argument('--auto', action='store_true',
                        help='Match endpoints of the streamlines along an '
                             'automatically determined axis.')

    p.add_argument('--swap', action='store_true',
                   help='Swap head <-> tail convention. '
                        'Can be useful when the reference is not in RAS.')
    add_reference_arg(p)
    add_verbose_arg(p)
    add_overwrite_arg(p)

    return p
Exemplo n.º 18
0
def _build_arg_parser():
    p = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)

    p.add_argument('in_bundle',
                   help='Fiber bundle file to compute statistics on.')

    p.add_argument('label_map',
                   help='Label map (.npz) of the corresponding '
                   'fiber bundle.')
    p.add_argument('distance_map',
                   help='Distance map (.npz) of the corresponding '
                   'bundle/centroid streamline.')
    p.add_argument('metrics',
                   nargs='+',
                   help='Nifti metric(s) to compute statistics on.')

    p.add_argument('--density_weighting',
                   action='store_true',
                   help='If set, weight statistics by the number of '
                   'streamlines passing through each voxel.')
    p.add_argument('--distance_weighting',
                   action='store_true',
                   help='If set, weight statistics by the inverse of the '
                   'distance between a streamline and the centroid.')

    add_reference_arg(p)
    add_json_args(p)
    return p
Exemplo n.º 19
0
def _build_arg_parser():
    p = argparse.ArgumentParser(description=__doc__,
                                formatter_class=argparse.RawTextHelpFormatter)
    p.add_argument('in_volume',
                   help='Volume used as background (e.g. T1, FA, b0).')
    p.add_argument('in_bundles',
                   nargs='+',
                   help='List of tractography files supported by nibabel '
                   'or binary mask files.')
    p.add_argument('out_image',
                   help='Name of the output image mosaic '
                   '(e.g. mosaic.jpg, mosaic.png).')

    p.add_argument('--uniform_coloring',
                   nargs=3,
                   metavar=('R', 'G', 'B'),
                   type=float,
                   help='Assign an uniform color to streamlines (or ROIs).')
    p.add_argument('--random_coloring',
                   metavar='SEED',
                   type=int,
                   help='Assign a random color to streamlines (or ROIs).')
    p.add_argument('--zoom',
                   type=float,
                   default=1.0,
                   help='Rendering zoom. '
                   'A value greater than 1 is a zoom-in,\n'
                   'a value less than 1 is a zoom-out [%(default)s].')

    p.add_argument('--ttf',
                   default=None,
                   help='Path of the true type font to use for legends.')
    p.add_argument('--ttf_size',
                   type=int,
                   default=35,
                   help='Font size (int) to use for the legends '
                   '[%(default)s].')
    p.add_argument('--opacity_background',
                   type=float,
                   default=0.4,
                   help='Opacity of background image, between 0 and 1.0 '
                   '[%(default)s].')
    p.add_argument('--resolution_of_thumbnails',
                   type=int,
                   default=300,
                   help='Resolution of thumbnails used in mosaic '
                   '[%(default)s].')

    p.add_argument('--light_screenshot',
                   action='store_true',
                   help='Keep only 3 views instead of 6 '
                   '[%(default)s].')
    p.add_argument('--no_information',
                   action='store_true',
                   help='Don\'t display axis and bundle information '
                   '[%(default)s].')
    add_reference_arg(p)
    add_overwrite_arg(p)
    return p
Exemplo n.º 20
0
def _build_arg_parser():
    p = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                description=__doc__)

    p.add_argument('in_tractogram', help='Streamlines input file name.')
    p.add_argument('out_tractogram', help='Streamlines output file name.')

    p.add_argument('--min_x',
                   default=0.,
                   type=float,
                   help='Minimum distance in the first dimension, in mm.'
                   '[%(default)s]')
    p.add_argument('--max_x',
                   default=np.inf,
                   type=float,
                   help='Maximum distance in the first dimension, in mm.'
                   '[%(default)s]')
    p.add_argument('--min_y',
                   default=0.,
                   type=float,
                   help='Minimum distance in the second dimension, in mm.'
                   '[%(default)s]')
    p.add_argument('--max_y',
                   default=np.inf,
                   type=float,
                   help='Maximum distance in the second dimension, in mm.'
                   '[%(default)s]')
    p.add_argument('--min_z',
                   default=0.,
                   type=float,
                   help='Minimum distance in the third dimension, in mm.'
                   '[%(default)s]')
    p.add_argument('--max_z',
                   default=np.inf,
                   type=float,
                   help='Maximum distance in the third dimension, in mm.'
                   '[%(default)s]')
    p.add_argument('--use_abs',
                   action='store_true',
                   help="If set, will use the total of distances in absolute "
                   "value (ex, coming back on yourself will contribute "
                   "to the total distance instead of cancelling it).")

    p.add_argument('--no_empty',
                   action='store_true',
                   help='Do not write file if there is no streamline.')
    p.add_argument('--display_counts',
                   action='store_true',
                   help='Print streamline count before and after filtering.')
    p.add_argument('--save_rejected',
                   metavar='filename',
                   help="Save the SFT of rejected streamlines.")

    add_reference_arg(p)
    add_overwrite_arg(p)
    add_verbose_arg(p)
    add_json_args(p)

    return p
Exemplo n.º 21
0
def _build_arg_parser():
    p = argparse.ArgumentParser(description=__doc__,
                                formatter_class=argparse.RawTextHelpFormatter)

    p.add_argument("in_tractogram", help="Input tractogram to score")
    p.add_argument("gt_config",
                   help=".json dict configured as specified above.")
    p.add_argument("out_dir", help="Output directory.")

    g = p.add_argument_group("Additions to gt_config")
    p.add_argument("--gt_dir",
                   metavar='DIR',
                   help="Root path of the ground truth files listed in the "
                   "gt_config.\n If not set, filenames in the config "
                   "file are considered\n as complete paths.")
    g.add_argument("--use_gt_masks_as_limits_masks",
                   action='store_true',
                   help="If set, the gt_config's 'gt_mask' will also be used "
                   "as\n'limits_mask' for each bundle. Note that this "
                   "means the\nOR will necessarily be 0.")

    g = p.add_argument_group("Preprocessing")
    g.add_argument("--dilate_endpoints",
                   metavar="NB_PASS",
                   default=0,
                   type=int,
                   help="Dilate inclusion masks n-times. Default: 0.")
    g.add_argument("--remove_invalid",
                   action="store_true",
                   help="Remove invalid streamlines before scoring.")

    g = p.add_argument_group("Tractometry choices")
    g.add_argument("--save_wpc_separately",
                   action='store_true',
                   help="If set, streamlines rejected from VC based on the "
                   "config\nfile criteria will be saved separately from "
                   "IS (and IC)\nin one file *_WPC.tck per bundle.")
    g.add_argument("--compute_ic",
                   action='store_true',
                   help="If set, IS are split into NC + IC, where IC are "
                   "computed as one bundle per\npair of ROI not "
                   "belonging to a true connection, named\n*_*_IC.tck.")
    g.add_argument("--remove_wpc_belonging_to_another_bundle",
                   action='store_true',
                   help="If set, WPC actually belonging to VC (from another "
                   "bundle,\nof course; in the case of overlapping ROIs) "
                   "will be removed\nfrom the WPC classification.")

    p.add_argument("--no_empty",
                   action='store_true',
                   help='Do not write file if there is no streamline.')

    add_json_args(p)
    add_overwrite_arg(p)
    add_reference_arg(p)
    add_verbose_arg(p)

    return p
Exemplo n.º 22
0
def _build_arg_parser():
    p = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                description=__doc__)

    p.add_argument('operation',
                   choices=OPERATIONS.keys(),
                   metavar='OPERATION',
                   help='The type of operation to be performed on the '
                   'streamlines. Must\nbe one of the following: '
                   '%(choices)s.')
    p.add_argument('in_tractograms',
                   metavar='INPUT_FILES',
                   nargs='+',
                   help='The list of files that contain the ' +
                   'streamlines to operate on.')
    p.add_argument('out_tractogram',
                   metavar='OUTPUT_FILE',
                   help='The file where the remaining streamlines '
                   'are saved.')

    p.add_argument('--precision',
                   '-p',
                   metavar='NBR_OF_DECIMALS',
                   type=int,
                   default=4,
                   help='Precision used to compare streamlines [%(default)s].')
    p.add_argument('--robust',
                   '-r',
                   action='store_true',
                   help='Use version robust to small translation/rotation.')

    p.add_argument('--no_metadata',
                   '-n',
                   action='store_true',
                   help='Strip the streamline metadata from the output.')
    p.add_argument('--fake_metadata',
                   action='store_true',
                   help='Skip the metadata verification, create fake metadata '
                   'if missing, can lead to unexpected behavior.')
    p.add_argument('--save_indices',
                   '-s',
                   metavar='OUT_INDEX_FILE',
                   help='Save the streamline indices to the supplied '
                   'json file.')

    p.add_argument('--ignore_invalid',
                   action='store_true',
                   help='If set, does not crash because of invalid '
                   'streamlines.')

    add_json_args(p)
    add_reference_arg(p)
    add_verbose_arg(p)
    add_overwrite_arg(p)

    return p
Exemplo n.º 23
0
def _build_arg_parser():
    p = argparse.ArgumentParser(description=__doc__,
                                formatter_class=argparse.RawTextHelpFormatter)

    p.add_argument('in_bundle', help='Fiber bundle file.')

    add_reference_arg(p)
    add_json_args(p)

    return p
Exemplo n.º 24
0
def _build_arg_parser():
    p = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                epilog=EPILOG,
                                description=__doc__)

    p.add_argument('in_tractogram', help='Path of the input tractogram file.')
    p.add_argument('in_wmparc',
                   help='Path of the white matter parcellation atlas\n' +
                   '(.nii or .nii.gz)')
    p.add_argument('out_path', help='Path to the output files.')

    p.add_argument('--minL',
                   default=0.,
                   type=float,
                   help='Minimum length of streamlines, in mm. [%(default)s]')
    p.add_argument('--maxL',
                   default=np.inf,
                   type=float,
                   help='Maximum length of streamlines, in mm. [%(default)s]')
    p.add_argument('-a',
                   dest='angle',
                   default=np.inf,
                   type=float,
                   help='Maximum looping (or turning) angle of\n' +
                   'a streamline, in degrees. [%(default)s]')

    p.add_argument('--csf_bin',
                   help='Allow CSF endings filtering with this binary\n' +
                   'mask instead of using the atlas (.nii or .nii.gz)')
    p.add_argument('--ctx_dilation_radius',
                   type=float,
                   default=0.,
                   help='Cortical labels dilation radius, in mm.\n' +
                   ' [%(default)s]')
    p.add_argument('--save_intermediate_tractograms',
                   action='store_true',
                   help='Save accepted and discarded streamlines\n' +
                   ' after each step.')
    p.add_argument('--save_volumes',
                   action='store_true',
                   help='Save volumetric images (e.g. binarised label\n' +
                   ' images, etc) in the filtering process.')
    p.add_argument('--save_counts',
                   action='store_true',
                   help='Save the streamline counts to a file (.json)')
    p.add_argument('--no_empty',
                   action='store_true',
                   help='Do not write file if there is no streamlines.')

    add_reference_arg(p)
    add_verbose_arg(p)
    add_overwrite_arg(p)
    add_json_args(p)

    return p
Exemplo n.º 25
0
def _build_arg_parser():
    p = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                description=__doc__)

    p.add_argument('in_tractogram', help='Path of the input tractogram file.')
    p.add_argument('out_tractogram',
                   help='Path of the output tractogram file.')

    p.add_argument('--drawn_roi',
                   nargs=3,
                   action='append',
                   metavar=('ROI_NAME', 'MODE', 'CRITERIA'),
                   help='Filename of a hand drawn ROI (.nii or .nii.gz).')
    p.add_argument('--atlas_roi',
                   nargs=4,
                   action='append',
                   metavar=('ROI_NAME', 'ID', 'MODE', 'CRITERIA'),
                   help='Filename of an atlas (.nii or .nii.gz).')
    p.add_argument('--bdo',
                   nargs=3,
                   action='append',
                   metavar=('BDO_NAME', 'MODE', 'CRITERIA'),
                   help='Filename of a bounding box (bdo) file from MI-Brain.')

    p.add_argument('--x_plane',
                   nargs=3,
                   action='append',
                   metavar=('PLANE', 'MODE', 'CRITERIA'),
                   help='Slice number in X, in voxel space.')
    p.add_argument('--y_plane',
                   nargs=3,
                   action='append',
                   metavar=('PLANE', 'MODE', 'CRITERIA'),
                   help='Slice number in Y, in voxel space.')
    p.add_argument('--z_plane',
                   nargs=3,
                   action='append',
                   metavar=('PLANE', 'MODE', 'CRITERIA'),
                   help='Slice number in Z, in voxel space.')
    p.add_argument('--filtering_list',
                   help='Text file containing one rule per line\n'
                   '(i.e. drawn_roi mask.nii.gz both_ends include).')
    p.add_argument('--no_empty',
                   action='store_true',
                   help='Do not write file if there is no streamline.')
    p.add_argument('--display_counts',
                   action='store_true',
                   help='Print streamline count before and after filtering')

    add_reference_arg(p)
    add_verbose_arg(p)
    add_overwrite_arg(p)
    add_json_args(p)

    return p
Exemplo n.º 26
0
def _build_arg_parser():

    p = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                description=__doc__)

    p.add_argument('operation',
                   choices=OPERATIONS.keys(),
                   metavar='OPERATION',
                   help='The type of operation to be performed on the '
                   'streamlines. Must\nbe one of the following: '
                   '%(choices)s.')

    p.add_argument('inputs',
                   metavar='INPUT_FILES',
                   nargs='+',
                   help='The list of files that contain the ' +
                   'streamlines to operate on.')

    p.add_argument('output',
                   metavar='OUTPUT_FILE',
                   help='The file where the remaining streamlines '
                   'are saved.')

    p.add_argument('--precision',
                   '-p',
                   metavar='NUMBER_OF_DECIMALS',
                   type=int,
                   help='The precision used when comparing streamlines.')
    p.add_argument('--no_metadata',
                   '-n',
                   action='store_true',
                   help='Strip the streamline metadata from the output.')

    p.add_argument('--save_metadata_indices',
                   '-m',
                   action='store_true',
                   help='Save streamline indices to metadata. Has no '
                   'effect if --no-data\nis present. Will '
                   'overwrite \'ids\' metadata if already present.')
    p.add_argument('--save_indices',
                   '-s',
                   metavar='OUTPUT_INDEX_FILE',
                   help='Save the streamline indices to the supplied '
                   'json file.')

    p.add_argument('--ignore_invalid',
                   action='store_true',
                   help='If set, does not crash because of invalid '
                   'streamlines.')

    add_reference_arg(p)
    add_verbose_arg(p)
    add_overwrite_arg(p)

    return p
def _build_arg_parser():
    p = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
                                description=__doc__,
                                epilog=EPILOG)

    p.add_argument('in_tractogram', help='Input tractogram filename.')
    p.add_argument('in_model', help='Model to use for recognition.')
    p.add_argument('in_transfo',
                   help='Path for the transformation to model space '
                   '(.txt, .npy or .mat).')
    p.add_argument('out_tractogram', help='Output tractogram filename.')

    p.add_argument('--tractogram_clustering_thr',
                   type=float,
                   default=8,
                   help='Clustering threshold used for the whole brain '
                   '[%(default)smm].')
    p.add_argument('--model_clustering_thr',
                   type=float,
                   default=4,
                   help='Clustering threshold used for the model '
                   '[%(default)smm].')
    p.add_argument('--pruning_thr',
                   type=float,
                   default=6,
                   help='MDF threshold used for final streamlines selection '
                   '[%(default)smm].')

    p.add_argument('--slr_threads',
                   type=int,
                   default=None,
                   help='Number of threads for SLR [all].')
    p.add_argument('--seed',
                   type=int,
                   default=None,
                   help='Random number generator seed [%(default)s].')
    p.add_argument('--inverse',
                   action='store_true',
                   help='Use the inverse transformation.')
    p.add_argument('--no_empty',
                   action='store_true',
                   help='Do not write file if there is no streamline.')

    group = p.add_mutually_exclusive_group()
    group.add_argument(
        '--in_pickle',
        help='Input pickle clusters map file.\n'
        'Will override the tractogram_clustering_thr parameter.')
    group.add_argument('--out_pickle', help='Output pickle clusters map file.')

    add_reference_arg(p)
    add_verbose_arg(p)
    add_overwrite_arg(p)

    return p
Exemplo n.º 28
0
def _build_arg_parser():
    p = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawTextHelpFormatter,
    )
    p.add_argument('in_bundles_dir',
                   help='Folder containing all the bundle files (.trk).')
    p.add_argument('labels_list',
                   help='Text file containing the list of labels from the '
                   'atlas.')
    p.add_argument('--volume',
                   metavar='OUT_FILE',
                   help='Output file for the volume weighted matrix (.npy).')
    p.add_argument('--streamline_count',
                   metavar='OUT_FILE',
                   help='Output file for the streamline count weighted matrix '
                   '(.npy).')
    p.add_argument('--length',
                   metavar='OUT_FILE',
                   help='Output file for the length weighted matrix (.npy).')
    p.add_argument('--similarity',
                   nargs=2,
                   metavar=('IN_FOLDER', 'OUT_FILE'),
                   help='Input folder containing the averaged bundle density\n'
                   'maps (.nii.gz) and output file for the similarity '
                   'weighted matrix (.npy).')
    p.add_argument('--maps',
                   nargs=2,
                   action='append',
                   metavar=('IN_FOLDER', 'OUT_FILE'),
                   help='Input folder containing pre-computed maps (.nii.gz)\n'
                   'and output file for the weighted matrix (.npy).')
    p.add_argument('--metrics',
                   nargs=2,
                   action='append',
                   metavar=('IN_FILE', 'OUT_FILE'),
                   help='Input (.nii.gz). and output file (.npy) for a metric '
                   'weighted matrix.')

    p.add_argument(
        '--density_weighting',
        action="store_true",
        help='Use density-weighting for the metric weighted matrix.')
    p.add_argument('--no_self_connection',
                   action="store_true",
                   help='Eliminate the diagonal from the matrices.')

    add_processes_arg(p)
    add_reference_arg(p)
    add_verbose_arg(p)
    add_overwrite_arg(p)

    return p
Exemplo n.º 29
0
def _build_arg_parser():
    p = argparse.ArgumentParser(description=__doc__,
                                formatter_class=argparse.RawTextHelpFormatter)
    p.add_argument('in_bundles',
                   nargs='+',
                   help='List of tractography files supported by nibabel.')
    p.add_argument('in_labels',
                   nargs='+',
                   help='List of labels maps that matches the bundles.')

    p.add_argument('--fitting_func',
                   choices=['lin_up', 'lin_down', 'exp', 'inv', 'log'],
                   default=None,
                   help='Function to weigh points using their distance.'
                   '\n[Default: %(default)s]')

    p2 = p.add_argument_group(title='Visualization options')
    p3 = p2.add_mutually_exclusive_group()
    p3.add_argument('--show_rendering',
                    action='store_true',
                    help='Display VTK window (optional).')
    p3.add_argument('--save_rendering',
                    metavar='OUT_FOLDER',
                    help='Save VTK render in the specified folder (optional)')
    p2.add_argument('--wireframe',
                    action='store_true',
                    help='Use wireframe for the tube rendering.')
    p2.add_argument('--error_coloring',
                    action='store_true',
                    help='Use the fitting error to color the tube.')
    p2.add_argument('--width',
                    type=float,
                    default=0.2,
                    help='Width of tubes or lines representing streamlines'
                    '\n[Default: %(default)s]')
    p2.add_argument('--opacity',
                    type=float,
                    default=0.2,
                    help='Opacity for the streamlines rendered with the tube.'
                    '\n[Default: %(default)s]')
    p2.add_argument('--background',
                    metavar=('R', 'G', 'B'),
                    nargs=3,
                    default=[1, 1, 1],
                    type=parser_color_type,
                    help='RBG values [0, 255] of the color of the background.'
                    '\n[Default: %(default)s]')

    add_reference_arg(p)
    add_json_args(p)
    add_overwrite_arg(p)

    return p
def _build_arg_parser():
    p = argparse.ArgumentParser(description=__doc__,
                                formatter_class=argparse.RawTextHelpFormatter)
    p.add_argument('in_bundles', nargs='+', help='Path of the input bundles.')
    p.add_argument('out_json', help='Path of the output file.')

    add_reference_arg(p)
    add_processes_arg(p)
    add_json_args(p)
    add_overwrite_arg(p)

    return p