Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions neo/rawio/neuralynxrawio/nlxheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ def _to_bool(txt):
r' \(h:m:s\.ms\) (?P<time>\S+)',
filename_regex=r'## File Name (?P<filename>\S+)',
datetimeformat='%m/%d/%Y %H:%M:%S.%f'),
'neuraview2': dict(
datetime1_regex=r'## Date Opened: \(mm/dd/yyy\): (?P<date>\S+)'
r' At Time: (?P<time>\S+)',
datetime2_regex=r'## Date Closed: \(mm/dd/yyy\): (?P<date>\S+)'
r' At Time: (?P<time>\S+)',
filename_regex=r'## File Name: (?P<filename>\S+)',
datetimeformat='%m/%d/%Y %H:%M:%S'),
# Cheetah after v 5.6.4 and default for others such as Pegasus
'def': dict(
datetime1_regex=r'-TimeCreated (?P<date>\S+) (?P<time>\S+)',
Expand Down Expand Up @@ -148,7 +155,7 @@ def __init__(self, filename):
chid_entries = re.findall(r'\w+', self['channel_ids'])
self['channel_ids'] = [int(c) for c in chid_entries]
else:
self['channel_ids'] = [name]
self['channel_ids'] = ['unknown']

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

# version and application name
# older Cheetah versions with CheetahRev property
Expand All @@ -172,10 +179,15 @@ def __init__(self, filename):
match = re.findall(pattern, self['ApplicationName'])
assert len(match) == 1, 'impossible to find application name and version'
self['ApplicationName'], app_version = match[0]
# BML Ncs file writing contained neither property, assume BML version 2
else:
# BML Ncs file contain neither property, but 'NLX_Base_Class_Type'
elif 'NLX_Base_Class_Type' in txt_header:
self['ApplicationName'] = 'BML'
app_version = "2.0"
# Neuraview Ncs file contained neither property nor
# NLX_Base_Class_Type information
else:
self['ApplicationName'] = 'Neuraview'
app_version = '2'

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

Expand Down Expand Up @@ -216,6 +228,9 @@ def __init__(self, filename):
elif an == 'BML':
hpd = NlxHeader.header_pattern_dicts['bml']
av = "2"
elif an == 'Neuraview':
hpd = NlxHeader.header_pattern_dicts['neuraview2']
av = "2"
else:
an = "Unknown"
av = "NA"
Expand Down
13 changes: 13 additions & 0 deletions neo/test/iotest/test_neuralynxio.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ class CommonNeuralynxIOTest(BaseTestIO, unittest.TestCase, ):
entities_to_download = TestNeuralynxRawIO.entities_to_download
entities_to_test = TestNeuralynxRawIO.entities_to_test


class TestCheetah_Neuraview(CommonNeuralynxIOTest, unittest.TestCase):
files_to_test = []

def test_read_block(self):
dirname = self.get_local_path('neuralynx/Neuraview_v2/original_data')
nio = NeuralynxIO(dirname=dirname, use_cache=False)
bl = nio.read_block()

# This dataset contains two event sets
self.assertEqual(len(bl.segments[0].events), 2)


class TestCheetah_v551(CommonNeuralynxIOTest, unittest.TestCase):
cheetah_version = '5.5.1'
files_to_test = []
Expand Down