Пример #1
0
 def fast_odf(self,s):
     odf = np.zeros(self.odfn)
     Eq=np.zeros((self.sz,self.sz,self.sz))
     #for i in range(self.dn):
     #    Eq[self.q[i][0],self.q[i][1],self.q[i][2]]+=s[i]/s[0]
     Eq[self.q[:,0],self.q[:,1],self.q[:,2]]=s[:]/np.float(s[0])
     #self.Eqs.append(Eq)
     if  self.operator=='laplacian':
         LEq=laplace(Eq)
         sign=-1
     if self.operator=='laplap':
         LEq=laplace(laplace(Eq))
         sign=1
     if  self.operator=='signal':
         LEq=Eq
         sign=1
     #LEs=map_coordinates(LEq,self.Ys.T,order=1)
     #"""
     LEs=np.zeros(self.Ysn)
     strides=np.array(LEq.strides,'i8')
     map_coordinates_trilinear_iso(LEq,self.Ys,
                                   strides,self.Ysn, LEs)
     #LEs=map_coordinates(LEq,self.zoom*self.Ys,order=1)
     LEs=LEs.reshape(self.odfn,self.radiusn)
     LEs=LEs*self.radius
     #LEs=LEs*self.radius*self.zoom
     LEsum=np.sum(LEs,axis=1)
     #This is what the following code is doing
     #for i in xrange(self.odfn):
     #    odf[i]=np.sum(LEsum[self.eqinds[i]])/self.eqinds_len[i]
     #odf2=odf.copy()
     LES=LEsum[self.eqinds_com]
     sum_on_blocks_1d(LES,self.eqinds_len,odf,self.odfn)
     odf=odf/self.eqinds_len
     return self.angular_weighting(sign*odf)
Пример #2
0
 def fast_odf(self, s):
     odf = np.zeros(self.odfn)
     Eq = np.zeros((self.sz, self.sz, self.sz))
     #for i in range(self.dn):
     #    Eq[self.q[i][0],self.q[i][1],self.q[i][2]]+=s[i]/s[0]
     Eq[self.q[:, 0], self.q[:, 1], self.q[:, 2]] = s[:] / np.float(s[0])
     #self.Eqs.append(Eq)
     if self.operator == 'laplacian':
         LEq = laplace(Eq)
         sign = -1
     if self.operator == 'laplap':
         LEq = laplace(laplace(Eq))
         sign = 1
     if self.operator == 'signal':
         LEq = Eq
         sign = 1
     #LEs=map_coordinates(LEq,self.Ys.T,order=1)
     #"""
     LEs = np.zeros(self.Ysn)
     strides = np.array(LEq.strides, 'i8')
     map_coordinates_trilinear_iso(LEq, self.Ys, strides, self.Ysn, LEs)
     #LEs=map_coordinates(LEq,self.zoom*self.Ys,order=1)
     LEs = LEs.reshape(self.odfn, self.radiusn)
     LEs = LEs * self.radius
     #LEs=LEs*self.radius*self.zoom
     LEsum = np.sum(LEs, axis=1)
     #This is what the following code is doing
     #for i in xrange(self.odfn):
     #    odf[i]=np.sum(LEsum[self.eqinds[i]])/self.eqinds_len[i]
     #odf2=odf.copy()
     LES = LEsum[self.eqinds_com]
     sum_on_blocks_1d(LES, self.eqinds_len, odf, self.odfn)
     odf = odf / self.eqinds_len
     return self.angular_weighting(sign * odf)
Пример #3
0
def test_trilinear_interp_cubic_voxels():
    A=np.ones((17,17,17))
    B=np.zeros(3)
    strides=np.array(A.strides, np.intp)
    A[7,7,7]=2
    points=np.array([[0,0,0],[7.,7.5,7.],[3.5,3.5,3.5]])
    map_coordinates_trilinear_iso(A,points,strides,3,B)
    assert_array_almost_equal(B,np.array([ 1. ,  1.5,  1. ]))
Пример #4
0
def test_trilinear_interp_cubic_voxels():
    A=np.ones((17,17,17))
    B=np.zeros(3)
    strides=np.array(A.strides, np.intp)
    A[7,7,7]=2
    points=np.array([[0,0,0],[7.,7.5,7.],[3.5,3.5,3.5]])
    map_coordinates_trilinear_iso(A,points,strides,3,B)
    assert_array_almost_equal(B,np.array([ 1. ,  1.5,  1. ]))
Пример #5
0
def test_trilinear_interp_cubic_voxels():
    A = np.ones((17, 17, 17))
    B = np.zeros(3)
    strides = np.array(A.strides, np.intp)
    A[7, 7, 7] = 2
    points = np.array([[0, 0, 0], [7., 7.5, 7.], [3.5, 3.5, 3.5]])
    map_coordinates_trilinear_iso(A, points, strides, 3, B)
    assert_array_almost_equal(B, np.array([1., 1.5, 1.]))
    # All of the input array, points array, strides array and output array must
    # be C-contiguous.  Check by passing in versions that aren't C contiguous
    assert_raises(ValueError, map_coordinates_trilinear_iso, A.copy(order='F'),
                  points, strides, 3, B)
    assert_raises(ValueError, map_coordinates_trilinear_iso, A,
                  points.copy(order='F'), strides, 3, B)
    assert_raises(ValueError, map_coordinates_trilinear_iso, A, points,
                  stepped_1d(strides), 3, B)
    assert_raises(ValueError, map_coordinates_trilinear_iso, A, points,
                  strides, 3, stepped_1d(B))
Пример #6
0
def test_trilinear_interp_cubic_voxels():
    A = np.ones((17, 17, 17))
    B = np.zeros(3)
    strides = np.array(A.strides, np.intp)
    A[7, 7, 7] = 2
    points = np.array([[0, 0, 0], [7., 7.5, 7.], [3.5, 3.5, 3.5]])
    map_coordinates_trilinear_iso(A, points, strides, 3, B)
    assert_array_almost_equal(B, np.array([1., 1.5, 1.]))
    # All of the input array, points array, strides array and output array must
    # be C-contiguous.  Check by passing in versions that aren't C contiguous
    assert_raises(ValueError, map_coordinates_trilinear_iso,
                  A.copy(order='F'), points, strides, 3, B)
    assert_raises(ValueError, map_coordinates_trilinear_iso,
                  A, points.copy(order='F'), strides, 3, B)
    assert_raises(ValueError, map_coordinates_trilinear_iso,
                  A, points, stepped_1d(strides), 3, B)
    assert_raises(ValueError, map_coordinates_trilinear_iso,
                  A, points, strides, 3, stepped_1d(B))