if not os.path.exists(outpathbval) or not os.path.exists(outpathbvec) or overwrite: mkcdir(outpathsubj) writeformat="tab" writeformat="dsi" bvals = glob.glob(os.path.join(outpath, "*bvals*.txt")) bvecs = glob.glob(os.path.join(outpath, "*bvec*.txt")) if np.size(bvals)>0 and np.size(bvecs)>0: shutil.copy(bvals[0], outpathbval) shutil.copy(bvecs[0], outpathbvec) results=[] if subject_processes>1: if function_processes>1: pool = MyPool(subject_processes) else: pool = mp.Pool(subject_processes) results = pool.starmap_async(launch_preprocessing, [(proc_subjn+subject, largerfile(glob.glob(os.path.join(os.path.join(diffpath, "*" + subject + "*")))[0]), outpath, cleanup, nominal_bval, bonusshortcutfolder, gunniespath, function_processes, masking, ref, transpose, overwrite, denoise, recenter, verbose) for subject in subjects]).get() else: for subject in subjects: max_size=0 subjectpath = glob.glob(os.path.join(os.path.join(diffpath, "*" + subject + "*")))[0] max_file=largerfile(subjectpath) launch_preprocessing(proc_subjn+subject, max_file, outpath, cleanup, nominal_bval, bonusshortcutfolder, gunniespath, function_processes, masking, ref, transpose, overwrite, denoise, recenter, verbose)
else: for subject in subjects: max_size = 0 subjectpath = glob.glob( os.path.join(os.path.join(outpath, "diffusion*" + subject + "*")))[0] print(subjectpath) max_file = largerfile(subjectpath) max_file = os.path.join(subjectpath, "nii4D_" + proc_subjn + subject + ".nii.gz") print(max_file) #command = gunniespath + "mouse_diffusion_preprocessing.bash"+ f" {subject} {max_file} {outpath}" subject_f = proc_subjn + subject if os.path.exists( os.path.join( '/mnt/munin6/Badea/Lab/mouse/ADDeccode_symlink_pool/', f'{subject_f}_subjspace_coreg.nii.gz')): print( f'Could not find subject {subject_f} in main diffusion folder but result was found in SAMBA prep folder' ) #elif os.path.exists(os.path.join('/mnt/munin6/Badea/Lab/mouse/VBM_21ADDecode03_IITmean_RPI_fullrun-work/dwi/SyN_0p5_3_0p5_fa/faMDT_NoNameYet_n37_i6/reg_images/',f'{subject_f}_rd_to_MDT.nii.gz')): # print(f'Could not find subject {subject_f} in main diff folder OR samba init but was in results of SAMBA') else: launch_preprocessing(proc_subjn + subject, max_file, outpath, cleanup, nominal_bval, SAMBA_inputs_folder, shortcuts_all_folder, gunniespath, function_processes, masking, ref, transpose, overwrite, denoise, verbose) #results.append(launch_preprocessing(subject, max_file, outpath))
results = pool.starmap_async(launch_preprocessing, [ (subject, largerfile( glob.glob(os.path.join(os.path.join( dwipath, "*" + subject + "*")))[0]), outpath) for subject in subjects ]).get() else: for subject in subjects: max_size = 0 subjectpath = glob.glob( os.path.join(os.path.join(dwipath, "*" + subject + "*")))[0] max_file = largerfile(subjectpath) #command = gunniespath + "mouse_diffusion_preprocessing.bash"+ f" {subject} {max_file} {outpath}" launch_preprocessing(subject, max_file, outpath, nominal_bval=800, shortcutpath=shortcutpath, bonusniftipath=None, gunniespath="/Users/alex/bass/gitfolder/gunnies/", matlabpath="/Users/alex/Documents/MATLAB/") #results.append(launch_preprocessing(subject, max_file, outpath)) """ subjectlist = ["58215","58216","58217","58218","58219","58221","58222","58223","58224","58225","58226","58228","58229","58230","58231","58232","58633","58634","58635","58636","58649","58650","58651","58653","58654"] for subj in subjectlist: fbvals_new = fbvals.replace("58214", subj) shutil.copyfile(fbvals, fbvals_new) fbvecs_new = fbvals.replace("58214", subj) shutil.copyfile(fbvals, fbvals_new) """