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

Function read_trans

mne/transforms.py:572–608  ·  view source on GitHub ↗

Read a ``-trans.fif`` file. Parameters ---------- fname : path-like The name of the file. return_all : bool If True, return all transformations in the file. False (default) will only return the first. .. versionadded:: 0.15 %(verbose)s Retur

(fname, return_all=False, verbose=None)

Source from the content-addressed store, hash-verified

570
571@verbose
572def read_trans(fname, return_all=False, verbose=None):
573 """Read a ``-trans.fif`` file.
574
575 Parameters
576 ----------
577 fname : path-like
578 The name of the file.
579 return_all : bool
580 If True, return all transformations in the file.
581 False (default) will only return the first.
582
583 .. versionadded:: 0.15
584 %(verbose)s
585
586 Returns
587 -------
588 trans : dict | list of dict
589 The transformation dictionary from the fif file.
590
591 See Also
592 --------
593 write_trans
594 mne.transforms.Transform
595 """
596 fname = _check_fname(fname, overwrite="read", must_exist=True)
597 fid, tree, directory = fiff_open(fname)
598
599 trans = list()
600 with fid:
601 for t in directory:
602 if t.kind == FIFF.FIFF_COORD_TRANS:
603 trans.append(read_tag(fid, t.pos).data)
604 if not return_all:
605 break
606 if len(trans) == 0:
607 raise OSError("This does not seem to be a -trans.fif file.")
608 return trans if return_all else trans[0]
609
610
611@verbose

Callers 15

test_coregistrationFunction · 0.90
test_stc_near_sensorsFunction · 0.90
test_get_transFunction · 0.90
test_io_transFunction · 0.90
test_combineFunction · 0.90
test_volume_registrationFunction · 0.90
raw_dataFunction · 0.90
test_plot_alignment_megFunction · 0.90
test_plot_alignment_surfFunction · 0.90

Calls 4

_check_fnameFunction · 0.85
fiff_openFunction · 0.85
read_tagFunction · 0.85
appendMethod · 0.45

Tested by 14

test_coregistrationFunction · 0.72
test_stc_near_sensorsFunction · 0.72
test_get_transFunction · 0.72
test_io_transFunction · 0.72
test_combineFunction · 0.72
test_volume_registrationFunction · 0.72
raw_dataFunction · 0.72
test_plot_alignment_megFunction · 0.72
test_plot_alignment_surfFunction · 0.72