Ejemplo n.º 1
0
def _mk_stats_parser():
    p = ArgParser(add_help=False)
    # p.add_argument_group("Statistics options",
    #                      "Options for calculating statistics.")
    default_fwhms = "0.2"
    p.set_defaults(stats_kernels=default_fwhms)
    p.set_defaults(calc_stats=True)
    p.add_argument(
        "--calc-stats",
        dest="calc_stats",
        action="store_true",
        help=
        "Calculate statistics at the end of the registration. [Default = %(default)s]"
    )
    p.add_argument(
        "--no-calc-stats",
        dest="calc_stats",
        action="store_false",
        help=
        "If specified, statistics are not calculated. Opposite of --calc-stats."
    )
    p.add_argument(
        "--stats-kernels",
        dest="stats_kernels",
        type=str,
        help=
        "comma separated list of blurring kernels for analysis. [Default = %(default)s]."
    )
    return p
Ejemplo n.º 2
0
def _mk_thickness_parser(parser: ArgParser):
    group = parser.add_argument_group("Thickness",
                                      "Thickness calculation options.")
    group.add_argument("--run-thickness",
                       action='store_true',
                       dest="run_thickness",
                       help="Run thickness computation.")
    group.add_argument("--no-run-thickness",
                       action='store_false',
                       dest="run_thickness",
                       help="Don't run thickness computation.")
    parser.set_defaults(run_thickness=True)
    group.add_argument(
        "--label-mapping",
        type=str,
        dest="label_mapping",
        help="path to CSV file mapping; see minclaplace/wiki/LaplaceGrid")
    group.add_argument(
        "--atlas-fwhm",
        dest="atlas_fwhm",
        type=float,  # default ?!
        help="Blurring kernel (mm) for atlas")
    group.add_argument(
        "--thickness-fwhm",
        dest="thickness_fwhm",
        type=float,  # default??
        help="Blurring kernel (mm) for cortical surfaces")
    return parser
Ejemplo n.º 3
0
def _mk_lsq12_parser():
    p = ArgParser(add_help=False)
    # group = parser.add_argument_group("LSQ12 registration options",
    #                                  "Options for performing a pairwise, affine registration")
    p.set_defaults(run_lsq12=True)
    p.add_argument("--run-lsq12", dest="run_lsq12",
                   action="store_true",
                   help="Actually run the 12 parameter alignment [default = %(default)s]")
    p.add_argument("--no-run-lsq12", dest="run_lsq12",
                   action="store_false",
                   help="Opposite of --run-lsq12")
    p.add_argument("--lsq12-max-pairs", dest="max_pairs",
                   type=parse_nullable_int, default=25,
                   help="Maximum number of pairs to register together ('None' implies all pairs). "
                        "[Default = %(default)s]")
    p.add_argument("--lsq12-likefile", dest="like_file",
                   type=str, default=None,
                   help="Can optionally specify a 'like'-file for resampling at the end of pairwise "
                        "alignment. Default is None, which means that the input file will be used. "
                        "[Default = %(default)s]")
    p.add_argument("--lsq12-protocol", dest="protocol",
                   type=str,
                   help="Can optionally specify a registration protocol that is different from defaults. "
                        "Parameters must be specified as in the following example: \n"
                        "applications_testing/test_data/minctracc_example_linear_protocol.csv \n"
                        "[Default = %(default)s].")
    return p
Ejemplo n.º 4
0
def _mk_maget_parser(parser : ArgParser):
    group = parser.add_argument_group("MAGeT options", "Options for running MAGeT.")
    group.add_argument("--atlas-library", dest="atlas_lib",  # can't make required=True since may not be using MAGeT :|
                       type=str,                             # TODO: check existence of this dir?
                       help="Directory of existing atlas/label pairs")
    group.add_argument("--pairwise", dest="pairwise",
                       action="store_true",
                       help="""If specified, register inputs to each other pairwise. [Default]""")
    group.add_argument("--no-pairwise", dest="pairwise",
                       action="store_false",
                       help="""If specified, only register inputs to atlases in library.""")
    parser.set_defaults(pairwise=True)
    group.add_argument("--mask", dest="mask",
                       action="store_true", default=False,
                       help="Create a mask for all images prior to handling labels. [Default = %(default)s]")
    group.add_argument("--mask-only", dest="mask_only",
                       action="store_true", default=False,
                       help="Create a mask for all images only, do not run full algorithm. [Default = %(default)s]")
    group.add_argument("--max-templates", dest="max_templates",
                       default=25, type=int,
                       help="Maximum number of templates to generate. [Default = %(default)s]")
    group.add_argument("--masking-method", dest="mask_method",
                       default="minctracc", type=str,
                       help="Specify whether to use minctracc or mincANTS for masking. [Default = %(default)s].")
    group.add_argument("--masking-nlin-protocol", dest="masking_nlin_protocol",
                       # TODO basically copied from nlin parser
                       type=str, default=None,
                       help="Can optionally specify a registration protocol that is different from nlin protocol. "
                            "Parameters must be specified as in either or the following examples: \n"
                            "applications_testing/test_data/minctracc_example_nlin_protocol.csv \n"
                            "applications_testing/test_data/mincANTS_example_nlin_protocol.csv \n"
                            "[Default = %(default)s]")
    return parser
Ejemplo n.º 5
0
def _mk_segmentation_parser(parser : ArgParser, default : bool):
    group = parser.add_argument_group("Segmentation", "Segmentation options.")
    group.add_argument("--run-maget", action='store_true', dest="run_maget",
                       help="Run MAGeT segmentation. [default = %(default)s]")
    group.add_argument("--no-run-maget", dest="run_maget",
                       action='store_false', help="Don't run MAGeT segmentation")
    parser.set_defaults(run_maget=True)
    return parser
Ejemplo n.º 6
0
def _mk_segmentation_parser(parser: ArgParser, default: bool):
    group = parser.add_argument_group("Segmentation", "Segmentation options.")
    group.add_argument("--run-maget",
                       action='store_true',
                       dest="run_maget",
                       help="Run MAGeT segmentation. [default = %(default)s]")
    group.add_argument("--no-run-maget",
                       dest="run_maget",
                       action='store_false',
                       help="Don't run MAGeT segmentation")
    parser.set_defaults(run_maget=True)
    return parser
Ejemplo n.º 7
0
def _mk_lsq12_parser():
    p = ArgParser(add_help=False)
    # group = parser.add_argument_group("LSQ12 registration options",
    #                                  "Options for performing a pairwise, affine registration")
    p.set_defaults(run_lsq12=True)
    p.set_defaults(generate_tournament_style_lsq12_avg=False)
    p.add_argument(
        "--run-lsq12",
        dest="run_lsq12",
        action="store_true",
        help="Actually run the 12 parameter alignment [default = %(default)s]")
    p.add_argument("--no-run-lsq12",
                   dest="run_lsq12",
                   action="store_false",
                   help="Opposite of --run-lsq12")
    p.add_argument(
        "--lsq12-max-pairs",
        dest="max_pairs",
        type=parse_nullable_int,
        default=25,
        help=
        "Maximum number of pairs to register together ('None' implies all pairs). "
        "[Default = %(default)s]")
    p.add_argument(
        "--lsq12-likefile",
        dest="like_file",
        type=str,
        default=None,
        help=
        "Can optionally specify a 'like'-file for resampling at the end of pairwise "
        "alignment. Default is None, which means that the input file will be used. "
        "[Default = %(default)s]")
    p.add_argument(
        "--lsq12-protocol",
        dest="protocol",
        type=str,
        help=
        "Can optionally specify a registration protocol that is different from defaults. "
        "Parameters must be specified as in the following example: \n"
        "applications_testing/test_data/minctracc_example_linear_protocol.csv \n"
        "[Default = %(default)s].")
    #p.add_argument("--generate-tournament-style-lsq12-avg", dest="generate_tournament_style_lsq12_avg",
    #               action="store_true",
    #               help="Instead of creating the average of the lsq12 resampled files "
    #                    "by simply averaging them directly, create an iterative average "
    #                    "as follows. Perform a non linear registration between pairs "
    #                    "of files. Resample each file halfway along that transformation "
    #                    "in order for them to end up in the middle. Average those two files. "
    #                    "Then continue on to the next level as in a tournament. [default = %(default)s]")
    #p.add_argument("--no-generate-tournament-style-lsq12-avg", dest="generate_tournament_style_lsq12_avg",
    #               action="store_false",
    #               help="Opposite of --generate-tournament-style-lsq12-avg")
    return p
Ejemplo n.º 8
0
def get_settings_parser() -> ArgParser:
    """Returns the single global argument parser for adding parameters.

    Parameters can be added in all modules by add_argument.
    After calling parse() once in the main program, all settings
    are available in the global settings dictionary.
    """
    global _parser  # pylint: disable=global-statement
    if not _parser:
        _parser = ArgParser(  # default_config_files=["default.cfg"],
            formatter_class=ArgumentDefaultsRawHelpFormatter)
        _parser.set_defaults(seed=0)
    return _parser
Ejemplo n.º 9
0
def _mk_thickness_parser(parser : ArgParser):
    group = parser.add_argument_group("Thickness", "Thickness calculation options.")
    group.add_argument("--run-thickness", action='store_true', dest="run_thickness",
                       help="Run thickness computation.")
    group.add_argument("--no-run-thickness", action='store_false', dest="run_thickness",
                       help="Don't run thickness computation.")
    parser.set_defaults(run_thickness=True)
    group.add_argument("--label-mapping", type=str, dest="label_mapping",
                       help="path to CSV file mapping; see minclaplace/wiki/LaplaceGrid")
    group.add_argument("--atlas-fwhm", dest="atlas_fwhm", type=float, # default ?!
                       help="Blurring kernel (mm) for atlas")
    group.add_argument("--thickness-fwhm", dest="thickness_fwhm", type=float, # default??
                       help="Blurring kernel (mm) for cortical surfaces")
    return parser
Ejemplo n.º 10
0
def _mk_stats_parser():
    p = ArgParser(add_help=False)
    # p.add_argument_group("Statistics options",
    #                      "Options for calculating statistics.")
    default_fwhms = "0.2"
    p.set_defaults(stats_kernels=default_fwhms)
    p.set_defaults(calc_stats=True)
    p.add_argument("--calc-stats", dest="calc_stats",
                   action="store_true",
                   help="Calculate statistics at the end of the registration. [Default = %(default)s]")
    p.add_argument("--no-calc-stats", dest="calc_stats",
                   action="store_false",
                   help="If specified, statistics are not calculated. Opposite of --calc-stats.")
    p.add_argument("--stats-kernels", dest="stats_kernels",
                   type=str,
                   help="comma separated list of blurring kernels for analysis. [Default = %(default)s].")
    return p
Ejemplo n.º 11
0
def _mk_lsq12_parser():
    p = ArgParser(add_help=False)
    # group = parser.add_argument_group("LSQ12 registration options",
    #                                  "Options for performing a pairwise, affine registration")
    p.set_defaults(run_lsq12=True)
    p.set_defaults(generate_tournament_style_lsq12_avg=False)
    p.add_argument("--run-lsq12", dest="run_lsq12",
                   action="store_true",
                   help="Actually run the 12 parameter alignment [default = %(default)s]")
    p.add_argument("--no-run-lsq12", dest="run_lsq12",
                   action="store_false",
                   help="Opposite of --run-lsq12")
    p.add_argument("--lsq12-max-pairs", dest="max_pairs",
                   type=parse_nullable_int, default=25,
                   help="Maximum number of pairs to register together ('None' implies all pairs). "
                        "[Default = %(default)s]")
    p.add_argument("--lsq12-likefile", dest="like_file",
                   type=str, default=None,
                   help="Can optionally specify a 'like'-file for resampling at the end of pairwise "
                        "alignment. Default is None, which means that the input file will be used. "
                        "[Default = %(default)s]")
    p.add_argument("--lsq12-protocol", dest="protocol",
                   type=str,
                   help="Can optionally specify a registration protocol that is different from defaults. "
                        "Parameters must be specified as in the following example: \n"
                        "applications_testing/test_data/minctracc_example_linear_protocol.csv \n"
                        "[Default = %(default)s].")
    #p.add_argument("--generate-tournament-style-lsq12-avg", dest="generate_tournament_style_lsq12_avg",
    #               action="store_true",
    #               help="Instead of creating the average of the lsq12 resampled files "
    #                    "by simply averaging them directly, create an iterative average "
    #                    "as follows. Perform a non linear registration between pairs "
    #                    "of files. Resample each file halfway along that transformation "
    #                    "in order for them to end up in the middle. Average those two files. "
    #                    "Then continue on to the next level as in a tournament. [default = %(default)s]")
    #p.add_argument("--no-generate-tournament-style-lsq12-avg", dest="generate_tournament_style_lsq12_avg",
    #               action="store_false",
    #               help="Opposite of --generate-tournament-style-lsq12-avg")
    return p
Ejemplo n.º 12
0
def _mk_nlin_parser(p: ArgParser):
    group = p.add_argument_group(
        "Nonlinear registration options",
        "Options for performing a non-linear registration")
    group.add_argument(
        "--registration-method",
        dest="reg_method",
        default="ANTS",
        choices=["ANTS", "antsRegistration", "minctracc"],
        help="Specify algorithm used for non-linear registrations. "
        "[Default = %(default)s]")
    # TODO wire up the choices here in reg_method and reg_strategy to the actual ones ...
    group.add_argument(
        "--registration-strategy",
        dest="reg_strategy",
        default="build_model",
        choices=[
            'build_model', 'pairwise', 'tournament',
            'tournament_and_build_model', 'pairwise_and_build_model'
        ],
        help="Process used for model construction [Default = %(default)s")
    group.add_argument(
        "--nlin-protocol",
        dest="nlin_protocol",
        type=str,
        default=None,
        help=
        "Can optionally specify a registration protocol that is different from defaults. "
        "Parameters must be specified as in either or the following examples: \n"
        "applications_testing/test_data/minctracc_example_nlin_protocol.csv \n"
        "applications_testing/test_data/mincANTS_example_nlin_protocol.csv \n"
        "[Default = %(default)s]")
    group.add_argument("--use-robust-averaging",
                       dest="use_robust_averaging",
                       action='store_true',
                       help="use robust intensity averaging if possible")
    p.set_defaults(use_robust_averaging=False)
    return p
Ejemplo n.º 13
0
def _mk_lsq6_parser(with_nuc : bool = True,
                    with_inormalize : bool = True):
    p = ArgParser(add_help=False)
    p.set_defaults(lsq6_method="lsq6_large_rotations")
    p.set_defaults(nuc = True if with_nuc else False)
    p.set_defaults(inormalize = True if with_inormalize else False)
    p.set_defaults(copy_header_info=False)
    # TODO: should this actually be part of the LSQ6 component?  What would it return in this case?
    p.set_defaults(run_lsq6=True)
    p.add_argument("--run-lsq6", dest="run_lsq6",
                   action="store_true",
                   help="Actually run the 6 parameter alignment [default = %(default)s]")
    p.add_argument("--no-run-lsq6", dest="run_lsq6",
                   action="store_false",
                   help="Opposite of --run-lsq6")
    # TODO should be part of some mutually exclusive group ...
    p.add_argument("--init-model", dest="init_model",
                   type=str, default=None,
                   help="File in standard space in the initial model. The initial model "
                        "can also have a file in native space and potentially a transformation "
                        "file. See our wiki (https://wiki.mouseimaging.ca/) for detailed "
                        "information on initial models. [Default = %(default)s]")
    p.add_argument("--lsq6-target", dest="lsq6_target",
                   type=str, default=None,
                   help="File to be used as the target for the initial (often 6-parameter) alignment. "
                        "[Default = %(default)s]")
    p.add_argument("--bootstrap", dest="bootstrap",
                   action="store_true", default=False,
                   help="Use the first input file to the pipeline as the target for the "
                        "initial (often 6-parameter) alignment. [Default = %(default)s]")
    # TODO: add information about the pride of models to the code in such a way that it
    # is reflected on GitHub
    p.add_argument("--pride-of-models", dest="pride_of_models",
                   type=str, default=None,
                   help="(selected longitudinal pipelines only!) Specify a csv file that contains the mapping of "
                        "all your initial models at different time points. The idea is that you might "
                        "want to use different initial models for the time points in your data. "
                        "The csv file should have one column called \"model_file\", and one column "
                        "called \"time_point\". The time points can be given in either integer values "
                        "or float values. Each model file should point to the file in standard space "
                        "for that particular model.  [Default = %(default)s]")
    # TODO: do we need to implement this option? This was for Kieran Short, but the procedure
    # he will be using in the future most likely will not involve this option.
    # group.add_argument("--lsq6-alternate-data-prefix", dest="lsq6_alternate_prefix",
    #                   type=str, default=None,
    #                   help="Specify a prefix for an augmented data set to use for the 6 parameter "
    #                   "alignment. Assumptions: there is a matching alternate file for each regular input "
    #                   "file, e.g. input files are: input_1.mnc input_2.mnc ... input_n.mnc. If the "
    #                   "string provided for this flag is \"aug_\", then the following files should exist: "
    #                   "aug_input_1.mnc aug_input_2.mnc ... aug_input_n.mnc. These files are assumed to be "
    #                   "in the same orientation/location as the regular input files.  They will be used for "
    #                   "for the 6 parameter alignment. The transformations will then be used to transform "
    #                   "the regular input files, with which the pipeline will continue.")
    p.add_argument("--lsq6-simple", dest="lsq6_method",
                   action="store_const", const="lsq6_simple",
                   help="Run a 6 parameter alignment assuming that the input files are roughly "
                        "aligned: same space, similar orientation. Keep in mind that if you use an "
                        "initial model with both a standard and a native space, the assumption is "
                        "that the input files are already roughly aligned to the native space. "
                        "Three iterations are run: 1st is 17 times stepsize blur, 2nd is 9 times "
                        "stepsize gradient, 3rd is 4 times stepsize blur. [Default = %(default)s]")
    p.add_argument("--lsq6-centre-estimation", dest="lsq6_method",
                   action="store_const", const="lsq6_centre_estimation",
                   help="Run a 6 parameter alignment assuming that the input files have a "
                        "similar orientation, but are scanned in different coils/spaces. [Default = %(default)s]")
    p.add_argument("--lsq6-large-rotations", dest="lsq6_method",
                   action="store_const", const="lsq6_large_rotations",
                   help="Run a 6 parameter alignment assuming that the input files have a random "
                        "orientation and are scanned in different coils/spaces. A brute force search over "
                        "the x,y,z rotation space is performed to find the best 6 parameter alignment. "
                        "[Default = %(default)s]")
    p.add_argument("--lsq6-large-rotations-tmp-dir", dest="rotation_tmp_dir",
                   type=str, default="/dev/shm/",
                   help="Specify the directory that rotational_minctracc.py uses for temporary files. "
                        "By default we use /dev/shm/, because this program involves a lot of I/O, and "
                        "this is probably one of the fastest way to provide this. [Default = %(default)s]")
    p.add_argument("--lsq6-large-rotations-parameters", dest="rotation_params",
                   type=str, default="5,4,10,8",
                   help="Settings for the large rotation alignment. factor=factor based on smallest file "
                        "resolution: 1) blur factor, 2) resample step size factor, 3) registration step size "
                        "factor, 4) w_translations factor  ***** if you are working with mouse brain data "
                        " the defaults do not have to be based on the file resolution; a default set of "
                        " settings works for all mouse brain. In order to use those setting, specify: "
                        "\"mousebrain\" as the argument for this option. ***** [default = %(default)s]")
    p.add_argument("--lsq6-rotational-range", dest="rotation_range",
                   type=int, default=50,
                   help="Settings for the rotational range in degrees when running the large rotation "
                        "alignment. [Default = %(default)s]")
    p.add_argument("--lsq6-rotational-interval", dest="rotation_interval",
                   type=int, default=10,
                   help="Settings for the rotational interval in degrees when running the large rotation "
                        "alignment. [Default = %(default)s]")
    p.add_argument("--nuc", dest="nuc",
                   action="store_true",
                   help="Perform non-uniformity correction. [Default = %(default)s]")
    p.add_argument("--no-nuc", dest="nuc",
                   action="store_false",
                   help="If specified, do not perform non-uniformity correction. Opposite of --nuc.")
    p.add_argument("--inormalize", dest="inormalize",
                   action="store_true",
                   help="Normalize the intensities after lsq6 alignment and nuc, if done. "
                        "[Default = %(default)s] ")
    p.add_argument("--no-inormalize", dest="inormalize",
                   action="store_false",
                   help="If specified, do not perform intensity normalization. Opposite of --inormalize.")
    p.add_argument("--copy-header-info-to-average", dest="copy_header_info",
                   action="store_true",
                   help="Copy the MINC header information of the first input file into the "
                        "average that is created. [Default = %(default)s] ")
    p.add_argument("--no-copy-header-info-to-average", dest="copy_header_info",
                   action="store_false",
                   help="Opposite of --copy-header-info-to-average.")
    p.add_argument("--lsq6-protocol", dest="protocol_file",
                   type=str, default=None,
                   help="Specify an lsq6 protocol that overrides the default setting for stages in "
                        "the 6 parameter minctracc call. Parameters must be specified as in the following \n"
                        "example: applications_testing/test_data/minctracc_example_linear_protocol.csv \n"
                        "[Default = %(default)s].")
    return p
Ejemplo n.º 14
0
def _mk_maget_parser(parser: ArgParser):
    group = parser.add_argument_group("MAGeT options",
                                      "Options for running MAGeT.")
    group.add_argument(
        "--atlas-library",
        dest=
        "atlas_lib",  # can't make required=True since may not be using MAGeT :|
        type=str,  # TODO: check existence of this dir?
        help=
        "Directory of existing atlas/label pairs (alternative to --atlas-csv)")
    group.add_argument(
        "--atlas-csv",
        dest="atlas_csv",
        type=str,
        help=
        "CSV containing (at least) `file`, `mask_file`, `label_file` columns "
        "(alternative to --atlas-library)")
    group.add_argument(
        "--pairwise",
        dest="pairwise",
        action="store_true",
        help=
        """If specified, register inputs to each other pairwise. [Default]""")
    group.add_argument(
        "--no-pairwise",
        dest="pairwise",
        action="store_false",
        help="""If specified, only register inputs to atlases in library.""")
    parser.set_defaults(pairwise=True)
    group.add_argument(
        "--mask",
        dest="mask",
        action="store_true",
        default=True,
        help=
        "Create a mask for all images prior to handling labels. [Default = %(default)s]"
    )
    group.add_argument("--no-mask",
                       dest="mask",
                       action="store_false",
                       default=True,
                       help="Opposite of --mask.")
    group.add_argument(
        "--mask-only",
        dest="mask_only",
        action="store_true",
        default=False,
        help=
        "Create a mask for all images only, do not run full algorithm. [Default = %(default)s]"
    )
    group.add_argument(
        "--max-templates",
        dest="max_templates",
        default=25,
        type=int,
        help="Maximum number of templates to generate. [Default = %(default)s]"
    )
    group.add_argument(
        "--masking-method",
        dest="mask_method",
        default="minctracc",
        type=str,
        help=
        "Specify whether to use minctracc or ANTS for masking. [Default = %(default)s]."
    )
    group.add_argument(
        "--masking-nlin-protocol",
        dest="masking_nlin_protocol",
        # TODO basically copied from nlin parser
        type=str,
        default=None,
        help=
        "Can optionally specify a registration protocol that is different from nlin protocol. "
        "Parameters must be specified as in either or the following examples: \n"
        "applications_testing/test_data/minctracc_example_nlin_protocol.csv \n"
        "applications_testing/test_data/mincANTS_example_nlin_protocol.csv \n"
        "[Default = %(default)s]")
    return parser
Ejemplo n.º 15
0
def _mk_lsq6_parser(with_nuc: bool = True, with_inormalize: bool = True):
    p = ArgParser(add_help=False)
    p.set_defaults(lsq6_method="lsq6_large_rotations")
    p.set_defaults(nuc=True if with_nuc else False)
    p.set_defaults(inormalize=True if with_inormalize else False)
    p.set_defaults(copy_header_info=False)
    # TODO: should this actually be part of the LSQ6 component?  What would it return in this case?
    p.set_defaults(run_lsq6=True)
    p.add_argument(
        "--run-lsq6",
        dest="run_lsq6",
        action="store_true",
        help="Actually run the 6 parameter alignment [default = %(default)s]")
    p.add_argument("--no-run-lsq6",
                   dest="run_lsq6",
                   action="store_false",
                   help="Opposite of --run-lsq6")
    # TODO should be part of some mutually exclusive group ...
    p.add_argument(
        "--init-model",
        dest="init_model",
        type=str,
        default=None,
        help="File in standard space in the initial model. The initial model "
        "can also have a file in native space and potentially a transformation "
        "file. See our wiki (https://wiki.mouseimaging.ca/) for detailed "
        "information on initial models. [Default = %(default)s]")
    p.add_argument(
        "--lsq6-target",
        dest="lsq6_target",
        type=str,
        default=None,
        help=
        "File to be used as the target for the initial (often 6-parameter) alignment. "
        "[Default = %(default)s]")
    p.add_argument(
        "--bootstrap",
        dest="bootstrap",
        action="store_true",
        default=False,
        help="Use the first input file to the pipeline as the target for the "
        "initial (often 6-parameter) alignment. [Default = %(default)s]")
    # TODO: add information about the pride of models to the code in such a way that it
    # is reflected on GitHub
    p.add_argument(
        "--pride-of-models",
        dest="pride_of_models",
        type=str,
        default=None,
        help=
        "(selected longitudinal pipelines only!) Specify a csv file that contains the mapping of "
        "all your initial models at different time points. The idea is that you might "
        "want to use different initial models for the time points in your data. "
        "The csv file should have one column called \"model_file\", and one column "
        "called \"time_point\". The time points can be given in either integer values "
        "or float values. Each model file should point to the file in standard space "
        "for that particular model.  [Default = %(default)s]")
    # TODO: do we need to implement this option? This was for Kieran Short, but the procedure
    # he will be using in the future most likely will not involve this option.
    # group.add_argument("--lsq6-alternate-data-prefix", dest="lsq6_alternate_prefix",
    #                   type=str, default=None,
    #                   help="Specify a prefix for an augmented data set to use for the 6 parameter "
    #                   "alignment. Assumptions: there is a matching alternate file for each regular input "
    #                   "file, e.g. input files are: input_1.mnc input_2.mnc ... input_n.mnc. If the "
    #                   "string provided for this flag is \"aug_\", then the following files should exist: "
    #                   "aug_input_1.mnc aug_input_2.mnc ... aug_input_n.mnc. These files are assumed to be "
    #                   "in the same orientation/location as the regular input files.  They will be used for "
    #                   "for the 6 parameter alignment. The transformations will then be used to transform "
    #                   "the regular input files, with which the pipeline will continue.")
    p.add_argument(
        "--lsq6-simple",
        dest="lsq6_method",
        action="store_const",
        const="lsq6_simple",
        help=
        "Run a 6 parameter alignment assuming that the input files are roughly "
        "aligned: same space, similar orientation. Keep in mind that if you use an "
        "initial model with both a standard and a native space, the assumption is "
        "that the input files are already roughly aligned to the native space. "
        "Three iterations are run: 1st is 17 times stepsize blur, 2nd is 9 times "
        "stepsize gradient, 3rd is 4 times stepsize blur. [Default = %(default)s]"
    )
    p.add_argument(
        "--lsq6-centre-estimation",
        dest="lsq6_method",
        action="store_const",
        const="lsq6_centre_estimation",
        help="Run a 6 parameter alignment assuming that the input files have a "
        "similar orientation, but are scanned in different coils/spaces. [Default = %(default)s]"
    )
    p.add_argument(
        "--lsq6-large-rotations",
        dest="lsq6_method",
        action="store_const",
        const="lsq6_large_rotations",
        help=
        "Run a 6 parameter alignment assuming that the input files have a random "
        "orientation and are scanned in different coils/spaces. A brute force search over "
        "the x,y,z rotation space is performed to find the best 6 parameter alignment. "
        "[Default = %(default)s]")
    p.add_argument(
        "--lsq6-large-rotations-tmp-dir",
        dest="rotation_tmp_dir",
        type=str,
        default="/dev/shm/",
        help=
        "Specify the directory that rotational_minctracc.py uses for temporary files. "
        "By default we use /dev/shm/, because this program involves a lot of I/O, and "
        "this is probably one of the fastest way to provide this. [Default = %(default)s]"
    )
    p.add_argument(
        "--lsq6-large-rotations-parameters",
        dest="rotation_params",
        type=str,
        default="5,4,10,8",
        help=
        "Settings for the large rotation alignment. factor=factor based on smallest file "
        "resolution: 1) blur factor, 2) resample step size factor, 3) registration step size "
        "factor, 4) w_translations factor  ***** if you are working with mouse brain data "
        " the defaults do not have to be based on the file resolution; a default set of "
        " settings works for all mouse brain. In order to use those setting, specify: "
        "\"mousebrain\" as the argument for this option. ***** [default = %(default)s]"
    )
    p.add_argument(
        "--lsq6-rotational-range",
        dest="rotation_range",
        type=int,
        default=50,
        help=
        "Settings for the rotational range in degrees when running the large rotation "
        "alignment. [Default = %(default)s]")
    p.add_argument(
        "--lsq6-rotational-interval",
        dest="rotation_interval",
        type=int,
        default=10,
        help=
        "Settings for the rotational interval in degrees when running the large rotation "
        "alignment. [Default = %(default)s]")
    p.add_argument(
        "--nuc",
        dest="nuc",
        action="store_true",
        help="Perform non-uniformity correction. [Default = %(default)s]")
    p.add_argument(
        "--no-nuc",
        dest="nuc",
        action="store_false",
        help=
        "If specified, do not perform non-uniformity correction. Opposite of --nuc."
    )
    p.add_argument(
        "--inormalize",
        dest="inormalize",
        action="store_true",
        help="Normalize the intensities after lsq6 alignment and nuc, if done. "
        "[Default = %(default)s] ")
    p.add_argument(
        "--no-inormalize",
        dest="inormalize",
        action="store_false",
        help=
        "If specified, do not perform intensity normalization. Opposite of --inormalize."
    )
    p.add_argument(
        "--copy-header-info-to-average",
        dest="copy_header_info",
        action="store_true",
        help="Copy the MINC header information of the first input file into the "
        "average that is created. [Default = %(default)s] ")
    p.add_argument("--no-copy-header-info-to-average",
                   dest="copy_header_info",
                   action="store_false",
                   help="Opposite of --copy-header-info-to-average.")
    p.add_argument(
        "--lsq6-protocol",
        dest="protocol_file",
        type=str,
        default=None,
        help=
        "Specify an lsq6 protocol that overrides the default setting for stages in "
        "the 6 parameter minctracc call. Parameters must be specified as in the following \n"
        "example: applications_testing/test_data/minctracc_example_linear_protocol.csv \n"
        "[Default = %(default)s].")
    return p
Ejemplo n.º 16
0
    def _create_parser():
        parser = ArgParser(prog='releaser',
                           default_config_files=['.releaser'],
                           auto_env_var_prefix='releaser_')

        parser.add_argument('--config', is_config_file=True)

        parser.add_argument('--repository',
                            dest='repo',
                            type=Repo,
                            default=Repo(Path.cwd()))

        parser.add_argument('--preprod-url', dest='preprod_url', default=None)

        parser.add_argument('--release-branch', default='master')

        parser.add_argument('--app-name')
        parser.add_argument('--release-date', default='today')
        parser.add_argument('--issue-tracker-url')

        next_version_group = parser.add_mutually_exclusive_group()
        next_version_group.add_argument('--build',
                                        action='store_const',
                                        const='BUILD',
                                        env_var='RELEASER_NEXT_VERSION',
                                        dest='next_version')
        next_version_group.add_argument('--patch',
                                        action='store_const',
                                        const='PATCH',
                                        env_var='RELEASER_NEXT_VERSION',
                                        dest='next_version')
        next_version_group.add_argument('--minor',
                                        action='store_const',
                                        const='MINOR',
                                        env_var='RELEASER_NEXT_VERSION',
                                        dest='next_version')
        next_version_group.add_argument('--major',
                                        action='store_const',
                                        const='MAJOR',
                                        env_var='RELEASER_NEXT_VERSION',
                                        dest='next_version')
        next_version_group.set_defaults(next_version='MINOR')

        subparsers = parser.add_subparsers(dest='command')
        versions_subparser = subparsers.add_parser('versions')
        subparsers.add_parser('changes')
        subparsers.add_parser('draft')
        subparsers.add_parser('tag')

        parser.add_argument('--template-mail',
                            type=Path,
                            dest='template_mail_path',
                            default=ROOT / 'releaser/templates/mail.md.j2')

        parser.add_argument('--template-tag',
                            type=Path,
                            dest='template_tag_path',
                            default=ROOT / 'releaser/templates/tag.md.j2')

        parser.add_argument('--template-changes',
                            type=Path,
                            dest='template_changes_path',
                            default=ROOT / 'releaser/templates/changes.md.j2')

        parser.add_argument('--start', default='today @ 21:45')
        parser.add_argument('--end', default='today @ 22:15')

        parser.set_defaults(command='changes')

        versions_subparser.add_argument('n',
                                        nargs='?',
                                        type=int,
                                        default=999999999)

        return parser
Ejemplo n.º 17
0
    # General settings
    p.add_argument(
        '--verbose',
        type=int,
        default=0,
        help='Verbosity level. '
        'Default: 0',
    )
    p.add_argument(
        '--wasserstein',
        dest='wasserstein',
        action='store_true',
        help='If given, use wasserstein GAN.',
    )
    p.set_defaults(wasserstein=False)
    p.add_argument(
        '--GPU',
        type=int,
        default=0,
        help='Which GPU. '
        'Default: 0',
    )
    p.add_argument(
        '--load_model',
        dest='load_model',
        action='store_true',
        help='If given, load model.',
    )
    p.set_defaults(load_model=False)
                default=[-90, 90],
                help='Latitude range. Default = [-90, 90]')
 p.add_argument('--target_factor',
                type=float,
                default=1.,
                help='Factor to multiply targets with. For TF comparison '
                'set to 1e-3. Default = 1.')
 p.add_argument('--random_seed',
                type=int,
                default=42,
                help='Random seed for shuffling of data.')
 p.add_argument('--shuffle',
                dest='shuffle',
                action='store_true',
                help='If given, shuffle data along sample dimension.')
 p.set_defaults(shuffle=False)
 p.add_argument('--only_norm',
                dest='only_norm',
                action='store_true',
                help='If given, only compute and save normalization file.')
 p.set_defaults(only_norm=False)
 p.add_argument('--flx_same_dt',
                dest='flx_same_dt',
                action='store_true',
                help='If given, take surface fluxes from same time step.')
 p.set_defaults(flx_same_dt=False)
 p.add_argument('--norm_features',
                type=str,
                default=None,
                help='by_var or by_lev')
 p.add_argument('--norm_targets',
Ejemplo n.º 19
0
 )
 p.add_argument(
     '--test_dates',
     type=str,
     nargs='+',
     default=['2016-01-01', '2017-01-01'],
     help='Test start (inc) and stop (exc) dates in format '
     'yyyy-mm-dd. Default: 2016-01-01 2017-01-01',
 )
 p.add_argument(
     '--use_aux',
     dest='use_aux',
     action='store_true',
     help='If given, use auxiliary variables.',
 )
 p.set_defaults(use_aux=False)
 p.add_argument(
     '--add_current_error',
     dest='add_current_error',
     action='store_true',
     help='If given, use current error.',
 )
 p.set_defaults(add_current_error=False)
 p.add_argument(
     '--current_error_len',
     type=int,
     default=1,
     help='Length of current error. Default: 1',
 )
 p.set_defaults(current_error=False)
 p.add_argument(