예제 #1
0
def array_count_critical(rawdata,upsample=3,cut=True,cutoff=0.4):
    '''
    Count critical points in the phase gradient map
    '''
    # can only handle dim 3 for now
    assert len(shape(rawdata))==3
    if cut:
        data = dct_upsample(dct_cut_antialias(rawdata,cutoff,ELECTRODE_SPACING),factor=upsample)
    else:
        data = dct_upsample(data,factor=upsample)
    dz = array_phase_gradient(data).transpose((2,0,1))
    # extract curl via a kernal
    # take real component, centres have curl +- pi
    curl = np.complex64([[-1-1j,-1+1j],[1-1j,1+1j]])
    curl = np.convolve2d(curl,np.ones((2,2))/4,'full')
    winding = arr([np.convolve2d(z,curl,'same','symm').real for z in dz])

    # extract inflection points ( extrema, saddles )
    # by looking for sign changes in derivatives
    # avoid points that are close to singular
    ok        = ~(np.abs(winding)<1e-1)[...,:-1,:-1]
    ddx       = np.diff(np.sign(dz.real),1,1)[...,:,:-1]/2
    ddy       = np.diff(np.sign(dz.imag),1,2)[...,:-1,:]/2
    saddles   = (ddx*ddy==-1)*ok
    maxima    = (ddx*ddy== 1)*(ddx==-1)*ok
    minima    = (ddx*ddy== 1)*(ddx== 1)*ok
    sum2 = lambda x: np.sum(np.int32(x),axis=(1,2))
    nclockwise = sum2(winding>3)
    nwidersyns = sum2(winding<-3)
    nsaddles   = sum2(saddles  )
    nmaxima    = sum2(maxima   )
    nminima    = sum2(minima   )
    return nclockwise, nwidersyns, nsaddles, nmaxima, nminima
예제 #2
0
def array_count_centers(rawdata,upsample=3,cut=True,cutoff=0.4):
    '''
    Counting centers -- looks for channels around which phase skips +-pi
    will miss rotating centers closer than half the electrode spacing
    '''
    # can only handle dim 3 for now
    assert len(rawdata.shape)==3
    if cut:
        data = dct_upsample(dct_cut_antialias(
            rawdata,cutoff,ELECTRODE_SPACING),factor=upsample)
    else:
        data = dct_upsample(data,factor=upsample)
    dz = array_phase_gradient(data)
    curl = np.complex64([[-1-1j,-1+1j],[1-1j,1+1j]])
    curl = np.convolve2d(curl,np.ones((2,2))/4,'full')
    winding = arr([real(np.convolve2d(z,curl,'valid','symm')) for z in dz.transpose((2,0,1))])
    nclockwise = np.sum(np.int32(winding> 3),axis=(1,2))
    nwidersyns = np.sum(np.int32(winding<-3),axis=(1,2))
    return nclockwise, nwidersyns