Example #1
0
def getArgumentParser(ap = ap.ArgumentParser(description = DESCRIPTION, formatter_class=ap.RawTextHelpFormatter)):

	#input type
	group = ap.add_mutually_exclusive_group(required=True)
	group.add_argument("-i", "--input",
		help="Two csv files: [regressor(s)] [covariates]. Please note that if the -r option is used, the regressor(s) will be treated as dependent variable(s).", 
		nargs=2, 
		metavar=('*.csv', '*.csv'))
	group.add_argument("-f", "--file",  
		help="One csv file: [regressors(s)]", 
		nargs=1, 
		metavar=('*.csv'))

	#options
	ap.add_argument("-d", "--demean", 
		help="demean columns", 
		action="store_true")
	ap.add_argument("-s", "--stddemean", 
		help="demean and standardize columns", 
		action="store_true")

	#which tool to use
	proceducetype = ap.add_mutually_exclusive_group(required=True)
	proceducetype.add_argument("-o", "--orthogonalize", 
		help="orthogonalize the inputs", 
		action="store_true")
	proceducetype.add_argument("-r", "--residuals", 
		help="residuals after regressing covariates", 
		action="store_true")
	proceducetype.add_argument("-j", "--juststandarize", 
		help="Just demean or standardize the regressors. i.e., no regression or orthogonization",
		action="store_true")

	return ap
Example #2
0
def getArgumentParser(ap=ap.ArgumentParser(description=DESCRIPTION)):
    group = ap.add_mutually_exclusive_group(required=True)
    group.add_argument("-i",
                       "--input",
                       nargs=2,
                       help="[Predictor(s)] [Covariate(s)] (recommended)",
                       metavar=('*.csv', '*.csv'))
    group.add_argument("-r",
                       "--regressors",
                       nargs=1,
                       help="Single step regression",
                       metavar=('*.csv'))
    ap.add_argument(
        "-i_tmi",
        "--tmifile",
        help=
        "Vertex analysis. Input surface: e.g. --vertex [area or thickness]",
        nargs=1,
        metavar=('*.tmi'),
        required=True)
    ap.add_argument(
        "-sa",
        "--setadjacencyobjs",
        help=
        "Specify the adjaceny object to use for each mask. The number of inputs must match the number of masks in the tmi file. Note, the objects start at zero. e.g., -sa 0 1 0 1",
        nargs='+',
        type=str,
        metavar=('int'))
    ap.add_argument("-n",
                    "--numperm",
                    nargs=1,
                    type=int,
                    help="# of permutations",
                    metavar=('INT'),
                    required=True)
    parallel = ap.add_mutually_exclusive_group(required=False)
    parallel.add_argument("-p",
                          "--gnuparallel",
                          nargs=1,
                          type=int,
                          help="Use GNU parallel. Specify number of cores",
                          metavar=('INT'))
    parallel.add_argument("-c",
                          "--condor",
                          help="Use HTCondor.",
                          action="store_true")
    parallel.add_argument("-f",
                          "--fslsub",
                          help="Use fsl_sub script.",
                          action="store_true")
    parallel.add_argument(
        "-t",
        "--cmdtext",
        help="Outputs a text file with one command per line.",
        action="store_true")
    return ap
Example #3
0
def getArgumentParser(ap=ap.ArgumentParser(description=DESCRIPTION)):
    datatype = ap.add_mutually_exclusive_group(required=True)
    datatype.add_argument("--voxel",
                          help="Voxel analysis",
                          action="store_true")
    datatype.add_argument(
        "--vertex",
        help=
        "Vertex analysis. Input surface: e.g. --vertex [area or thickness]",
        nargs=1,
        metavar=('surface'))
    ap.add_argument(
        "-m",
        "--mediation",
        help=
        "Mediation analysis [M or I or Y]. If not specified, then multiple regression is performed.",
        nargs=1,
        choices=['I', 'M', 'Y'],
        metavar=('STR'))
    ap.add_argument("-n",
                    "--numperm",
                    nargs=1,
                    type=int,
                    help="# of permutations",
                    metavar=('INT'),
                    required=True)
    ap.add_argument(
        "-v",
        "--specifyvars",
        nargs=2,
        type=int,
        help=
        "Optional for multiple regression. Specify which regressors are permuted [first] [last]. For one variable, first=last.",
        metavar=('INT', 'INT'))
    group = ap.add_mutually_exclusive_group(required=False)
    group.add_argument("-p",
                       "--gnuparallel",
                       nargs=1,
                       type=int,
                       help="Use GNU parallel. Specify number of cores",
                       metavar=('INT'))
    group.add_argument("-c",
                       "--condor",
                       help="Use HTCondor.",
                       action="store_true")
    group.add_argument("-f",
                       "--fslsub",
                       help="Use fsl_sub script.",
                       action="store_true")
    return ap
def getArgumentParser(ap=ap.ArgumentParser(
    description=DESCRIPTION, formatter_class=ap.RawTextHelpFormatter)):
    datatype = ap.add_mutually_exclusive_group(required=True)
    datatype.add_argument("--voxel", help="Voxel input", action="store_true")
    datatype.add_argument("--vertex", help="Vertex input", action="store_true")
    datatype.add_argument(
        "--bothhemi",
        help=
        "Special case in which vertex images from both hemispheres are input and processed together.",
        action="store_true")
    ap.add_argument(
        "-i",
        "--input",
        help="Text file of compoments to remove (as a single column).",
        nargs=1,
        metavar=('*[.txt or .csv]'),
        required=True)
    ap.add_argument("-o",
                    "--output",
                    help="[Output Image Basename]",
                    nargs=1,
                    required=True)
    ap.add_argument("--clean",
                    help="Remove the ICA_temp directory.",
                    action='store_true')
    return ap
Example #5
0
def getArgumentParser(ap=ap.ArgumentParser(
    description=DESCRIPTION, formatter_class=ap.RawTextHelpFormatter)):
    datatype = ap.add_mutually_exclusive_group(required=True)
    datatype.add_argument("--voxel", help="Voxel input", action="store_true")
    datatype.add_argument("--vertex", help="Vertex input", action="store_true")
    ap.add_argument("-o",
                    "--output",
                    nargs=1,
                    help="[4D_image]",
                    metavar=('*.nii.gz or *.mgh'),
                    required=True)
    ap.add_argument("-i",
                    "--input",
                    nargs='+',
                    help="[3Dimage] ...",
                    metavar=('*.nii.gz or *.mgh'),
                    required=True)
    ap.add_argument("-m",
                    "--mask",
                    nargs=1,
                    help="[3Dimage]",
                    metavar=('*.nii.gz or *.mgh'))
    ap.add_argument("-s", "--scale", action='store_true')
    ap.add_argument(
        "--fastica",
        help=
        "Independent component analysis. Input the number of components (e.g.,--fastica 8 for eight components). Outputs the recovered sources, and the component fit for each subject. (recommended to scale first)",
        nargs=1,
        metavar=('INT'))
    return ap
def getArgumentParser(ap = ap.ArgumentParser(description = DESCRIPTION)):
	group = ap.add_mutually_exclusive_group(required=True)
	group.add_argument("-i", "--inputtxt",
		nargs=1,
		help="input a text file surface values (i.e., a list of cortical thickness values)")
	group.add_argument("-s", "--inputsurface",
		nargs=1,
		help="input a surface", 
		metavar=('*.mgh'))
	ap.add_argument("-t", "--transpose",
		action='store_true',
		help="Transpose input file.")
	return ap
Example #7
0
def getArgumentParser(ap=ap.ArgumentParser(description=DESCRIPTION)):

    group = ap.add_mutually_exclusive_group(required=True)
    group.add_argument("-i",
                       "--input",
                       nargs=2,
                       help="[Predictor(s)] [Covariate(s)] (recommended)",
                       metavar=('*.csv', '*.csv'))
    group.add_argument("-r",
                       "--regressors",
                       nargs=1,
                       help="Single step regression",
                       metavar=('*.csv'))
    group.add_argument(
        "-m",
        "--onesample",
        nargs=1,
        help="One sample t-test. i.e., test sample mean or intercept.",
        metavar=('*.csv or none'))
    ap.add_argument("-f",
                    "--ftest",
                    help="""
				Perform mixed-effect model ANOVA on predictors (experimental).
				The square root of the f-statistic image undergoes TFCE.
				""",
                    action="store_true")
    ap.add_argument(
        "-t",
        "--tfce",
        help=
        "TFCE settings. H (i.e., height raised to power H), E (i.e., extent raised to power E), Connectivity (either 26 or 6 directions). Default: %(default)s).",
        nargs=3,
        default=[2, 1, 26],
        metavar=('H', 'E', '[6 or 26]'))
    ap.add_argument(
        "-v",
        "--voxelregressor",
        nargs=1,
        help=
        "Add a voxel-wise independent regressor (beta feature). A variance inflation factor (VIF) image will also be produced to check for multicollinearity (generally, VIF > 5 suggest problematic collinearity.)",
        metavar=('*.nii.gz'))
    return ap
Example #8
0
def getArgumentParser(ap=ap.ArgumentParser(description=DESCRIPTION)):

    group = ap.add_mutually_exclusive_group(required=True)
    group.add_argument("-l",
                       "--label",
                       metavar=('*_label_surface.mgh'),
                       nargs=1)
    group.add_argument("-a", "--annot", metavar=('*annot'), nargs=1)
    ap.add_argument("-i",
                    "--input",
                    nargs=1,
                    help="Load 4D surface files",
                    metavar=('?h.all.???.mgh'),
                    required=True)
    ap.add_argument("-r",
                    "--range",
                    nargs=2,
                    help="Input range of labels to extract. (e.g.: -r 1 12)",
                    metavar=('INT', 'INT'))
    return ap
Example #9
0
def getArgumentParser(ap = ap.ArgumentParser(description = DESCRIPTION)):

	ap.add_argument("-i_tmi", "--tmifile",
		help="Input the *.tmi file for analysis.", 
		nargs=1,
		metavar=('*.tmi'),
		required=True)
	ap.add_argument("-os", "--outputstats",  
		help = "Calculates the stats without permutation testing, and outputs the tmi", 
		action =('store_true'))
	ap.add_argument("-n", "--numperm", 
		nargs=1,
		type=int,
		help="# of permutations",
		metavar=('INT'))
	ap.add_argument("-um", "--usepreviousmemorymapping", 
		help="Skip the creation of memory mapped objects. It will give an error if tmi_temp folder does not exist.",
		action="store_true")

	group = ap.add_mutually_exclusive_group(required=True)
	group.add_argument("-i", "--input", 
		nargs='+', 
		help="[Predictor(s)]", 
		metavar=('*.csv'))
	group.add_argument("-im", "--inputmediation", 
		nargs=3, 
		help="[Mediation Type {I,M,Y}] [Predictor] [Dependent]", 
		metavar=('{I,M,Y}','*.csv', '*.csv'))
	ap.add_argument("-c", "--covariates", 
		nargs=1, 
		help="[Covariate(s)]", 
		metavar=('*.csv'))

	ap.add_argument("--tfce", 
		help="TFCE settings. H (i.e., height raised to power H), E (i.e., extent raised to power E). Default: %(default)s). H=2, E=2/3. Multiple sets of H and E values can be entered with using the -st option.", 
		nargs='+', 
		default=[2.0,0.67],
		type=float,
		metavar=('H', 'E'))
	ap.add_argument("-sa", "--setadjacencyobjs",
		help="Specify the adjaceny object to use for each mask. The number of inputs must match the number of masks in the tmi file. Note, the objects start at zero. e.g., -sa 0 1 0 1",
		nargs='+',
		type=int,
		metavar=('INT'))
	ap.add_argument("-st", "--assigntfcesettings",
		help="Specify the tfce H and E settings for each mask. -st is useful for combined analysis do voxel and vertex data. More than one set of values must inputted with --tfce. The number of inputs must match the number of masks in the tmi file. The input corresponds to each pair of --tfce setting starting at zero. e.g., -st 0 0 0 0 1 1",
		nargs='+',
		type=int,
		metavar=('INT'))
	ap.add_argument("--noweight", 
		help="Do not weight each vertex for density of vertices within the specified geodesic distance (not recommended).", 
		action="store_true")
	ap.add_argument("--subset",
		help="Analyze a subset of subjects based on a single column text file. Subset will be performed based on whether each input is finite (keep) or text (remove).", 
		nargs=1)

	parallel = ap.add_mutually_exclusive_group(required=False)
	parallel.add_argument("-p","--gnuparallel", 
		nargs=1, 
		type=int, 
		help="Use GNU parallel. Specify number of cores", 
		metavar=('INT'))
	parallel.add_argument("-cd","--condor", 
		help="Use HTCondor.", 
		action="store_true")
	parallel.add_argument("-f","--fslsub", 
		help="Use fsl_sub script.",
		action="store_true")
	parallel.add_argument("-t","--cmdtext", 
		help="Outputs a text file with one command per line.",
		action="store_true")
	parallel.add_argument("--serial", 
		help="Runs the command sequentially using one core (not recommended)",
		action="store_true")
	return ap
Example #10
0
def getArgumentParser(ap=ap.ArgumentParser(description=DESCRIPTION)):

    # output
    ogroup = ap.add_mutually_exclusive_group(required=True)
    ogroup.add_argument("-o",
                        "--outputnpy",
                        action='store_true',
                        help="Output adjacency set as a numpy file.")
    ogroup.add_argument(
        "-a",
        "--appendtmi",
        nargs=1,
        help=
        "Append the adjacency set to a specified tmi file. i.e., -a all.surfaces.tmi",
        metavar=('*.tmi'))

    # input
    ap.add_argument(
        "-t",
        "--datatype",
        nargs=1,
        help=
        "Input file type. Note, use srf for freesurfer even if there is no extension. mni_obj refers to CIVET mni object files *.obj not waveform objects.",
        choices=('voxel', 'srf', 'ply', 'mni_obj', 'gii'),
        required=True)
    ap.add_argument(
        "-i",
        '--input',
        nargs='+',
        help=
        "Input surface object(s) or binarized images mask(s). i.e., -i lh.midthickness rh.midthickness [OR] -i mean_FA_skeleton_mask.nii.gz.",
        required=True)

    #options
    ap.add_argument(
        "-va",
        "--voxeladjacency",
        nargs=1,
        help=
        "Required with -t voxel. Set voxel adjacency to 6 or 26 direction. In general, 6 is used for volumetric data, and 26 is used for skeletonised data",
        choices=(6, 26),
        type=int,
        required=False)
    surfaceadjgroup = ap.add_mutually_exclusive_group(required=False)
    surfaceadjgroup.add_argument(
        "-d",
        "--geodistance",
        nargs=2,
        help=
        "Recommended for surfaces. Enter the [minimum distance(mm)] [maximum distance(mm)]. i.e., -d 1.0 3.0",
        metavar=('Float', 'Float'),
        required=False)
    ap.add_argument(
        "-s",
        "--stepsize",
        nargs=1,
        help=
        "For -d option, specify the [step size (mm)] default: %(default)s). i.e., -d 1.0",
        metavar=('Float'),
        default=[1.0],
        type=float)
    ap.add_argument(
        "-p",
        "--projectfraction",
        nargs=1,
        help=
        "Optional. For surface inputs, a project transformation is performed by a set fraction from white matter surface. i.e, 0.5 is midthickness surface",
        metavar=('Float'),
        type=float,
        required=False)
    ap.add_argument(
        "-sa",
        "--setappendadj",
        nargs=1,
        help=
        "Specify the geodesic distance to append to a tmi file. This option is strongly recommended with -a because so one adjacency set corresponds to one surface in a tmi file. i.e., -sa 3.0",
        metavar=('Float'),
        required=False)
    ap.add_argument(
        "-it",
        "--inputthickness",
        nargs='+',
        help=
        "Required with -p option. Input surface file for surface projection. Currently, only freesurfer is supported.",
        metavar=('string'),
        type=str,
        required=False)
    surfaceadjgroup.add_argument(
        "-m",
        "--triangularmesh",
        help=
        "For surfaces, create adjacency based on triangular mesh without specifying distance (not recommended).",
        action='store_true')
    return ap
Example #11
0
def getArgumentParser(ap=ap.ArgumentParser(
    description=DESCRIPTION, formatter_class=ap.RawTextHelpFormatter)):
    #input type

    outname = ap.add_mutually_exclusive_group(required=True)
    outname.add_argument("-o",
                         "--outputname",
                         help="Output file name.",
                         nargs=1,
                         metavar='*.tmi')
    outname.add_argument("-a",
                         "--append",
                         help="Append information to an existing *.tmi file.",
                         nargs=1,
                         metavar='*.tmi')

    ap.add_argument(
        "-i",
        "--inputimages",
        help=
        "Input neuroimage(s) in *nii, *mgh or *mnc. Note, this should be used for group data (i.e., 4D images).",
        nargs='+',
        metavar=('MGH or NIFTI or MNC'))
    ap.add_argument(
        "-c_i",
        "--concatenateimages",
        help=
        "Input a set of neuroimages that are then concatenated. The images should be in the same space. Only one set of concatenated can be added at a time. To add multiple modalities (or surfaces) used the rerun %(prog)s --append (the number of subjects has to be the same). (e.g. -c_i FAtoStd/Subject*_FAtoStd.nii.gz",
        nargs='+',
        metavar=('MGH or NIFTI or MNC'))
    ap.add_argument(
        "-s",
        "--scale",
        help=
        "Scale each image that is being concatenated. Must be used with -c_i. Useful when importing timeseries data.",
        action='store_true')
    ap.add_argument(
        "--concatenatename",
        help=
        "Specify a 4D image name for concatenated images. Must be used with -c_i.",
        nargs=1)

    ap.add_argument(
        "-i_text",
        "--inputtext",
        help=
        "Input neuroimage(s) in *nii, *mgh or *mnc. Note, this should be used for group data (i.e., 4D images).",
        nargs='+',
        metavar=('*.txt or *.csv'))
    ap.add_argument(
        "-c_text",
        "--concatenatetext",
        help=
        "Input text files with a single column that will be concatenated. The text should be in the same space (i.e., same length). Only one set of concatenated can be added at a time. To add multiple modalities used the rerun %(prog)s --append (the number of subjects has to be the same).",
        nargs='+',
        metavar=('*.txt or *.csv'))
    ap.add_argument(
        "-c_bin",
        "--concatenatebinary",
        help=
        "Input a set of binary images that encoded <f (float) that are then concatenated. The input should be check afterwards. Each image should be of the same length. To add multiple modalities (or surfaces) used the rerun %(prog)s --append. (e.g. [for ENIGMA-shape output], -c_bin Subject*/LogJacs_10.raw)",
        nargs='+',
        metavar=('*.bin or *.raw'))

    ap.add_argument(
        "-i_masks",
        "--inputmasks",
        help=
        "Input masks (recommended). There should be same number of input images as masks. The file formats do not have to match, but the masks should be in binary format. If masks are not entered, they will be created using non-zero data.",
        nargs='+',
        metavar=('MGH or NIFTI or MNC'))

    in_surface = ap.add_mutually_exclusive_group(required=False)
    in_surface.add_argument(
        "-i_fs",
        "--inputfreesurfer",
        help=
        "Input a freesurfer surface (e.g., -i_fs $SUBJECTS_DIR/fsaverage/surf/lh.midthickness $SUBJECTS_DIR/fsaverage/surf/rh.midthickness)",
        nargs='+',
        metavar=('*'))
    in_surface.add_argument(
        "-i_gifti",
        "--inputgifti",
        help="Input a gifti surface file (e.g., --i_gifti average.surf.gii)",
        nargs='+',
        metavar=('*.surf.gii'))
    in_surface.add_argument(
        "-i_mni",
        "--inputmniobj",
        help="Input a MNI object file (e.g., --i_mni l_hemi.obj r_hemi.obj)",
        nargs='+',
        metavar=('*.obj'))
    in_surface.add_argument(
        "-i_ply",
        "--inputply",
        help=
        "Input a MNI object file (e.g., --i_ply l_hemi.ply). Note, vertex colors will be stripped.",
        nargs='+',
        metavar=('*.ply'))
    ap.add_argument(
        "-i_adj",
        "--inputadjacencyobject",
        help=
        "Input adjacency objects for each surface. There should be same number of input images as masks.",
        nargs='+',
        metavar=('*.npy'))

    ap.add_argument(
        "--outputtype",
        default='binary',
        const='binary',
        nargs='?',
        choices=['binary', 'ascii'],
        help=
        "Set output type. (default: %(default)s). The ascii option will not store adjacency objects."
    )

    return ap
Example #12
0
                    steps += extra_step
                steps += 1
            else:
                steps += lookup[last_val]
                break

        lookup[i] = steps


argparse = argparse.ArgumentParser()
argparse.add_argument('value',
                      metavar='N',
                      type=int,
                      help='The last value to compute e.g. 100000')

div_group = argparse.add_mutually_exclusive_group(required=True)
div_group.add_argument('-sd',
                       '--simple-div2',
                       action='store_true',
                       help='Use \'/\' to divide by 2')
div_group.add_argument('-bd',
                       '--bitwise-div2',
                       action='store_true',
                       help='Use bitwise (>> 1) to divide by 2')

argparse.add_argument(
    '-ssmd',
    '--single-step-multiply-divide',
    action='store_true',
    help='Whether to perform multiply by 3 and divide by 2 in a single step')
Example #13
0
def getArgumentParser(ap=ap.ArgumentParser(
    description=DESCRIPTION, formatter_class=ap.RawTextHelpFormatter)):
    #input type
    igroup = ap.add_mutually_exclusive_group(required=True)
    igroup.add_argument(
        "-i_fs",
        "--inputfreesurfer",
        help=
        "Input a freesurfer surface (e.g., -i_fs $SUBJECTS_DIR/fsaverage/surf/lh.midthickness)",
        nargs=1,
        metavar=('*'))
    igroup.add_argument(
        "-i_gifti",
        "--inputgifti",
        help="Input a gifti surface file (e.g., --i_gifti average.surf.gii)",
        nargs=1,
        metavar=('*.surf.gii'))
    igroup.add_argument(
        "-i_mni",
        "--inputmniobj",
        help="Input a MNI object file (e.g., --i_mni l_hemi.obj)",
        nargs=1,
        metavar=('*.obj'))
    igroup.add_argument(
        "-i_ply",
        "--inputply",
        help=
        "Input a MNI object file (e.g., --i_ply l_hemi.ply). Note, vertex colors will be stripped.",
        nargs=1,
        metavar=('*.ply'))
    # voxel to surface conversion
    igroup.add_argument(
        "-i_voxel",
        "--inputvoxel",
        help=
        "Input a voxel (nifti, minc, mgh). e.g. -i_voxel tstat_pFWER_corr.nii.gz",
        nargs=1)
    ap.add_argument(
        "-vol",
        "--specifyvolume",
        help="Specify volume if -i_voxel is 4D (the first volume is 0)",
        nargs=1)
    ap.add_argument(
        "-vt",
        "--voxelthreshold",
        help=
        "Apply a threshold to -i_voxel image (zeros everything below value). e.g. -vt 0.95",
        nargs=1)
    ap.add_argument(
        "-vb",
        "--voxelbackbone",
        help=
        "Add binary mask backbone to the voxel image. e.g. -vb binary_mask_skeleton.nii.gz",
        nargs=1)
    ap.add_argument(
        "-vp",
        "--paintvoxelsurface",
        help=
        "Must be used with -i_voxel and -o_ply options. Input the sigificance threshold (low and high), and either: red-yellow (r_y), blue-lightblue (b_lb) or any matplotlib colorschemes (https://matplotlib.org/examples/color/colormaps_reference.html). Note, thresholds must be postive. e.g., -vp 0.95 1 r_y",
        nargs=3,
        metavar=('float', 'float', 'colormap'))
    ap.add_argument(
        "-ov_mgh",
        "--outputvoxelsurfmgh",
        help=
        "Output a mgh file of the surface. This is only useful for visualization purposes.",
        nargs=1)

    ogroup = ap.add_mutually_exclusive_group(required=True)
    ogroup.add_argument(
        "-o_fs",
        "--outputfreesurfer",
        help=
        "Output file name for freesurfer surface (e.g., -o_fs lh.32k.midthickness)",
        nargs=1,
        metavar=('*'))
    ogroup.add_argument(
        "-o_obj",
        "--outputwaveform",
        help=
        "Output file name for waveform object file for visualization with blender (or any other 3D viewer). This is NOT an MNI object file.",
        nargs=1,
        metavar=('*'))
    ogroup.add_argument(
        "-o_stl",
        "--outputstl",
        help=
        "Output file name for STereoLithography (STL) object file for visualization with blender (or any other 3D viewer).",
        nargs=1,
        metavar=('*'))
    ogroup.add_argument(
        "-o_ply",
        "--outputply",
        help=
        "Output file name for Polygon File Format (PYL) object file for visualization with blender (or any other 3D viewer).",
        nargs=1,
        metavar=('*'))

    ap.add_argument(
        "-p",
        "--paintsurface",
        help=
        "Projects surface file onto a ply mesh for visualization of results using a 3D viewer. Must be used with -o_ply option. Input the surface file (*.mgh), the sigificance threshold (low and high), and either: red-yellow (r_y), blue-lightblue (b_lb) or any matplotlib colorschemes (https://matplotlib.org/examples/color/colormaps_reference.html). Note, thresholds must be postive. e.g., -p image.mgh 0.95 1 r_y",
        nargs=4,
        metavar=('*.mgh', 'float', 'float', 'colormap'))
    ap.add_argument(
        "-s",
        "--paintsecondsurface",
        help=
        "Projects a second surface file onto a ply mesh for visualization of resutls using a 3D viewer. Must be used with -o_ply and -p options. Input the surface file (*.mgh), the sigificance threshold (low and high), and either: red-yellow (r_y), blue-lightblue (b_lb) or any matplotlib colorschemes (https://matplotlib.org/examples/color/colormaps_reference.html). Note, thresholds must be postive. e.g., -s negimage.mgh 0.95 1 b_lb",
        nargs=4,
        metavar=('*.mgh', 'float', 'float', 'colormap'))

    ap.add_argument(
        "-l",
        "--paintfslabel",
        help=
        "Projects freesurface label file onto a ply mesh for visualization of resutls using a 3D viewer. Must be used with -o_ply option. Input the label (*.label or *.label-????) and either: red-yellow (r_y), blue-lightblue (b_lb) or any matplotlib colorschemes (https://matplotlib.org/examples/color/colormaps_reference.html). More than one label can be included. e.g. -l label1.label rainbow label2.label Reds",
        nargs='+',
        metavar=('*.label colormap'))
    ap.add_argument(
        "-a",
        "--paintfsannot",
        help=
        "Projects freesurface annotation file onto a ply mesh for visualization of resutls using a 3D viewer. Must be used with -o_ply option. The legend is outputed",
        nargs=1,
        metavar=('*.annot'))

    return ap
def getArgumentParser(ap=ap.ArgumentParser(description=DESCRIPTION)):
    datatype = ap.add_mutually_exclusive_group(required=True)
    datatype.add_argument("--voxel",
                          help="Voxel analysis.",
                          action="store_true")
    datatype.add_argument(
        "--vertex",
        help="Vertex analysis. Input surface: e.g. --vertex {surface}",
        nargs=1,
        metavar=('surface'))

    stat = ap.add_mutually_exclusive_group(required=False)
    stat.add_argument(
        "-m",
        "--mediation",
        help=
        "Mediation analysis [M or I or Y]. If not specified, then multiple regression is performed.",
        nargs=1,
        choices=['I', 'M', 'Y'],
        metavar=('STR'))
    stat.add_argument("-glm",
                      "--generalizedlinearmodel",
                      help="GLM analysis with tm-models.",
                      action='store_true')
    stat.add_argument("-med",
                      "--modelmediation",
                      help="Mediation with tm-models",
                      action='store_true')
    stat.add_argument("-ofa",
                      "--onebetweenssubjectfactor",
                      help="One factor repeated measure ANCOVA with tm-models",
                      action='store_true')
    stat.add_argument("-tfa",
                      "--twobetweenssubjectfactor",
                      help="Two factor repeated measure ANCOVA with tm-models",
                      action='store_true')
    stat.add_argument("-cos",
                      "--cosinor",
                      help="Cosinor model",
                      action='store_true')
    stat.add_argument("-mcos", "--cosinormediation", action='store_true')

    ap.add_argument("-n",
                    "--numperm",
                    nargs=1,
                    type=int,
                    help="# of permutations",
                    metavar=('INT'),
                    required=True)
    ap.add_argument(
        "-v",
        "--specifyvars",
        nargs=2,
        type=int,
        help=
        "Optional for multiple regression. Specify which regressors are permuted [first] [last]. For one variable, first=last.",
        metavar=('INT', 'INT'))
    ap.add_argument("-e",
                    "--exchangeblock",
                    nargs=1,
                    help="Exchangability blocks",
                    metavar=('*.csv'),
                    required=False)
    group = ap.add_mutually_exclusive_group(required=False)
    group.add_argument("-p",
                       "--gnuparallel",
                       nargs=1,
                       type=int,
                       help="Use GNU parallel. Specify number of cores",
                       metavar=('INT'))
    group.add_argument("-c",
                       "--condor",
                       help="Use HTCondor.",
                       action="store_true")
    group.add_argument("-f",
                       "--fslsub",
                       help="Use fsl_sub script.",
                       action="store_true")
    return ap
def getArgumentParser(ap=ap.ArgumentParser(description=DESCRIPTION,
                                           formatter_class=formatter_class)):
    group = ap.add_mutually_exclusive_group(required=True)
    group.add_argument("-i",
                       "--input",
                       nargs='+',
                       help="[Predictor(s)]",
                       metavar=('*.csv'))
    group.add_argument("-im",
                       "--inputmediation",
                       nargs=3,
                       help="[Mediation Type {I,M,Y}] [Predictor] [Dependent]",
                       metavar=('{I,M,Y}', '*.csv', '*.csv'))
    ap.add_argument("-c",
                    "--covariates",
                    nargs=1,
                    help="[Covariate(s)]",
                    metavar=('*.csv'))
    group.add_argument("-r",
                       "--regressors",
                       nargs=1,
                       help="Single step regression",
                       metavar=('*.csv'))
    ap.add_argument(
        "-i_tmi",
        "--tmifile",
        help=
        "Vertex analysis. Input surface: e.g. --vertex [area or thickness]",
        nargs=1,
        metavar=('*.tmi'),
        required=True)
    ap.add_argument(
        "--tfce",
        help=
        "TFCE settings. H (i.e., height raised to power H), E (i.e., extent raised to power E). Default: %(default)s). H=2, E=2/3. Multiple sets of H and E values can be entered with using the -st option.",
        nargs='+',
        type=str,
        metavar=('H', 'E'))
    ap.add_argument(
        "-sa",
        "--setadjacencyobjs",
        help=
        "Specify the adjaceny object to use for each mask. The number of inputs must match the number of masks in the tmi file. Note, the objects start at zero. e.g., -sa 0 1 0 1",
        nargs='+',
        type=str,
        metavar=('int'))
    ap.add_argument(
        "-st",
        "--assigntfcesettings",
        help=
        "Specify the tfce H and E settings for each mask. -st is useful for combined analysis do voxel and vertex data. More than one set of values must inputted with --tfce. The number of inputs must match the number of masks in the tmi file. The input corresponds to each pair of --tfce setting starting at zero. e.g., -st 0 0 0 0 1 1",
        nargs='+',
        type=str,
        metavar=('INT'))
    ap.add_argument(
        "--noweight",
        help=
        "Do not weight each vertex for density of vertices within the specified geodesic distance (not recommended).",
        action="store_true")
    ap.add_argument(
        "--subset",
        help=
        "Analyze a subset of subjects based on a single column text file. Subset will be performed based on whether each input is finite (keep) or text (remove).",
        nargs=1)
    ap.add_argument("-n",
                    "--numperm",
                    nargs=1,
                    type=int,
                    help="# of permutations",
                    metavar=('INT'),
                    required=True)
    parallel = ap.add_mutually_exclusive_group(required=False)
    parallel.add_argument("-p",
                          "--gnuparallel",
                          nargs=1,
                          type=int,
                          help="Use GNU parallel. Specify number of cores",
                          metavar=('INT'))
    parallel.add_argument("-cd",
                          "--condor",
                          help="Use HTCondor.",
                          action="store_true")
    parallel.add_argument("-f",
                          "--fslsub",
                          help="Use fsl_sub script.",
                          action="store_true")
    parallel.add_argument(
        "-t",
        "--cmdtext",
        help="Outputs a text file with one command per line.",
        action="store_true")
    return ap
Example #16
0
    'append' --> allows utuple uses of same -i , and creates a list ie '-i 1 -i 2' --> i = [1,2]
    'append_const' --> constant definition for append, need 'const' field
    'count' --> counts the number of args used, eg: -vvv --> 3
choices=<list> --> argument must be in the list/tuple/list/set
required=<Bool> --> set the arg to required or not
help = <str> --> help string will be displayed for each arg when -h is used


can concat togehter args if none or the last require a value
parsing
-xyz (if at least x,y have defaults)

abreviations allowed (arguments = 'name', 'territorial') (acceptable, -na -ter) etc... unless ambiguious


group = argparse.add_mutually_exclusive_group()    
    group.add_argument...
any arguments added, only 1 can be used or error

.set_defaults(**kwargs) --> will become default arguments even if the arguments were not created with .add_argument
.get_default('key') --> return the default of the key

--- useage ---
(above class saved in Args.py modual)
import Args
arg_parser = Args.Args()
inputArgs = arg_parser.parse()
inputArgs.ARGNAME #ie inputArgs.sample


def getArgumentParser(ap=ap.ArgumentParser(description=DESCRIPTION)):

    ap.add_argument("-i_tmi",
                    "--tmifile",
                    help="Input the *.tmi file for analysis.",
                    nargs=1,
                    metavar=('*.tmi'),
                    required=True)

    group = ap.add_mutually_exclusive_group(required=True)
    group.add_argument("-i",
                       "--input",
                       nargs='+',
                       help="[Predictor(s)]",
                       metavar=('*.csv'))
    group.add_argument("-im",
                       "--inputmediation",
                       nargs=3,
                       help="[Mediation Type {I,M,Y}] [Predictor] [Dependent]",
                       metavar=('{I,M,Y}', '*.csv', '*.csv'))
    ap.add_argument("-c",
                    "--covariates",
                    nargs=1,
                    help="[Covariate(s)]",
                    metavar=('*.csv'))
    group.add_argument("-r",
                       "--regressors",
                       nargs=1,
                       help="Single step regression",
                       metavar=('*.csv'))
    group.add_argument(
        "-mfwe",
        "--multisurfacefwecorrection",
        help=
        "Input the stats tmi using -i_tmi *.tmi. The corrected files will be appended to the stats tmi. Note, the intercepts will be ignored.",
        action='store_true')
    group.add_argument(
        "-medfwe",
        "--mediationmfwe",
        nargs=1,
        choices=['I', 'M', 'Y'],
        help=
        "Input the stats tmi using -i_tmi *.tmi. Select the mediation type {I,M,Y}. The corrected files will be appended to the stats tmi."
    )

    ap.add_argument("-p",
                    "--randomise",
                    help="Specify the range of permutations. e.g, -p 1 200",
                    nargs=2,
                    type=int,
                    metavar=['INT'])
    ap.add_argument("-i_name",
                    "--analysisname",
                    help="Input the *.tmi file for analysis.",
                    nargs=1)
    ap.add_argument(
        "--tfce",
        help=
        "TFCE settings. H (i.e., height raised to power H), E (i.e., extent raised to power E). Default: %(default)s). H=2, E=2/3. Multiple sets of H and E values can be entered with using the -st option.",
        nargs='+',
        default=[2.0, 0.67],
        type=float,
        metavar=('H', 'E'))
    ap.add_argument(
        "-sa",
        "--setadjacencyobjs",
        help=
        "Specify the adjaceny object to use for each mask. The number of inputs must match the number of masks in the tmi file. Note, the objects start at zero. e.g., -sa 0 1 0 1",
        nargs='+',
        type=int,
        metavar=('INT'))
    ap.add_argument(
        "-st",
        "--assigntfcesettings",
        help=
        "Specify the tfce H and E settings for each mask. -st is useful for combined analysis do voxel and vertex data. More than one set of values must inputted with --tfce. The number of inputs must match the number of masks in the tmi file. The input corresponds to each pair of --tfce setting starting at zero. e.g., -st 0 0 0 0 1 1",
        nargs='+',
        type=int,
        metavar=('INT'))
    ap.add_argument(
        "--noweight",
        help=
        "Do not weight each vertex for density of vertices within the specified geodesic distance (not recommended).",
        action="store_true")
    ap.add_argument(
        "--subset",
        help=
        "Analyze a subset of subjects based on a single column text file. Subset will be performed based on whether each input is finite (keep) or text (remove).",
        nargs=1)
    ap.add_argument("--outtype",
                    help="Specify the output file type",
                    nargs='+',
                    default=['tmi'],
                    choices=('tmi', 'mgh', 'nii.gz', 'auto'))
    ap.add_argument(
        "-cs",
        "--concatestats",
        help=
        "Concantenate FWE corrected p statistic images to the stats file. Must be used with -mfwe option",
        action="store_true")
    ap.add_argument(
        "-l",
        "--neglog",
        help=
        "Output negative log(10) pFWE corrected images (useful for visualizing effect sizes).",
        action="store_true")
    ap.add_argument(
        "-op",
        "--outputply",
        help=
        "Projects pFWE corrected for negative and positive TFCE transformed t-statistics onto a ply mesh for visualization of results using a 3D viewer. Must be used with -mfwe option. The sigificance threshold (low and high), and either: red-yellow (r_y), blue-lightblue (b_lb) or any matplotlib colorschemes (https://matplotlib.org/examples/color/colormaps_reference.html). Note, thresholds must be postive. e.g., -op 0.95 1 r_y b_lb",
        nargs=4,
        metavar=('float', 'float', 'colormap', 'colormap'))

    #	ap.add_argument("--plysmoothing",
    #		help = "Apply Laplician or Taubin smoothing before visualization. Input the number of iterations (e.g., -ss 5).",
    #		nargs = 1,
    #		type = int,
    #		metavar = 'int')
    #	ap.add_argument("--smoothingtype",
    #		help = "Set type of surface smoothing to use (choices are: %(choices)s). The default is laplacian. The Taubin (aka low-pass) filter smooths curves/surfaces without the shrinkage of the laplacian filter.",
    #		nargs = 1,
    #		choices = ['laplacian','taubin'],
    #		default = ['laplacian'],
    #		metavar = 'str')

    correctionoptions = ap.add_mutually_exclusive_group(required=False)
    correctionoptions.add_argument(
        "-ss",
        "--setsurface",
        help=
        "Must be used with -mfwe option. Input the set of surfaces to create pFWE corrected images using a range. Family-wise error rate correction will only applied to the specified surfaces. e.g., -ss 0 1 5 6",
        nargs='+',
        type=int,
        metavar=('INT'))
    correctionoptions.add_argument(
        "-ssr",
        "--setsurfacerange",
        help=
        "Must be used with -mfwe option. Input a range to set the surfaces to create pFWE corrected images using a range. Family-wise error rate correction will only applied to the specified surfaces. e.g., -ssr 0 3",
        nargs=2,
        type=int,
        metavar=('INT'))

    return ap
def getArgumentParser(ap=ap.ArgumentParser(description=DESCRIPTION)):

    group = ap.add_mutually_exclusive_group(required=True)
    group.add_argument("-i",
                       "--input",
                       nargs=2,
                       help="[Predictor(s)] [Covariate(s)] (recommended)",
                       metavar=('*.csv', '*.csv'))
    group.add_argument("-r",
                       "--regressors",
                       nargs=1,
                       help="Single step regression",
                       metavar=('*.csv'))

    ap.add_argument("-s",
                    "--surface",
                    nargs=1,
                    metavar=('area or thickness'),
                    required=True)
    ap.add_argument(
        "-f",
        "--fwhm",
        help=
        "Specific all surface file with different smoothing. Default is 03B (recommended)",
        nargs=1,
        default=['03B'],
        metavar=('??B'))

    mask = ap.add_mutually_exclusive_group(required=False)
    mask.add_argument(
        "--fmri",
        help=
        "Masking threshold for fMRI surfaces. Default is 0.1 (i.e., mask regions with values less than -0.1 and greater than 0.1)",
        const=0.1,
        type=float,
        nargs='?')
    mask.add_argument(
        "-m",
        "--fsmask",
        help="Create masking array based on fsaverage label. Default is cortex",
        const='cortex',
        nargs='?')
    mask.add_argument(
        "-l",
        "--label",
        help="Load label as masking array for lh and rh, respectively.",
        nargs=2,
        metavar=('lh.*.label', 'rh.*.label'))
    mask.add_argument(
        "-b",
        "--binmask",
        help="Load binary mask surface for lh and rh, respectively.",
        nargs=2,
        metavar=('lh.*.mgh', 'rh.*.mgh'))

    adjac = ap.add_mutually_exclusive_group(required=False)
    adjac.add_argument(
        "-d",
        "--dist",
        help=
        "Load supplied adjacency sets geodesic distance in mm. Default is 3 (recommended).",
        choices=[1, 2, 3],
        type=int,
        nargs=1,
        default=[3])
    adjac.add_argument("-a",
                       "--adjfiles",
                       help="Load custom adjacency set for each hemisphere.",
                       nargs=2,
                       metavar=('*.npy', '*.npy'))
    adjac.add_argument(
        "-t",
        "--triangularmesh",
        help=
        "Create adjacency based on triangular mesh without specifying distance.",
        action='store_true')
    ap.add_argument(
        "--inputsurfs",
        help=
        "Load surfaces for triangular mesh tfce. --triangularmesh option must be used.",
        nargs=2,
        metavar=('lh.*.srf', 'rh.*.srf'))
    ap.add_argument(
        "--tfce",
        help=
        "TFCE settings. H (i.e., height raised to power H), E (i.e., extent raised to power E). Default: %(default)s). H=2, E=2/3 is the point at which the cummulative density function is approximately Gaussian distributed.",
        nargs=2,
        default=[2, 0.67],
        metavar=('H', 'E'))
    ap.add_argument(
        "--noweight",
        help=
        "Do not weight each vertex for density of vertices within the specified geodesic distance.",
        action="store_true")
    ap.add_argument(
        "-v",
        "--vertexregressor",
        nargs=2,
        help=
        "Add a vertex-wise independent regressor (beta feature). A variance inflation factor (VIF) image will also be produced to check for multicollinearity (generally, VIF > 5 suggest problematic collinearity.)",
        metavar=('mgh', 'mgh'))

    return ap
Example #19
0
def getArgumentParser(ap=ap.ArgumentParser(description=DESCRIPTION)):

    ap.add_argument("-i_tmi",
                    "--tmifile",
                    help="Input the *.tmi file for analysis.",
                    nargs=1,
                    metavar=('*.tmi'),
                    required=True)

    group = ap.add_mutually_exclusive_group(required=True)
    group.add_argument("-i",
                       "--input",
                       nargs=2,
                       help="[Predictor(s)] [Covariate(s)]",
                       metavar=('*.csv', '*.csv'))
    group.add_argument("-r",
                       "--regressors",
                       nargs=1,
                       help="Single step regression",
                       metavar=('*.csv'))
    group.add_argument(
        "-mfwe",
        "--multisurfacefwecorrection",
        help=
        "Input the stats tmi using -i_tmi *.tmi. The corrected files will be appended to the stats tmi. Note, the intercepts will be ignored.",
        action='store_true')
    ap.add_argument(
        "-m",
        "--mediation",
        nargs=2,
        help=
        "Perform a mediation analysis. The type of mediation {I,M,Y} and dependent variable must be inputted.",
        metavar=('{I,M,Y}', '*.csv'))
    ap.add_argument("-p",
                    "--randomise",
                    help="Specify the range of permutations. e.g, -p 1 200",
                    nargs=2,
                    type=int,
                    metavar=['INT'])
    ap.add_argument("-i_name",
                    "--analysisname",
                    help="Input the *.tmi file for analysis.",
                    nargs=1)
    ap.add_argument(
        "--tfce",
        help=
        "TFCE settings. H (i.e., height raised to power H), E (i.e., extent raised to power E). Default: %(default)s). H=2, E=2/3 is the point at which the cummulative density function is approximately Gaussian distributed.",
        nargs='+',
        default=[2.0, 0.67],
        type=float,
        metavar=('H', 'E'))
    ap.add_argument(
        "-sa",
        "--setadjacencyobjs",
        help=
        "Specify the adjaceny object to use for each mask. The number of inputs must match the number of masks in the tmi file. Note, the objects start at zero. e.g., -sa 0 1 0 1",
        nargs='+',
        type=int,
        metavar=('INT'))
    ap.add_argument(
        "-st",
        "--setfcesettings",
        help=
        "Specify the tfce H and E settings for each mask. -st is useful for combined analysis do voxel and vertex data, and it only makes sense if more than one set of values are inputted with --tfce. The number of inputs must match the number of masks in the tmi file. The input corresponds to each pair of --tfce setting starting at zero. e.g., -st 0 0 0 0 1 1",
        nargs='+',
        type=int,
        metavar=('INT'))
    ap.add_argument(
        "--noweight",
        help=
        "Do not weight each vertex for density of vertices within the specified geodesic distance (not recommended).",
        action="store_true")
    ap.add_argument("--outtype",
                    help="Specify the output file type",
                    nargs='+',
                    default=['tmi'],
                    choices=('tmi', 'mgh', 'nii.gz', 'auto'))
    ap.add_argument(
        "-c",
        "--concatestats",
        help=
        "Concantenate FWE corrected p statistic images to the stats file. Must be used with -mfwe option",
        action="store_true")
    ap.add_argument(
        "-l",
        "--neglog",
        help=
        "Output negative log(10) pFWE corrected images (useful for visualizing effect sizes).",
        action="store_true")
    ap.add_argument(
        "-op",
        "--outputply",
        help=
        "Projects pFWE corrected for negative and positive TFCE transformed t-statistics onto a ply mesh for visualization of results using a 3D viewer. Must be used with -mfwe option. The sigificance threshold (low and high), and either: red-yellow (r_y), blue-lightblue (b_lb) or any matplotlib colorschemes (https://matplotlib.org/examples/color/colormaps_reference.html). Note, thresholds must be postive. e.g., -op 0.95 1 r_y b_lb",
        nargs=4,
        metavar=('float', 'float', 'colormap', 'colormap'))
    correctionoptions = ap.add_mutually_exclusive_group(required=False)
    correctionoptions.add_argument(
        "-ss",
        "--setsurface",
        help=
        "Must be used with -mfwe option. Input the set of surfaces to create pFWE corrected images using a range. Family-wise error rate correction will only applied to the specified surfaces. e.g., -ss 0 1 5 6",
        nargs='+',
        type=int,
        metavar=('INT'))
    correctionoptions.add_argument(
        "-ssr",
        "--setsurfacerange",
        help=
        "Must be used with -mfwe option. Input a range to set the surfaces to create pFWE corrected images using a range. Family-wise error rate correction will only applied to the specified surfaces. e.g., -ssr 0 3",
        nargs=2,
        type=int,
        metavar=('INT'))

    return ap