else: aparc = bg.copy_file(aparc, outdirs["anatomydir"][0]) aparcnii = bg.convert(aparc, aparcnii) bg.remove_files([aparc]) # make pons refdir, _ = outdirs["refdir"] brainstem = os.path.join(refdir, "brainstem.nii.gz") if os.path.isfile(brainstem): logging.warning("brainstem %s exists, skipping" % (brainstem)) else: # copy aseg+aparc to refdir try: caparcnii = bg.copy_file(aparcnii, refdir) bg.make_brainstem(caparcnii) brainstem = bg.unzip_file(brainstem) bg.remove_files([caparcnii.replace(".gz", "")]) except: logging.warning("Check %s" % (brainstem)) rawtracer, exists = outdirs["rawtracer"] rawtracer_base, _ = os.path.split(rawtracer) os.system("rm -rf %s" % rawtracer_base) tracerdir, _ = outdirs["tracerdir"] newname = "%s_%s" % (subid, tracer) copied_ecats = bg.copy_files(ecats, tracerdir) bg.convertallecat(copied_ecats, newname) logging.info("ecats converted for %s " % (subid))
logging.error('%s NO APARC ASEG: %s' % (subid, aparc)) else: aparc = bg.copy_file(aparc, outdirs['anatomydir'][0]) aparcnii = bg.convert(aparc, aparcnii) bg.remove_files([aparc]) # make cerebellum refdir, _ = outdirs['refdir'] cerebellum = os.path.join(refdir, 'grey_cerebellum.nii') if os.path.isfile(cerebellum): logging.warning('cerebellum %s exists, skipping' % (cerebellum)) else: # copy aseg+aparc to refdir try: caparcnii = bg.copy_file(aparcnii, refdir) bg.make_cerebellum_nibabel(caparcnii) bg.remove_files([caparcnii]) except: logging.warning('Fail: unable to make %s' % (cerebellum)) rawtracer, exists = outdirs['rawtracer'] os.system('rm %s' % rawtracer) tracerdir, _ = outdirs['tracerdir'] newname = '%s_%s' % (subid, tracer) copied_ecats = bg.copy_files(ecats, tracerdir) bg.convertallecat(copied_ecats, newname) logging.info('ecats converted for %s ' % (subid))
# make cerebellum refdir,_ = outdirs['refdir'] cerebellum = os.path.join(refdir, 'grey_cerebellum.nii') if os.path.isfile(cerebellum): logging.warning('cerebellum %s exists, skipping'%(cerebellum)) else: # copy aseg+aparc to refdir try: caparcnii = bg.copy_file(aparcnii, refdir) bg.make_cerebellum_nibabel(caparcnii) bg.remove_files([caparcnii]) except: logging.warning('Fail: unable to make %s'%(cerebellum)) rawtracer, exists = outdirs['rawtracer'] os.system('rm %s'%rawtracer) tracerdir, _ = outdirs['tracerdir'] newname = '%s_%s' % (subid, tracer) niftis = bg.biograph_dicom_convert(tgz[0], tracerdir, subid, tracer) ## center new nifti files orig_dir, _ = bg.make_dir(tracerdir, dirname='orig') copied_orig = bg.copy_files(niftis, orig_dir) bg.remove_files(niftis) for f,nf in zip(copied_orig, niftis): print f, nf nicm.CMTransform(f).fix(new_file = nf) logging.info('biograph dicoms converted for %s ' % (subid))
bg.remove_files([aparc]) # make cerebellum refdir, _ = outdirs['refdir'] cerebellum = os.path.join(refdir, 'grey_cerebellum.nii') if os.path.isfile(cerebellum): logging.warning('cerebellum %s exists, skipping' % (cerebellum)) else: # copy aseg+aparc to refdir try: caparcnii = bg.copy_file(aparcnii, refdir) bg.make_cerebellum_nibabel(caparcnii) bg.remove_files([caparcnii]) except: logging.warning('Fail: unable to make %s' % (cerebellum)) rawtracer, exists = outdirs['rawtracer'] os.system('rm %s' % rawtracer) tracerdir, _ = outdirs['tracerdir'] newname = '%s_%s' % (subid, tracer) niftis = bg.biograph_dicom_convert(tgz[0], tracerdir, subid, tracer) ## center new nifti files orig_dir, _ = bg.make_dir(tracerdir, dirname='orig') copied_orig = bg.copy_files(niftis, orig_dir) bg.remove_files(niftis) for f, nf in zip(copied_orig, niftis): print f, nf nicm.CMTransform(f).fix(new_file=nf) logging.info('biograph dicoms converted for %s ' % (subid))