def cmp_res_R2(lstRat, lstNiiNames, strPathOut, strPathMdl, lgcSveMdlTc=True,<EOL>lgcDel=False, strNmeExt='<STR_LIT>'):
print('<STR_LIT>')<EOL>indPosR2 = [ind for ind, item in enumerate(lstNiiNames) if '<STR_LIT>' in item]<EOL>indPosBetas = [ind for ind, item in enumerate(lstNiiNames) if '<STR_LIT>' in<EOL>item]<EOL>msgError = '<STR_LIT>'<EOL>assert len(indPosR2) == <NUM_LIT:1>, msgError<EOL>assert len(indPosBetas) == <NUM_LIT:1>, msgError<EOL>indPosR2 = indPosR2[<NUM_LIT:0>]<EOL>indPosBetas = indPosBetas[<NUM_LIT:0>]<EOL>lstCmpRes = []<EOL>for indRat in range(len(lstRat)):<EOL><INDENT>strExpSve = '<STR_LIT:_>' + str(lstRat[indRat])<EOL>if lstRat[indRat] == <NUM_LIT:1.0>:<EOL><INDENT>strExpSve = '<STR_LIT>'<EOL><DEDENT>lstPthNames = [strPathOut + strNii + strNmeExt + strExpSve + '<STR_LIT>'<EOL>for strNii in lstNiiNames]<EOL>lstCmpRes.append(lstPthNames)<EOL><DEDENT>print('<STR_LIT>')<EOL>aryWnrR2 = load_nii(lstCmpRes[<NUM_LIT:0>][indPosR2])[<NUM_LIT:0>]<EOL>aryRatMap = np.zeros(aryWnrR2.shape)<EOL>aryRatMap[np.nonzero(aryWnrR2)] = <NUM_LIT:1.0><EOL>for indRat, lstMaps in zip(lstRat[<NUM_LIT:1>:], lstCmpRes[<NUM_LIT:1>:]):<EOL><INDENT>aryTmpR2 = load_nii(lstMaps[indPosR2])[<NUM_LIT:0>]<EOL>aryTmpBetas = load_nii(lstMaps[indPosBetas])[<NUM_LIT:0>]<EOL>aryLgcWnr = np.greater(aryTmpR2, aryWnrR2)<EOL>aryLgcCtrSur1 = np.logical_and(np.greater(aryTmpBetas[..., <NUM_LIT:0>], <NUM_LIT:0.0>),<EOL>np.less(aryTmpBetas[..., <NUM_LIT:1>], <NUM_LIT:0.0>))<EOL>aryLgcCtrSur2 = np.less(np.abs(aryTmpBetas[..., <NUM_LIT:1>]),<EOL>np.abs(aryTmpBetas[..., <NUM_LIT:0>]))<EOL>aryLgcCtrSur = np.logical_and(aryLgcCtrSur1, aryLgcCtrSur2)<EOL>aryLgcWnr = np.logical_and(aryLgcWnr, aryLgcCtrSur)<EOL>aryWnrR2[aryLgcWnr] = np.copy(aryTmpR2[aryLgcWnr])<EOL>aryRatMap[aryLgcWnr] = indRat<EOL><DEDENT>lstRatMap = []<EOL>for strPthMaps in lstCmpRes[-<NUM_LIT:1>]:<EOL><INDENT>lstRatMap.append(np.zeros(nb.load(strPthMaps).shape))<EOL><DEDENT>for indRat, lstMaps in zip(lstRat, lstCmpRes):<EOL><INDENT>lgcWinnerMap = [aryRatMap == indRat][<NUM_LIT:0>]<EOL>for indMap, _ in enumerate(lstMaps):<EOL><INDENT>aryTmpMap = load_nii(lstMaps[indMap])[<NUM_LIT:0>]<EOL>if indRat == <NUM_LIT:1.0> and indMap == indPosBetas:<EOL><INDENT>aryTmpMap = np.concatenate((aryTmpMap,<EOL>np.zeros(aryTmpMap.shape)),<EOL>axis=-<NUM_LIT:1>)<EOL><DEDENT>aryCrrWnrMap = np.copy(lstRatMap[indMap])<EOL>aryCrrWnrMap[lgcWinnerMap] = np.copy(aryTmpMap[lgcWinnerMap])<EOL>lstRatMap[indMap] = aryCrrWnrMap<EOL><DEDENT><DEDENT>print('<STR_LIT>')<EOL>hdrMsk, aryAff = load_nii(lstMaps[indPosR2])[<NUM_LIT:1>:]<EOL>for indMap, aryMap in enumerate(lstRatMap):<EOL><INDENT>niiOut = nb.Nifti1Image(aryMap,<EOL>aryAff,<EOL>header=hdrMsk<EOL>)<EOL>strTmp = strPathOut + '<STR_LIT>' + lstNiiNames[indMap] + strNmeExt +'<STR_LIT>'<EOL>nb.save(niiOut, strTmp)<EOL><DEDENT>niiOut = nb.Nifti1Image(aryRatMap,<EOL>aryAff,<EOL>header=hdrMsk<EOL>)<EOL>strTmp = strPathOut + '<STR_LIT>' + '<STR_LIT>' + strNmeExt + '<STR_LIT>'<EOL>nb.save(niiOut, strTmp)<EOL>if lgcSveMdlTc:<EOL><INDENT>print('<STR_LIT>' +<EOL>'<STR_LIT>')<EOL>lstCmpMdlRsp = []<EOL>for indRat in range(len(lstRat)):<EOL><INDENT>strExpSve = '<STR_LIT:_>' + str(lstRat[indRat])<EOL>if lstRat[indRat] == <NUM_LIT:1.0>:<EOL><INDENT>strExpSve = '<STR_LIT>'<EOL><DEDENT>lstPthNames = [strPathMdl + strNpy + strNmeExt + strExpSve + '<STR_LIT>'<EOL>for strNpy in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']]<EOL>lstCmpMdlRsp.append(lstPthNames)<EOL><DEDENT>lstPrfTcSur = []<EOL>lstMdlParamsSur = []<EOL>lstMdlRspSur = []<EOL>for indNpy, lstNpy in enumerate(lstCmpMdlRsp[<NUM_LIT:1>:]):<EOL><INDENT>lstPrfTcSur.append(np.load(lstNpy[<NUM_LIT:0>]))<EOL>lstMdlParamsSur.append(np.load(lstNpy[<NUM_LIT:1>]))<EOL>lstMdlRspSur.append(np.load(lstNpy[<NUM_LIT:2>]))<EOL><DEDENT>aryPrfTcSur = np.stack(lstPrfTcSur, axis=<NUM_LIT:2>)<EOL>aryMdlParamsSur = np.stack(lstMdlParamsSur, axis=<NUM_LIT:2>)<EOL>aryMdlRspSur = np.stack(lstMdlRspSur, axis=<NUM_LIT:2>)<EOL>aryPrfTc = np.load(lstCmpMdlRsp[<NUM_LIT:0>][<NUM_LIT:0>])<EOL>aryMdlParams = np.load(lstCmpMdlRsp[<NUM_LIT:0>][<NUM_LIT:1>])<EOL>aryMdlRsp = np.load(lstCmpMdlRsp[<NUM_LIT:0>][<NUM_LIT:2>])<EOL>aryPrfTc = np.concatenate((aryPrfTc, np.zeros(aryPrfTc.shape)), axis=<NUM_LIT:1>)<EOL>aryMdlParams = np.stack((aryMdlParams, aryMdlParams), axis=<NUM_LIT:1>)<EOL>aryMdlRsp = np.stack((aryMdlRsp, np.zeros(aryMdlRsp.shape)), axis=<NUM_LIT:1>)<EOL>aryPrfTcSur = np.concatenate((np.expand_dims(aryPrfTc, axis=<NUM_LIT:2>),<EOL>aryPrfTcSur), axis=<NUM_LIT:2>)<EOL>aryMdlParamsSur = np.concatenate((np.expand_dims(aryMdlParams, axis=<NUM_LIT:2>),<EOL>aryMdlParamsSur), axis=<NUM_LIT:2>)<EOL>aryMdlRspSur = np.concatenate((np.expand_dims(aryMdlRsp, axis=<NUM_LIT:2>),<EOL>aryMdlRspSur), axis=<NUM_LIT:2>)<EOL>np.save(strPathMdl + '<STR_LIT>' + '<STR_LIT>', aryPrfTcSur)<EOL>np.save(strPathMdl + '<STR_LIT>' + '<STR_LIT>', aryMdlParamsSur)<EOL>np.save(strPathMdl + '<STR_LIT>' + '<STR_LIT>', aryMdlRspSur)<EOL><DEDENT>if lgcDel:<EOL><INDENT>lstCmpRes = [item for sublist in lstCmpRes[<NUM_LIT:1>:] for item in sublist]<EOL>print('<STR_LIT>')<EOL>for strMap in lstCmpRes[:]:<EOL><INDENT>os.remove(strMap)<EOL><DEDENT>if lgcSveMdlTc:<EOL><INDENT>lstCmpMdlRsp = [item for sublist in lstCmpMdlRsp[<NUM_LIT:1>:] for item in<EOL>sublist]<EOL>for strMap in lstCmpMdlRsp[:]:<EOL><INDENT>os.remove(strMap)<EOL><DEDENT><DEDENT><DEDENT>
Compare results for different exponents and create winner nii.

    Parameters
    ----------
    lstRat : list
        List of floats containing the ratios that were tested for surround
        suppression.
    lstNiiNames : list
        List of names of the different pRF maps (e.g. xpos, ypos, SD)
    strPathOut : string
        Path to the parent directory where the results should be saved.
    strPathMdl : string
        Path to the parent directory where pRF models should be saved.
    lgcDel : boolean
        Should model time courses be saved as npy file?
    lgcDel : boolean
        Should inbetween results (in form of nii files) be deleted?
    strNmeExt : string
        Extra name appendix to denominate experiment name. If undesidered,
        provide empty string.

    Notes
    -----
    [1] This function does not return any arrays but instead saves to disk.