Skip to content

Commit cb52773

Browse files
rob-lukecbrnr
authored andcommitted
Add ability to load NIRX data by passing path to header file (#7731)
1 parent 09530fd commit cb52773

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

mne/io/nirx/nirx.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from configparser import ConfigParser, RawConfigParser
66
import glob as glob
77
import re as re
8+
import os.path as op
89

910
import numpy as np
1011

@@ -23,7 +24,7 @@ def read_raw_nirx(fname, preload=False, verbose=None):
2324
Parameters
2425
----------
2526
fname : str
26-
Path to the NIRX data folder.
27+
Path to the NIRX data folder or header file.
2728
%(preload)s
2829
%(verbose)s
2930
@@ -50,7 +51,7 @@ class RawNIRX(BaseRaw):
5051
Parameters
5152
----------
5253
fname : str
53-
Path to the NIRX data folder.
54+
Path to the NIRX data folder or header file.
5455
%(preload)s
5556
%(verbose)s
5657
@@ -65,6 +66,9 @@ def __init__(self, fname, preload=False, verbose=None):
6566
from ...coreg import get_mni_fiducials # avoid circular import prob
6667
logger.info('Loading %s' % fname)
6768

69+
if fname.endswith('.hdr'):
70+
fname = op.dirname(op.abspath(fname))
71+
6872
# Check if required files exist and store names for later use
6973
files = dict()
7074
keys = ('dat', 'evt', 'hdr', 'inf', 'set', 'tpl', 'wl1', 'wl2',

mne/io/nirx/tests/test_nirx.py

+11
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@
2525
'NIRx', 'nirx_15_2_recording_w_short')
2626

2727

28+
@requires_testing_data
29+
def test_nirx_hdr_load():
30+
"""Test reading NIRX files using path to header file."""
31+
fname = fname_nirx_15_2_short + "/NIRS-2019-08-23_001.hdr"
32+
raw = read_raw_nirx(fname, preload=True)
33+
34+
# Test data import
35+
assert raw._data.shape == (26, 145)
36+
assert raw.info['sfreq'] == 12.5
37+
38+
2839
@requires_testing_data
2940
def test_nirx_15_2_short():
3041
"""Test reading NIRX files."""

0 commit comments

Comments
 (0)