Exemple #1
0
with tractography. 'bedpostx' takes about 5 hours of compute time. This routine
need specific files that are checked with the 'bedpostx_datacheck' command.
"""

bedpostx_indir = os.path.join(outdir, "bedpostx")
bedpostx_outdir = os.path.join(outdir, "bedpostx.bedpostX")
if not os.path.isdir(bedpostx_indir):
    os.mkdir(bedpostx_indir)
if len(os.listdir(bedpostx_outdir)) == 0:
    shutil.copy2(mask_file, bedpostx_indir)
    data_ext = ".".join(diffusion_file.split(".")[1:])
    shutil.copy2(diffusion_file, os.path.join(bedpostx_indir,
                                              "data." + data_ext))
    shutil.copy2(bvecs_file, os.path.join(bedpostx_indir, "bvecs"))
    shutil.copy2(bvals_file, os.path.join(bedpostx_indir, "bvals"))
    if not bedpostx_datacheck(bedpostx_indir):
        raise IOError("'{0}' does not contain the data expected by "
                      "'bedpostx'.".format(bedpostx_indir))

    (bedpostx_outdir, merged_th, merged_ph,
     merged_f, mean_th, mean_ph,
     mean_f, dyads) = bedpostx(
        bedpostx_indir)
else:
    merged_files = glob.glob(os.path.join(bedpostx_outdir, "merged*"))
    if len(merged_files) == 0:
        raise IOError("FilesDoNotExist: in '{0}'.".format(bedpostx_outdir))

"""
Tractography
============
about 5 hours of compute time. This routine need specific files that are
checked with the 'bedpostx_datacheck' command.
"""

# copy all necessary files in the same repertory for the bedpostx execution
bedpostx_indir = os.path.join(subjdir, "diffusion")
bedpostx_outdir = os.path.join(subjdir, "diffusion.bedpostX")
if not os.path.isdir(bedpostx_indir):
    os.mkdir(bedpostx_indir)
if len(os.listdir(bedpostx_outdir)) == 0:
    shutil.copy2(mask_file, bedpostx_indir)
    data_ext = ".".join(args.diffusion_file.split(".")[1:])
    shutil.copy2(args.diffusion_file, os.path.join(
                 bedpostx_indir, "data." + data_ext))
    shutil.copy2(args.bvecs_file, os.path.join(bedpostx_indir, "bvecs"))
    shutil.copy2(args.bvals_file, os.path.join(bedpostx_indir, "bvals"))
    if not bedpostx_datacheck(bedpostx_indir, shfile=args.fslconfig):
        raise IOError("'{0}' does not contain the data expected by "
                      "'bedpostx'.".format(bedpostx_indir))

    # execute bedpostx
    (bedpostx_outdir, merged_th, merged_ph,
     merged_f, mean_th, mean_ph,
     mean_f, dyads) = bedpostx(
        bedpostx_indir,
        shfile=args.fslconfig)
else:
    merged_files = glob.glob(os.path.join(bedpostx_outdir, "merged*"))
    if len(merged_files) == 0:
        raise IOError("FilesDoNotExist: in '{0}'.".format(bedpostx_outdir))
Exemple #3
0
checked with the 'bedpostx_datacheck' command.
"""

# copy all necessary files in the same repertory for the bedpostx execution
bedpostx_indir = os.path.join(subjdir, "diffusion")
bedpostx_outdir = os.path.join(subjdir, "diffusion.bedpostX")
if not os.path.isdir(bedpostx_indir):
    os.mkdir(bedpostx_indir)
if not os.path.isdir(bedpostx_outdir) or len(os.listdir(bedpostx_outdir)) == 0:
    shutil.copy2(mask_file, bedpostx_indir)
    data_ext = ".".join(args.diffusion_file.split(".")[1:])
    shutil.copy2(args.diffusion_file,
                 os.path.join(bedpostx_indir, "data." + data_ext))
    shutil.copy2(args.bvecs_file, os.path.join(bedpostx_indir, "bvecs"))
    shutil.copy2(args.bvals_file, os.path.join(bedpostx_indir, "bvals"))
    if not bedpostx_datacheck(bedpostx_indir, shfile=args.fslconfig):
        raise IOError("'{0}' does not contain the data expected by "
                      "'bedpostx'.".format(bedpostx_indir))

    # execute bedpostx
    if not args.rician:
        args.rician = None
    (bedpostx_outdir, merged_th, merged_ph, merged_f, mean_th, mean_ph, mean_f,
     mean_d, mean_S0, dyads) = bedpostx(bedpostx_indir,
                                        n=args.n,
                                        model=args.model,
                                        rician=args.rician,
                                        shfile=args.fslconfig,
                                        b=args.burnin,
                                        cpus=args.cpus)
else: