def bedpostx_diffusion_model(outdir, dwi, bval, bvec, nodif_brain_mask): """ <unit> <output name="bedpostx_dir" type="Directory" /> <input name="outdir" type="Directory" /> <input name="dwi" type="File" /> <input name="bval" type="File" /> <input name="bvec" type="File" /> <input name="nodif_brain_mask" type="File" /> </unit> """ bedpostx_indir = os.path.join(outdir, "bedpostx") create_bedpostx_indir(bedpostx_indir, dwi, bval, bvec, nodif_brain_mask) bedpostx_dir = bedpostx(bedpostx_indir)[0] return bedpostx_dir
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))
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 ============ We compute the fibers starting at a specific gyrus, connecting the other gyri only with the 'network' option. The result is stored in the 'fdt_paths' image. The 'fdt_network_matrix' is a 2D region-by-region connectivity matrix. """ probtrackx2_outdir = os.path.join(outdir, "proba_region_connectivity")
# 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: merged_files = glob.glob(os.path.join(bedpostx_outdir, "merged*")) if len(merged_files) == 0: raise IOError("FilesDoNotExist: in '{0}'.".format(bedpostx_outdir))
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: merged_files = glob.glob(os.path.join(bedpostx_outdir, "merged*")) if len(merged_files) == 0: raise IOError("FilesDoNotExist: in '{0}'.".format(bedpostx_outdir))
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: merged_files = glob.glob(os.path.join(bedpostx_outdir, "merged*")) if len(merged_files) == 0: raise IOError("FilesDoNotExist: in '{0}'.".format(bedpostx_outdir))