edf2csv 0.8.53 → 0.8.55
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/cli.js +4 -4
- package/dist/cli.js.map +1 -1
- package/dist/convert/run.d.ts +4 -1
- package/dist/convert/run.js +45 -11
- package/dist/convert/run.js.map +1 -1
- package/dist/edf/header.js +17 -2
- package/dist/edf/header.js.map +1 -1
- package/package.json +1 -1
package/dist/convert/run.d.ts
CHANGED
|
@@ -239,7 +239,10 @@ export declare function noSignalFile(file: EdfFile, plan: ConversionPlan): Diagn
|
|
|
239
239
|
* hint the parser could not have known was false, and `withoutFileRateWarning` drops a header
|
|
240
240
|
* diagnostic the plan supersedes. A conversion to a directory keeps every word.
|
|
241
241
|
*/
|
|
242
|
-
export declare function
|
|
242
|
+
export declare function withSidecarsNamed(diagnostics: readonly Diagnostic[], { toStdout, gzip }: {
|
|
243
|
+
toStdout: boolean;
|
|
244
|
+
gzip: boolean;
|
|
245
|
+
}): Diagnostic[];
|
|
243
246
|
/**
|
|
244
247
|
* `--annotations-only` on a recording that has no annotations.
|
|
245
248
|
*
|
package/dist/convert/run.js
CHANGED
|
@@ -98,10 +98,10 @@ export async function convert(inputPath, options = {}) {
|
|
|
98
98
|
readerHungUp,
|
|
99
99
|
annotationCount: 0,
|
|
100
100
|
// Over both lists, because the timing warnings are pushed onto the plan's.
|
|
101
|
-
diagnostics:
|
|
101
|
+
diagnostics: withSidecarsNamed([
|
|
102
102
|
...withTimingPromiseKept(withoutFileRateWarning(file.diagnostics), timing.starts !== null),
|
|
103
103
|
...plan.diagnostics,
|
|
104
|
-
], true),
|
|
104
|
+
], { toStdout: true, gzip: plan.gzip }),
|
|
105
105
|
plan,
|
|
106
106
|
file,
|
|
107
107
|
elapsedMs: Date.now() - startedAt,
|
|
@@ -197,7 +197,13 @@ export async function convert(inputPath, options = {}) {
|
|
|
197
197
|
files: written,
|
|
198
198
|
readerHungUp: false,
|
|
199
199
|
annotationCount: annotationsWritten,
|
|
200
|
-
|
|
200
|
+
// The directory path needs it too: `--gzip` changes the names, and two of these
|
|
201
|
+
// sentences are a file name and nothing else. See withSidecarsNamed.
|
|
202
|
+
diagnostics: withSidecarsNamed([
|
|
203
|
+
...withTimingPromiseKept(withoutFileRateWarning(file.diagnostics), timing.starts !== null),
|
|
204
|
+
...plan.diagnostics,
|
|
205
|
+
...stale,
|
|
206
|
+
], { toStdout: false, gzip: plan.gzip }),
|
|
201
207
|
plan,
|
|
202
208
|
file,
|
|
203
209
|
elapsedMs: Date.now() - startedAt,
|
|
@@ -1516,11 +1522,33 @@ export function noSignalFile(file, plan) {
|
|
|
1516
1522
|
* hint the parser could not have known was false, and `withoutFileRateWarning` drops a header
|
|
1517
1523
|
* diagnostic the plan supersedes. A conversion to a directory keeps every word.
|
|
1518
1524
|
*/
|
|
1519
|
-
export function
|
|
1520
|
-
if (!toStdout)
|
|
1525
|
+
export function withSidecarsNamed(diagnostics, { toStdout, gzip }) {
|
|
1526
|
+
if (!toStdout && !gzip)
|
|
1521
1527
|
return [...diagnostics];
|
|
1528
|
+
const channels = outputCsvName('channels', gzip);
|
|
1529
|
+
const annotations = outputCsvName('annotations', gzip);
|
|
1522
1530
|
return diagnostics.map((diagnostic) => {
|
|
1523
|
-
|
|
1531
|
+
/*
|
|
1532
|
+
The header's own `NO_SAMPLES`, which names the file that describes the channel it is
|
|
1533
|
+
about — and under `--stdout` there is no such file, so the reassurance is empty:
|
|
1534
|
+
|
|
1535
|
+
$ edf2csv one-empty-channel.edf --stdout > rows.csv
|
|
1536
|
+
warning: Signal 1 ("unused") carries no samples at all (0 per data record).
|
|
1537
|
+
It is described in channels.csv but left out of the converted data.
|
|
1538
|
+
|
|
1539
|
+
Under `--gzip` the file is there under another name. Both are settled here.
|
|
1540
|
+
*/
|
|
1541
|
+
if (diagnostic.code === 'NO_SAMPLES' && diagnostic.hint?.startsWith('It is described in')) {
|
|
1542
|
+
return {
|
|
1543
|
+
...diagnostic,
|
|
1544
|
+
hint: toStdout
|
|
1545
|
+
? 'It is left out of the converted data, and --stdout writes no channels.csv to ' +
|
|
1546
|
+
'describe it in — convert to a directory for that.'
|
|
1547
|
+
: `It is described in ${channels} but left out of the converted data.`,
|
|
1548
|
+
};
|
|
1549
|
+
}
|
|
1550
|
+
if (toStdout &&
|
|
1551
|
+
diagnostic.code === 'START_TIME_UNREADABLE' &&
|
|
1524
1552
|
diagnostic.hint?.includes('metadata.json records')) {
|
|
1525
1553
|
return {
|
|
1526
1554
|
...diagnostic,
|
|
@@ -1533,9 +1561,13 @@ export function withSidecarsUnwritten(diagnostics, toStdout) {
|
|
|
1533
1561
|
diagnostic.hint?.includes('onsets in annotations.csv')) {
|
|
1534
1562
|
return {
|
|
1535
1563
|
...diagnostic,
|
|
1536
|
-
hint:
|
|
1537
|
-
'
|
|
1538
|
-
|
|
1564
|
+
hint: toStdout
|
|
1565
|
+
? 'Sample times are written from zero instead, so every row is present and the ' +
|
|
1566
|
+
'column increases. The onsets that recover absolute times are in the annotation ' +
|
|
1567
|
+
'channel; --stdout writes no annotations.csv, so convert to a directory for them.'
|
|
1568
|
+
: 'Sample times are written from zero instead, so every row is present and the ' +
|
|
1569
|
+
`column increases. Add the onsets in ${annotations} to recover absolute times if ` +
|
|
1570
|
+
'you need them.',
|
|
1539
1571
|
};
|
|
1540
1572
|
}
|
|
1541
1573
|
return diagnostic;
|
|
@@ -1713,10 +1745,12 @@ bom) {
|
|
|
1713
1745
|
decimals: g.channels.map((c) => c.decimals),
|
|
1714
1746
|
})),
|
|
1715
1747
|
},
|
|
1716
|
-
notes: [
|
|
1748
|
+
notes: withSidecarsNamed([
|
|
1717
1749
|
...withTimingPromiseKept(withoutFileRateWarning(file.diagnostics), timedFromRecords),
|
|
1718
1750
|
...plan.diagnostics,
|
|
1719
|
-
]
|
|
1751
|
+
],
|
|
1752
|
+
// metadata.json is only written into a directory, so this one is never the stdout case.
|
|
1753
|
+
{ toStdout: false, gzip: plan.gzip }).map((d) => ({
|
|
1720
1754
|
code: d.code,
|
|
1721
1755
|
severity: d.severity,
|
|
1722
1756
|
message: d.message,
|