agramfort: Lgtm

Merge when Travis is happy

Thx for the quick fix
diff --git a/mne/io/brainvision/brainvision.py b/mne/io/brainvision/brainvision.py
index 35fd057a2..81b41fa78 100644
--- a/mne/io/brainvision/brainvision.py
+++ b/mne/io/brainvision/brainvision.py
@@ -396,6 +396,10 @@ def _get_eeg_info(vhdr_fname, eog, misc):
     info['filename'] = vhdr_fname
     eeg_info = {}
 
+    ext = os.path.splitext(vhdr_fname)[-1]
+    if ext != '.vhdr':
+        raise IOError("The header file must be given to read the data, "
+                      "not the '%s' file." % ext)
     with open(vhdr_fname, 'r') as f:
         # extract the first section to resemble a cfg
         l = f.readline().strip()

check extension of brainvision file
I mistakenly tried:

raw = mne.io.read_raw_brainvision('test.vmrk')

instead of

raw = mne.io.read_raw_brainvision('test.vhdr')

and got this error, which is not super explicit:

--> 402         assert l == 'Brain Vision Data Exchange Header File Version 1.0'

to help here we should check file extension and use a properly exception (not this assert).

@teonlamont can you take care of that?

thanks heaps.


diff --git a/mne/io/brainvision/tests/test_brainvision.py b/mne/io/brainvision/tests/test_brainvision.py
index 44eb09816..5131d978a 100644
--- a/mne/io/brainvision/tests/test_brainvision.py
+++ b/mne/io/brainvision/tests/test_brainvision.py
@@ -22,6 +22,7 @@ from mne.io import read_raw_brainvision
 FILE = inspect.getfile(inspect.currentframe())
 data_dir = op.join(op.dirname(op.abspath(FILE)), 'data')
 vhdr_path = op.join(data_dir, 'test.vhdr')
+vmrk_path = op.join(data_dir, 'test.vmrk')
 vhdr_highpass_path = op.join(data_dir, 'test_highpass.vhdr')
 montage = op.join(data_dir, 'test.hpts')
 eeg_bin = op.join(data_dir, 'test_bin_raw.fif')
@@ -42,6 +43,7 @@ def test_brainvision_data_filters():
 def test_brainvision_data():
     """Test reading raw Brain Vision files
     """
+    assert_raises(IOError, read_raw_brainvision, vmrk_path)
     assert_raises(TypeError, read_raw_brainvision, vhdr_path, montage,
                   preload=True, scale="0")
     raw_py = read_raw_brainvision(vhdr_path, montage, eog=eog, preload=True)

pip install -e .[dev]
parse_log_pytest
requirements.txt
numpy>=1.16.0 pandas>=1.0.0 scikit-learn h5py pysurfer nose nose-timer pytest
apt-get update apt-get install -y gcc
3.7
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
apptools==5.2.1
certifi @ file:///croot/certifi_1671487769961/work/certifi
configobj==5.0.9
cycler==0.11.0
envisage==7.0.3
exceptiongroup==1.2.2
fonttools==4.38.0
h5py==3.8.0
importlib-metadata==6.7.0
importlib-resources==5.12.0
iniconfig==2.0.0
joblib==1.3.2
kiwisolver==1.4.5
matplotlib==3.5.3
mayavi==4.8.1
-e git+https://github.com/mne-tools/mne-python.git@acf8364f01f98233613f7574cac7d533c35183bf#egg=mne
nibabel==4.0.2
nose==1.3.7
nose-timer==1.0.1
numpy==1.21.6
packaging==24.0
pandas==1.3.5
Pillow==9.5.0
pluggy==1.2.0
pyface==8.0.0
Pygments==2.17.2
pyparsing==3.1.4
pysurfer==0.11.2
pytest==7.4.4
python-dateutil==2.9.0.post0
pytz==2025.2
scikit-learn==1.0.2
scipy==1.7.3
six==1.17.0
threadpoolctl==3.1.0
tomli==2.0.1
traits==6.4.3
traitsui==8.0.0
typing_extensions==4.7.1
vtk==9.3.1
zipp==3.15.0

name: mne-python
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - apptools==5.2.1
      - configobj==5.0.9
      - cycler==0.11.0
      - envisage==7.0.3
      - exceptiongroup==1.2.2
      - fonttools==4.38.0
      - h5py==3.8.0
      - importlib-metadata==6.7.0
      - importlib-resources==5.12.0
      - iniconfig==2.0.0
      - joblib==1.3.2
      - kiwisolver==1.4.5
      - matplotlib==3.5.3
      - mayavi==4.8.1
      - nibabel==4.0.2
      - nose==1.3.7
      - nose-timer==1.0.1
      - numpy==1.21.6
      - packaging==24.0
      - pandas==1.3.5
      - pillow==9.5.0
      - pluggy==1.2.0
      - pyface==8.0.0
      - pygments==2.17.2
      - pyparsing==3.1.4
      - pysurfer==0.11.2
      - pytest==7.4.4
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - scikit-learn==1.0.2
      - scipy==1.7.3
      - six==1.17.0
      - threadpoolctl==3.1.0
      - tomli==2.0.1
      - traits==6.4.3
      - traitsui==8.0.0
      - typing-extensions==4.7.1
      - vtk==9.3.1
      - zipp==3.15.0
prefix: /opt/conda/envs/mne-python

mne/io/brainvision/tests/test_brainvision.py::test_brainvision_data
mne/io/brainvision/tests/test_brainvision.py::test_brainvision_data_filters mne/io/brainvision/tests/test_brainvision.py::test_events mne/io/brainvision/tests/test_brainvision.py::test_read_segment
mne/io/brainvision/brainvision.py
mne/io/brainvision/brainvision.py