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)
| 854 | |
| 855 | |
| 856 | def _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 |
no test coverage detected