Skip to content

Commit f825422

Browse files
authored
Merge pull request #1733 from danielparthier/WinWCP_rec_datetime
WinWcpRawIO: Add rec_datetime to header dict and block annotation from file
2 parents 5a6786a + b1aa752 commit f825422

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

neo/rawio/winwcprawio.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"""
1010

1111
import struct
12+
import datetime
1213

1314
import numpy as np
1415

@@ -61,6 +62,7 @@ def _parse_header(self):
6162
continue
6263
key, val = line.split("=")
6364
if key in [
65+
"VER",
6466
"NC",
6567
"NR",
6668
"NBH",
@@ -80,6 +82,12 @@ def _parse_header(self):
8082
header[key] = val
8183

8284
nb_segment = header["NR"]
85+
86+
# get rec_datetime when WCP data file version is later than 8
87+
if header["VER"] > 8:
88+
rec_datetime = datetime.datetime.strptime(header["RTIME"], "%d/%m/%Y %H:%M:%S")
89+
else:
90+
rec_datetime = None
8391
all_sampling_interval = []
8492
# loop for record number
8593
for seg_index in range(header["NR"]):
@@ -167,7 +175,8 @@ def _parse_header(self):
167175

168176
# insert some annotation at some place
169177
self._generate_minimal_annotations()
170-
178+
bl_annotations = self.raw_annotations["blocks"][0]
179+
bl_annotations["rec_datetime"] = rec_datetime
171180
def _segment_t_start(self, block_index, seg_index):
172181
return 0.0
173182

neo/test/iotest/test_winwcpio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ class TestRawBinarySignalIO(
1414
):
1515
ioclass = WinWcpIO
1616
entities_to_download = ["winwcp"]
17-
entities_to_test = ["winwcp/File_winwcp_1.wcp"]
17+
entities_to_test = [
18+
"winwcp/File_winwcp_1.wcp",
19+
"winwcp/file_with_recording_time/File_winwcp_2.wcp",
20+
]
1821

1922

2023
if __name__ == "__main__":

neo/test/rawiotest/test_winwcprawio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ class TestWinWcpRawIO(
1010
):
1111
rawioclass = WinWcpRawIO
1212
entities_to_download = ["winwcp"]
13-
entities_to_test = ["winwcp/File_winwcp_1.wcp"]
13+
entities_to_test = [
14+
"winwcp/File_winwcp_1.wcp",
15+
"winwcp/file_with_recording_time/File_winwcp_2.wcp",
16+
]
1417

1518

1619
if __name__ == "__main__":

0 commit comments

Comments
 (0)