Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
massich committed Jun 19, 2019
1 parent fcb9b90 commit 83166e9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mne/io/cnt/cnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ..utils import (_mult_cal_one, _find_channels, _create_chs, read_str,
_deprecate_stim_channel, _synthesize_stim_channel)
from ..meas_info import _empty_info
from ..base import BaseRaw, _check_update_montage
from ..base import BaseRaw
from ...annotations import Annotations


Expand Down Expand Up @@ -432,14 +432,14 @@ def __init__(self, input_fname, montage=None, eog=(), misc=(), ecg=(),
info, cnt_info = _get_cnt_info(input_fname, eog, ecg, emg, misc,
data_format, _date_format, stim_channel)
last_samps = [cnt_info['n_samples'] - 1]
_check_update_montage(info, montage)
super(RawCNT, self).__init__(
info, preload, filenames=[input_fname], raw_extras=[cnt_info],
last_samps=last_samps, orig_format='int', verbose=verbose)

data_format = 'int32' if cnt_info['n_bytes'] == 4 else 'int16'
self.set_annotations(
_read_annotations_cnt(input_fname, data_format=data_format))
self.set_montage(montage)

@verbose
def _read_segment_file(self, data, idx, fi, start, stop, cals, mult):
Expand Down
18 changes: 18 additions & 0 deletions mne/io/cnt/tests/test_cnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,37 @@

import numpy as np
from numpy.testing import assert_array_equal
from copy import deepcopy
import pytest

from mne import pick_types
from mne.utils import run_tests_if_main
from mne.utils.numerics import object_diff
from mne.datasets import testing
from mne.io.tests.test_raw import _test_raw_reader
from mne.io.cnt import read_raw_cnt
from mne.annotations import read_annotations
from mne.digitization import Digitization

data_path = testing.data_path(download=False)
fname = op.join(data_path, 'CNT', 'scan41_short.cnt')


@testing.requires_testing_data
def test_montage():
"""Test setting up one of the default montages."""
with pytest.warns(RuntimeWarning, match='number of bytes'):
raw = read_raw_cnt(fname, montage=None, eog='auto',
misc=['NA1', 'LEFT_EAR'])
assert raw.info['dig'] is None
original_chs = deepcopy(raw.info['chs'])

raw.set_montage('biosemi128') # set a random montage of same num channels
assert isinstance(raw.info['dig'], Digitization)
assert raw.info['dig']
assert object_diff(raw.info['chs'], original_chs)


@testing.requires_testing_data
def test_data():
"""Test reading raw cnt files."""
Expand Down

0 comments on commit 83166e9

Please sign in to comment.