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

Function _scale_params

mne/coreg.py:856–890  ·  view source on GitHub ↗

Assemble parameters for scaling. Returns ------- subjects_dir : path-like Subjects directory. subject_from : str Name of the source subject. scale : array Scaling factor, either shape=() for uniform scaling or shape=(3,) for non-uniform scaling.

(subject_to, subject_from, scale, subjects_dir)

Source from the content-addressed store, hash-verified

854
855
856def _scale_params(subject_to, subject_from, scale, subjects_dir):
857 """Assemble parameters for scaling.
858
859 Returns
860 -------
861 subjects_dir : path-like
862 Subjects directory.
863 subject_from : str
864 Name of the source subject.
865 scale : array
866 Scaling factor, either shape=() for uniform scaling or shape=(3,) for
867 non-uniform scaling.
868 uniform : bool
869 Whether scaling is uniform.
870 """
871 subjects_dir = get_subjects_dir(subjects_dir, raise_error=True)
872 if (subject_from is None) != (scale is None):
873 raise TypeError(
874 "Need to provide either both subject_from and scale parameters, or neither."
875 )
876
877 if subject_from is None:
878 cfg = read_mri_cfg(subject_to, subjects_dir)
879 subject_from = cfg["subject_from"]
880 n_params = cfg["n_params"]
881 assert n_params in (1, 3)
882 scale = cfg["scale"]
883 scale = np.atleast_1d(scale)
884 if scale.ndim != 1 or scale.shape[0] not in (1, 3):
885 raise ValueError(
886 "Invalid shape for scale parameter. Need scalar or array of length 3. Got "
887 f"shape {scale.shape}."
888 )
889 n_params = len(scale)
890 return str(subjects_dir), subject_from, scale, n_params == 1
891
892
893@verbose

Callers 5

scale_bemFunction · 0.85
scale_labelsFunction · 0.85
scale_source_spaceFunction · 0.85
_scale_mriFunction · 0.85
_scale_xfmFunction · 0.85

Calls 2

get_subjects_dirFunction · 0.85
read_mri_cfgFunction · 0.85

Tested by

no test coverage detected