|
22 | 22 | from ..viz import plot_montage |
23 | 23 | from .channels import _contains_ch_type |
24 | 24 | from ..transforms import (apply_trans, get_ras_to_neuromag_trans, _sph_to_cart, |
25 | | - _topo_to_sph, _str_to_frame, _frame_to_str) |
| 25 | + _topo_to_sph, _frame_to_str) |
26 | 26 | from .._digitization import Digitization |
27 | 27 | from .._digitization._utils import (_make_dig_points, _read_dig_points, |
28 | 28 | write_dig, _read_dig_fif) |
|
34 | 34 | _check_fname) |
35 | 35 |
|
36 | 36 | from .layout import _pol_to_cart, _cart_to_sph |
37 | | -from ._dig_montage_utils import _transform_to_head_call, _read_dig_montage_fif |
| 37 | +from ._dig_montage_utils import _transform_to_head_call |
38 | 38 | from ._dig_montage_utils import _read_dig_montage_egi, _read_dig_montage_bvct |
39 | 39 | from ._dig_montage_utils import _foo_get_data_from_dig |
40 | 40 | from ._dig_montage_utils import _fix_data_fiducials |
@@ -764,13 +764,6 @@ def nasion(self): |
764 | 764 | return _foo_get_data_from_dig(self.dig).nasion |
765 | 765 |
|
766 | 766 |
|
767 | | -def _check_frame(d, frame_str): |
768 | | - """Check coordinate frames.""" |
769 | | - if d['coord_frame'] != _str_to_frame[frame_str]: |
770 | | - raise RuntimeError('dig point must be in %s coordinate frame, got %s' |
771 | | - % (frame_str, _frame_to_str[d['coord_frame']])) |
772 | | - |
773 | | - |
774 | 767 | def _get_scaling(unit, scale): |
775 | 768 | if unit not in scale: |
776 | 769 | raise ValueError("Unit needs to be one of %s, not %r" % |
@@ -821,6 +814,41 @@ def transform_to_head(montage): |
821 | 814 | return montage |
822 | 815 |
|
823 | 816 |
|
| 817 | +def _read_dig_montage_deprecation_warning_helper(**kwargs): |
| 818 | + if kwargs.pop('fif') is not None: |
| 819 | + warn('Using "read_dig_montage" with "fif" not None' |
| 820 | + ' is deprecated and will be removed in v0.20' |
| 821 | + ' Please use read_dig_fif instead.', DeprecationWarning) |
| 822 | + return |
| 823 | + if kwargs.pop('egi') is not None: |
| 824 | + warn('Using "read_dig_montage" with "egi" not None' |
| 825 | + ' is deprecated and will be removed in v0.20' |
| 826 | + ' Please use read_dig_egi instead.', DeprecationWarning) |
| 827 | + return |
| 828 | + if kwargs.pop('bvct') is not None: |
| 829 | + warn('Using "read_dig_montage" with "bvct" not None' |
| 830 | + ' is deprecated and will be removed in v0.20.' |
| 831 | + ' Please use read_dig_captrack instead.', DeprecationWarning) |
| 832 | + return |
| 833 | + |
| 834 | + # XXX: for now we only have implemented the case where hsp, hpi and elp |
| 835 | + # are np.arrays. we need read_dig_polhemus for the str cases. Plus, |
| 836 | + # we need to make sure that we can handle a mix of arrays and str. The |
| 837 | + # mixed case is not in our code-base but there was nothing preventing |
| 838 | + # a user to do so. |
| 839 | + # |
| 840 | + # we can assume that whatever is not None or np.array is path-like |
| 841 | + # therefore str. |
| 842 | + if [kk for kk in ('hsp', 'hpi', 'elp') if isinstance(kwargs[kk], |
| 843 | + np.ndarray)]: |
| 844 | + warn('Passing "np.arrays" to "hsp", "hpi" or "elp" in' |
| 845 | + ' "read_dig_montage" is deprecated and will be removed in v0.20.' |
| 846 | + ' Please use "make_dig_montage" instead.', DeprecationWarning) |
| 847 | + return |
| 848 | + |
| 849 | + pass # noqa # XXX: will grow with issue-6461 |
| 850 | + |
| 851 | + |
824 | 852 | def read_dig_montage(hsp=None, hpi=None, elp=None, |
825 | 853 | point_names=None, unit='auto', fif=None, egi=None, |
826 | 854 | bvct=None, transform=True, dev_head_t=False, ): |
@@ -911,15 +939,25 @@ def read_dig_montage(hsp=None, hpi=None, elp=None, |
911 | 939 | EGI_SCALE = dict(mm=1e-3, cm=1e-2, auto=1e-2, m=1) |
912 | 940 | NUMPY_DATA_SCALE = dict(mm=1e-3, cm=1e-2, auto=1e-3, m=1) |
913 | 941 |
|
| 942 | + _read_dig_montage_deprecation_warning_helper( |
| 943 | + hsp=hsp, hpi=hpi, elp=elp, fif=fif, egi=egi, bvct=bvct, |
| 944 | + ) |
| 945 | + |
914 | 946 | if fif is not None: |
915 | 947 | _raise_transform_err = True if dev_head_t or not transform else False |
916 | | - data = _read_dig_montage_fif( |
917 | | - fname=fif, |
918 | | - _raise_transform_err=_raise_transform_err, |
919 | | - _all_data_kwargs_are_none=all( |
920 | | - x is None for x in (hsp, hpi, elp, point_names, egi, bvct)) |
| 948 | + _all_data_kwargs_are_none = all( |
| 949 | + x is None for x in (hsp, hpi, elp, point_names, egi, bvct) |
921 | 950 | ) |
922 | 951 |
|
| 952 | + if _raise_transform_err: |
| 953 | + raise ValueError('transform must be True and dev_head_t must be' |
| 954 | + ' False for FIF dig montage') |
| 955 | + if not _all_data_kwargs_are_none: |
| 956 | + raise ValueError('hsp, hpi, elp, point_names, egi must all be' |
| 957 | + ' None if fif is not None') |
| 958 | + |
| 959 | + return read_dig_fif(fname=fif) |
| 960 | + |
923 | 961 | elif egi is not None: |
924 | 962 | data = _read_dig_montage_egi( |
925 | 963 | fname=egi, |
|
0 commit comments