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

Function combine_transforms

mne/transforms.py:519–568  ·  view source on GitHub ↗

Combine two transforms. Parameters ---------- t_first : dict First transform. t_second : dict Second transform. fro : int From coordinate frame. to : int To coordinate frame. Returns ------- trans : dict Combined transform

(t_first, t_second, fro, to)

Source from the content-addressed store, hash-verified

517
518
519def combine_transforms(t_first, t_second, fro, to):
520 """Combine two transforms.
521
522 Parameters
523 ----------
524 t_first : dict
525 First transform.
526 t_second : dict
527 Second transform.
528 fro : int
529 From coordinate frame.
530 to : int
531 To coordinate frame.
532
533 Returns
534 -------
535 trans : dict
536 Combined transformation.
537 """
538 fro = _to_const(fro)
539 to = _to_const(to)
540 if t_first["from"] != fro:
541 raise RuntimeError(
542 'From mismatch: {fro1} ("{cf1}") != {fro2} ("{cf2}")'.format(
543 fro1=t_first["from"],
544 cf1=_coord_frame_name(t_first["from"]),
545 fro2=fro,
546 cf2=_coord_frame_name(fro),
547 )
548 )
549 if t_first["to"] != t_second["from"]:
550 raise RuntimeError(
551 'Transform mismatch: t1["to"] = {to1} ("{cf1}"), '
552 't2["from"] = {fro2} ("{cf2}")'.format(
553 to1=t_first["to"],
554 cf1=_coord_frame_name(t_first["to"]),
555 fro2=t_second["from"],
556 cf2=_coord_frame_name(t_second["from"]),
557 )
558 )
559 if t_second["to"] != to:
560 raise RuntimeError(
561 'To mismatch: {to1} ("{cf1}") != {to2} ("{cf2}")'.format(
562 to1=t_second["to"],
563 cf1=_coord_frame_name(t_second["to"]),
564 to2=to,
565 cf2=_coord_frame_name(to),
566 )
567 )
568 return Transform(fro, to, np.dot(t_second["trans"], t_first["trans"]))
569
570
571@verbose

Callers 15

test_transformsFunction · 0.90
test_combineFunction · 0.90
_scale_xfmFunction · 0.85
head_to_mriFunction · 0.85
head_to_mniFunction · 0.85
read_talxfmFunction · 0.85
_read_mri_infoFunction · 0.85
export_volumeMethod · 0.85
_add_interpolatorFunction · 0.85
_make_bti_dig_pointsFunction · 0.85
_make_trans_digFunction · 0.85

Calls 3

_to_constFunction · 0.85
_coord_frame_nameFunction · 0.85
TransformClass · 0.85

Tested by 2

test_transformsFunction · 0.72
test_combineFunction · 0.72