edfcore 0.2.21 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/recording.d.ts +12 -1
- package/dist/recording.d.ts.map +1 -1
- package/dist/recording.js +4 -1
- package/dist/recording.js.map +1 -1
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +8 -1
- package/dist/stream.js.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/recording.ts +7 -1
- package/src/stream.ts +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,16 @@ alone does not tell you whether you were affected.
|
|
|
6
6
|
edfcore is pre-1.0. Patch releases have carried behaviour changes where the old behaviour was a
|
|
7
7
|
defect; those are called out below.
|
|
8
8
|
|
|
9
|
+
## 0.2.22
|
|
10
|
+
|
|
11
|
+
- **Fixed** `streamRecords` skipping the signal validation `readWindow` and `readEnvelope` both do
|
|
12
|
+
before resolving the window. It validated `chunkRecords` and not `signalIndices`, and
|
|
13
|
+
`readRecords` — where the check lived — only ran once the window resolved to at least one
|
|
14
|
+
record. So a window past the end, one inside an EDF+D gap, or one of zero duration reported a
|
|
15
|
+
non-existent channel, or the annotations channel, as "no data here". Both siblings carry a
|
|
16
|
+
comment explaining that a caller mistake is a caller mistake wherever the window lands; this was
|
|
17
|
+
the third one, and the odd one out. A valid selection over an empty window still yields nothing.
|
|
18
|
+
|
|
9
19
|
## 0.2.21
|
|
10
20
|
|
|
11
21
|
- **Fixed** `matchSignals` and `filterAnnotationsByText` returning roughly half their matches when
|
package/dist/constants.d.ts
CHANGED
|
@@ -109,5 +109,5 @@ export declare const SIGNAL_FIELD_BLOCK_OFFSETS: {
|
|
|
109
109
|
readonly reserved: 224;
|
|
110
110
|
};
|
|
111
111
|
/** Published package version. Kept in sync with package.json by a test. */
|
|
112
|
-
export declare const VERSION = "0.2.
|
|
112
|
+
export declare const VERSION = "0.2.22";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
package/dist/recording.d.ts
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* already read — annotation regions live inside those bytes, so this costs no extra I/O and makes
|
|
21
21
|
* a sparsely indexed file safe for the data you actually received.
|
|
22
22
|
*/
|
|
23
|
-
import type { ByteSource, DecodeAnnotationsOptions, EdfAnnotationsResult, EdfChunk, EdfGap, EdfRecordIndex, EdfRecording, OpenOptions, ReadOptions, RecordRange, RecordSelection, WindowSelection } from './types.js';
|
|
23
|
+
import type { ByteSource, DecodeAnnotationsOptions, EdfAnnotationsResult, EdfChunk, EdfGap, EdfHeader, EdfRecordIndex, EdfRecording, EdfSignal, OpenOptions, ReadOptions, RecordRange, RecordSelection, WindowSelection } from './types.js';
|
|
24
24
|
/**
|
|
25
25
|
* Open a recording: the header, then the timeline.
|
|
26
26
|
*
|
|
@@ -28,6 +28,17 @@ import type { ByteSource, DecodeAnnotationsOptions, EdfAnnotationsResult, EdfChu
|
|
|
28
28
|
* it is two more, probing the first and last records for their timekeeping onsets.
|
|
29
29
|
*/
|
|
30
30
|
export declare function openEdf(source: ByteSource, options?: OpenOptions): Promise<EdfRecording>;
|
|
31
|
+
/**
|
|
32
|
+
* The signals to decode, deduplicated and in the order given.
|
|
33
|
+
*
|
|
34
|
+
* An annotation signal is refused with a plain `RangeError` rather than an `EdfError`: its bytes
|
|
35
|
+
* are TAL text, and decoding them as samples produces numbers that look exactly like a signal.
|
|
36
|
+
* That is the failure this library exists to prevent, and it can only ever be a caller's mistake.
|
|
37
|
+
*
|
|
38
|
+
* Exported for `stream.ts`, which must produce the byte-identical refusal `readWindow` does — not
|
|
39
|
+
* for the barrel. Validating a selection is not a public operation.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveSignals(header: EdfHeader, signalIndices: readonly number[]): readonly EdfSignal[];
|
|
31
42
|
/**
|
|
32
43
|
* The gap immediately before `recordStart`, when the index knows where the gaps are.
|
|
33
44
|
*
|
package/dist/recording.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recording.d.ts","sourceRoot":"","sources":["../src/recording.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAUH,OAAO,KAAK,EACV,UAAU,EACV,wBAAwB,EACxB,oBAAoB,EACpB,QAAQ,EAER,MAAM,
|
|
1
|
+
{"version":3,"file":"recording.d.ts","sourceRoot":"","sources":["../src/recording.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAUH,OAAO,KAAK,EACV,UAAU,EACV,wBAAwB,EACxB,oBAAoB,EACpB,QAAQ,EAER,MAAM,EACN,SAAS,EACT,cAAc,EACd,YAAY,EACZ,SAAS,EACT,WAAW,EACX,WAAW,EACX,WAAW,EACX,eAAe,EACf,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAI9F;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,SAAS,EACjB,aAAa,EAAE,SAAS,MAAM,EAAE,GAC/B,SAAS,SAAS,EAAE,CA2BtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQxF;AAuED,kGAAkG;AAClG,wBAAsB,WAAW,CAC/B,SAAS,EAAE,YAAY,EACvB,SAAS,EAAE,eAAe,EAC1B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,QAAQ,CAAC,CAEnB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,UAAU,CAC9B,SAAS,EAAE,YAAY,EACvB,SAAS,EAAE,eAAe,EAC1B,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,SAAS,QAAQ,EAAE,CAAC,CA2B9B;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,wBAAwB,GAAG,WAAW,GAC/C,OAAO,CAAC,oBAAoB,CAAC,CAG/B"}
|
package/dist/recording.js
CHANGED
|
@@ -45,8 +45,11 @@ export async function openEdf(source, options) {
|
|
|
45
45
|
* An annotation signal is refused with a plain `RangeError` rather than an `EdfError`: its bytes
|
|
46
46
|
* are TAL text, and decoding them as samples produces numbers that look exactly like a signal.
|
|
47
47
|
* That is the failure this library exists to prevent, and it can only ever be a caller's mistake.
|
|
48
|
+
*
|
|
49
|
+
* Exported for `stream.ts`, which must produce the byte-identical refusal `readWindow` does — not
|
|
50
|
+
* for the barrel. Validating a selection is not a public operation.
|
|
48
51
|
*/
|
|
49
|
-
function resolveSignals(header, signalIndices) {
|
|
52
|
+
export function resolveSignals(header, signalIndices) {
|
|
50
53
|
const seen = new Set();
|
|
51
54
|
const signals = [];
|
|
52
55
|
for (const signalIndex of signalIndices) {
|
package/dist/recording.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recording.js","sourceRoot":"","sources":["../src/recording.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,yBAA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AO,EAAE,OAAO,CAAC,CAAC;IAC1F,OAAO,iBAAiB,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AACtE,CAAC"}
|
package/dist/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAe,eAAe,EAAE,MAAM,YAAY,CAAC;AAKpG;;;;;;;GAOG;AACH,wBAAuB,aAAa,CAClC,SAAS,EAAE,YAAY,EACvB,SAAS,EAAE,eAAe,EAC1B,OAAO,CAAC,EAAE,WAAW,GACpB,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAe,eAAe,EAAE,MAAM,YAAY,CAAC;AAKpG;;;;;;;GAOG;AACH,wBAAuB,aAAa,CAClC,SAAS,EAAE,YAAY,EACvB,SAAS,EAAE,eAAe,EAC1B,OAAO,CAAC,EAAE,WAAW,GACpB,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC,CAyC3C"}
|
package/dist/stream.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* Chunks arrive in time order, never span a gap, and carry the same `precededByGap` a
|
|
13
13
|
* `readWindow` chunk would, so a consumer sees the discontinuities rather than a smooth lie.
|
|
14
14
|
*/
|
|
15
|
-
import { readRecords } from './recording.js';
|
|
15
|
+
import { readRecords, resolveSignals } from './recording.js';
|
|
16
16
|
import { resolveTimeWindow } from './time/window.js';
|
|
17
17
|
/** How many records to read at a time when the caller does not say. */
|
|
18
18
|
const DEFAULT_STREAM_RECORDS = 256;
|
|
@@ -30,6 +30,13 @@ export async function* streamRecords(recording, selection, options) {
|
|
|
30
30
|
throw new RangeError(`streamRecords(): chunkRecords must be a positive whole number, received ${chunkRecords}. ` +
|
|
31
31
|
'Next: omit it for the default, or pass how many records you want to hold at once.');
|
|
32
32
|
}
|
|
33
|
+
// Validated BEFORE the window is resolved, for the reason `readWindow` and `readEnvelope` both
|
|
34
|
+
// state: a caller mistake is a caller mistake wherever the window lands. Resolving first meant
|
|
35
|
+
// that a window past the end, one inside an EDF+D gap, or one of zero duration produced no
|
|
36
|
+
// records, so `readRecords` never ran, so a signal index that does not exist — or the
|
|
37
|
+
// annotations channel, the refusal this library exists for — was reported as "no data here".
|
|
38
|
+
// Every other selection error in the package surfaces on the spot; this one waited for data.
|
|
39
|
+
resolveSignals(recording.header, selection.signalIndices);
|
|
33
40
|
const ranges = resolveTimeWindow(recording.timeline, recording.index, selection.startSeconds, selection.durationSeconds);
|
|
34
41
|
for (const run of ranges) {
|
|
35
42
|
let scanned = 0;
|
package/dist/stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,uEAAuE;AACvE,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAEnC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,aAAa,CAClC,SAAuB,EACvB,SAA0B,EAC1B,OAAqB;IAErB,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY,IAAI,sBAAsB,CAAC;IACtE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;QAC5D,MAAM,IAAI,UAAU,CAClB,2EAA2E,YAAY,IAAI;YACzF,mFAAmF,CACtF,CAAC;IACJ,CAAC;IAED,+FAA+F;IAC/F,+FAA+F;IAC/F,2FAA2F;IAC3F,sFAAsF;IACtF,6FAA6F;IAC7F,6FAA6F;IAC7F,cAAc,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,aAAa,CAAC,CAAC;IAE1D,MAAM,MAAM,GAAG,iBAAiB,CAC9B,SAAS,CAAC,QAAQ,EAClB,SAAS,CAAC,KAAK,EACf,SAAS,CAAC,YAAY,EACtB,SAAS,CAAC,eAAe,CAC1B,CAAC;IAEF,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,OAAO,OAAO,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC;YAC3B,MAAM,OAAO,GAAgB;gBAC3B,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,OAAO;gBAC1B,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC;aACnD,CAAC;YACF,0FAA0F;YAC1F,4FAA4F;YAC5F,MAAM,MAAM,WAAW,CACrB,SAAS,EACT,EAAE,aAAa,EAAE,SAAS,CAAC,aAAa,EAAE,OAAO,EAAE,EACnD,OAAO,CACR,CAAC;YACF,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC;QAC3B,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
package/src/recording.ts
CHANGED
|
@@ -65,8 +65,14 @@ export async function openEdf(source: ByteSource, options?: OpenOptions): Promis
|
|
|
65
65
|
* An annotation signal is refused with a plain `RangeError` rather than an `EdfError`: its bytes
|
|
66
66
|
* are TAL text, and decoding them as samples produces numbers that look exactly like a signal.
|
|
67
67
|
* That is the failure this library exists to prevent, and it can only ever be a caller's mistake.
|
|
68
|
+
*
|
|
69
|
+
* Exported for `stream.ts`, which must produce the byte-identical refusal `readWindow` does — not
|
|
70
|
+
* for the barrel. Validating a selection is not a public operation.
|
|
68
71
|
*/
|
|
69
|
-
function resolveSignals(
|
|
72
|
+
export function resolveSignals(
|
|
73
|
+
header: EdfHeader,
|
|
74
|
+
signalIndices: readonly number[],
|
|
75
|
+
): readonly EdfSignal[] {
|
|
70
76
|
const seen = new Set<number>();
|
|
71
77
|
const signals: EdfSignal[] = [];
|
|
72
78
|
for (const signalIndex of signalIndices) {
|
package/src/stream.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* `readWindow` chunk would, so a consumer sees the discontinuities rather than a smooth lie.
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import { readRecords } from './recording.js';
|
|
16
|
+
import { readRecords, resolveSignals } from './recording.js';
|
|
17
17
|
import { resolveTimeWindow } from './time/window.js';
|
|
18
18
|
import type { EdfChunk, EdfRecording, ReadOptions, RecordRange, StreamSelection } from './types.js';
|
|
19
19
|
|
|
@@ -41,6 +41,14 @@ export async function* streamRecords(
|
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
// Validated BEFORE the window is resolved, for the reason `readWindow` and `readEnvelope` both
|
|
45
|
+
// state: a caller mistake is a caller mistake wherever the window lands. Resolving first meant
|
|
46
|
+
// that a window past the end, one inside an EDF+D gap, or one of zero duration produced no
|
|
47
|
+
// records, so `readRecords` never ran, so a signal index that does not exist — or the
|
|
48
|
+
// annotations channel, the refusal this library exists for — was reported as "no data here".
|
|
49
|
+
// Every other selection error in the package surfaces on the spot; this one waited for data.
|
|
50
|
+
resolveSignals(recording.header, selection.signalIndices);
|
|
51
|
+
|
|
44
52
|
const ranges = resolveTimeWindow(
|
|
45
53
|
recording.timeline,
|
|
46
54
|
recording.index,
|