MCPcopy Index your code
hub / github.com/mne-tools/mne-python / _grid_interp

Function _grid_interp

mne/source_space/_source_space.py:2418–2435  ·  view source on GitHub ↗

Compute a grid-to-grid linear or nearest interpolation given.

(from_shape, to_shape, trans, order=1, inuse=None)

Source from the content-addressed store, hash-verified

2416
2417
2418def _grid_interp(from_shape, to_shape, trans, order=1, inuse=None):
2419 """Compute a grid-to-grid linear or nearest interpolation given."""
2420 from_shape = np.array(from_shape, int)
2421 to_shape = np.array(to_shape, int)
2422 trans = np.array(trans, np.float64) # to -> from
2423 assert trans.shape == (4, 4) and np.array_equal(trans[3], [0, 0, 0, 1])
2424 assert from_shape.shape == to_shape.shape == (3,)
2425 shape = (np.prod(to_shape), np.prod(from_shape))
2426 if inuse is None:
2427 inuse = np.ones(shape[1], bool)
2428 assert inuse.dtype == np.dtype(bool)
2429 assert inuse.shape == (shape[1],)
2430 data, indices, indptr = _grid_interp_jit(from_shape, to_shape, trans, order, inuse)
2431 data = np.concatenate(data)
2432 indices = np.concatenate(indices)
2433 indptr = np.cumsum(indptr)
2434 interp = csr_array((data, indices, indptr), shape=shape)
2435 return interp
2436
2437
2438# This is all set up to do jit, but it's actually slower!

Callers 3

test_resample_equivFunction · 0.90
_morph_volsMethod · 0.85
_add_interpolatorFunction · 0.85

Calls 1

_grid_interp_jitFunction · 0.85

Tested by 1

test_resample_equivFunction · 0.72