Exemple #1
0
def compute_rsf(rois):
    """ computes an RSF for each roi in input argument and returns an array with same size as input """
    sameshape, shape = check_roi_shape(rois)
    if not sameshape:
        raise AssertionError('ROIs do NOT have same shape, exiting program,'\
                             'check your ROIS dimensions')
    startdir = os.getcwd()

    fullshape = tuple([len(rois)] + list(shape))
    rsfs = np.zeros(fullshape)
    for ind, roi in enumerate(rois):

        petpsf = es.PetPsf(roi)
        xyresult = petpsf.convolve_xy()
        zresult = petpsf.convolve_z()
        file = petpsf.save_result()
        sfile = pp.fname_presuffix(file, prefix='s')
        smfile = metzler.smooth_mask_nipy(file, sfile, fwhm=4)
        smdata = smfile.get_data()
        rsfs[ind, :, :, :] = smdata

    return rsfs
Exemple #2
0
def compute_rsf(rois):
    """ computes an RSF for each roi in input argument and returns an array with same size as input """
    sameshape, shape = check_roi_shape(rois)
    if not sameshape:
        raise AssertionError('ROIs do NOT have same shape, exiting program,'\
                             'check your ROIS dimensions')
    startdir = os.getcwd()
    
    fullshape = tuple([len(rois)] + list(shape))
    rsfs = np.zeros(fullshape)
    for ind, roi in enumerate(rois):
        
        petpsf = es.PetPsf(roi)
        xyresult = petpsf.convolve_xy()
        zresult = petpsf.convolve_z()
        file = petpsf.save_result()
        sfile = pp.fname_presuffix(file, prefix='s')
        smfile = metzler.smooth_mask_nipy(file,sfile,fwhm=4)
        smdata = smfile.get_data()
        rsfs[ind,:,:,:]  = smdata
    
    return rsfs
        pvcdir, exists = bg.make_dir(pth, 'pvc_metzler')
        if exists:
            logging.error('%s exists, remove to re-run' % (pvcdir))
            continue
        # get ponsnormd
        globstr = '%s/nonan-ponsnormed_%s*nii*' % (pth, subid)
        ponsnormd = pp.find_single_file(globstr)
        if ponsnormd is None:
            logging.error('%s missing, skipping' % (globstr))
            continue
        # copy ponsnormd to pvc directory
        cponsnormd = bg.copy_file(ponsnormd, pvcdir)
        # get raparc
        corgdir = os.path.join(pth, 'coreg_mri2fdg')
        globstr = '%s/rB*aparc_aseg.nii' % (corgdir)
        raparc = pp.find_single_file(globstr)
        if raparc is None:
            logging.error('%s missing, skipping ' % (globstr))
            continue
        #copy raparc_aseg to pvd dir
        craparc = bg.copy_file(raparc, pvcdir)
        # make brainamsk
        bmask = metzler.make_aseg_brainmask(craparc)
        os.unlink(craparc)
        smooth_bmask = pp.fname_presuffix(bmask, prefix='s')
        _ = metzler.smooth_mask_nipy(bmask, smooth_bmask)
        ero_bmask = metzler.fsl_erode2d(bmask)
        pvcpet = metzler.calc_pvc(cponsnormd, ero_bmask, smooth_bmask)
        os.unlink(cponsnormd)
        logging.info('Created %s' % (pvcpet))
Exemple #4
0
        if exists:
            logging.error('%s exists, remove to re-run'%(pvcdir))
            continue
        # get ponsnormd
        globstr = '%s/nonan-ponsnormed_%s*nii*'%(pth,subid)                  
        ponsnormd = pp.find_single_file(globstr)
        if ponsnormd is None:
            logging.error('%s missing, skipping'%(globstr))
            continue
        # copy ponsnormd to pvc directory
        cponsnormd = bg.copy_file(ponsnormd, pvcdir)
        # get raparc
        corgdir = os.path.join(pth, 'coreg_mri2fdg')
        globstr = '%s/rB*aparc_aseg.nii'%(corgdir)
        raparc = pp.find_single_file(globstr)
        if raparc is None:
            logging.error('%s missing, skipping '%(globstr))
            continue
        #copy raparc_aseg to pvd dir
        craparc = bg.copy_file(raparc, pvcdir)
        # make brainamsk
        bmask = metzler.make_aseg_brainmask(craparc)
        os.unlink(craparc)
        smooth_bmask = pp.fname_presuffix(bmask, prefix='s')
        _ = metzler.smooth_mask_nipy(bmask, smooth_bmask)
        ero_bmask = metzler.fsl_erode2d(bmask)
        pvcpet = metzler.calc_pvc(cponsnormd, ero_bmask, smooth_bmask)
        os.unlink(cponsnormd)
        logging.info('Created %s'%(pvcpet))