def sub2tmp2mni(templatePath, siteName, caselist, ref= False, tar_unproc= False, tar_harm= False):

    # obtain the transform
    moving = pjoin(templatePath, f'Mean_{siteName}_FA.nii.gz')

    outPrefix= pjoin(templatePath, f'TemplateToMNI_{siteName}')
    warp2mni= outPrefix+'1Warp.nii.gz'
    trans2mni= outPrefix+'0GenericAffine.mat'
    # template is created once, it is expected that the user wants to keep the template same during debugging
    # so in case multiple debug is needed, pass the registration
    if not exists(warp2mni):
        antsReg(mniTmp, None, moving, outPrefix)

    imgs, _= read_caselist(caselist)

    pool= multiprocessing.Pool(N_proc)
    for imgPath in imgs:

        if ref:
            pool.apply_async(func= register_reference, args= (imgPath, warp2mni, trans2mni, templatePath, ))
        elif tar_unproc:
            pool.apply_async(func= register_target, args= (imgPath, templatePath, ))
        elif tar_harm:
            pool.apply_async(func= register_harmonized, args= (imgPath, warp2mni, trans2mni, templatePath, siteName, ))

    pool.close()
    pool.join()
def sub2tmp2mni(templatePath,
                siteName,
                caselist,
                ref=False,
                tar_unproc=False,
                tar_harm=False):

    # obtain the transform
    moving = pjoin(templatePath, f'Mean_{siteName}_FA_b{bshell_b}.nii.gz')

    outPrefix = pjoin(templatePath, f'TemplateToMNI_{siteName}')
    warp2mni = outPrefix + '1Warp.nii.gz'
    trans2mni = outPrefix + '0GenericAffine.mat'

    # check existence of transforms created with _b{bmax}
    if not exists(warp2mni):
        antsReg(mniTmp, None, moving, outPrefix)

    imgs, _ = read_caselist(caselist)

    pool = multiprocessing.Pool(N_proc)
    for imgPath in imgs:

        if ref:
            pool.apply_async(func=register_reference,
                             args=(
                                 imgPath,
                                 warp2mni,
                                 trans2mni,
                                 templatePath,
                             ))
        elif tar_unproc:
            pool.apply_async(func=register_target,
                             args=(
                                 imgPath,
                                 templatePath,
                             ))
        elif tar_harm:
            pool.apply_async(func=register_harmonized,
                             args=(
                                 imgPath,
                                 warp2mni,
                                 trans2mni,
                                 templatePath,
                                 siteName,
                             ))

    pool.close()
    pool.join()
Beispiel #3
0
def analyzeStat(file, templatePath):

    skel = load(pjoin(ROOTDIR, 'IITAtlas', 'IITmean_FA_skeleton.nii.gz'))
    skel_mask = (skel.get_data() > 0) * 1.

    imgs, _ = read_caselist(file)

    meanAttr = []
    for imgPath in imgs:
        inPrefix = imgPath.split('.nii')[0]
        prefix = psplit(inPrefix)[-1]

        faImg = pjoin(templatePath, prefix + f'_InMNI_FA.nii.gz')
        data = load(faImg).get_data()
        temp = data * skel_mask
        meanAttr.append(temp[temp > 0].mean())

    return meanAttr
Beispiel #4
0
def analyzeStat(file, templatePath):
    '''
    :param file: list of (FA or MD or GFA) that are already in MNI space
    :return: mean of the images
    '''

    skel = load(pjoin(ROOTDIR, 'IITAtlas', 'IITmean_FA_skeleton.nii.gz'))
    skel_mask = (skel.get_data() > 0) * 1.

    imgs, _ = read_caselist(file)

    meanAttr = []
    for imgPath in imgs:
        inPrefix = imgPath.split('.nii')[0]
        prefix = basename(inPrefix)

        faImg = pjoin(templatePath, prefix + f'_InMNI_FA.nii.gz')
        data = load(faImg).get_data()
        temp = data * skel_mask
        meanAttr.append(temp[temp > 0].mean())

    return meanAttr