logging.info("realigned %s" % subid) # make final mean image meanimg = pp.make_summed_image(tmprealigned) # move data back to main directory nifti_dir, _ = os.path.split(nifti[0]) movedmean = bg.copy_file(meanimg, nifti_dir) # QA if not hasqa: logging.info("qa %s" % subid) qa.plot_movement(tmpparameterfile, subid) # get rid of NAN in files no_nanfiles = pp.clean_nan(tmprealigned) # make 4d volume to visualize movement img4d = qa.make_4d_nibabel(no_nanfiles) bg.zip_files(tmprealigned) # save qa image # qa.save_qa_img(img4d) qa.plot_movement(tmpparameterfile, subid) qa.calc_robust_median_diff(img4d) qa.screen_pet(img4d) # remove tmpfiles bg.remove_files(no_nanfiles) bg.remove_files(newnifti) # coreg pons to pet # find PONS
indir='%s/'%root) subs.sort() for sub in subs: _, subid = os.path.split(sub) logging.info('%s'%subid) # check is ponsnormed exists searchstring = '%s/fdg/nonan-ponsnormed_*.nii*'%sub pn = pp.find_single_file(searchstring) if pn is not None: logging.info('%s exists, skipping'%(pn)) continue # find sum searchstring = '%s/fdg/sum_rB*.nii*' % sub sum = pp.find_single_file(searchstring) if sum is None: logging.error('%s not found'%(searchstring)) continue searchstr = '%s/fdg/ref_region/rpons_tu.nii*' % sub pons = pp.find_single_file(searchstr) if pons is None: logging.error('%s not found'%(searchstring)) continue outfname = os.path.join(sub, 'fdg', 'ponsnormed_%s_%s.nii'%(subid, tracer.lower())) pp.make_pons_normed(pet, newpons, outfname) no_nanfiles = pp.clean_nan([outfname]) logging.info('saved %s'%(outfname))
logging.info('realigned %s' % subid) # make final mean image meanimg = pp.make_summed_image(tmprealigned) # move data back to main directory nifti_dir, _ = os.path.split(nifti[0]) movedmean = bg.copy_file(meanimg, nifti_dir) #QA if not hasqa: logging.info('qa %s' % subid) qa.plot_movement(tmpparameterfile, subid) # get rid of NAN in files no_nanfiles = pp.clean_nan(tmprealigned) #make 4d volume to visualize movement img4d = qa.make_4d_nibabel(no_nanfiles) bg.zip_files(tmprealigned) #save qa image #qa.save_qa_img(img4d) qa.plot_movement(tmpparameterfile, subid) qa.calc_robust_median_diff(img4d) qa.screen_pet(img4d) #remove tmpfiles bg.remove_files(no_nanfiles) bg.remove_files(newnifti) # coreg pons to pet # find PONS