Skip to content

Commit 37b9059

Browse files
author
BptGrm
authored
black formatting
1 parent 8ec58f7 commit 37b9059

File tree

3 files changed

+25
-22
lines changed

3 files changed

+25
-22
lines changed

neo/rawio/neuralynxrawio/ncssections.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -190,17 +190,19 @@ def _buildNcsSections(ncsMemMap, sampFreq, gapTolerance=0):
190190
and ncsMemMap["sample_rate"][0] == ncsMemMap["sample_rate"][-1]
191191
and ncsMemMap["timestamp"][-1] == predLastBlockStartTime
192192
):
193-
lastBlkEndTime = NcsSectionsFactory.calc_sample_time(sampFreq, ncsMemMap["timestamp"][-1], ncsMemMap["nb_valid"][-1])
193+
lastBlkEndTime = NcsSectionsFactory.calc_sample_time(
194+
sampFreq, ncsMemMap["timestamp"][-1], ncsMemMap["nb_valid"][-1]
195+
)
194196
n_samples = NcsSection._RECORD_SIZE * (ncsMemMap.size - 1) + ncsMemMap["nb_valid"][-1]
195197
section0 = NcsSection(
196-
startRec=0,
197-
startTime=ncsMemMap["timestamp"][0],
198-
endRec=ncsMemMap.size - 1,
199-
endTime=lastBlkEndTime,
200-
n_samples=n_samples
201-
)
198+
startRec=0,
199+
startTime=ncsMemMap["timestamp"][0],
200+
endRec=ncsMemMap.size - 1,
201+
endTime=lastBlkEndTime,
202+
n_samples=n_samples,
203+
)
202204
ncsSects.sects.append(section0)
203-
205+
204206
else:
205207
# need to parse all data block to detect gaps
206208
# check when the predicted timestamp is outside the tolerance
@@ -210,19 +212,19 @@ def _buildNcsSections(ncsMemMap, sampFreq, gapTolerance=0):
210212
gap_inds = np.flatnonzero(np.abs(delta - delta_prediction) > gapTolerance)
211213
gap_inds += 1
212214

213-
sections_limits = [ 0 ] + gap_inds.tolist() + [len(ncsMemMap)]
215+
sections_limits = [0] + gap_inds.tolist() + [len(ncsMemMap)]
214216

215217
for i in range(len(gap_inds) + 1):
216218
start = sections_limits[i]
217219
stop = sections_limits[i + 1]
218-
duration = np.uint64(1e6 / sampFreq * ncsMemMap["nb_valid"][stop-1])
220+
duration = np.uint64(1e6 / sampFreq * ncsMemMap["nb_valid"][stop - 1])
219221
ncsSects.sects.append(
220222
NcsSection(
221223
startRec=start,
222224
startTime=ncsMemMap["timestamp"][start],
223-
endRec=stop-1,
224-
endTime=ncsMemMap["timestamp"][stop-1] + duration,
225-
n_samples=np.sum(ncsMemMap["nb_valid"][start:stop])
225+
endRec=stop - 1,
226+
endTime=ncsMemMap["timestamp"][stop - 1] + duration,
227+
n_samples=np.sum(ncsMemMap["nb_valid"][start:stop]),
226228
)
227229
)
228230

@@ -274,7 +276,6 @@ def build_for_ncs_file(ncsMemMap, nlxHdr, gapTolerance=None, strict_gap_mode=Tru
274276
# quarter of paquet size is tolerate
275277
gapTolerance = round(0.25 * NcsSection._RECORD_SIZE * 1e6 / freq)
276278
ncsSects = NcsSectionsFactory._buildNcsSections(ncsMemMap, freq, gapTolerance=gapTolerance)
277-
278279

279280
# take longer data block to compute reaal sampling rate
280281
# ind_max = np.argmax([section.n_samples for section in ncsSects.sects])
@@ -292,7 +293,6 @@ def build_for_ncs_file(ncsMemMap, nlxHdr, gapTolerance=None, strict_gap_mode=Tru
292293
ncsSects.sampFreqUsed = sampFreqUsed
293294
ncsSects.microsPerSampUsed = NcsSectionsFactory.get_micros_per_samp_for_freq(sampFreqUsed)
294295

295-
296296
elif acqType == "BML" or acqType == "ATLAS":
297297
# BML & ATLAS style with fractional frequency and micros per samp
298298
if strict_gap_mode:
@@ -305,7 +305,6 @@ def build_for_ncs_file(ncsMemMap, nlxHdr, gapTolerance=None, strict_gap_mode=Tru
305305
ncsSects.sampFreqUsed = freq
306306
ncsSects.microsPerSampUsed = NcsSectionsFactory.get_micros_per_samp_for_freq(freq)
307307

308-
309308
else:
310309
raise TypeError("Unknown Ncs file type from header.")
311310

neo/rawio/neuralynxrawio/neuralynxrawio.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ class NeuralynxRawIO(BaseRawIO):
8787
Otherwise set 0 of time to first time in dataset
8888
strict_gap_mode: bool, default: True
8989
Detect gaps using strict mode or not.
90-
* strict_gap_mode = True then a gap is consider when timstamp difference between two
90+
* strict_gap_mode = True then a gap is consider when timstamp difference between two
9191
consequtive data packet is more than one sample interval.
9292
* strict_gap_mode = False then a gap has an increased tolerance. Some new system with different clock need this option
9393
otherwise, too many gaps are detected
94-
94+
9595
Notes
9696
-----
9797
* This IO supports NCS, NEV, NSE and NTT file formats (not NVT or NRD yet)
@@ -131,7 +131,9 @@ class NeuralynxRawIO(BaseRawIO):
131131
("samples", "int16", (NcsSection._RECORD_SIZE)),
132132
]
133133

134-
def __init__(self, dirname="", filename="", exclude_filename=None, keep_original_times=False, strict_gap_mode=True, **kargs):
134+
def __init__(
135+
self, dirname="", filename="", exclude_filename=None, keep_original_times=False, strict_gap_mode=True, **kargs
136+
):
135137

136138
if dirname != "":
137139
self.dirname = dirname
@@ -797,7 +799,9 @@ def scan_stream_ncs_files(self, ncs_filenames):
797799

798800
verify_sec_struct = NcsSectionsFactory._verifySectionsStructure
799801
if not chanSectMap or (not verify_sec_struct(data, chan_ncs_sections)):
800-
chan_ncs_sections = NcsSectionsFactory.build_for_ncs_file(data, nlxHeader, strict_gap_mode=self.strict_gap_mode)
802+
chan_ncs_sections = NcsSectionsFactory.build_for_ncs_file(
803+
data, nlxHeader, strict_gap_mode=self.strict_gap_mode
804+
)
801805

802806
# register file section structure for all contained channels
803807
for chan_uid in zip(nlxHeader["channel_names"], np.asarray(nlxHeader["channel_ids"], dtype=str)):

neo/test/rawiotest/test_neuralynxrawio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def test_build_given_actual_frequency(self):
228228
ncsBlocks = NcsSections()
229229
ncsBlocks.sampFreqUsed = 1 / (35e-6)
230230
ncsBlocks.microsPerSampUsed = 35
231-
231+
232232
ncsBlocks = NcsSectionsFactory._buildNcsSections(data0, ncsBlocks.sampFreqUsed)
233233

234234
self.assertEqual(len(ncsBlocks.sects), 1)
@@ -324,7 +324,7 @@ class TestNcsSections(TestNeuralynxRawIO, unittest.TestCase):
324324
"""
325325
Test building NcsBlocks for files of different revisions.
326326
"""
327-
327+
328328
entities_to_test = []
329329

330330
def test_equality(self):

0 commit comments

Comments
 (0)