Exemplo n.º 1
0
def process_exp_argv(argv):
    """Process pos arguments for python programs with a invocation like:
            
            $ python ./script.py name data roifile cond [, filtfile]
    """
    if len(argv) == 6:
        basename = argv[1]  ## name
        dataname = argv[2]  ## data
        _, rois = load_roifile(argv[3])  ## roifile
        cond = argv[4]  ## cond
        tr = argv[5]
        filtfile = None
    elif len(argv) == 7:
        basename = argv[1]
        dataname = argv[2]
        _, rois = load_roifile(argv[3])
        cond = argv[4]
        tr = argv[5]
        filtfile = argv[6]
    else:
        raise ValueError("Wrong number of arguments")

    return basename, dataname, rois, cond, tr, filtfile
Exemplo n.º 2
0
parser.add_argument(
        "filtfile", 
        help="Name of this exp",
        nargs='?',
        default=None
        )
args = parser.parse_args()


# ---------------------------------------------------------------------------
# Process argv
# ---------------------------------------------------------------------------
# Replace this with good arg processing....
# basename, dataname, rois, cond, tr, filtfile = process_exp_argv(sys.argv)
data = get_data(args.data)
_, rois = load_roifile(args.roifile)  ## roifile

# ---------------------------------------------------------------------------
# Setup exp
# ---------------------------------------------------------------------------
spacetime = SelectSpace(PCA(6, whiten=True), fir, mode="decompose")
exp = DecomposeExp(
        spacetime, data, window=args.window, nsig=3, tr=args.tr
        )

# ---------------------------------------------------------------------------
# And run each roi
# ---------------------------------------------------------------------------
for n, roi in enumerate(rois):
    print("{3}: {0} ({1}/{2})".format(roi, n+1, len(rois), args.data))   
    exp.run(
    
    # ----
    # Create a place for 
    # the roi data to 
    # live if necessary.
    try:
        os.mkdir("./roinii")
    except OSError:
        pass
    
    # ----
    # Process argv
    if len(sys.argv[1:]) != 1:
        raise ValueError("One arguments are required.")
    
    # ----
    # Go!
    rois, names = load_roifile(sys.argv[1])
    
    # Build up arguements lists
    # creates needs 
    # (roi, path, niipartial, name, restart)
    arglist = []
    for roi, name in zip(rois, names):
        print("Creating ROI data for {0} as {1}.".format(roi, name))
        arglist.append((roi, path, niipartial, name, restart))
    
    # Parallelize using the arglist and Pool
    pool = Pool(ncore)
    pool.map(create, arglist)
Exemplo n.º 4
0
    # Log success
    f = open("{0}_roinii.log".format(expname), "a")
    f.write("{0}:{1}\n".format(maskname, newname))
    f.close()


if __name__ == '__main__':
    """Command line invocation setup."""

    ncore = 1
    overwrite = False

    # Process argv
    if len(sys.argv[1:]) != 2:
        raise ValueError("Two arguments are required.")
    roinames, newnames = load_roifile(sys.argv[1])
    expname = sys.argv[2]

    # Cleaup success log from previous runs
    try:
        os.remove("{0}_roinii.log".format(expname))
    except OSError:
        pass

    # Go, multpprocess on request
    if ncore == 1:
        [
            create(roiname, newname, expname, overwrite)
            for roiname, newname in zip(roinames, newnames)
        ]
    elif ncore > 1:
Exemplo n.º 5
0
    # ----
    # Create a place for
    # the roi data to
    # live if necessary.
    try:
        os.mkdir("./roinii")
    except OSError:
        pass

    # ----
    # Process argv
    if len(sys.argv[1:]) != 1:
        raise ValueError("One arguments are required.")

    # ----
    # Go!
    rois, names = load_roifile(sys.argv[1])

    # Build up arguements lists
    # creates needs
    # (roi, path, niipartial, name, restart)
    arglist = []
    for roi, name in zip(rois, names):
        print("Creating ROI data for {0} as {1}.".format(roi, name))
        arglist.append((roi, path, niipartial, name, restart))

    # Parallelize using the arglist and Pool
    pool = Pool(ncore)
    pool.map(create, arglist)
Exemplo n.º 6
0
    # Log success
    f = open("{0}_roinii.log".format(expname), "a")
    f.write("{0}:{1}\n".format(maskname, newname))
    f.close()


if __name__ == '__main__':
    """Command line invocation setup."""    

    ncore = 1
    overwrite = False

    # Process argv
    if len(sys.argv[1:]) != 2:
        raise ValueError("Two arguments are required.")
    roinames, newnames = load_roifile(sys.argv[1])
    expname = sys.argv[2]
   
    # Cleaup success log from previous runs
    try:
        os.remove("{0}_roinii.log".format(expname))
    except OSError:
        pass

    # Go, multpprocess on request
    if ncore == 1:
        [create(roiname, newname, expname, overwrite) for
                roiname, newname in zip(roinames, newnames)] 
    elif ncore > 1:
        p = Pool(ncore)
        for roiname, newname in zip(roinames, newnames):