MCPcopy
hub / github.com/mne-tools/mne-python / apply_trans

Function apply_trans

mne/transforms.py:257–286  ·  view source on GitHub ↗

Apply a transform matrix to an array of points. Parameters ---------- trans : array, shape = (4, 4) | instance of Transform Transform matrix. pts : array, shape = (3,) | (n, 3) Array with coordinates for one or n points. move : bool If True (default), app

(trans, pts, move=True)

Source from the content-addressed store, hash-verified

255
256
257def apply_trans(trans, pts, move=True):
258 """Apply a transform matrix to an array of points.
259
260 Parameters
261 ----------
262 trans : array, shape = (4, 4) | instance of Transform
263 Transform matrix.
264 pts : array, shape = (3,) | (n, 3)
265 Array with coordinates for one or n points.
266 move : bool
267 If True (default), apply translation.
268
269 Returns
270 -------
271 transformed_pts : shape = (3,) | (n, 3)
272 Transformed point(s).
273 """
274 if isinstance(trans, dict):
275 trans = trans["trans"]
276 pts = np.asarray(pts)
277 if pts.size == 0:
278 return pts.copy()
279
280 # apply rotation & scale
281 out_pts = np.dot(pts, trans[:3, :3].T)
282 # apply translation
283 if move:
284 out_pts += trans[:3, 3]
285
286 return out_pts
287
288
289def rotation(x=0, y=0, z=0):

Callers 15

test_make_montage_volumeFunction · 0.90
test_read_ctfFunction · 0.90
test_hsp_elpFunction · 0.90
test_nirsport_v2Function · 0.90
test_nirx_15_2_shortFunction · 0.90
test_nirx_15_3_shortFunction · 0.90
test_nirx_15_2Function · 0.90
test_nirx_15_0Function · 0.90
test_montage_head_frameFunction · 0.90

Calls 1

copyMethod · 0.45

Tested by 15

test_make_montage_volumeFunction · 0.72
test_read_ctfFunction · 0.72
test_hsp_elpFunction · 0.72
test_nirsport_v2Function · 0.72
test_nirx_15_2_shortFunction · 0.72
test_nirx_15_3_shortFunction · 0.72
test_nirx_15_2Function · 0.72
test_nirx_15_0Function · 0.72
test_montage_head_frameFunction · 0.72