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

Function read_source_morph

mne/morph.py:852–887  ·  view source on GitHub ↗

Load the morph for source estimates from a file. Parameters ---------- fname : path-like Path to the file containing the morph source estimates. Returns ------- source_morph : instance of SourceMorph The loaded morph.

(fname)

Source from the content-addressed store, hash-verified

850
851
852def read_source_morph(fname):
853 """Load the morph for source estimates from a file.
854
855 Parameters
856 ----------
857 fname : path-like
858 Path to the file containing the morph source estimates.
859
860 Returns
861 -------
862 source_morph : instance of SourceMorph
863 The loaded morph.
864 """
865 read_hdf5, _ = _import_h5io_funcs()
866 vals = read_hdf5(fname)
867 if vals["pre_affine"] is not None: # reconstruct
868 from dipy.align.imaffine import AffineMap
869
870 affine = vals["pre_affine"]
871 vals["pre_affine"] = AffineMap(None)
872 vals["pre_affine"].__dict__ = affine
873 if vals["sdr_morph"] is not None:
874 from dipy.align.imwarp import DiffeomorphicMap
875
876 morph = vals["sdr_morph"]
877 vals["sdr_morph"] = DiffeomorphicMap(None, [])
878 vals["sdr_morph"].__dict__ = morph
879 # Backward compat with when it used to be a list
880 if isinstance(vals["vertices_to"], np.ndarray):
881 vals["vertices_to"] = [vals["vertices_to"]]
882 # Backward compat with when it used to be a single array
883 if isinstance(vals["src_data"].get("inuse", None), np.ndarray):
884 vals["src_data"]["inuse"] = [vals["src_data"]["inuse"]]
885 # added with compute_vol_morph_mat in 0.22:
886 vals["vol_morph_mat"] = vals.get("vol_morph_mat", None)
887 return SourceMorph(**vals)
888
889
890###############################################################################

Calls 2

_import_h5io_funcsFunction · 0.85
SourceMorphClass · 0.85