edfcore 0.6.22 → 0.6.23
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-header.d.ts.map +1 -1
- package/dist/format-header.js +28 -1
- package/dist/format-header.js.map +1 -1
- package/docs/CHANGELOG.md +22 -0
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/format-header.ts +26 -1
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.23";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-header.d.ts","sourceRoot":"","sources":["../src/format-header.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,OAAO,KAAK,EAAmB,SAAS,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"format-header.d.ts","sourceRoot":"","sources":["../src/format-header.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAQH,OAAO,KAAK,EAAmB,SAAS,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAsElF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CA+HrF"}
|
package/dist/format-header.js
CHANGED
|
@@ -53,9 +53,36 @@ function dimensionSuffix(signal) {
|
|
|
53
53
|
const dimension = printable(signal.physicalDimension);
|
|
54
54
|
return dimension === '' ? '' : ` ${dimension}`;
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The rate for the table, rounded when the exact value would not fit in a column.
|
|
58
|
+
*
|
|
59
|
+
* `sampleRateHz` is `samplesPerRecord / recordDurationSeconds`, and that division does not have to
|
|
60
|
+
* come out. A 0.29 s record holding 20 samples is 68.96551724137932 Hz, and interpolating it raw
|
|
61
|
+
* put seventeen digits into a nine-character column — pushing `range` off its position on that row
|
|
62
|
+
* alone, which is the alignment `formatHeader` was fixed for once already in 0.3.96, arriving by a
|
|
63
|
+
* different route. It also stated a derived quotient to the last bit of a float64, in a table whose
|
|
64
|
+
* other numbers are what the file says.
|
|
65
|
+
*
|
|
66
|
+
* `~` rather than a silently rounded number, because this module promises never to invent a value.
|
|
67
|
+
* The exact rate is on `signal.sampleRateHz`, `edfcore signals` prints it unrounded for scripts,
|
|
68
|
+
* and `samplesPerRecord` is the authoritative field either way — `cli.md` says to index by that and
|
|
69
|
+
* never by the rate.
|
|
70
|
+
*
|
|
71
|
+
* A rate whose exact spelling already fits is printed exactly, so the ordinary file is unchanged
|
|
72
|
+
* and the tilde means something when it appears. A rate too small to survive two decimal places
|
|
73
|
+
* falls back to the exact value rather than printing `~0 Hz`, which would be a claim rather than a
|
|
74
|
+
* rounding.
|
|
75
|
+
*/
|
|
56
76
|
function formatRate(signal) {
|
|
77
|
+
const rate = signal.sampleRateHz;
|
|
57
78
|
// undefined is the honest answer for a zero record duration, which is legal EDF.
|
|
58
|
-
|
|
79
|
+
if (rate === undefined)
|
|
80
|
+
return '—';
|
|
81
|
+
const exact = `${rate}`;
|
|
82
|
+
if (exact.length <= 6)
|
|
83
|
+
return `${exact} Hz`;
|
|
84
|
+
const rounded = Number(rate.toFixed(2));
|
|
85
|
+
return rounded === 0 ? `${exact} Hz` : `~${rounded} Hz`;
|
|
59
86
|
}
|
|
60
87
|
/**
|
|
61
88
|
* A multi-line summary of a header.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-header.js","sourceRoot":"","sources":["../src/format-header.ts"],"names":[],"mappings":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,KAAK,EAAE,MAAM,CAAC;SAE1B;aACE,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC;YAC/B,yFAAyF;YACzF,sFAAsF;aACrF,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;aACtD,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;QAChF,IAAI,OAAO,EAAE,eAAe,KAAK,KAAK,EAAE,CAAC;YACvC,KAAK,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,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.23
|
|
10
|
+
|
|
11
|
+
- **Fixed** a derived sample rate blowing the column it is printed in. `sampleRateHz` is
|
|
12
|
+
`samplesPerRecord / recordDurationSeconds` and that division does not have to come out: a 0.29 s
|
|
13
|
+
record holding 20 samples is 68.96551724137932 Hz, seventeen digits in a nine-character column.
|
|
14
|
+
`edfcore header` printed it raw, so `range` moved off its position on that row and no other, and
|
|
15
|
+
a reader comparing two rows found the last column of one of them somewhere else.
|
|
16
|
+
- It is the defect 0.3.96 fixed for the heading, arriving by a different route: that one was a
|
|
17
|
+
hand-spaced literal disagreeing with the widths beneath it, this one is a value wider than the
|
|
18
|
+
width. Both make the same table unreadable in the same place.
|
|
19
|
+
- A rate whose exact spelling fits is printed exactly, so the ordinary file is unchanged. One that
|
|
20
|
+
does not is rounded to two decimals and marked `~`, because this module promises never to invent
|
|
21
|
+
a value — and a rate too small to survive two decimals falls back to the exact spelling rather
|
|
22
|
+
than printing `~0 Hz`, which would be a claim rather than a rounding.
|
|
23
|
+
- Nothing a script reads moved. `signal.sampleRateHz` is untouched, `edfcore signals` prints it
|
|
24
|
+
unrounded, `edfcore json` carries it in full, and `samplesPerRecord` is the authoritative field
|
|
25
|
+
either way. A table for a person is the one place four significant figures beat seventeen.
|
|
26
|
+
- `a-rate-that-does-not-divide.test.ts` checks the property rather than the site: every row's
|
|
27
|
+
`range` starts at the same column as every other row's and as the heading's, over all thirteen
|
|
28
|
+
shapes. The matrix only reaches this because 0.6.20 put a 0.29 s record in it — before that every
|
|
29
|
+
shape had a duration of 1 s or 0 s, and every rate was a whole number.
|
|
30
|
+
|
|
9
31
|
## 0.6.22
|
|
10
32
|
|
|
11
33
|
- **Added** the four declared range numbers and `scale` to each signal in `edfcore json`, so the
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
package/src/format-header.ts
CHANGED
|
@@ -58,9 +58,34 @@ function dimensionSuffix(signal: EdfHeader['signals'][number]): string {
|
|
|
58
58
|
return dimension === '' ? '' : ` ${dimension}`;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* The rate for the table, rounded when the exact value would not fit in a column.
|
|
63
|
+
*
|
|
64
|
+
* `sampleRateHz` is `samplesPerRecord / recordDurationSeconds`, and that division does not have to
|
|
65
|
+
* come out. A 0.29 s record holding 20 samples is 68.96551724137932 Hz, and interpolating it raw
|
|
66
|
+
* put seventeen digits into a nine-character column — pushing `range` off its position on that row
|
|
67
|
+
* alone, which is the alignment `formatHeader` was fixed for once already in 0.3.96, arriving by a
|
|
68
|
+
* different route. It also stated a derived quotient to the last bit of a float64, in a table whose
|
|
69
|
+
* other numbers are what the file says.
|
|
70
|
+
*
|
|
71
|
+
* `~` rather than a silently rounded number, because this module promises never to invent a value.
|
|
72
|
+
* The exact rate is on `signal.sampleRateHz`, `edfcore signals` prints it unrounded for scripts,
|
|
73
|
+
* and `samplesPerRecord` is the authoritative field either way — `cli.md` says to index by that and
|
|
74
|
+
* never by the rate.
|
|
75
|
+
*
|
|
76
|
+
* A rate whose exact spelling already fits is printed exactly, so the ordinary file is unchanged
|
|
77
|
+
* and the tilde means something when it appears. A rate too small to survive two decimal places
|
|
78
|
+
* falls back to the exact value rather than printing `~0 Hz`, which would be a claim rather than a
|
|
79
|
+
* rounding.
|
|
80
|
+
*/
|
|
61
81
|
function formatRate(signal: EdfHeader['signals'][number]): string {
|
|
82
|
+
const rate = signal.sampleRateHz;
|
|
62
83
|
// undefined is the honest answer for a zero record duration, which is legal EDF.
|
|
63
|
-
|
|
84
|
+
if (rate === undefined) return '—';
|
|
85
|
+
const exact = `${rate}`;
|
|
86
|
+
if (exact.length <= 6) return `${exact} Hz`;
|
|
87
|
+
const rounded = Number(rate.toFixed(2));
|
|
88
|
+
return rounded === 0 ? `${exact} Hz` : `~${rounded} Hz`;
|
|
64
89
|
}
|
|
65
90
|
|
|
66
91
|
/**
|