|
17 | 17 | from ..label import Label |
18 | 18 | from ..source_estimate import _get_src_type, _make_stc, _prepare_label_extraction |
19 | 19 | from ..source_space._source_space import SourceSpaces, _get_vertno |
20 | | -from ..utils import _validate_type, logger, verbose |
| 20 | +from ..utils import _check_option, _validate_type, logger, verbose |
21 | 21 | from .inverse import apply_inverse |
22 | 22 |
|
23 | 23 |
|
@@ -159,12 +159,9 @@ def _get_psf_ctf( |
159 | 159 | _mode_map = { |
160 | 160 | "max": "maxnorm", |
161 | 161 | "svd": "pca", |
162 | | - "mean": "mean", |
163 | | - "sum": "sum", |
164 | | - "maxval": "maxval", |
165 | 162 | } |
166 | 163 | funcs, pca_var = _summarise_psf_ctf( |
167 | | - funcs, _mode_map[mode], n_comp, return_pca_vars, nn |
| 164 | + funcs, _mode_map.get(mode, mode), n_comp, return_pca_vars, nn |
168 | 165 | ) |
169 | 166 |
|
170 | 167 | if not vector: # if one value per vertex requested |
@@ -201,15 +198,15 @@ def _get_psf_ctf( |
201 | 198 |
|
202 | 199 | def _check_get_psf_ctf_params(mode, n_comp, return_pca_vars): |
203 | 200 | """Check input parameters of _get_psf_ctf() for consistency.""" |
204 | | - valid_modes = (None, "mean", "max", "svd", "sum", "maxval") |
205 | | - if mode not in valid_modes: |
206 | | - raise ValueError(f"mode must be one of {valid_modes}, got {mode!r} instead.") |
| 201 | + _validate_type(mode, (str, None), "mode") |
| 202 | + # provide backward compatibility for old mode names |
| 203 | + mode = {"pca": "svd", "maxnorm": "max"}.get(mode, mode) |
| 204 | + _check_option("mode", mode, (None, "mean", "max", "svd", "sum", "maxval")) |
207 | 205 | if mode in [None, "mean", "sum"] and n_comp > 1: |
208 | 206 | msg = f"n_comp must be 1 for mode={mode}." |
209 | 207 | raise ValueError(msg) |
210 | 208 | if mode != "svd" and return_pca_vars: |
211 | | - msg = "SVD variances can only be returned if mode='svd'." |
212 | | - raise ValueError(msg) |
| 209 | + raise ValueError("SVD variances can only be returned if mode='svd'.") |
213 | 210 |
|
214 | 211 |
|
215 | 212 | def _vertices_for_get_psf_ctf(idx, src): |
|
0 commit comments