Skip to content

Commit d9c8683

Browse files
authored
Merge pull request #1424 from PeterNSteinmetz/docPurposeNcsSections
Document the purpose of NcsSections module.
2 parents 40b3e31 + 5b8898e commit d9c8683

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

neo/rawio/neuralynxrawio/ncssections.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
"""
2+
Objects to represent continguous sections of samples in a Neuralynx continuously sampled .Ncs
3+
file. These sections are considered contiguous in that they have a start time, a sampling rate,
4+
and a length.
5+
6+
Defining these sections is complicated due to the physical structure of .Ncs files which contain
7+
both a header and a set of fixed length records, CscRecords.
8+
9+
Each CscRecord has a start time in microseconds, a channel id (chan_id), a stated sampling
10+
frequency (sampFreq) which is rounded to the whole sample/s, and a number of valid samples
11+
(nb_valid), which may be less than the physical maximum of 512. In principle each of these
12+
parameters may vary in each record in the file; however, there are no known examples of .Ncs
13+
files where the chan_id or sampFreq varied from record to record.
14+
15+
The header normally, though not always, contains a stated sampling frequency, which may be
16+
rounded to a whole number of samples per second or not.
17+
18+
Finally, the actual sampling frequency used within a section may be slightly different than any of
19+
the two frequencies above (that in the records or that in the header). This often arises due to
20+
clock drift over the course of a longer recording combined with the fact that only whole
21+
microseconds are recorded in the CscRecords. This can easily be 0.01% amounting to 0.2 seconds over
22+
the course of a half hour recording.
23+
24+
These files may often contain apparent gaps of time between the sequential CscRecords in a file.
25+
A gap is where the predicted time at the start of the next record, based on taking the start time
26+
of the record and then adding 1/sampling rate x nbValid, does not agree exactly with the start time
27+
given in the next record.
28+
29+
These gaps vary from those of less than one microsecond, likely due to rounding of the start time,
30+
to gaps of many minutes, which may be introduced by the human operator stopping and starting
31+
recording during a recording session.
32+
33+
The challenge addressed by the NcsSectionsFactory of this module is to separate those intended
34+
gaps from those introduced by a quirk of the hardware, recording software, or file format.
35+
"""
136
import math
237
import numpy as np
338

0 commit comments

Comments
 (0)