Skip to content

Commit

Permalink
Add ability to load NIRX data by passing path to header file (#7731)
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-luke authored and cbrnr committed May 9, 2020
1 parent 09530fd commit cb52773
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mne/io/nirx/nirx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from configparser import ConfigParser, RawConfigParser
import glob as glob
import re as re
import os.path as op

import numpy as np

Expand All @@ -23,7 +24,7 @@ def read_raw_nirx(fname, preload=False, verbose=None):
Parameters
----------
fname : str
Path to the NIRX data folder.
Path to the NIRX data folder or header file.
%(preload)s
%(verbose)s
Expand All @@ -50,7 +51,7 @@ class RawNIRX(BaseRaw):
Parameters
----------
fname : str
Path to the NIRX data folder.
Path to the NIRX data folder or header file.
%(preload)s
%(verbose)s
Expand All @@ -65,6 +66,9 @@ def __init__(self, fname, preload=False, verbose=None):
from ...coreg import get_mni_fiducials # avoid circular import prob
logger.info('Loading %s' % fname)

if fname.endswith('.hdr'):
fname = op.dirname(op.abspath(fname))

# Check if required files exist and store names for later use
files = dict()
keys = ('dat', 'evt', 'hdr', 'inf', 'set', 'tpl', 'wl1', 'wl2',
Expand Down
11 changes: 11 additions & 0 deletions mne/io/nirx/tests/test_nirx.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@
'NIRx', 'nirx_15_2_recording_w_short')


@requires_testing_data
def test_nirx_hdr_load():
"""Test reading NIRX files using path to header file."""
fname = fname_nirx_15_2_short + "/NIRS-2019-08-23_001.hdr"
raw = read_raw_nirx(fname, preload=True)

# Test data import
assert raw._data.shape == (26, 145)
assert raw.info['sfreq'] == 12.5


@requires_testing_data
def test_nirx_15_2_short():
"""Test reading NIRX files."""
Expand Down

0 comments on commit cb52773

Please sign in to comment.