Skip to content

Commit ca35743

Browse files
authored
Merge pull request #1005 from JuliaSprenger/add/neuraview
[neuralynx] add support for neuraview file header
2 parents c690c15 + 2d09a3c commit ca35743

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

neo/rawio/neuralynxrawio/nlxheader.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ def _to_bool(txt):
105105
r' \(h:m:s\.ms\) (?P<time>\S+)',
106106
filename_regex=r'## File Name (?P<filename>\S+)',
107107
datetimeformat='%m/%d/%Y %H:%M:%S.%f'),
108+
'neuraview2': dict(
109+
datetime1_regex=r'## Date Opened: \(mm/dd/yyy\): (?P<date>\S+)'
110+
r' At Time: (?P<time>\S+)',
111+
datetime2_regex=r'## Date Closed: \(mm/dd/yyy\): (?P<date>\S+)'
112+
r' At Time: (?P<time>\S+)',
113+
filename_regex=r'## File Name: (?P<filename>\S+)',
114+
datetimeformat='%m/%d/%Y %H:%M:%S'),
108115
# Cheetah after v 5.6.4 and default for others such as Pegasus
109116
'def': dict(
110117
datetime1_regex=r'-TimeCreated (?P<date>\S+) (?P<time>\S+)',
@@ -148,7 +155,7 @@ def __init__(self, filename):
148155
chid_entries = re.findall(r'\w+', self['channel_ids'])
149156
self['channel_ids'] = [int(c) for c in chid_entries]
150157
else:
151-
self['channel_ids'] = [name]
158+
self['channel_ids'] = ['unknown']
152159

153160
# convert channel names
154161
if 'channel_names' in self:
@@ -158,7 +165,7 @@ def __init__(self, filename):
158165
assert len(self['channel_names']) == len(self['channel_ids']), \
159166
'Number of channel ids does not match channel names.'
160167
else:
161-
self['channel_names'] = [name] * len(self['channel_ids'])
168+
self['channel_names'] = ['unknown'] * len(self['channel_ids'])
162169

163170
# version and application name
164171
# older Cheetah versions with CheetahRev property
@@ -172,10 +179,15 @@ def __init__(self, filename):
172179
match = re.findall(pattern, self['ApplicationName'])
173180
assert len(match) == 1, 'impossible to find application name and version'
174181
self['ApplicationName'], app_version = match[0]
175-
# BML Ncs file writing contained neither property, assume BML version 2
176-
else:
182+
# BML Ncs file contain neither property, but 'NLX_Base_Class_Type'
183+
elif 'NLX_Base_Class_Type' in txt_header:
177184
self['ApplicationName'] = 'BML'
178185
app_version = "2.0"
186+
# Neuraview Ncs file contained neither property nor
187+
# NLX_Base_Class_Type information
188+
else:
189+
self['ApplicationName'] = 'Neuraview'
190+
app_version = '2'
179191

180192
self['ApplicationVersion'] = distutils.version.LooseVersion(app_version)
181193

@@ -216,6 +228,9 @@ def __init__(self, filename):
216228
elif an == 'BML':
217229
hpd = NlxHeader.header_pattern_dicts['bml']
218230
av = "2"
231+
elif an == 'Neuraview':
232+
hpd = NlxHeader.header_pattern_dicts['neuraview2']
233+
av = "2"
219234
else:
220235
an = "Unknown"
221236
av = "NA"

neo/test/iotest/test_neuralynxio.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ class CommonNeuralynxIOTest(BaseTestIO, unittest.TestCase, ):
2323
entities_to_download = TestNeuralynxRawIO.entities_to_download
2424
entities_to_test = TestNeuralynxRawIO.entities_to_test
2525

26+
27+
class TestCheetah_Neuraview(CommonNeuralynxIOTest, unittest.TestCase):
28+
files_to_test = []
29+
30+
def test_read_block(self):
31+
dirname = self.get_local_path('neuralynx/Neuraview_v2/original_data')
32+
nio = NeuralynxIO(dirname=dirname, use_cache=False)
33+
bl = nio.read_block()
34+
35+
# This dataset contains two event sets
36+
self.assertEqual(len(bl.segments[0].events), 2)
37+
38+
2639
class TestCheetah_v551(CommonNeuralynxIOTest, unittest.TestCase):
2740
cheetah_version = '5.5.1'
2841
files_to_test = []

0 commit comments

Comments
 (0)