Skip to content

Commit

Permalink
Fix conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelgarcia committed Mar 6, 2024
2 parents 6385b0f + 6cd8158 commit 165a0a4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
13 changes: 7 additions & 6 deletions neo/rawio/neuralynxrawio/ncssections.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
The challenge addressed by the NcsSectionsFactory of this module is to separate those intended
gaps from those introduced by a quirk of the hardware, recording software, or file format.
"""

import math
import numpy as np

Expand Down Expand Up @@ -87,12 +88,12 @@ class NcsSection:
_RECORD_SIZE = 512 # nb sample per signal record

def __init__(self, startRec, startTime, endRec, endTime, n_samples):
self.startRec = startRec # index of starting record
self.startTime = startTime # starttime of first record
self.endRec = endRec # index of last record (inclusive)
self.endTime = endTime # end time of last record, that is, the end time of the last
# sampling period contained in the last record of the section
self.n_samples = n_samples # number of samples in record which are valid
self.startRec = startRec # index of starting record
self.startTime = startTime # starttime of first record
self.endRec = endRec # index of last record (inclusive)
self.endTime = endTime # end time of last record, that is, the end time of the last
# sampling period contained in the last record of the section
self.n_samples = n_samples # number of samples in record which are valid

def __eq__(self, other):
return (
Expand Down
2 changes: 1 addition & 1 deletion neo/rawio/neuralynxrawio/neuralynxrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def _parse_header(self):
internal_ids = []
else:
data = self._get_file_map(filename)
if data.shape[0] == 0: # empty file
if data.shape[0] == 0: # empty file
self._empty_nse_ntt.append(filename)
internal_ids = np.unique(data[["event_id", "ttl_input"]]).tolist()
for internal_event_id in internal_ids:
Expand Down
39 changes: 20 additions & 19 deletions neo/rawio/neuralynxrawio/nlxheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,52 +81,53 @@ def _to_bool(txt):
"bml": dict(
datetime1_regex=r"## Time Opened: \(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"
datetimeformat="%m/%d/%y %H:%M:%S.%f",
),
# Cheetah after version 1 and before version 5
"bv5": dict(
datetime1_regex=r"## Time Opened: \(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"
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"
datetimeformat="%m/%d/%Y %H:%M:%S.%f",
),
# Cheetah version 5.6.0, some range of versions in between
"v5.6.0": dict(
datetime1_regex=r"## Time Opened: \(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"
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+)" r" \(h:m:s\.ms\) (?P<time>\S+)",
datetime2_regex=r"## Time Closed \(m/d/y\): (?P<date>\S+)" r" \(h:m:s\.ms\) (?P<time>\S+)",
filename_regex=r"## File Name (?P<filename>\S+)",
datetimeformat="%m/%d/%Y %H:%M:%S.%f"
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"
datetimeformat="%m/%d/%Y %H:%M:%S",
),
'peg': dict(
datetime1_regex=r'-TimeCreated (?P<date>\S+) (?P<time>\S+)',
datetime2_regex=r'-TimeClosed (?P<date>\S+) (?P<time>\S+)',
"peg": dict(
datetime1_regex=r"-TimeCreated (?P<date>\S+) (?P<time>\S+)",
datetime2_regex=r"-TimeClosed (?P<date>\S+) (?P<time>\S+)",
filename_regex=r'-OriginalFileName "?(?P<filename>\S+)"?',
datetimeformat=r'%Y/%m/%d %H:%M:%S',
datetime2format=r'%Y/%m/%d %H:%M:%S.f'),
datetimeformat=r"%Y/%m/%d %H:%M:%S",
datetime2format=r"%Y/%m/%d %H:%M:%S.f",
),
# 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+)",
datetime2_regex=r"-TimeClosed (?P<date>\S+) (?P<time>\S+)",
filename_regex=r'-OriginalFileName "?(?P<filename>\S+)"?',
datetimeformat="%Y/%m/%d %H:%M:%S"
datetimeformat="%Y/%m/%d %H:%M:%S",
),
}

Expand All @@ -144,7 +145,7 @@ def __init__(self, filename, props_only=False):

# must start with 8 # characters
if not props_only and not txt_header.startswith("########"):
ValueError("Neuralynx files must start with 8 # characters.")
ValueError("Neuralynx files must start with 8 # characters.")

self.read_properties(filename, txt_header)

Expand All @@ -163,7 +164,6 @@ def build_with_properties_only(filename):
"""
res = OrderedDict()


def read_properties(self, filename, txt_header):
"""
Read properties from header and place in OrderedDictionary which this object is.
Expand Down Expand Up @@ -272,8 +272,8 @@ def readTimeDate(self, txt_header):
elif an == "Neuraview":
hpd = NlxHeader.header_pattern_dicts["neuraview2"]
av = Version("2")
elif an == 'Pegasus':
hpd = NlxHeader.header_pattern_dicts['peg']
elif an == "Pegasus":
hpd = NlxHeader.header_pattern_dicts["peg"]
av = Version("2")
else:
an = "Unknown"
Expand All @@ -289,15 +289,16 @@ def readTimeDate(self, txt_header):
dt1 = sr.groupdict()
try: # allow two possible formats for date and time
self["recording_opened"] = datetime.datetime.strptime(
dt1["date"] + " " + dt1["time"], hpd["datetimeformat"])
dt1["date"] + " " + dt1["time"], hpd["datetimeformat"]
)
except:
try:
self["recording_opened"] = datetime.datetime.strptime(
dt1["date"] + " " + dt1["time"], hpd["datetime2format"])
dt1["date"] + " " + dt1["time"], hpd["datetime2format"]
)
except:
self["recording_opened"] = None


# close time, if available
if "datetime2_regex" in hpd:
sr = re.search(hpd["datetime2_regex"], txt_header)
Expand Down
2 changes: 1 addition & 1 deletion neo/test/rawiotest/test_neuralynxrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TestNeuralynxRawIO(
"neuralynx/Cheetah_v5.5.1/original_data",
"neuralynx/Cheetah_v5.6.3/original_data",
"neuralynx/Cheetah_v5.7.4/original_data",
"neuralynx/Cheetah_v6.3.2/incomplete_blocks"
"neuralynx/Cheetah_v6.3.2/incomplete_blocks",
]

def test_scan_ncs_files(self):
Expand Down

0 comments on commit 165a0a4

Please sign in to comment.