edfcore 0.6.24 → 0.6.26
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/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/format-annotations.d.ts.map +1 -1
- package/dist/format-annotations.js +27 -3
- package/dist/format-annotations.js.map +1 -1
- package/dist/header/variant.d.ts.map +1 -1
- package/dist/header/variant.js +36 -2
- package/dist/header/variant.js.map +1 -1
- package/docs/CHANGELOG.md +40 -0
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/format-annotations.ts +28 -3
- package/src/header/variant.ts +37 -2
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.6.
|
|
112
|
+
export declare const VERSION = "0.6.26";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-annotations.d.ts","sourceRoot":"","sources":["../src/format-annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,2FAA2F;IAC3F,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,kGAAkG;IAClG,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;AA0CD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,SAAS,aAAa,EAAE,EACrC,OAAO,CAAC,EAAE,wBAAwB,GACjC,MAAM,
|
|
1
|
+
{"version":3,"file":"format-annotations.d.ts","sourceRoot":"","sources":["../src/format-annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,2FAA2F;IAC3F,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,kGAAkG;IAClG,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;AA0CD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,SAAS,aAAa,EAAE,EACrC,OAAO,CAAC,EAAE,wBAAwB,GACjC,MAAM,CAsDR"}
|
|
@@ -65,18 +65,42 @@ export function formatAnnotations(annotations, options) {
|
|
|
65
65
|
if (annotations.length === 0)
|
|
66
66
|
return '';
|
|
67
67
|
const limit = requireItemLimit(options?.maxItems, annotations.length);
|
|
68
|
-
|
|
68
|
+
/*
|
|
69
|
+
* Both time columns are sized from the rows being printed, the way `formatHeader` sizes its
|
|
70
|
+
* index column, because both can hold a value wider than a fixed width.
|
|
71
|
+
*
|
|
72
|
+
* `hh:mm:ss.mmm` is twelve characters until it is not. A negative onset spends one on the sign —
|
|
73
|
+
* `-00:00:01.500`, which the note at the top of this file argues is legal and which 0.3.45
|
|
74
|
+
* exists to print correctly — and the hours are deliberately not wrapped at 24, so a week of
|
|
75
|
+
* long-term monitoring reads `168:00:00.000`. Either one on one row of a listing moved the text
|
|
76
|
+
* column on that row and no other, and the onset column was not padded at all, so the misaligned
|
|
77
|
+
* row was usually the first: a pre-stimulus baseline sorts before everything (fixed in 0.6.25).
|
|
78
|
+
*
|
|
79
|
+
* Twelve is the floor, so a listing whose times all fit prints exactly what it printed before —
|
|
80
|
+
* including one where every event is instantaneous and every duration is empty.
|
|
81
|
+
*/
|
|
82
|
+
const cells = [];
|
|
69
83
|
for (let i = 0; i < limit; i += 1) {
|
|
70
84
|
const annotation = annotations[i];
|
|
71
85
|
if (annotation === undefined)
|
|
72
86
|
continue;
|
|
87
|
+
cells.push({
|
|
88
|
+
onset: clock(annotation.onsetTicksFromFirstRecord),
|
|
89
|
+
duration: duration(annotation),
|
|
90
|
+
annotation,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const onsetWidth = Math.max(12, ...cells.map((cell) => cell.onset.length));
|
|
94
|
+
const durationWidth = Math.max(12, ...cells.map((cell) => cell.duration.length));
|
|
95
|
+
const rows = [];
|
|
96
|
+
for (const { onset, duration: span, annotation } of cells) {
|
|
73
97
|
// Annotation text is exposed verbatim by design — the TAL grammar reserves 0x00, 0x14 and
|
|
74
98
|
// 0x15 and nothing else, so 0x0a and 0x09 reach `text` unchanged. One event holding a newline
|
|
75
99
|
// would print as two rows, and the second would carry no time of its own, so it reads as an
|
|
76
100
|
// event at the time above it. `annotation.text` still holds the bytes as written.
|
|
77
101
|
const parts = [
|
|
78
|
-
|
|
79
|
-
|
|
102
|
+
onset.padEnd(onsetWidth),
|
|
103
|
+
span.padEnd(durationWidth),
|
|
80
104
|
printable(annotation.text),
|
|
81
105
|
];
|
|
82
106
|
if (options?.includeChannel === true && annotation.channelLabel !== undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-annotations.js","sourceRoot":"","sources":["../src/format-annotations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAehD,MAAM,qBAAqB,GAAG,gBAAgB,GAAG,KAAK,CAAC;AAEvD;;;;;;GAMG;AACH,SAAS,KAAK,CAAC,KAAa;IAC1B,2FAA2F;IAC3F,gGAAgG;IAChG,gGAAgG;IAChG,6FAA6F;IAC7F,wFAAw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gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAKhF;AA8CD;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,GAAG,cAAc,CAqG3F"}
|
package/dist/header/variant.js
CHANGED
|
@@ -70,6 +70,35 @@ export function reservedMarkerOf(reserved) {
|
|
|
70
70
|
}
|
|
71
71
|
return undefined;
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* The containers whose first bytes are already in hand when `NOT_AN_EDF_FILE` is thrown.
|
|
75
|
+
*
|
|
76
|
+
* That message's `Next:` clause has always said "a gzip, zip or vendor container has to be
|
|
77
|
+
* unpacked before edfcore sees it" — a menu, offered while holding the two bytes that say which
|
|
78
|
+
* one it is. `1f 8b` is a gzip and nothing else, and a reader who has just been handed the hex is
|
|
79
|
+
* being asked to look it up.
|
|
80
|
+
*
|
|
81
|
+
* Only the archive formats, and only by their magic number. Naming a container is a fact about the
|
|
82
|
+
* first bytes; guessing at a vendor's binary EEG format from the same two bytes would be a claim
|
|
83
|
+
* about the whole file, and the generic clause still covers those.
|
|
84
|
+
*/
|
|
85
|
+
const CONTAINERS = [
|
|
86
|
+
['a gzip', [0x1f, 0x8b]],
|
|
87
|
+
['a zip', [0x50, 0x4b, 0x03, 0x04]],
|
|
88
|
+
['an empty zip', [0x50, 0x4b, 0x05, 0x06]],
|
|
89
|
+
['a bzip2', [0x42, 0x5a, 0x68]],
|
|
90
|
+
['an xz', [0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00]],
|
|
91
|
+
['a zstd', [0x28, 0xb5, 0x2f, 0xfd]],
|
|
92
|
+
['a 7-Zip archive', [0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c]],
|
|
93
|
+
];
|
|
94
|
+
/** The container these bytes begin with, or `undefined` — which is most files. */
|
|
95
|
+
function containerAt(bytes) {
|
|
96
|
+
for (const [name, magic] of CONTAINERS) {
|
|
97
|
+
if (magic.every((byte, at) => bytes[at] === byte))
|
|
98
|
+
return name;
|
|
99
|
+
}
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
73
102
|
function markerFamily(marker) {
|
|
74
103
|
return marker === 'EDF+C' || marker === 'EDF+D' ? 'EDF' : 'BDF';
|
|
75
104
|
}
|
|
@@ -98,14 +127,19 @@ export function detectVariant(headerBytes, sink) {
|
|
|
98
127
|
const isEdf = !isBdf && isEdfVersionBlock(versionBytes);
|
|
99
128
|
if (!isBdf && !isEdf) {
|
|
100
129
|
const raw = readAsciiField(headerBytes, HEADER_FIELDS.version.offset, HEADER_FIELDS.version.length);
|
|
130
|
+
const container = containerAt(headerBytes);
|
|
101
131
|
throw fatalError({
|
|
102
132
|
code: 'NOT_AN_EDF_FILE',
|
|
103
133
|
message: `version field (8 bytes at offset ${HEADER_FIELDS.version.offset}) is ` +
|
|
104
134
|
`${JSON.stringify(raw)}, bytes ${hexBytes(versionBytes)}: this is neither EDF's ` +
|
|
105
135
|
`"0" followed by seven spaces nor BDF's 0xff followed by "BIOSEMI". ` +
|
|
136
|
+
(container === undefined ? '' : `Those first bytes are ${container}. `) +
|
|
106
137
|
'EDF specification, header record bytes 0-7 (version of this data format). ' +
|
|
107
|
-
|
|
108
|
-
|
|
138
|
+
(container === undefined
|
|
139
|
+
? 'Next: confirm the bytes are an uncompressed EDF or BDF recording — a gzip, zip or ' +
|
|
140
|
+
'vendor container has to be unpacked before edfcore sees it.'
|
|
141
|
+
: `Next: unpack ${container} and open the EDF or BDF file inside it — edfcore reads ` +
|
|
142
|
+
'recordings, not archives.'),
|
|
109
143
|
field: 'version',
|
|
110
144
|
byteOffset: HEADER_FIELDS.version.offset,
|
|
111
145
|
byteLength: HEADER_FIELDS.version.length,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variant.js","sourceRoot":"","sources":["../../src/header/variant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,E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CAAC,eAAe;KAC1E,CAAC;AACJ,CAAC"}
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,46 @@ 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.6.26
|
|
10
|
+
|
|
11
|
+
- **Changed** `NOT_AN_EDF_FILE` to say which archive it was handed, when the first bytes say so.
|
|
12
|
+
That message's `Next:` clause has always read "a gzip, zip or vendor container has to be unpacked
|
|
13
|
+
before edfcore sees it" — a menu, offered on the same line as the hex that answers it. `1f 8b` is
|
|
14
|
+
a gzip and nothing else, and the message printed those bytes and asked the reader to look them up.
|
|
15
|
+
- It is also the likeliest first meeting with this package. Recordings travel compressed —
|
|
16
|
+
PhysioNet ships `.zip`, teuniz.net ships `.zip`, a shared study arrives as `.gz` — so pointing
|
|
17
|
+
edfcore at the download rather than at what is inside it is the ordinary mistake, not an exotic
|
|
18
|
+
one. `edfcore header study.edf.gz` now says it is a gzip and to unpack it.
|
|
19
|
+
- Seven magic numbers: gzip, zip, an empty zip, bzip2, xz, zstd and 7-Zip. Archive formats only,
|
|
20
|
+
and only by magic number — naming a container is a fact about the first bytes, while guessing a
|
|
21
|
+
vendor's binary EEG format from two of them would be a claim about the whole file. Everything
|
|
22
|
+
unrecognised keeps the general advice, which `it-says-which-container.test.ts` checks with bytes
|
|
23
|
+
chosen to sit one value away from a magic number, because a table that matched everything would
|
|
24
|
+
be worse than the menu.
|
|
25
|
+
- Same code, same field, same bytes, same `Next:` shape. A program branching on `code` sees nothing.
|
|
26
|
+
|
|
27
|
+
## 0.6.25
|
|
28
|
+
|
|
29
|
+
- **Fixed** an event listing losing its columns to a time wider than twelve characters.
|
|
30
|
+
`formatAnnotations` padded the duration to twelve and did not pad the onset at all, which works
|
|
31
|
+
for exactly as long as every time is `hh:mm:ss.mmm`. Two documented cases are not.
|
|
32
|
+
- A NEGATIVE onset spends one character on the sign. That file's own note argues at length that a
|
|
33
|
+
negative onset is legal — EDF+ measures from the header start time and a recording may begin
|
|
34
|
+
after its first annotation — and 0.3.45 exists to print one correctly. It is also how a
|
|
35
|
+
pre-stimulus baseline is spelled, so it sorts before everything: the misaligned row was usually
|
|
36
|
+
the first one in the listing.
|
|
37
|
+
- A recording past 100 HOURS does it too. The hours are deliberately not wrapped at 24, because
|
|
38
|
+
"a 30-hour recording is a real thing and `30:12:00.000` is more useful than `06:12:00.000` on day
|
|
39
|
+
two" — and long-term epilepsy monitoring runs for a week, which is `168:00:00.000`. A duration
|
|
40
|
+
that long overflowed the padded column outright.
|
|
41
|
+
- Both widths come from the rows being printed now, with twelve as the floor, so a listing whose
|
|
42
|
+
times all fit prints byte for byte what it printed before — including one where every event is
|
|
43
|
+
instantaneous and every duration is blank.
|
|
44
|
+
- Same defect as the sample rate (0.6.23) and the signal index (0.6.24), in the third formatter: a
|
|
45
|
+
value wider than the width it was given. `an-event-listing-lines-up.test.ts` checks the property
|
|
46
|
+
rather than the three cases, over the matrix as well as the cases, because the property is what
|
|
47
|
+
survives the next column.
|
|
48
|
+
|
|
9
49
|
## 0.6.24
|
|
10
50
|
|
|
11
51
|
- **Fixed** the signal-index column being three characters wide whatever the file, so signal 1000
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -90,17 +90,42 @@ export function formatAnnotations(
|
|
|
90
90
|
|
|
91
91
|
const limit = requireItemLimit(options?.maxItems, annotations.length);
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
/*
|
|
94
|
+
* Both time columns are sized from the rows being printed, the way `formatHeader` sizes its
|
|
95
|
+
* index column, because both can hold a value wider than a fixed width.
|
|
96
|
+
*
|
|
97
|
+
* `hh:mm:ss.mmm` is twelve characters until it is not. A negative onset spends one on the sign —
|
|
98
|
+
* `-00:00:01.500`, which the note at the top of this file argues is legal and which 0.3.45
|
|
99
|
+
* exists to print correctly — and the hours are deliberately not wrapped at 24, so a week of
|
|
100
|
+
* long-term monitoring reads `168:00:00.000`. Either one on one row of a listing moved the text
|
|
101
|
+
* column on that row and no other, and the onset column was not padded at all, so the misaligned
|
|
102
|
+
* row was usually the first: a pre-stimulus baseline sorts before everything (fixed in 0.6.25).
|
|
103
|
+
*
|
|
104
|
+
* Twelve is the floor, so a listing whose times all fit prints exactly what it printed before —
|
|
105
|
+
* including one where every event is instantaneous and every duration is empty.
|
|
106
|
+
*/
|
|
107
|
+
const cells = [];
|
|
94
108
|
for (let i = 0; i < limit; i += 1) {
|
|
95
109
|
const annotation = annotations[i];
|
|
96
110
|
if (annotation === undefined) continue;
|
|
111
|
+
cells.push({
|
|
112
|
+
onset: clock(annotation.onsetTicksFromFirstRecord),
|
|
113
|
+
duration: duration(annotation),
|
|
114
|
+
annotation,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
const onsetWidth = Math.max(12, ...cells.map((cell) => cell.onset.length));
|
|
118
|
+
const durationWidth = Math.max(12, ...cells.map((cell) => cell.duration.length));
|
|
119
|
+
|
|
120
|
+
const rows: string[] = [];
|
|
121
|
+
for (const { onset, duration: span, annotation } of cells) {
|
|
97
122
|
// Annotation text is exposed verbatim by design — the TAL grammar reserves 0x00, 0x14 and
|
|
98
123
|
// 0x15 and nothing else, so 0x0a and 0x09 reach `text` unchanged. One event holding a newline
|
|
99
124
|
// would print as two rows, and the second would carry no time of its own, so it reads as an
|
|
100
125
|
// event at the time above it. `annotation.text` still holds the bytes as written.
|
|
101
126
|
const parts = [
|
|
102
|
-
|
|
103
|
-
|
|
127
|
+
onset.padEnd(onsetWidth),
|
|
128
|
+
span.padEnd(durationWidth),
|
|
104
129
|
printable(annotation.text),
|
|
105
130
|
];
|
|
106
131
|
if (options?.includeChannel === true && annotation.channelLabel !== undefined) {
|
package/src/header/variant.ts
CHANGED
|
@@ -116,6 +116,36 @@ export function reservedMarkerOf(reserved: string): EdfReservedMarker | undefine
|
|
|
116
116
|
return undefined;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
/**
|
|
120
|
+
* The containers whose first bytes are already in hand when `NOT_AN_EDF_FILE` is thrown.
|
|
121
|
+
*
|
|
122
|
+
* That message's `Next:` clause has always said "a gzip, zip or vendor container has to be
|
|
123
|
+
* unpacked before edfcore sees it" — a menu, offered while holding the two bytes that say which
|
|
124
|
+
* one it is. `1f 8b` is a gzip and nothing else, and a reader who has just been handed the hex is
|
|
125
|
+
* being asked to look it up.
|
|
126
|
+
*
|
|
127
|
+
* Only the archive formats, and only by their magic number. Naming a container is a fact about the
|
|
128
|
+
* first bytes; guessing at a vendor's binary EEG format from the same two bytes would be a claim
|
|
129
|
+
* about the whole file, and the generic clause still covers those.
|
|
130
|
+
*/
|
|
131
|
+
const CONTAINERS: ReadonlyArray<readonly [string, readonly number[]]> = [
|
|
132
|
+
['a gzip', [0x1f, 0x8b]],
|
|
133
|
+
['a zip', [0x50, 0x4b, 0x03, 0x04]],
|
|
134
|
+
['an empty zip', [0x50, 0x4b, 0x05, 0x06]],
|
|
135
|
+
['a bzip2', [0x42, 0x5a, 0x68]],
|
|
136
|
+
['an xz', [0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00]],
|
|
137
|
+
['a zstd', [0x28, 0xb5, 0x2f, 0xfd]],
|
|
138
|
+
['a 7-Zip archive', [0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c]],
|
|
139
|
+
];
|
|
140
|
+
|
|
141
|
+
/** The container these bytes begin with, or `undefined` — which is most files. */
|
|
142
|
+
function containerAt(bytes: Uint8Array): string | undefined {
|
|
143
|
+
for (const [name, magic] of CONTAINERS) {
|
|
144
|
+
if (magic.every((byte, at) => bytes[at] === byte)) return name;
|
|
145
|
+
}
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
|
|
119
149
|
function markerFamily(marker: EdfReservedMarker): EdfFamily {
|
|
120
150
|
return marker === 'EDF+C' || marker === 'EDF+D' ? 'EDF' : 'BDF';
|
|
121
151
|
}
|
|
@@ -157,15 +187,20 @@ export function detectVariant(headerBytes: Uint8Array, sink: DiagnosticSink): Ed
|
|
|
157
187
|
HEADER_FIELDS.version.offset,
|
|
158
188
|
HEADER_FIELDS.version.length,
|
|
159
189
|
);
|
|
190
|
+
const container = containerAt(headerBytes);
|
|
160
191
|
throw fatalError({
|
|
161
192
|
code: 'NOT_AN_EDF_FILE',
|
|
162
193
|
message:
|
|
163
194
|
`version field (8 bytes at offset ${HEADER_FIELDS.version.offset}) is ` +
|
|
164
195
|
`${JSON.stringify(raw)}, bytes ${hexBytes(versionBytes)}: this is neither EDF's ` +
|
|
165
196
|
`"0" followed by seven spaces nor BDF's 0xff followed by "BIOSEMI". ` +
|
|
197
|
+
(container === undefined ? '' : `Those first bytes are ${container}. `) +
|
|
166
198
|
'EDF specification, header record bytes 0-7 (version of this data format). ' +
|
|
167
|
-
|
|
168
|
-
|
|
199
|
+
(container === undefined
|
|
200
|
+
? 'Next: confirm the bytes are an uncompressed EDF or BDF recording — a gzip, zip or ' +
|
|
201
|
+
'vendor container has to be unpacked before edfcore sees it.'
|
|
202
|
+
: `Next: unpack ${container} and open the EDF or BDF file inside it — edfcore reads ` +
|
|
203
|
+
'recordings, not archives.'),
|
|
169
204
|
field: 'version',
|
|
170
205
|
byteOffset: HEADER_FIELDS.version.offset,
|
|
171
206
|
byteLength: HEADER_FIELDS.version.length,
|