edfcore 0.2.20 → 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 +21 -0
- package/dist/annotations-query.d.ts.map +1 -1
- package/dist/annotations-query.js +4 -1
- package/dist/annotations-query.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/header/lookup.d.ts +16 -0
- package/dist/header/lookup.d.ts.map +1 -1
- package/dist/header/lookup.js +25 -1
- package/dist/header/lookup.js.map +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/annotations-query.ts +4 -1
- package/src/constants.ts +1 -1
- package/src/header/lookup.ts +26 -1
- package/src/recording.ts +7 -1
- package/src/stream.ts +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,27 @@ 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
|
+
|
|
19
|
+
## 0.2.21
|
|
20
|
+
|
|
21
|
+
- **Fixed** `matchSignals` and `filterAnnotationsByText` returning roughly half their matches when
|
|
22
|
+
the caller's `RegExp` carried a `g` or `y` flag. `RegExp.prototype.test` starts from `lastIndex`
|
|
23
|
+
and advances it with those flags, so across an array each element's answer depended on what the
|
|
24
|
+
previous one matched: four EEG channels and `/^EEG/g` gave back the first and the third. Even a
|
|
25
|
+
match-everything pattern stopped returning every signal once it carried the flag, and a second
|
|
26
|
+
call with the same regex object gave a different answer than the first. A `g` flag on a
|
|
27
|
+
membership test means nothing, so both now test against a clone with `lastIndex` reset — cloned
|
|
28
|
+
rather than reset in place, so a shared module-level regex is never mutated.
|
|
29
|
+
|
|
9
30
|
## 0.2.20
|
|
10
31
|
|
|
11
32
|
- **Fixed** `filterAnnotationsByTime` dropping an annotation whose duration was written as an
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotations-query.d.ts","sourceRoot":"","sources":["../src/annotations-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
1
|
+
{"version":3,"file":"annotations-query.d.ts","sourceRoot":"","sources":["../src/annotations-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAErE;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,SAAS,aAAa,EAAE,EACrC,MAAM,EAAE,mBAAmB,GAC1B,SAAS,aAAa,EAAE,CAsB1B;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,SAAS,aAAa,EAAE,EACrC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,GACnD,SAAS,aAAa,EAAE,CAU1B;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,SAAS,aAAa,EAAE,GACpC,aAAa,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAQlE;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,WAAW,EAAE,SAAS,aAAa,EAAE,EACrC,OAAO,EAAE,MAAM,GACd,SAAS,aAAa,EAAE,CAS1B"}
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* one puts events in the neighbouring window on exactly the files that bother to state their
|
|
19
19
|
* offset.
|
|
20
20
|
*/
|
|
21
|
+
import { matchesText } from './header/lookup.js';
|
|
21
22
|
import { secondsToTicks } from './tal/ticks.js';
|
|
22
23
|
/**
|
|
23
24
|
* The annotations that overlap a time window, in the recording's own timebase.
|
|
@@ -60,7 +61,9 @@ export function filterAnnotationsByText(annotations, match) {
|
|
|
60
61
|
const test = typeof match === 'string'
|
|
61
62
|
? (text) => text === match
|
|
62
63
|
: match instanceof RegExp
|
|
63
|
-
?
|
|
64
|
+
? // Not `match.test` directly: a `g` or `y` flag makes `test` stateful across the array
|
|
65
|
+
// and silently returns about half the true matches. See `matchesText`.
|
|
66
|
+
matchesText(match)
|
|
64
67
|
: match;
|
|
65
68
|
return Object.freeze(annotations.filter((annotation) => test(annotation.text)));
|
|
66
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotations-query.js","sourceRoot":"","sources":["../src/annotations-query.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CACrC,WAAqC,EACrC,MAA2B;IAE3B,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACjD,MAAM,EAAE,GAAG,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IACzD,IAAI,EAAE,IAAI,IAAI;QAA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,EAAkB,CAAC;IACzC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CACxF,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAC3B,WAAqC,EACrC,OAAe;IAEf,MAAM,EAAE,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACnC,OAAO,MAAM,CAAC,MAAM,CAClB,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;QAChC,MAAM,KAAK,GAAG,UAAU,CAAC,yBAAyB,CAAC;QACnD,MAAM,QAAQ,GAAG,UAAU,CAAC,aAAa,IAAI,EAAE,CAAC;QAChD,OAAO,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,IAAI,EAAE,GAAG,KAAK,GAAG,QAAQ,CAAC;IAC/E,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
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/header/lookup.d.ts
CHANGED
|
@@ -30,6 +30,22 @@ export declare function findSignals(header: EdfHeader, label: string): readonly
|
|
|
30
30
|
* edfcore could return that would not be a guess.
|
|
31
31
|
*/
|
|
32
32
|
export declare function getSignal(header: EdfHeader, selector: number | string): EdfSignal;
|
|
33
|
+
/**
|
|
34
|
+
* A membership test over a caller's RegExp that cannot be poisoned by its own flags.
|
|
35
|
+
*
|
|
36
|
+
* `RegExp.prototype.test` is STATEFUL when the pattern carries `g` or `y`: it starts from
|
|
37
|
+
* `lastIndex` and advances it on every match. Used across an array — which is what every filter
|
|
38
|
+
* here does — that makes the result depend on what the previous element matched, so `/EEG/g` over
|
|
39
|
+
* four EEG channels returns the first and third and silently drops the other two. The caller sees
|
|
40
|
+
* half a montage with no error, and even a match-everything pattern stops returning every signal
|
|
41
|
+
* once it carries the flag.
|
|
42
|
+
*
|
|
43
|
+
* A `g` flag on a membership test means nothing, so honouring its statefulness serves no one. The
|
|
44
|
+
* regex is CLONED rather than reset in place: resetting the caller's object would mutate an
|
|
45
|
+
* argument, and a module-level `const PATTERN = /x/g` shared with a `String.replace` elsewhere
|
|
46
|
+
* would then behave differently depending on whether edfcore had been called first.
|
|
47
|
+
*/
|
|
48
|
+
export declare function matchesText(match: RegExp): (text: string) => boolean;
|
|
33
49
|
/**
|
|
34
50
|
* Every data signal whose label matches a pattern.
|
|
35
51
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../src/header/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO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AAE,MAAM,KAAK,OAAO,CAAC,GAC3C,SAAS,SAAS,EAAE,CAKtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAEjE"}
|
package/dist/header/lookup.js
CHANGED
|
@@ -64,6 +64,30 @@ export function getSignal(header, selector) {
|
|
|
64
64
|
'first is how the wrong channel ends up in a paper. Next: call findSignals() to get them ' +
|
|
65
65
|
'all, or select by index.', { label: trimEdfField(selector), matchingIndices });
|
|
66
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* A membership test over a caller's RegExp that cannot be poisoned by its own flags.
|
|
69
|
+
*
|
|
70
|
+
* `RegExp.prototype.test` is STATEFUL when the pattern carries `g` or `y`: it starts from
|
|
71
|
+
* `lastIndex` and advances it on every match. Used across an array — which is what every filter
|
|
72
|
+
* here does — that makes the result depend on what the previous element matched, so `/EEG/g` over
|
|
73
|
+
* four EEG channels returns the first and third and silently drops the other two. The caller sees
|
|
74
|
+
* half a montage with no error, and even a match-everything pattern stops returning every signal
|
|
75
|
+
* once it carries the flag.
|
|
76
|
+
*
|
|
77
|
+
* A `g` flag on a membership test means nothing, so honouring its statefulness serves no one. The
|
|
78
|
+
* regex is CLONED rather than reset in place: resetting the caller's object would mutate an
|
|
79
|
+
* argument, and a module-level `const PATTERN = /x/g` shared with a `String.replace` elsewhere
|
|
80
|
+
* would then behave differently depending on whether edfcore had been called first.
|
|
81
|
+
*/
|
|
82
|
+
export function matchesText(match) {
|
|
83
|
+
const pattern = new RegExp(match.source, match.flags);
|
|
84
|
+
return (text) => {
|
|
85
|
+
// `y` anchors at `lastIndex`, so this also makes a sticky pattern test from the start of each
|
|
86
|
+
// string rather than from wherever the previous element left off.
|
|
87
|
+
pattern.lastIndex = 0;
|
|
88
|
+
return pattern.test(text);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
67
91
|
/**
|
|
68
92
|
* Every data signal whose label matches a pattern.
|
|
69
93
|
*
|
|
@@ -77,7 +101,7 @@ export function getSignal(header, selector) {
|
|
|
77
101
|
* exact-match case `findSignals` already covers.
|
|
78
102
|
*/
|
|
79
103
|
export function matchSignals(header, match) {
|
|
80
|
-
const test = match instanceof RegExp ? (
|
|
104
|
+
const test = match instanceof RegExp ? matchesText(match) : match;
|
|
81
105
|
return Object.freeze(header.signals.filter((signal) => signal.kind === 'data' && test(signal.label)));
|
|
82
106
|
}
|
|
83
107
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../src/header/lookup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAGjF;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,MAAM,OAAO,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,OAAO,KAAK,qBAAqB,IAAI,OAAO,KAAK,qBAAqB,CAAC;AAChF,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,WAAW,CAAC,MAAiB,EAAE,KAAa;IAC1D,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACnC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC;AACnF,CAAC;AAED,SAAS,WAAW,CAAC,MAAiB;IACpC,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAA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AuB,CAAC,MAAiB;IACvD,OAAO,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,qBAAqB,CAAC;AAC3D,CAAC"}
|
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,EAA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AAE,OAAO,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,E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import { matchesText } from './header/lookup.js';
|
|
22
23
|
import { secondsToTicks } from './tal/ticks.js';
|
|
23
24
|
import type { EdfAnnotation, EdfAnnotationWindow } from './types.js';
|
|
24
25
|
|
|
@@ -73,7 +74,9 @@ export function filterAnnotationsByText(
|
|
|
73
74
|
typeof match === 'string'
|
|
74
75
|
? (text: string): boolean => text === match
|
|
75
76
|
: match instanceof RegExp
|
|
76
|
-
?
|
|
77
|
+
? // Not `match.test` directly: a `g` or `y` flag makes `test` stateful across the array
|
|
78
|
+
// and silently returns about half the true matches. See `matchesText`.
|
|
79
|
+
matchesText(match)
|
|
77
80
|
: match;
|
|
78
81
|
return Object.freeze(annotations.filter((annotation) => test(annotation.text)));
|
|
79
82
|
}
|
package/src/constants.ts
CHANGED
package/src/header/lookup.ts
CHANGED
|
@@ -80,6 +80,31 @@ export function getSignal(header: EdfHeader, selector: number | string): EdfSign
|
|
|
80
80
|
);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
/**
|
|
84
|
+
* A membership test over a caller's RegExp that cannot be poisoned by its own flags.
|
|
85
|
+
*
|
|
86
|
+
* `RegExp.prototype.test` is STATEFUL when the pattern carries `g` or `y`: it starts from
|
|
87
|
+
* `lastIndex` and advances it on every match. Used across an array — which is what every filter
|
|
88
|
+
* here does — that makes the result depend on what the previous element matched, so `/EEG/g` over
|
|
89
|
+
* four EEG channels returns the first and third and silently drops the other two. The caller sees
|
|
90
|
+
* half a montage with no error, and even a match-everything pattern stops returning every signal
|
|
91
|
+
* once it carries the flag.
|
|
92
|
+
*
|
|
93
|
+
* A `g` flag on a membership test means nothing, so honouring its statefulness serves no one. The
|
|
94
|
+
* regex is CLONED rather than reset in place: resetting the caller's object would mutate an
|
|
95
|
+
* argument, and a module-level `const PATTERN = /x/g` shared with a `String.replace` elsewhere
|
|
96
|
+
* would then behave differently depending on whether edfcore had been called first.
|
|
97
|
+
*/
|
|
98
|
+
export function matchesText(match: RegExp): (text: string) => boolean {
|
|
99
|
+
const pattern = new RegExp(match.source, match.flags);
|
|
100
|
+
return (text: string): boolean => {
|
|
101
|
+
// `y` anchors at `lastIndex`, so this also makes a sticky pattern test from the start of each
|
|
102
|
+
// string rather than from wherever the previous element left off.
|
|
103
|
+
pattern.lastIndex = 0;
|
|
104
|
+
return pattern.test(text);
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
83
108
|
/**
|
|
84
109
|
* Every data signal whose label matches a pattern.
|
|
85
110
|
*
|
|
@@ -96,7 +121,7 @@ export function matchSignals(
|
|
|
96
121
|
header: EdfHeader,
|
|
97
122
|
match: RegExp | ((label: string) => boolean),
|
|
98
123
|
): readonly EdfSignal[] {
|
|
99
|
-
const test = match instanceof RegExp ? (
|
|
124
|
+
const test = match instanceof RegExp ? matchesText(match) : match;
|
|
100
125
|
return Object.freeze(
|
|
101
126
|
header.signals.filter((signal) => signal.kind === 'data' && test(signal.label)),
|
|
102
127
|
);
|
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,
|