## find brainmask globstr = os.path.join(s, 'anatomy', 'brainmask.nii') brainmask = pp.find_single_file(globstr) ## find sum globstr = os.path.join(s, 'fdg', 'sum_r*.nii') sum = pp.find_single_file(globstr) if brainmask is None or sum is None: logging.error('pet2mri sum: %s brainmask: %s' % (sum, brainmask)) continue ## coreg pet 2 brainmask cpons = bg.copy_file(ponsnormed, coregdir) csum = bg.copy_file(sum, coregdir) corg_out = pp.simple_coregister(str(brainmask), str(csum), other=str(cpons)) if not corg_out.runtime.returncode == 0: logging.error(corg_out.runtime.stderr) continue rpons = corg_out.outputs.coregistered_files # copy ponsnormed to freesurfer subjects petdir cponsnormed = bg.copy_file(rpons, petdir) globstr = os.path.join(fsdir, 'mri', 'T1.mgz') t1 = pp.find_single_file(globstr) if t1 is None: logging.error('%s not found' % globstr) continue xfm = fst.fs_generate_dat(cponsnormed, t1, subid) outfiles = fst.pet_2_surf(cponsnormed, xfm, mridir)
## find brainmask globstr = os.path.join(s, 'anatomy','brainmask.nii') brainmask = pp.find_single_file(globstr) ## find sum globstr = os.path.join(s, 'fdg','sum_r*.nii') sum = pp.find_single_file(globstr) if brainmask is None or sum is None: logging.error('pet2mri sum: %s brainmask: %s'%(sum, brainmask)) continue ## coreg pet 2 brainmask cpons = bg.copy_file(ponsnormed, coregdir) csum = bg.copy_file(sum, coregdir) corg_out = pp.simple_coregister(str(brainmask), str(csum), other=str(cpons)) if not corg_out.runtime.returncode == 0: logging.error(corg_out.runtime.stderr) continue rpons = corg_out.outputs.coregistered_files # copy ponsnormed to freesurfer subjects petdir cponsnormed = bg.copy_file(rpons, petdir) globstr = os.path.join(fsdir, 'mri', 'T1.mgz') t1 = pp.find_single_file(globstr) if t1 is None: logging.error('%s not found'%globstr) continue xfm = fst.fs_generate_dat(cponsnormed, t1, subid) outfiles = fst.pet_2_surf(cponsnormed, xfm, mridir)
## find sum globstr = os.path.join(s, "pib", "realign_QA", "mean20min*.nii") sum = pp.find_single_file(globstr) if brainmask is None or sum is None: logging.error("pet2mri sum: %s brainmask: %s" % (sum, brainmask)) continue # move dvr and sum to coregdir, unzip if necessary cdvr = bg.copy_file(dvr, coregdir) csum = bg.copy_file(sum, coregdir) cdvr = bg.unzip_file(cdvr) csum = bg.unzip_file(csum) ## coreg pet 2 brainmask corg_out = pp.simple_coregister(str(brainmask), str(csum), other=str(cdvr)) if not corg_out.runtime.returncode == 0: logging.error(corg_out.runtime.traceback) continue rdvr = corg_out.outputs.coregistered_files # copy dvr to freesurfer subjects petdir cdvr = bg.copy_file(rdvr, petdir) globstr = os.path.join(fsdir, "mri", "T1.mgz") t1 = pp.find_single_file(globstr) if t1 is None: logging.error("%s not found" % globstr) continue xfm = fst.fs_generate_dat(cdvr, t1, subid) outfiles = fst.pet_2_surf(cdvr, xfm, mridir) # zip files in coregdir allf = glob("%s/*" % coregdir) bg.zip_files(allf)
sum = pp.find_single_file(globstr) if brainmask is None or sum is None: logging.error('pet2mri sum: %s brainmask: %s' % (sum, brainmask)) continue # move dvr and sum to coregdir, unzip if necessary cdvr = bg.copy_file(dvr, coregdir) csum = bg.copy_file(sum, coregdir) cdvr = bg.unzip_file(cdvr) csum = bg.unzip_file(csum) ## coreg pet 2 brainmask corg_out = pp.simple_coregister(str(brainmask), str(csum), other=str(cdvr)) if not corg_out.runtime.returncode == 0: logging.error(corg_out.runtime.traceback) continue rdvr = corg_out.outputs.coregistered_files # copy dvr to freesurfer subjects petdir cdvr = bg.copy_file(rdvr, petdir) globstr = os.path.join(fsdir, 'mri', 'T1.mgz') t1 = pp.find_single_file(globstr) if t1 is None: logging.error('%s not found' % globstr) continue xfm = fst.fs_generate_dat(cdvr, t1, subid) outfiles = fst.pet_2_surf(cdvr, xfm, mridir) # zip files in coregdir allf = glob('%s/*' % coregdir) bg.zip_files(allf)