Skip to content

Commit

Permalink
Merge pull request #1257 from PeterNSteinmetz/CheetahV5.6.0FixesOnly
Browse files Browse the repository at this point in the history
After discussion among the maintainers we decided to merge this, but we should look at this again to check if the values are available in the info dictionary.
  • Loading branch information
apdavison authored Jan 26, 2024
2 parents 54d65ef + 6ca631b commit 340bbdc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion neo/rawio/neuralynxrawio/ncssections.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def build_for_ncs_file(ncsMemMap, nlxHdr):

# digital lynx style with fractional frequency and micros per samp determined from
# block times
elif acqType == "DIGITALLYNX" or acqType == "DIGITALLYNXSX" or acqType == 'CHEETAH64' or acqType == 'RAWDATAFILE':
elif acqType in ["DIGITALLYNX", "DIGITALLYNXSX", 'CHEETAH64', 'CHEETAH560', 'RAWDATAFILE']:
nomFreq = nlxHdr['sampling_rate']
nb = NcsSectionsFactory._buildForMaxGap(ncsMemMap, nomFreq)

Expand Down
19 changes: 10 additions & 9 deletions neo/rawio/neuralynxrawio/neuralynxrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,20 +850,21 @@ def get_nse_or_ntt_dtype(info, ext):
"""
dtype = [('timestamp', 'uint64'), ('channel_id', 'uint32'), ('unit_id', 'uint32')]

# count feature
nb_feature = 0
for k in info.keys():
if k.startswith('Feature '):
nb_feature += 1
# for purpose of dtypes, features in the file are always fixed 8 presently,
# whether mentioned in the header or not. Features may not be listed in the header
# if no feature names are assigned in Neuralynx software.
nb_feature = 8
dtype += [('features', 'int32', (nb_feature,))]

# count sample
# Number of samples are fixed in the file at 32 for .nse 32 * 4 for .ntt.
# WaveformLength may or may not be listed in the file depending on settings
# in the Neuralynx software, so don't try retrieving it.
if ext == 'nse':
nb_sample = info['WaveformLength']
nb_sample = 32
dtype += [('samples', 'int16', (nb_sample,))]
elif ext == 'ntt':
nb_sample = info['WaveformLength']
nb_chan = 4 # check this if not tetrode
nb_sample = 32
nb_chan = 4
dtype += [('samples', 'int16', (nb_sample, nb_chan))]

return dtype
12 changes: 10 additions & 2 deletions neo/rawio/neuralynxrawio/nlxheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ 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.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'),
# 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 @@ -223,6 +229,8 @@ def __init__(self, filename):
hpd = NlxHeader.header_pattern_dicts['bv5']
elif av <= Version('5.4.0'):
hpd = NlxHeader.header_pattern_dicts['v5.4.0']
elif av == Version('5.6.0'):
hpd = NlxHeader.header_pattern_dicts['v5.6.0']
elif av <= Version('5.6.4'):
hpd = NlxHeader.header_pattern_dicts['bv5.6.4']
else:
Expand Down Expand Up @@ -303,11 +311,11 @@ def type_of_recording(self):

elif 'FileType' in self:

if self['FileVersion'] in ['3.3', '3.4']:
if 'FileVersion' in self and self['FileVersion'] in ['3.3', '3.4']:
return self['AcquisitionSystem'].split()[1].upper()

else:
return 'UNKNOWN'
return 'CHEETAH560' # only known case of FileType without FileVersion

else:
return 'UNKNOWN'

0 comments on commit 340bbdc

Please sign in to comment.