def get_parser():
    'Parser to specify arguments and their defaults.'
    parser = argparse.ArgumentParser(prog='neuropredict', formatter_class=argparse.RawTextHelpFormatter, description='Easy, standardized and comprehensive predictive analysis.')
    help_text_fs_dir = textwrap.dedent('\n    Absolute path to ``SUBJECTS_DIR`` containing the finished runs of Freesurfer parcellation\n    Each subject will be queried after its ID in the metadata file.\n\n    E.g. ``--fs_subject_dir /project/freesurfer_v5.3``\n    \n \n ')
    help_text_user_defined_folder = textwrap.dedent("\n    List of absolute paths to user's own features.\n\n    Format: Each of these folders contains a separate folder for each subject (named after its ID in the metadata file)\n    containing a file called features.txt with one number per line.\n    All the subjects (in a given folder) must have the number of features (#lines in file).\n    Different parent folders (describing one feature set) can have different number of features for each subject,\n    but they must all have the same number of subjects (folders) within them.\n\n    Names of each folder is used to annotate the results in visualizations.\n    Hence name them uniquely and meaningfully, keeping in mind these figures will be included in your papers.\n    For example,\n\n    .. parsed-literal::\n\n        --user_feature_paths /project/fmri/ /project/dti/ /project/t1_volumes/\n\n    Only one of ``--pyradigm_paths``, ``user_feature_paths``, ``data_matrix_path`` or ``arff_paths`` options can be specified.\n    \n \n ")
    help_text_pyradigm_paths = textwrap.dedent('\n    Path(s) to pyradigm datasets.\n\n    Each path is self-contained dataset identifying each sample, its class and features.\n    \n \n ')
    help_text_data_matrix = textwrap.dedent("\n    List of absolute paths to text files containing one matrix of size N x p  (num_samples x num_features).\n\n    Each row in the data matrix file must represent data corresponding to sample in the same row\n    of the meta data file (meta data file and data matrix must be in row-wise correspondence).\n\n    Name of this file will be used to annotate the results and visualizations.\n\n    E.g. ``--data_matrix_paths /project/fmri.csv /project/dti.csv /project/t1_volumes.csv ``\n\n    Only one of ``--pyradigm_paths``, ``user_feature_paths``, ``data_matrix_path`` or ``arff_paths`` options can be specified.\n    \n    File format could be\n     - a simple comma-separated text file (with extension .csv or .txt): which can easily be read back with\n        numpy.loadtxt(filepath, delimiter=',')\n        or\n     - a numpy array saved to disk (with extension .npy or .numpy) that can read in with numpy.load(filepath).\n\n     One could use ``numpy.savetxt(data_array, delimiter=',')`` or ``numpy.save(data_array)`` to save features.\n\n     File format is inferred from its extension.\n     \n \n ")
    help_text_arff_paths = textwrap.dedent("\n    List of paths to files saved in Weka's ARFF dataset format.\n    \n    Note: \n     - this format does NOT allow IDs for each subject.\n     - given feature values are saved in text format, this can lead to large files with high-dimensional data, \n        compared to numpy arrays saved to disk in binary format.\n    \n    More info: https://www.cs.waikato.ac.nz/ml/weka/arff.html\n    \n \n ")
    help_text_positive_class = textwrap.dedent('\n    Name of the positive class (e.g. Alzheimers, MCI etc) to be used in calculation of area under the ROC curve.\n    Applicable only for binary classification experiments.\n\n    Default: class appearing last in order specified in metadata file.\n    \n \n ')
    help_text_train_perc = textwrap.dedent('\n    Percentage of the smallest class to be reserved for training.\n\n    Must be in the interval [0.01 0.99].\n\n    If sample size is sufficiently big, we recommend 0.5.\n    If sample size is small, or class imbalance is high, choose 0.8.\n    \n \n ')
    help_text_num_rep_cv = textwrap.dedent('\n    Number of repetitions of the repeated-holdout cross-validation.\n\n    The larger the number, more stable the estimates will be.\n    \n \n ')
    help_text_sub_groups = textwrap.dedent("\n    This option allows the user to study different combinations of classes in a multi-class (N>2) dataset.\n\n    For example, in a dataset with 3 classes CN, FTD and AD,\n    two studies of pair-wise combinations can be studied separately\n    with the following flag ``--sub_groups CN,FTD CN,AD``.\n    This allows the user to focus on few interesting subgroups depending on their dataset/goal.\n\n    Format: Different subgroups must be separated by space,\n    and each sub-group must be a comma-separated list of class names defined in the meta data file.\n    Hence it is strongly recommended to use class names without any spaces, commas, hyphens and special characters,\n    and ideally just alphanumeric characters separated by underscores.\n\n    Any number of subgroups can be specified, but each subgroup must have atleast two distinct classes.\n\n    Default: ``'all'``, leading to inclusion of all available classes in a all-vs-all multi-class setting.\n    \n \n ")
    help_text_metadata_file = textwrap.dedent('\n    Abs path to file containing metadata for subjects to be included for analysis.\n\n    At the minimum, each subject should have an id per row followed by the class it belongs to.\n\n    E.g.\n    .. parsed-literal::\n\n        sub001,control\n        sub002,control\n        sub003,disease\n        sub004,disease\n\n    \n \n ')
    help_text_feature_selection = textwrap.dedent("Number of features to select as part of feature selection.\n    Options:\n\n         - 'tenth'\n         - 'sqrt'\n         - 'log2'\n         - 'all'\n\n    Default: 'tenth' of the number of samples in the training set.\n\n    For example, if your dataset has 90 samples, you chose 50 percent for training (default),\n    then Y will have 90*.5=45 samples in training set, leading to 5 features to be selected for taining.\n    If you choose a fixed integer, ensure all the feature sets under evaluation have atleast that many features.\n    \n \n ")
    help_text_gs_level = textwrap.dedent('\n    Flag to specify the level of grid search during hyper-parameter optimization on the training set.\n    Allowed options are : \'none\', \'light\' and \'exhaustive\', in the order of how many values/values will be optimized. \n    \n    More parameters and more values demand more resources and much longer time for optimization.\n    \n    The \'light\' option tries to "folk wisdom" to try least number of values (no more than one or two),\n     for the parameters for the given classifier. (e.g. a lage number say 500 trees for a random forest optimization). \n     The \'light\' will be the fastest and should give a "rough idea" of predictive performance. \n     The \'exhaustive\' option will try to most parameter values for the most parameters that can be optimized.\n    ')
    help_text_make_vis = textwrap.dedent('\n    Option to make visualizations from existing results in the given path. \n    This is helpful when neuropredict failed to generate result figures automatically \n    e.g. on a HPC cluster, or another environment when DISPLAY is either not available.\n    \n    ')
    help_text_atlas = textwrap.dedent('\n    Name of the atlas to use for visualization. Default: fsaverage, if available.\n    \n \n ')
    help_text_num_cpus = textwrap.dedent('\n    Number of CPUs to use to parallelize CV repetitions.\n\n    Default : 4.\n\n    Number of CPUs will be capped at the number available on the machine if higher is requested.\n    \n \n ')
    help_text_out_dir = textwrap.dedent('\n    Output folder to store gathered features & results.\n    \n \n ')
    help_classifier = textwrap.dedent("\n    \n    String specifying one of the implemented classifiers. \n    (Classifiers are carefully chosen to allow for the comprehensive report provided by neuropredict).\n    \n    Default: 'RandomForestClassifier'\n    \n    ")
    help_feat_select_method = textwrap.dedent("\n    Feature selection method to apply prior to training the classifier.\n    \n    Default: 'VarianceThreshold', removing features with 0.001 percent of lowest variance (zeros etc).\n    \n    ")
    parser.add_argument('-m', '--meta_file', action='store', dest='meta_file', default=None, required=False, help=help_text_metadata_file)
    parser.add_argument('-o', '--out_dir', action='store', dest='out_dir', required=False, help=help_text_out_dir, default=None)
    parser.add_argument('-f', '--fs_subject_dir', action='store', dest='fs_subject_dir', default=None, help=help_text_fs_dir)
    user_defined = parser.add_argument_group(title='Input data and formats', description='Only one of the following types can be specified.')
    user_defined.add_argument('-y', '--pyradigm_paths', action='store', dest='pyradigm_paths', nargs='+', default=None, help=help_text_pyradigm_paths)
    user_defined.add_argument('-u', '--user_feature_paths', action='store', dest='user_feature_paths', nargs='+', default=None, help=help_text_user_defined_folder)
    user_defined.add_argument('-d', '--data_matrix_paths', action='store', dest='data_matrix_paths', nargs='+', default=None, help=help_text_data_matrix)
    user_defined.add_argument('-a', '--arff_paths', action='store', dest='arff_paths', nargs='+', default=None, help=help_text_arff_paths)
    cv_args_group = parser.add_argument_group(title='Cross-validation', description='Parameters related to training and optimization during cross-validation')
    cv_args_group.add_argument('-p', '--positive_class', action='store', dest='positive_class', default=None, help=help_text_positive_class)
    cv_args_group.add_argument('-t', '--train_perc', action='store', dest='train_perc', default=cfg.default_train_perc, help=help_text_train_perc)
    cv_args_group.add_argument('-n', '--num_rep_cv', action='store', dest='num_rep_cv', default=cfg.default_num_repetitions, help=help_text_num_rep_cv)
    cv_args_group.add_argument('-k', '--num_features_to_select', dest='num_features_to_select', action='store', default=cfg.default_num_features_to_select, help=help_text_feature_selection)
    cv_args_group.add_argument('-sg', '--sub_groups', action='store', dest='sub_groups', nargs='*', default='all', help=help_text_sub_groups)
    cv_args_group.add_argument('-g', '--gs_level', action='store', dest='gs_level', default='light', help=help_text_gs_level, choices=cfg.GRIDSEARCH_LEVELS)
    pipeline_group = parser.add_argument_group(title='Predictive Model', description='Parameters related to pipeline comprising the predictive model')
    pipeline_group.add_argument('-fs', '--feat_select_method', action='store', dest='feat_select_method', default=cfg.default_feat_select_method, help=help_feat_select_method, choices=cfg.feature_selection_choices)
    pipeline_group.add_argument('-e', '--classifier', action='store', dest='classifier', default=cfg.default_classifier, help=help_classifier, choices=cfg.classifier_choices)
    vis_args = parser.add_argument_group(title='Visualization', description='Parameters related to generating visualizations')
    vis_args.add_argument('-z', '--make_vis', action='store', dest='make_vis', default=None, help=help_text_make_vis)
    comp_args = parser.add_argument_group(title='Computing', description='Parameters related to computations/debugging')
    comp_args.add_argument('-c', '--num_procs', action='store', dest='num_procs', default=cfg.DEFAULT_NUM_PROCS, help=help_text_num_cpus)
    comp_args.add_argument('-v', '--version', action='version', version='%(prog)s {version}'.format(version=__version__))
    return parser
Parser to specify arguments and their defaults.
def get_parser():
    
    parser = argparse.ArgumentParser(prog='neuropredict', formatter_class=argparse.RawTextHelpFormatter, description='Easy, standardized and comprehensive predictive analysis.')
    help_text_fs_dir = textwrap.dedent('\n    Absolute path to ``SUBJECTS_DIR`` containing the finished runs of Freesurfer parcellation\n    Each subject will be queried after its ID in the metadata file.\n\n    E.g. ``--fs_subject_dir /project/freesurfer_v5.3``\n    \n \n ')
    help_text_user_defined_folder = textwrap.dedent("\n    List of absolute paths to user's own features.\n\n    Format: Each of these folders contains a separate folder for each subject (named after its ID in the metadata file)\n    containing a file called features.txt with one number per line.\n    All the subjects (in a given folder) must have the number of features (#lines in file).\n    Different parent folders (describing one feature set) can have different number of features for each subject,\n    but they must all have the same number of subjects (folders) within them.\n\n    Names of each folder is used to annotate the results in visualizations.\n    Hence name them uniquely and meaningfully, keeping in mind these figures will be included in your papers.\n    For example,\n\n    .. parsed-literal::\n\n        --user_feature_paths /project/fmri/ /project/dti/ /project/t1_volumes/\n\n    Only one of ``--pyradigm_paths``, ``user_feature_paths``, ``data_matrix_path`` or ``arff_paths`` options can be specified.\n    \n \n ")
    help_text_pyradigm_paths = textwrap.dedent('\n    Path(s) to pyradigm datasets.\n\n    Each path is self-contained dataset identifying each sample, its class and features.\n    \n \n ')
    help_text_data_matrix = textwrap.dedent("\n    List of absolute paths to text files containing one matrix of size N x p  (num_samples x num_features).\n\n    Each row in the data matrix file must represent data corresponding to sample in the same row\n    of the meta data file (meta data file and data matrix must be in row-wise correspondence).\n\n    Name of this file will be used to annotate the results and visualizations.\n\n    E.g. ``--data_matrix_paths /project/fmri.csv /project/dti.csv /project/t1_volumes.csv ``\n\n    Only one of ``--pyradigm_paths``, ``user_feature_paths``, ``data_matrix_path`` or ``arff_paths`` options can be specified.\n    \n    File format could be\n     - a simple comma-separated text file (with extension .csv or .txt): which can easily be read back with\n        numpy.loadtxt(filepath, delimiter=',')\n        or\n     - a numpy array saved to disk (with extension .npy or .numpy) that can read in with numpy.load(filepath).\n\n     One could use ``numpy.savetxt(data_array, delimiter=',')`` or ``numpy.save(data_array)`` to save features.\n\n     File format is inferred from its extension.\n     \n \n ")
    help_text_arff_paths = textwrap.dedent("\n    List of paths to files saved in Weka's ARFF dataset format.\n    \n    Note: \n     - this format does NOT allow IDs for each subject.\n     - given feature values are saved in text format, this can lead to large files with high-dimensional data, \n        compared to numpy arrays saved to disk in binary format.\n    \n    More info: https://www.cs.waikato.ac.nz/ml/weka/arff.html\n    \n \n ")
    help_text_positive_class = textwrap.dedent('\n    Name of the positive class (e.g. Alzheimers, MCI etc) to be used in calculation of area under the ROC curve.\n    Applicable only for binary classification experiments.\n\n    Default: class appearing last in order specified in metadata file.\n    \n \n ')
    help_text_train_perc = textwrap.dedent('\n    Percentage of the smallest class to be reserved for training.\n\n    Must be in the interval [0.01 0.99].\n\n    If sample size is sufficiently big, we recommend 0.5.\n    If sample size is small, or class imbalance is high, choose 0.8.\n    \n \n ')
    help_text_num_rep_cv = textwrap.dedent('\n    Number of repetitions of the repeated-holdout cross-validation.\n\n    The larger the number, more stable the estimates will be.\n    \n \n ')
    help_text_sub_groups = textwrap.dedent("\n    This option allows the user to study different combinations of classes in a multi-class (N>2) dataset.\n\n    For example, in a dataset with 3 classes CN, FTD and AD,\n    two studies of pair-wise combinations can be studied separately\n    with the following flag ``--sub_groups CN,FTD CN,AD``.\n    This allows the user to focus on few interesting subgroups depending on their dataset/goal.\n\n    Format: Different subgroups must be separated by space,\n    and each sub-group must be a comma-separated list of class names defined in the meta data file.\n    Hence it is strongly recommended to use class names without any spaces, commas, hyphens and special characters,\n    and ideally just alphanumeric characters separated by underscores.\n\n    Any number of subgroups can be specified, but each subgroup must have atleast two distinct classes.\n\n    Default: ``'all'``, leading to inclusion of all available classes in a all-vs-all multi-class setting.\n    \n \n ")
    help_text_metadata_file = textwrap.dedent('\n    Abs path to file containing metadata for subjects to be included for analysis.\n\n    At the minimum, each subject should have an id per row followed by the class it belongs to.\n\n    E.g.\n    .. parsed-literal::\n\n        sub001,control\n        sub002,control\n        sub003,disease\n        sub004,disease\n\n    \n \n ')
    help_text_feature_selection = textwrap.dedent("Number of features to select as part of feature selection.\n    Options:\n\n         - 'tenth'\n         - 'sqrt'\n         - 'log2'\n         - 'all'\n\n    Default: 'tenth' of the number of samples in the training set.\n\n    For example, if your dataset has 90 samples, you chose 50 percent for training (default),\n    then Y will have 90*.5=45 samples in training set, leading to 5 features to be selected for taining.\n    If you choose a fixed integer, ensure all the feature sets under evaluation have atleast that many features.\n    \n \n ")
    help_text_gs_level = textwrap.dedent('\n    Flag to specify the level of grid search during hyper-parameter optimization on the training set.\n    Allowed options are : \'none\', \'light\' and \'exhaustive\', in the order of how many values/values will be optimized. \n    \n    More parameters and more values demand more resources and much longer time for optimization.\n    \n    The \'light\' option tries to "folk wisdom" to try least number of values (no more than one or two),\n     for the parameters for the given classifier. (e.g. a lage number say 500 trees for a random forest optimization). \n     The \'light\' will be the fastest and should give a "rough idea" of predictive performance. \n     The \'exhaustive\' option will try to most parameter values for the most parameters that can be optimized.\n    ')
    help_text_make_vis = textwrap.dedent('\n    Option to make visualizations from existing results in the given path. \n    This is helpful when neuropredict failed to generate result figures automatically \n    e.g. on a HPC cluster, or another environment when DISPLAY is either not available.\n    \n    ')
    help_text_atlas = textwrap.dedent('\n    Name of the atlas to use for visualization. Default: fsaverage, if available.\n    \n \n ')
    help_text_num_cpus = textwrap.dedent('\n    Number of CPUs to use to parallelize CV repetitions.\n\n    Default : 4.\n\n    Number of CPUs will be capped at the number available on the machine if higher is requested.\n    \n \n ')
    help_text_out_dir = textwrap.dedent('\n    Output folder to store gathered features & results.\n    \n \n ')
    help_classifier = textwrap.dedent("\n    \n    String specifying one of the implemented classifiers. \n    (Classifiers are carefully chosen to allow for the comprehensive report provided by neuropredict).\n    \n    Default: 'RandomForestClassifier'\n    \n    ")
    help_feat_select_method = textwrap.dedent("\n    Feature selection method to apply prior to training the classifier.\n    \n    Default: 'VarianceThreshold', removing features with 0.001 percent of lowest variance (zeros etc).\n    \n    ")
    parser.add_argument('-m', '--meta_file', action='store', dest='meta_file', default=None, required=False, help=help_text_metadata_file)
    parser.add_argument('-o', '--out_dir', action='store', dest='out_dir', required=False, help=help_text_out_dir, default=None)
    parser.add_argument('-f', '--fs_subject_dir', action='store', dest='fs_subject_dir', default=None, help=help_text_fs_dir)
    user_defined = parser.add_argument_group(title='Input data and formats', description='Only one of the following types can be specified.')
    user_defined.add_argument('-y', '--pyradigm_paths', action='store', dest='pyradigm_paths', nargs='+', default=None, help=help_text_pyradigm_paths)
    user_defined.add_argument('-u', '--user_feature_paths', action='store', dest='user_feature_paths', nargs='+', default=None, help=help_text_user_defined_folder)
    user_defined.add_argument('-d', '--data_matrix_paths', action='store', dest='data_matrix_paths', nargs='+', default=None, help=help_text_data_matrix)
    user_defined.add_argument('-a', '--arff_paths', action='store', dest='arff_paths', nargs='+', default=None, help=help_text_arff_paths)
    cv_args_group = parser.add_argument_group(title='Cross-validation', description='Parameters related to training and optimization during cross-validation')
    cv_args_group.add_argument('-p', '--positive_class', action='store', dest='positive_class', default=None, help=help_text_positive_class)
    cv_args_group.add_argument('-t', '--train_perc', action='store', dest='train_perc', default=cfg.default_train_perc, help=help_text_train_perc)
    cv_args_group.add_argument('-n', '--num_rep_cv', action='store', dest='num_rep_cv', default=cfg.default_num_repetitions, help=help_text_num_rep_cv)
    cv_args_group.add_argument('-k', '--num_features_to_select', dest='num_features_to_select', action='store', default=cfg.default_num_features_to_select, help=help_text_feature_selection)
    cv_args_group.add_argument('-sg', '--sub_groups', action='store', dest='sub_groups', nargs='*', default='all', help=help_text_sub_groups)
    cv_args_group.add_argument('-g', '--gs_level', action='store', dest='gs_level', default='light', help=help_text_gs_level, choices=cfg.GRIDSEARCH_LEVELS)
    pipeline_group = parser.add_argument_group(title='Predictive Model', description='Parameters related to pipeline comprising the predictive model')
    pipeline_group.add_argument('-fs', '--feat_select_method', action='store', dest='feat_select_method', default=cfg.default_feat_select_method, help=help_feat_select_method, choices=cfg.feature_selection_choices)
    pipeline_group.add_argument('-e', '--classifier', action='store', dest='classifier', default=cfg.default_classifier, help=help_classifier, choices=cfg.classifier_choices)
    vis_args = parser.add_argument_group(title='Visualization', description='Parameters related to generating visualizations')
    vis_args.add_argument('-z', '--make_vis', action='store', dest='make_vis', default=None, help=help_text_make_vis)
    comp_args = parser.add_argument_group(title='Computing', description='Parameters related to computations/debugging')
    comp_args.add_argument('-c', '--num_procs', action='store', dest='num_procs', default=cfg.DEFAULT_NUM_PROCS, help=help_text_num_cpus)
    comp_args.add_argument('-v', '--version', action='version', version='%(prog)s {version}'.format(version=__version__))
    return parser