Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
0a2b959
Move constants into class so accessible for testing.
Oct 9, 2020
799c060
Test of building NcsBlocks.
Oct 12, 2020
409ea41
Handle old files with truncated frequency in header and test.
Oct 13, 2020
2c3f80b
Change interface on parse versus build.
Oct 16, 2020
6000687
Tests for PRE4 type and code corrections.
Oct 19, 2020
c4e05ae
Fix initializer, update loop vars.
Oct 26, 2020
85a05e8
Add additional tests on v5.5.1 with 2 blocks
Oct 26, 2020
846edb0
Tests of block construction for incomplete blocks
Oct 26, 2020
5ba6113
Fix up single block case.
Oct 26, 2020
153446d
Remove unneeded classes. Clean up style.
Oct 27, 2020
968261f
Use private dtype by new private name.
Oct 27, 2020
b6ecbcd
Add test of side effects of read_ncs_files
Oct 27, 2020
6982c59
Use NcsBlocksFactory and logical or.
Oct 27, 2020
d9ade17
Fix off by one in range for list. Comments.
Oct 28, 2020
4af130c
Use standard time calculation for last time of block.
Oct 28, 2020
88880e0
Remove test with tolerance over whole length. Fix microsPerSampUsed a…
Oct 29, 2020
6b8b64a
Tests of raw io for incomplete records multiple block case.
Oct 29, 2020
81f14b2
Update stop times to include time for samples in partially filled rec…
Oct 29, 2020
4ed5679
PEP and style cleanup. Corrected gap comment.
Oct 29, 2020
82c93d9
Line shortening for PEP8.
Oct 29, 2020
ba82efe
More PEP8 items.
Oct 29, 2020
b7d8712
Correct column error in data tested.
Oct 29, 2020
84af1cd
Update comment on PRE4 file limitations.
Oct 29, 2020
9008a53
Tests for PRE4 file type in Cheetah v4.0.2.
Oct 29, 2020
0671428
PEP8 indent corrections.
Oct 29, 2020
8589105
Small PEP8 correctin.
Oct 29, 2020
3ec6866
Proper time opened header for BML and use of frequency.
Oct 30, 2020
11aa8c8
Download files and activate tests for BML style files.
Oct 30, 2020
dc6cdd5
record start and end times in NcsBlocks for verification later
Oct 30, 2020
6515754
Code to handle digitallynx with cheetah v1
Oct 30, 2020
26b66be
Fixes to handle split block.
Nov 2, 2020
c9d7d78
Tests NcsBlockFactory with split blocks and unfilled records.
Nov 2, 2020
7a75ca4
Tests of data read in ncs files with partial records and split blocks.
Nov 2, 2020
d4fff81
Handle testing less data than available in all segments.
Nov 4, 2020
f014206
Read and test with partial blocks. Test all types in test_neuralyxio.
Nov 6, 2020
10dbaf1
Read and test with partial blocks. Test all types in test_neuralyxio.
Nov 6, 2020
8e91a5f
Merge branch 'splitBlockTesting' of github.com:PeterNSteinmetz/python…
Nov 6, 2020
c7522df
PEP8 fix ups.
Nov 6, 2020
b827ad5
Language and function renaming.
Nov 6, 2020
87fabbc
Language and function renaming.
Nov 6, 2020
875dab7
Merge branch 'splitBlockTesting' of github.com:PeterNSteinmetz/python…
Nov 6, 2020
3907d87
Move constants into class so accessible for testing.
Oct 9, 2020
589565e
Test of building NcsBlocks.
Oct 12, 2020
6ebcd75
Handle old files with truncated frequency in header and test.
Oct 13, 2020
1c5cd2c
Change interface on parse versus build.
Nov 7, 2020
e307614
Tests for PRE4 type and code corrections.
Nov 7, 2020
c5fac53
Fix initializer, update loop vars.
Oct 26, 2020
ddf26c6
Add additional tests on v5.5.1 with 2 blocks
Oct 26, 2020
b75989d
Tests of block construction for incomplete blocks
Oct 26, 2020
dd09521
Fix up single block case.
Oct 26, 2020
e17a869
Remove unneeded classes. Clean up style.
Nov 7, 2020
e90737a
Add test of side effects of read_ncs_files
Oct 27, 2020
1825772
Use NcsBlocksFactory and logical or.
Nov 7, 2020
97a694a
Fix off by one in range for list. Comments.
Oct 28, 2020
5a6dc62
Use standard time calculation for last time of block.
Oct 28, 2020
0837723
Remove test with tolerance over whole length. Fix microsPerSampUsed a…
Oct 29, 2020
32a26c7
Tests of raw io for incomplete records multiple block case.
Oct 29, 2020
917eb56
Update stop times to include time for samples in partially filled rec…
Oct 29, 2020
f28c4ca
PEP and style cleanup. Corrected gap comment.
Oct 29, 2020
50958f5
Line shortening for PEP8.
Oct 29, 2020
b2bbb39
More PEP8 items.
Nov 7, 2020
2ab65e7
Merge branch 'addNcsBlocks' of github.com:PeterNSteinmetz/python-neo …
Nov 7, 2020
76d3bb3
Remove conflict markers.
Nov 7, 2020
c8fa8f2
More conflict resolution for rebase.
Nov 7, 2020
b76f496
verify block function and test
Nov 9, 2020
f256caa
Call renamed functions.
Nov 9, 2020
c02a426
use _verifyBlockStructure to ensure same structure
Nov 9, 2020
9594cdb
Properly limit samples compared.
Nov 9, 2020
163d951
Merge branch 'Pre4Files' into master
Nov 9, 2020
89d6a2e
Merge branch 'BmlStyleFiles' into master
Nov 9, 2020
7bdfd93
Merge branch 'verifyBlockStructure' into master
Nov 9, 2020
2ae02ce
Merge branch 'master' of github.com:PeterNSteinmetz/python-neo into m…
Nov 9, 2020
a52ce08
Temporarily remove data test.
Nov 9, 2020
719ae42
Remove duplication of some older tests.
Nov 10, 2020
7a1bbe3
Comments on structure of segment defining fields.
Nov 11, 2020
d2ed448
Factor out NcsBlock object.
Nov 11, 2020
ea36ef0
Change factory methods to use NcsBlock.
Nov 11, 2020
3dd9e13
Rewrite tests for NcsBlocks refactoring.
Nov 11, 2020
de34eda
More refactoring of NcsBlocks.
Nov 11, 2020
1cbf855
Gather all NcsBlocks first, then build segements.
Nov 13, 2020
c92429a
Merge branch 'master' of github.com:NeuralEnsemble/python-neo into ma…
Nov 13, 2020
eb4e2ba
change name to _scan_ncs_files rather than read
Nov 13, 2020
8ac4928
Proper formatting of number of NcsBlock structures.
Nov 14, 2020
c1eb8dd
Move neuralynxrawio to subdirectory to factor our other classes.
Nov 14, 2020
54dd130
Eliminate WholeTimesPositionBlock as class.
Nov 16, 2020
ab463ee
Factor helper classes out in package.
Nov 17, 2020
f27a390
Merge branch 'factorNcsBlocksAndRepackage' into master
Nov 17, 2020
051f16d
Define data returned by scan_ncs_files and rename.
Nov 17, 2020
7980394
Return results from scan_ncs_files and unpack them into private atttr…
Nov 18, 2020
1d52241
Test returned results.
Nov 18, 2020
6a3ceeb
Fix for version 5.4.0 headers without :
Nov 18, 2020
e2dd5ce
Allow gap which is fraction of sample time, rather than fixed micros.
Nov 18, 2020
79ec566
Test changes for Cheetah v5.4.0.
Nov 18, 2020
7071432
Clean up some comments.
Nov 19, 2020
965bb7d
Better error message if header/pattern mismatch.
Nov 19, 2020
15eac00
PEP8 clean ups.
Nov 19, 2020
0475a77
Changes to address comments by Julia Sprenger
Nov 30, 2020
5378c26
Remove merge conflicts.
Nov 30, 2020
94120ae
Fix up some PEP8 comments.
Nov 20, 2020
a984d9f
Roll back inadvertent commit of local gin repository.
Nov 20, 2020
8d230f5
Fixup improperly resolved conflicts.
Nov 30, 2020
38f16ae
More PEP8 fixups.
Nov 21, 2020
6112b52
Replace inadvertently deleted package file.
Nov 21, 2020
b45ad3f
Repaired inadvertent modification of blocks variable in nixio
Nov 21, 2020
6467f30
Take 6.3.2 io tests out.
Nov 21, 2020
9f234ee
Specify no entitites to test.
Nov 24, 2020
57baec5
Retain tracking of maximum block length.
Nov 30, 2020
023ced0
PEP8 clean ups.
Nov 19, 2020
4f21b18
Download Cheetah 5.4.0 test data.
Nov 30, 2020
6912b95
use self for results
Nov 30, 2020
2fde8f8
Merge remote-tracking branch 'neuralensemble/master' into FixesForChe…
Nov 30, 2020
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
35 changes: 29 additions & 6 deletions neo/rawio/neuralynxrawio/nlxheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ def _to_bool(txt):
r' At Time: (?P<time>\S+)',
filename_regex=r'## File Name: (?P<filename>\S+)',
datetimeformat='%m/%d/%Y %H:%M:%S.%f'),
# Cheetah version 5.4.0
'v5.4.0': dict(
datetime1_regex=r'## Time Opened \(m/d/y\): (?P<date>\S+)'
r' At Time: (?P<time>\S+)',
datetime2_regex=r'## Time Closed \(m/d/y\): (?P<date>\S+)'
r' At Time: (?P<time>\S+)',
filename_regex=r'## File Name: (?P<filename>\S+)',
datetimeformat='%m/%d/%Y %H:%M:%S.%f'),
# Cheetah version 5 before and including v 5.6.4 as well as version 1
'bv5.6.4': dict(
datetime1_regex=r'## Time Opened \(m/d/y\): (?P<date>\S+)'
Expand Down Expand Up @@ -199,25 +207,40 @@ def __init__(self, filename):
hpd = NlxHeader.header_pattern_dicts['bv5.6.4']
elif av < '5':
hpd = NlxHeader.header_pattern_dicts['bv5']
elif av <= '5.4.0':
hpd = NlxHeader.header_pattern_dicts['v5.4.0']
elif av <= '5.6.4':
hpd = NlxHeader.header_pattern_dicts['bv5.6.4']
else:
hpd = NlxHeader.header_pattern_dicts['def']
elif an == 'BML':
hpd = NlxHeader.header_pattern_dicts['bml']
av = "2"
else:
an = "Unknown"
av = "NA"
hpd = NlxHeader.header_pattern_dicts['def']

# opening time
dt1 = re.search(hpd['datetime1_regex'], txt_header).groupdict()
self['recording_opened'] = datetime.datetime.strptime(
dt1['date'] + ' ' + dt1['time'], hpd['datetimeformat'])
sr = re.search(hpd['datetime1_regex'], txt_header)
if not sr:
raise IOError("No matching header open date/time for application {} " +
"version {}. Please contact developers.".format(an, av))
else:
dt1 = sr.groupdict()
self['recording_opened'] = datetime.datetime.strptime(
dt1['date'] + ' ' + dt1['time'], hpd['datetimeformat'])

# close time, if available
if 'datetime2_regex' in hpd:
dt2 = re.search(hpd['datetime2_regex'], txt_header).groupdict()
self['recording_closed'] = datetime.datetime.strptime(
dt2['date'] + ' ' + dt2['time'], hpd['datetimeformat'])
sr = re.search(hpd['datetime2_regex'], txt_header)
if not sr:
raise IOError("No matching header close date/time for application {} " +
"version {}. Please contact developers.".format(an, av))
else:
dt2 = sr.groupdict()
self['recording_closed'] = datetime.datetime.strptime(
dt2['date'] + ' ' + dt2['time'], hpd['datetimeformat'])

def type_of_recording(self):
"""
Expand Down
7 changes: 5 additions & 2 deletions neo/test/iotest/test_neuralynxio.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class CommonNeuralynxIOTest(BaseTestIO, unittest.TestCase, ):
'BML_unfilledsplit/original_data',
'Cheetah_v1.1.0/original_data',
'Cheetah_v4.0.2/original_data',
'Cheetah_v5.4.0/original_data',
'Cheetah_v5.5.1/original_data',
'Cheetah_v5.6.3/original_data',
'Cheetah_v5.7.4/original_data',
Expand All @@ -44,6 +45,8 @@ class CommonNeuralynxIOTest(BaseTestIO, unittest.TestCase, ):
'Cheetah_v4.0.2/original_data/CSC14_trunc.Ncs',
'Cheetah_v4.0.2/plain_data/CSC14_trunc.txt',
'Cheetah_v4.0.2/README.txt',
'Cheetah_v5.4.0/original_data/CSC5_trunc.Ncs',
'Cheetah_v5.4.0/plain_data/CSC5_trunc.txt',
'Cheetah_v5.5.1/original_data/CheetahLogFile.txt',
'Cheetah_v5.5.1/original_data/CheetahLostADRecords.txt',
'Cheetah_v5.5.1/original_data/Events.nev',
Expand Down Expand Up @@ -311,7 +314,7 @@ def _load_plaindata(self, filename, numSamps):
# np.testing.assert_allclose(plain_data[:numToTest],
# anasig.magnitude[:numToTest, 0] * gain_factor_0,
# rtol=0.01, err_msg=" for file " + filename)
@unittest.skip
@unittest.skip("nse failing for now as per issue #907")
def test_keep_original_spike_times(self):
for session in self.files_to_test:
dirname = self.get_filename_path(session)
Expand All @@ -322,7 +325,7 @@ def test_keep_original_spike_times(self):
filename = st.file_origin.replace('original_data', 'plain_data')
if '.nse' in st.file_origin:
filename = filename.replace('.nse', '.txt')
times_column = 0
times_column = 1
plain_data = np.loadtxt(filename)[:, times_column]
elif '.ntt' in st.file_origin:
filename = filename.replace('.ntt', '.txt')
Expand Down
9 changes: 7 additions & 2 deletions neo/test/rawiotest/test_neuralynxrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TestNeuralynxRawIO(BaseTestRawIO, unittest.TestCase, ):
'BML_unfilledsplit/original_data',
'Cheetah_v1.1.0/original_data',
'Cheetah_v4.0.2/original_data',
'Cheetah_v5.4.0/original_data',
'Cheetah_v5.5.1/original_data',
'Cheetah_v5.6.3/original_data',
'Cheetah_v5.7.4/original_data',
Expand All @@ -36,6 +37,8 @@ class TestNeuralynxRawIO(BaseTestRawIO, unittest.TestCase, ):
'Cheetah_v4.0.2/original_data/CSC14_trunc.Ncs',
'Cheetah_v4.0.2/plain_data/CSC14_trunc.txt',
'Cheetah_v4.0.2/README.txt',
'Cheetah_v5.4.0/original_data/CSC5_trunc.Ncs',
'Cheetah_v5.4.0/plain_data/CSC5_trunc.txt',
'Cheetah_v5.5.1/original_data/CheetahLogFile.txt',
'Cheetah_v5.5.1/original_data/CheetahLostADRecords.txt',
'Cheetah_v5.5.1/original_data/Events.nev',
Expand Down Expand Up @@ -79,7 +82,7 @@ class TestNeuralynxRawIO(BaseTestRawIO, unittest.TestCase, ):
'Cheetah_v6.3.2/incomplete_blocks/Events.nev',
'Cheetah_v6.3.2/incomplete_blocks/README.txt']

def test_read_ncs_files_sideeffects(self):
def test_scan_ncs_files(self):

# Test BML style of Ncs files, similar to PRE4 but with fractional frequency
# in the header and fractional microsPerSamp, which is then rounded as appropriate
Expand Down Expand Up @@ -124,7 +127,8 @@ def test_read_ncs_files_sideeffects(self):
# three blocks of records. Gaps are on the order of 60 microseconds or so.
rawio = NeuralynxRawIO(self.get_filename_path('Cheetah_v6.3.2/incomplete_blocks'))
rawio.parse_header()
# test values here from direct inspection of .ncs file
# test values here from direct inspection of .ncs file, except for 3rd block
# t_stop, which is extended due to events past the last block of ncs records.
self.assertEqual(rawio._nb_segment, 3)
self.assertListEqual(rawio._timestamp_limits, [(8408806811, 8427831990),
(8427832053, 8487768498),
Expand All @@ -143,6 +147,7 @@ class TestNcsRecordingType(TestNeuralynxRawIO, unittest.TestCase):

ncsTypeTestFiles = [
('Cheetah_v4.0.2/original_data/CSC14_trunc.Ncs', 'PRE4'),
('Cheetah_v5.4.0/original_data/CSC5_trunc.Ncs', 'DIGITALLYNX'),
('Cheetah_v5.5.1/original_data/STet3a.nse', 'DIGITALLYNXSX'),
('Cheetah_v5.5.1/original_data/Tet3a.ncs', 'DIGITALLYNXSX'),
('Cheetah_v5.6.3/original_data/CSC1.ncs', 'DIGITALLYNXSX'),
Expand Down