Skip to content

Commit

Permalink
[release]MNT: bump 0.20 + remove dead code (mne-tools#6821)
Browse files Browse the repository at this point in the history
* Bump 0.20

* FIX: stim_channel in CNT

* fix

* FIX: remove _deprecate_stim_channel

* fix docstring
  • Loading branch information
massich authored and larsoner committed Sep 24, 2019
1 parent 5a623c7 commit 5e16625
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 72 deletions.
2 changes: 1 addition & 1 deletion mne/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Dev branch marker is: 'X.Y.devN' where N is an integer.
#

__version__ = '0.19.0'
__version__ = '0.20.dev0'

# have to import verbose first since it's needed by many things
from .utils import (set_log_level, set_log_file, verbose, set_config,
Expand Down
46 changes: 5 additions & 41 deletions mne/io/cnt/cnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ...channels.layout import _topo_to_sphere
from ..constants import FIFF
from ..utils import (_mult_cal_one, _find_channels, _create_chs, read_str,
_deprecate_stim_channel, _synthesize_stim_channel,
_deprecate_montage)
from ..meas_info import _empty_info
from ..base import BaseRaw
Expand Down Expand Up @@ -96,7 +95,7 @@ def _translating_function(offset, n_channels, event_type,
@fill_doc
def read_raw_cnt(input_fname, montage='deprecated', eog=(), misc=(), ecg=(),
emg=(), data_format='auto', date_format='mm/dd/yy',
preload=False, stim_channel=False, verbose=None):
preload=False, verbose=None):
"""Read CNT data as raw object.
.. Note::
Expand Down Expand Up @@ -139,16 +138,6 @@ def read_raw_cnt(input_fname, montage='deprecated', eog=(), misc=(), ecg=(),
date_format : 'mm/dd/yy' | 'dd/mm/yy'
Format of date in the header. Defaults to 'mm/dd/yy'.
%(preload)s
stim_channel : bool | None
Add a stim channel from the events. Defaults to None to trigger a
future warning.
.. warning:: This defaults to True in 0.18 but will change to False in
0.19 (when no stim channel synthesis will be allowed)
and be removed in 0.20; migrate code to use
:func:`mne.events_from_annotations` instead.
.. versionadded:: 0.18
%(verbose)s
Returns
Expand All @@ -166,14 +155,12 @@ def read_raw_cnt(input_fname, montage='deprecated', eog=(), misc=(), ecg=(),
"""
return RawCNT(input_fname, montage=montage, eog=eog, misc=misc, ecg=ecg,
emg=emg, data_format=data_format, date_format=date_format,
preload=preload, stim_channel=stim_channel, verbose=verbose)
preload=preload, verbose=verbose)


def _get_cnt_info(input_fname, eog, ecg, emg, misc, data_format, date_format,
stim_channel_toggle):
def _get_cnt_info(input_fname, eog, ecg, emg, misc, data_format, date_format):
"""Read the cnt header."""
# XXX stim_channel_toggle is used because stim_channel was in use already
_deprecate_stim_channel(stim_channel_toggle, removed_in='0.20')

data_offset = 900 # Size of the 'SETUP' header.
cnt_info = dict()
Expand Down Expand Up @@ -287,16 +274,6 @@ def _get_cnt_info(input_fname, eog, ecg, emg, misc, data_format, date_format,
cal = np.fromfile(fid, dtype='f4', count=1)
cals.append(cal * sensitivity * 1e-6 / 204.8)

if stim_channel_toggle:
data_format = 'int32' if n_bytes == 4 else 'int16'
annot = _read_annotations_cnt(input_fname, data_format=data_format)
events = (np.stack((annot.onset * sfreq,
annot.duration * sfreq,
annot.description.astype(int)))
.astype(int)
.transpose())
stim_channel = _synthesize_stim_channel(events, n_samples)

info = _empty_info(sfreq)
if lowpass_toggle == 1:
info['lowpass'] = highcutoff
Expand All @@ -322,18 +299,6 @@ def _get_cnt_info(input_fname, eog, ecg, emg, misc, data_format, date_format,
for ch, loc in zip(chs, locs):
ch.update(loc=loc)

if stim_channel_toggle:
chan_info = {'cal': 1.0, 'logno': len(chs) + 1, 'scanno': len(chs) + 1,
'range': 1.0, 'unit_mul': 0., 'ch_name': 'STI 014',
'unit': FIFF.FIFF_UNIT_NONE,
'coord_frame': FIFF.FIFFV_COORD_UNKNOWN,
'loc': np.zeros(12),
'coil_type': FIFF.FIFFV_COIL_NONE,
'kind': FIFF.FIFFV_STIM_CH}
chs.append(chan_info)
baselines.append(0) # For stim channel
cnt_info.update(stim_channel=stim_channel)

cnt_info.update(baselines=np.array(baselines), n_samples=n_samples,
n_bytes=n_bytes)

Expand Down Expand Up @@ -411,8 +376,7 @@ class RawCNT(BaseRaw):

def __init__(self, input_fname, montage='deprecated', eog=(), misc=(),
ecg=(), emg=(), data_format='auto', date_format='mm/dd/yy',
preload=False, stim_channel=False,
verbose=None): # noqa: D102
preload=False, verbose=None): # noqa: D102

_check_option('date_format', date_format, ['mm/dd/yy', 'dd/mm/yy'])
if date_format == 'dd/mm/yy':
Expand All @@ -422,7 +386,7 @@ def __init__(self, input_fname, montage='deprecated', eog=(), misc=(),

input_fname = path.abspath(input_fname)
info, cnt_info = _get_cnt_info(input_fname, eog, ecg, emg, misc,
data_format, _date_format, stim_channel)
data_format, _date_format)
last_samps = [cnt_info['n_samples'] - 1]
super(RawCNT, self).__init__(
info, preload, filenames=[input_fname], raw_extras=[cnt_info],
Expand Down
3 changes: 1 addition & 2 deletions mne/io/fieldtrip/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
info_long_fields = ('hpi_meas', )

system_to_reader_fn_dict = {'neuromag306': mne.io.read_raw_fif,
'CNT': partial(mne.io.read_raw_cnt,
stim_channel=False),
'CNT': partial(mne.io.read_raw_cnt),
'CTF': partial(mne.io.read_raw_ctf,
clean_names=True),
'BTI': partial(mne.io.read_raw_bti,
Expand Down
28 changes: 0 additions & 28 deletions mne/io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from .constants import FIFF
from .meas_info import _get_valid_units
from .. import __version__
from ..utils import warn


Expand All @@ -33,33 +32,6 @@ def _deprecate_montage(raw, raw_type, montage, **kwargs):
warn(_MSG, DeprecationWarning)


def _deprecate_stim_channel(stim_channel, removed_in='0.19'):
minor_current = int(__version__.split('.')[1])
minor_removed_in = int(removed_in.split('.')[1])
if minor_current == minor_removed_in - 2:
if stim_channel is None:
_MSG = (
'The parameter `stim_channel` controlling the stim channel'
' synthesis has not been specified. In 0.%s it defaults to'
' True but will change to False in 0.%s (when no stim channel'
' synthesis will be allowed) and be removed in %s; migrate'
' code to use `stim_channel=False` and'
' :func:`mne.events_from_annotations` or set'
' `stim_channel=True` to avoid this warning.'
% (minor_removed_in - 2, minor_removed_in - 1, removed_in))
warn(_MSG, FutureWarning)

elif minor_current == minor_removed_in - 1:
if stim_channel is not False:
_MSG = ('stim_channel must be False or omitted; it will be '
'removed in %s' % removed_in)
raise ValueError(_MSG, DeprecationWarning)
else:
raise RuntimeError('stim_channel was supposed to be removed in version'
' %s, and it is still present in %s' %
(removed_in, __version__))


def _check_orig_units(orig_units):
"""Check original units from a raw file.
Expand Down

0 comments on commit 5e16625

Please sign in to comment.