예제 #1
0
def _compute_surrogate_density_dev(BFLs,xyz,dmax,nsamples=1):
    """
    caveat: does not work for nsamples>1
    This function computes a surrogate density 
    using graph diffusion techniques
    """
    import nipy.neurospin.utils.smoothing.smoothing as smoothing
    nvox = xyz.shape[0]
    nbsubj = np.size(BFLs)
    nlm = np.array([BFLs[s].k for s in range(nbsubj)])
    aux = np.zeros((nvox, nsamples*nbsubj))
    for s in range(nbsubj):
        if nlm[s]>0:
            for it in range(nsamples):
                js = (nvox*nr.rand(nlm[s])).astype(np.int)
                aux[js,s*nsamples+it] = 1.

    aux = smoothing.cartesian_smoothing(xyz.T,aux,dmax)
    
    surweight = np.zeros((nvox*nsamples,nbsubj),'d')
    for s in range(nbsubj):
        surweight[:,s] = np.reshape(aux[:,s*nsamples:(s+1)*nsamples],
                                        (nvox*nsamples))

    surweight = surweight*(2*np.pi*dmax*dmax)**1.5
    return surweight    
예제 #2
0
def _compute_density_dev(BFLs,xyz,dmax):
    """
    Computation of the density of the BFLs points in the xyz volume
    dmax is a scale parameter
    """
    import nipy.neurospin.utils.smoothing.smoothing as smoothing
    nvox = xyz.shape[0]
    nbsubj = np.size(BFLs)
    weight = np.zeros((nvox,nbsubj),'d')
    nlm = np.array([BFLs[s].k for s in range(nbsubj)])
    for s in range(nbsubj):
        if nlm[s]>0:
            weight[BFLs[s].seed,s] = 1
    weight = smoothing.cartesian_smoothing(np.transpose(xyz),weight,dmax)
    weight = weight*(2*np.pi*dmax*dmax)**1.5
    return weight