def load_res_prm(lstFunc, lstFlsMsk=None):
<EOL>lstPrm = []<EOL>for ind, path in enumerate(lstFunc):<EOL><INDENT>aryFnc = load_nii(path)[<NUM_LIT:0>].astype(np.float32)<EOL>if aryFnc.ndim == <NUM_LIT:3>:<EOL><INDENT>lstPrm.append(aryFnc)<EOL><DEDENT>elif aryFnc.ndim == <NUM_LIT:4>:<EOL><INDENT>for indAx in range(aryFnc.shape[-<NUM_LIT:1>]):<EOL><INDENT>lstPrm.append(aryFnc[..., indAx])<EOL><DEDENT><DEDENT><DEDENT>if lstFlsMsk is not None:<EOL><INDENT>lstMsk = [None] * len(lstFlsMsk)<EOL>for ind, path in enumerate(lstFlsMsk):<EOL><INDENT>aryMsk = load_nii(path)[<NUM_LIT:0>].astype(np.bool)<EOL>lstMsk[ind] = aryMsk<EOL><DEDENT><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT>if lstFlsMsk is None:<EOL><INDENT>lstPrmAry = [ary.flatten() for ary in lstPrm]<EOL><DEDENT>else:<EOL><INDENT>lstPrmAry = [None] * len(lstFlsMsk)<EOL>for indLst, aryMsk in enumerate(lstMsk):<EOL><INDENT>aryPrmSel = np.empty((np.sum(aryMsk), len(lstPrm)),<EOL>dtype=np.float32)<EOL>for indAry, aryPrm in enumerate(lstPrm):<EOL><INDENT>aryPrmSel[:, indAry] = aryPrm[aryMsk, ...]<EOL><DEDENT>lstPrmAry[indLst] = aryPrmSel<EOL><DEDENT><DEDENT>objHdr, aryAff = load_nii(lstFunc[<NUM_LIT:0>])[<NUM_LIT:1>:]<EOL>return lstPrmAry, objHdr, aryAff<EOL>
Load result parameters from multiple nii files, with optional mask.

    Parameters
    ----------
    lstFunc : list,
        list of str with file names of 3D or 4D nii files
    lstFlsMsk : list, optional
        list of str with paths to 3D nii files that can act as mask/s
    Returns
    -------
    lstPrmAry : list
        The list will contain as many numpy arrays as masks were provided.
        Each array is 2D with shape [nr voxel in mask, nr nii files in lstFunc]
    objHdr : header object
        Header of nii file.
    aryAff : np.array
        Array containing 'affine', i.e. information about spatial positioning
        of nii data.