edf2csv 0.9.39 → 0.9.41
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 +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/convert/run.d.ts +1 -1
- package/dist/convert/run.js +78 -12
- package/dist/convert/run.js.map +1 -1
- package/package.json +1 -1
package/dist/convert/run.d.ts
CHANGED
|
@@ -250,7 +250,7 @@ export declare function convertedChannels(plan: ConversionPlan): Set<number>;
|
|
|
250
250
|
*
|
|
251
251
|
* `writesSignals` rather than the option, because the plan is what settles it.
|
|
252
252
|
*/
|
|
253
|
-
export declare function withSignalTableUnwritten(diagnostics: readonly Diagnostic[], writesSignals: boolean, gzip: boolean, converted?: ReadonlySet<number>, toStdout?: boolean): Diagnostic[];
|
|
253
|
+
export declare function withSignalTableUnwritten(diagnostics: readonly Diagnostic[], writesSignals: boolean, gzip: boolean, converted?: ReadonlySet<number>, toStdout?: boolean, longLayout?: boolean): Diagnostic[];
|
|
254
254
|
/**
|
|
255
255
|
* The sidecar files a `--stdout` run does not write, taken out of the sentences about them.
|
|
256
256
|
*
|
package/dist/convert/run.js
CHANGED
|
@@ -107,7 +107,7 @@ export async function convert(inputPath, options = {}) {
|
|
|
107
107
|
diagnostics: withSidecarsNamed(withSignalTableUnwritten([
|
|
108
108
|
...withTimingPromiseKept(withoutFileRateWarning(file.diagnostics), timing.starts !== null),
|
|
109
109
|
...plan.diagnostics,
|
|
110
|
-
], plan.writeSignals, plan.gzip, convertedChannels(plan), true), { toStdout: true, gzip: plan.gzip }),
|
|
110
|
+
], plan.writeSignals, plan.gzip, convertedChannels(plan), true, plan.layout === 'long'), { toStdout: true, gzip: plan.gzip }),
|
|
111
111
|
plan,
|
|
112
112
|
file,
|
|
113
113
|
elapsedMs: Date.now() - startedAt,
|
|
@@ -209,7 +209,7 @@ export async function convert(inputPath, options = {}) {
|
|
|
209
209
|
...withTimingPromiseKept(withoutFileRateWarning(file.diagnostics), timing.starts !== null),
|
|
210
210
|
...plan.diagnostics,
|
|
211
211
|
...stale,
|
|
212
|
-
], plan.writeSignals, plan.gzip, convertedChannels(plan)), { toStdout: false, gzip: plan.gzip }),
|
|
212
|
+
], plan.writeSignals, plan.gzip, convertedChannels(plan), false, plan.layout === 'long'), { toStdout: false, gzip: plan.gzip }),
|
|
213
213
|
plan,
|
|
214
214
|
file,
|
|
215
215
|
elapsedMs: Date.now() - startedAt,
|
|
@@ -1679,7 +1679,29 @@ converted = new Set(),
|
|
|
1679
1679
|
thing `withSidecarsNamed` says one pass later about the sentences it knows. These are the
|
|
1680
1680
|
ones it has never been shown: they do not exist until this pass writes them.
|
|
1681
1681
|
*/
|
|
1682
|
-
toStdout = false
|
|
1682
|
+
toStdout = false,
|
|
1683
|
+
/*
|
|
1684
|
+
And whether the run puts the channel names in rows rather than in a header.
|
|
1685
|
+
|
|
1686
|
+
The three rewrites this pass makes about a channel's *name* were deliberately left out of
|
|
1687
|
+
the empty-window case at 0.9.39, on the grounds that a window holding no samples still
|
|
1688
|
+
writes the signal file's header row, so every column is there and named exactly as those
|
|
1689
|
+
sentences say. True of the wide layout, and of only the wide layout. A long signals.csv
|
|
1690
|
+
is `time_s,channel,value`: a channel appears in it as a *value* in the channel column, so
|
|
1691
|
+
a run with no rows names no channel anywhere, and all three went on saying it did:
|
|
1692
|
+
|
|
1693
|
+
$ edf2csv gappy.edf --layout long --start 2 --duration 1 --out ./converted
|
|
1694
|
+
warning: Signal 0 has no label. It will appear as "signal_0".
|
|
1695
|
+
warning: 2 signals share the label "dup" (positions #1, #2).
|
|
1696
|
+
... a column name each in the wide layout, and a distinct value in the
|
|
1697
|
+
channel column under --layout long.
|
|
1698
|
+
warning: No samples fall inside the requested window (2.000s to 3.000s), so the
|
|
1699
|
+
signal file holds its header and no data.
|
|
1700
|
+
|
|
1701
|
+
`channels.csv` still carries the name, which is what the `--annotations-only` rewrites
|
|
1702
|
+
have always offered in its place.
|
|
1703
|
+
*/
|
|
1704
|
+
longLayout = false) {
|
|
1683
1705
|
/*
|
|
1684
1706
|
And the third way to arrive with no cells and no rows, which is a window holding none.
|
|
1685
1707
|
|
|
@@ -1712,7 +1734,7 @@ toStdout = false) {
|
|
|
1712
1734
|
if (!writesSignals)
|
|
1713
1735
|
return true;
|
|
1714
1736
|
if (noRows)
|
|
1715
|
-
return !NAMES_A_COLUMN.has(diagnostic.code);
|
|
1737
|
+
return longLayout || !NAMES_A_COLUMN.has(diagnostic.code);
|
|
1716
1738
|
const named = /^Signal (\d+)\b/u.exec(diagnostic.message);
|
|
1717
1739
|
return named !== null && !converted.has(Number(named[1]));
|
|
1718
1740
|
};
|
|
@@ -1822,10 +1844,16 @@ toStdout = false) {
|
|
|
1822
1844
|
happens, since the names are derived from the whole file so that they agree with
|
|
1823
1845
|
channels.csv and across runs, and the column it is named for is one this run has not got.
|
|
1824
1846
|
*/
|
|
1825
|
-
|
|
1847
|
+
// Either noun the plan may have written: a column of the wide table, or the channel
|
|
1848
|
+
// column a long one names it in. Both are places this run has no rows in.
|
|
1849
|
+
if (diagnostic.code === 'DUPLICATE_LABEL' &&
|
|
1850
|
+
/ so (?:its column is "|it is named "[^"]*" in the channel column)/u.test(diagnostic.message)) {
|
|
1826
1851
|
return {
|
|
1827
1852
|
...diagnostic,
|
|
1828
|
-
message: diagnostic.message.replace(/ so its column is ("[^"]*")
|
|
1853
|
+
message: diagnostic.message.replace(/ so (?:its column is ("[^"]*")|it is named ("[^"]*") in the channel column)\.$/u,
|
|
1854
|
+
// Whichever of the two groups matched carries the name; the other is undefined,
|
|
1855
|
+
// and `$1` would have written an empty pair of quotes for the long-layout form.
|
|
1856
|
+
(_all, wide, long) => ` so it is named ${wide ?? long} in ${channelsFile}'s column cell` +
|
|
1829
1857
|
`${toStdout ? ' in any conversion that writes one' : ''}.`),
|
|
1830
1858
|
};
|
|
1831
1859
|
}
|
|
@@ -1860,11 +1888,18 @@ toStdout = false) {
|
|
|
1860
1888
|
...diagnostic,
|
|
1861
1889
|
hint: 'Their names are suffixed with the signal number so they stay distinguishable. ' +
|
|
1862
1890
|
(writesSignals
|
|
1863
|
-
?
|
|
1864
|
-
?
|
|
1865
|
-
`
|
|
1866
|
-
|
|
1867
|
-
|
|
1891
|
+
? noRows
|
|
1892
|
+
? toStdout
|
|
1893
|
+
? `The requested window holds no samples, and --stdout writes no ` +
|
|
1894
|
+
`${channelsFile} for the suffixed names to appear in — convert to a ` +
|
|
1895
|
+
`directory for that.`
|
|
1896
|
+
: `The requested window holds no samples, so the suffixed names appear only ` +
|
|
1897
|
+
`in ${channelsFile}'s column cells.`
|
|
1898
|
+
: toStdout
|
|
1899
|
+
? `--channels left this channel out, and --stdout writes no ${channelsFile} for ` +
|
|
1900
|
+
`its suffixed name to appear in — convert to a directory for that.`
|
|
1901
|
+
: `--channels left this channel out, so its suffixed name appears in ` +
|
|
1902
|
+
`${channelsFile}'s column cell and nowhere else.`
|
|
1868
1903
|
: toStdout
|
|
1869
1904
|
? // The one of the three this pass was extended without at 0.9.29. `--stdout`
|
|
1870
1905
|
// writes no channels.csv either, and the report saying this goes on to say
|
|
@@ -1917,6 +1952,37 @@ toStdout = false) {
|
|
|
1917
1952
|
`${records('the physical range the header gives')}`,
|
|
1918
1953
|
};
|
|
1919
1954
|
}
|
|
1955
|
+
/*
|
|
1956
|
+
And the one warning here that is about the printed text of a sample rather than a cell.
|
|
1957
|
+
|
|
1958
|
+
`VALUE_RESOLUTION` says a channel's step is below any precision `toFixed` can print, so
|
|
1959
|
+
consecutive samples land on the same text — and reassures the reader that nothing is
|
|
1960
|
+
lost from the data: "Every sample is written, in order". A window holding none writes no
|
|
1961
|
+
samples at all, which the warning under it says in as many words:
|
|
1962
|
+
|
|
1963
|
+
warning: fine steps by less than any number of decimals this can print, so some
|
|
1964
|
+
consecutive samples round to the same value in signals.csv.
|
|
1965
|
+
Every sample is written, in order, and the physical values are computed
|
|
1966
|
+
at full precision either way.
|
|
1967
|
+
warning: No samples fall inside the requested window (2.000s to 3.000s), so the
|
|
1968
|
+
signal file holds its header and no data.
|
|
1969
|
+
|
|
1970
|
+
plan.ts already gives this reassurance its own branch where the rate overflows to
|
|
1971
|
+
Infinity, on the stated grounds that "no rows are written at all, so 'Every sample is
|
|
1972
|
+
written, in order' would be the third untrue sentence". This is that same sentence,
|
|
1973
|
+
reached by the other route. `--annotations-only` and `--channels` never see it: the
|
|
1974
|
+
warning is raised per rate group from the channels the plan converts, so a run that
|
|
1975
|
+
converts none raises none.
|
|
1976
|
+
*/
|
|
1977
|
+
if (diagnostic.code === 'VALUE_RESOLUTION') {
|
|
1978
|
+
return {
|
|
1979
|
+
...diagnostic,
|
|
1980
|
+
message: diagnostic.message.replace(' so some consecutive samples round to the same value in', ' so some consecutive samples would round to the same value in'),
|
|
1981
|
+
hint: `No samples are converted ${because}, so none is rounded at all. The physical ` +
|
|
1982
|
+
'values are computed at full precision either way, and what a printed one loses ' +
|
|
1983
|
+
'is only in its text.',
|
|
1984
|
+
};
|
|
1985
|
+
}
|
|
1920
1986
|
if (diagnostic.code === 'DEGENERATE_DIGITAL_RANGE') {
|
|
1921
1987
|
return {
|
|
1922
1988
|
...diagnostic,
|
|
@@ -2380,7 +2446,7 @@ bom) {
|
|
|
2380
2446
|
notes: withSidecarsNamed(withSignalTableUnwritten([
|
|
2381
2447
|
...withTimingPromiseKept(withoutFileRateWarning(file.diagnostics), timedFromRecords),
|
|
2382
2448
|
...plan.diagnostics,
|
|
2383
|
-
], plan.writeSignals, plan.gzip, convertedChannels(plan)),
|
|
2449
|
+
], plan.writeSignals, plan.gzip, convertedChannels(plan), false, plan.layout === 'long'),
|
|
2384
2450
|
// metadata.json is only written into a directory, so this is never the stdout case.
|
|
2385
2451
|
{ toStdout: false, gzip: plan.gzip }).map((d) => ({
|
|
2386
2452
|
code: d.code,
|