edfcore 0.6.24 → 0.6.25

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.
@@ -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.24";
112
+ export declare const VERSION = "0.6.25";
113
113
  //# sourceMappingURL=constants.d.ts.map
package/dist/constants.js CHANGED
@@ -79,5 +79,5 @@ export const SIGNAL_FIELD_BLOCK_OFFSETS = {
79
79
  reserved: 224,
80
80
  };
81
81
  /** Published package version. Kept in sync with package.json by a test. */
82
- export const VERSION = '0.6.24';
82
+ export const VERSION = '0.6.25';
83
83
  //# sourceMappingURL=constants.js.map
@@ -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,CA6BR"}
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
- const rows = [];
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
- clock(annotation.onsetTicksFromFirstRecord),
79
- duration(annotation).padEnd(12),
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,wFAAwF;IACxF,MAAM,mBAAmB,GAAG,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC;IACnE,MAAM,QAAQ,GAAG,mBAAmB,GAAG,EAAE,CAAC;IAC1C,MAAM,iBAAiB,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,mBAAmB,CAAC;IAEhF,MAAM,YAAY,GAAG,iBAAiB,GAAG,KAAK,CAAC;IAC/C,MAAM,YAAY,GAAG,iBAAiB,GAAG,KAAK,CAAC;IAC/C,MAAM,OAAO,GAAG,YAAY,GAAG,GAAG,CAAC;IACnC,MAAM,YAAY,GAAG,YAAY,GAAG,GAAG,CAAC;IACxC,MAAM,OAAO,GAAG,YAAY,GAAG,GAAG,CA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AAM,CAAC,aAAa,CAAC;YAC1B,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC;SAC3B,CAAC;QACF,IAAI,OAAO,EAAE,cAAc,KAAK,IAAI,IAAI,UAAU,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YAC9E,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,GAAG,KAAK,CAAC;IAC1C,mFAAmF;IACnF,IAAI,MAAM,GAAG,CAAC;QAAE,IAAI,CAAC,IAAI,CAAC,WAAW,MAAM,OAAO,CAAC,CAAC;IAEpD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
package/docs/CHANGELOG.md CHANGED
@@ -6,6 +6,28 @@ 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.25
10
+
11
+ - **Fixed** an event listing losing its columns to a time wider than twelve characters.
12
+ `formatAnnotations` padded the duration to twelve and did not pad the onset at all, which works
13
+ for exactly as long as every time is `hh:mm:ss.mmm`. Two documented cases are not.
14
+ - A NEGATIVE onset spends one character on the sign. That file's own note argues at length that a
15
+ negative onset is legal — EDF+ measures from the header start time and a recording may begin
16
+ after its first annotation — and 0.3.45 exists to print one correctly. It is also how a
17
+ pre-stimulus baseline is spelled, so it sorts before everything: the misaligned row was usually
18
+ the first one in the listing.
19
+ - A recording past 100 HOURS does it too. The hours are deliberately not wrapped at 24, because
20
+ "a 30-hour recording is a real thing and `30:12:00.000` is more useful than `06:12:00.000` on day
21
+ two" — and long-term epilepsy monitoring runs for a week, which is `168:00:00.000`. A duration
22
+ that long overflowed the padded column outright.
23
+ - Both widths come from the rows being printed now, with twelve as the floor, so a listing whose
24
+ times all fit prints byte for byte what it printed before — including one where every event is
25
+ instantaneous and every duration is blank.
26
+ - Same defect as the sample rate (0.6.23) and the signal index (0.6.24), in the third formatter: a
27
+ value wider than the width it was given. `an-event-listing-lines-up.test.ts` checks the property
28
+ rather than the three cases, over the matrix as well as the cases, because the property is what
29
+ survives the next column.
30
+
9
31
  ## 0.6.24
10
32
 
11
33
  - **Fixed** the signal-index column being three characters wide whatever the file, so signal 1000
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edfcore",
3
- "version": "0.6.24",
3
+ "version": "0.6.25",
4
4
  "description": "Modern, typed, zero-dependency reader for EDF, EDF+, BDF and BDF+ biosignal files. Works in browsers and Node with true random access.",
5
5
  "keywords": [
6
6
  "edf",
package/src/constants.ts CHANGED
@@ -93,4 +93,4 @@ export const SIGNAL_FIELD_BLOCK_OFFSETS = {
93
93
  } as const;
94
94
 
95
95
  /** Published package version. Kept in sync with package.json by a test. */
96
- export const VERSION = '0.6.24';
96
+ export const VERSION = '0.6.25';
@@ -90,17 +90,42 @@ export function formatAnnotations(
90
90
 
91
91
  const limit = requireItemLimit(options?.maxItems, annotations.length);
92
92
 
93
- const rows: string[] = [];
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
- clock(annotation.onsetTicksFromFirstRecord),
103
- duration(annotation).padEnd(12),
127
+ onset.padEnd(onsetWidth),
128
+ span.padEnd(durationWidth),
104
129
  printable(annotation.text),
105
130
  ];
106
131
  if (options?.includeChannel === true && annotation.channelLabel !== undefined) {