예제 #1
0
def getSVDdata(ops):
    mov, max_proj = sparsedetect.get_mov(ops)
    ops['max_proj'] = max_proj
    nbins, Lyc, Lxc = np.shape(mov)

    sig = ops['diameter']/10. # PICK UP
    for j in range(nbins):
        mov[j,:,:] = gaussian_filter(mov[j,:,:], sig)

    # compute noise variance across frames
    sdmov = sparsedetect.get_sdmov(mov, ops)
    mov /= sdmov
    mov = np.reshape(mov, (-1,Lyc*Lxc))
    if 1:
        # compute covariance of binned frames
        cov = mov @ mov.transpose() / mov.shape[1]
        cov = cov.astype('float32')

        nsvd_for_roi = min(ops['nbinned'], int(cov.shape[0]/2))
        u, s, v = np.linalg.svd(cov)

        u = u[:, :nsvd_for_roi]
        U = u.transpose() @ mov
    else:
        U = mov
        u = []
    U = np.reshape(U, (-1,Lyc,Lxc))
    U = np.transpose(U, (1, 2, 0)).copy()
    return ops, U, sdmov, u
예제 #2
0
def getSVDproj(ops, u):
    mov, _ = sparsedetect.get_mov(ops)

    nbins, Lyc, Lxc = np.shape(mov)
    if ('smooth_masks' in ops) and ops['smooth_masks']:
        sig = np.maximum([.5, .5], ops['diameter']/20.)
        for j in range(nbins):
            mov[j,:,:] = ndimage.gaussian_filter(mov[j,:,:], sig)
    if 1:
        #sdmov = np.ones((Lyc*Lxc,), 'float32')
        sdmov = sparsedetect.get_sdmov(mov, ops)
        mov/=sdmov
        mov = np.reshape(mov, (-1,Lyc*Lxc))

        U = u.transpose() @ mov
        U = U.transpose().copy().reshape((Lyc,Lxc,-1))
    else:
        U = np.transpose(mov, (1, 2, 0)).copy()
    return U, sdmov