for i in range(1,13): resampDir = os.path.join(gsDir,'downSampled_'+str(i)) refName = os.path.join(resampDir,maskName) outName = os.path.join(resampDir,segOutName) floName = os.path.join(gsDir,diffSegName) if not os.path.isfile(outName): DPD.reg_resample(refName,floName,outName,other_args = '-psf') outName = os.path.join(resampDir,DWoutName) floName = os.path.join(gsDir,'DW.nii.gz') if not os.path.isfile(outName): DPD.reg_resample(refName,floName,outName,other_args = '-psf') shutil.copyfile(bvalName,os.path.join(resampDir,'bvals')) shutil.copyfile(bvecName,os.path.join(resampDir,'bvecs')) if not dtiCode == '0': dtOut = os.path.join(resampDir,'DT') if not os.path.isdir(dtOut): os.makedirs(dtOut) if not os.path.isfile(dtOut+'/DT_MD.nii.gz'): DPD.fit_diffusion_tensor(outName,bvecName,bvalName,refName,dtOut+'/DT',wls=True,dbg=False)
bvalName = os.path.join(dwDIR,'bvals') bvecName = os.path.join(dwDIR,'bvecs') return DWname,MaskName,bvalName,bvecName def get_direc_name(sysArgs): if len(sysArgs) < 2: print 'Please include the top directory. Exiting' exit() else: return sysArgs[1] topDir = get_direc_name(sys.argv) for dirName in get_immediate_subdirectories(topDir): if 'Readings' in dirName: readDir = os.path.join(topDir,dirName) for sampling in get_immediate_subdirectories(readDir): sampleDir = os.path.join(readDir,sampling) for it in get_immediate_subdirectories(sampleDir): itDir = os.path.join(sampleDir,it) dtOut = os.path.join(itDir,'DT') if not os.path.isdir(dtOut): os.makedirs(dtOut) DWname,MaskName,bvalName,bvecName = standard_dti_names(itDir) if not os.path.isfile(dtOut+'/DT_MD.nii.gz'): DPD.fit_diffusion_tensor(DWname,bvecName,bvalName,MaskName,dtOut+'/DT',wls=True,dbg=False)
if len(sysArgs) < 2: print 'Please include the top directory. Exiting' exit() else: return sysArgs[1] topDir = get_direc_name(sys.argv) for dirName in get_immediate_subdirectories(topDir): if 'Readings' in dirName: readDir = os.path.join(topDir, dirName) for sampling in get_immediate_subdirectories(readDir): sampleDir = os.path.join(readDir, sampling) for it in get_immediate_subdirectories(sampleDir): itDir = os.path.join(sampleDir, it) dtOut = os.path.join(itDir, 'DT') if not os.path.isdir(dtOut): os.makedirs(dtOut) DWname, MaskName, bvalName, bvecName = standard_dti_names( itDir) if not os.path.isfile(dtOut + '/DT_MD.nii.gz'): DPD.fit_diffusion_tensor(DWname, bvecName, bvalName, MaskName, dtOut + '/DT', wls=True, dbg=False)
for i in range(1, 13): resampDir = os.path.join(gsDir, 'downSampled_' + str(i)) refName = os.path.join(resampDir, maskName) outName = os.path.join(resampDir, segOutName) floName = os.path.join(gsDir, diffSegName) if not os.path.isfile(outName): DPD.reg_resample(refName, floName, outName, other_args='-psf') outName = os.path.join(resampDir, DWoutName) floName = os.path.join(gsDir, 'DW.nii.gz') if not os.path.isfile(outName): DPD.reg_resample(refName, floName, outName, other_args='-psf') shutil.copyfile(bvalName, os.path.join(resampDir, 'bvals')) shutil.copyfile(bvecName, os.path.join(resampDir, 'bvecs')) if not dtiCode == '0': dtOut = os.path.join(resampDir, 'DT') if not os.path.isdir(dtOut): os.makedirs(dtOut) if not os.path.isfile(dtOut + '/DT_MD.nii.gz'): DPD.fit_diffusion_tensor(outName, bvecName, bvalName, refName, dtOut + '/DT', wls=True, dbg=False)