def resample(self):
     print('Gridding...')
     dims = self.dims
     XYZ = np.mgrid[0:dims[0], 0:dims[1], 0:dims[2]]
     XYZ = np.rollaxis(XYZ, 0, 4)
     XYZ = np.reshape(XYZ, [np.prod(XYZ.shape[0:-1]), 3])
     res = np.zeros(dims)
     for t in range(self.nscans):
         print('Fully resampling scan %d/%d' % (t+1, self.nscans))
         X, Y, Z = grid_coords(XYZ, self.transforms[t], 
                               self.from_world, self.to_world)
         T = self.from_time(Z, self.timestamps[t])
         cspline_sample4d(res[:,:,:,t], self.cbspline, X, Y, Z, T)
     return res
 def resample_inmask(self, t):
     X, Y, Z = grid_coords(self.xyz, self.transforms[t], 
                           self.from_world, self.to_world)
     T = self.from_time(Z, self.timestamps[t])
     cspline_sample4d(self.data[:,t], self.cbspline, X, Y, Z, T)