edf2csv 0.8.37 → 0.8.39
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 +15 -1
- package/dist/cli.js.map +1 -1
- package/dist/convert/run.js +25 -5
- package/dist/convert/run.js.map +1 -1
- package/package.json +1 -1
package/dist/convert/run.js
CHANGED
|
@@ -11,7 +11,7 @@ import { finished } from 'node:stream/promises';
|
|
|
11
11
|
import { createGzip, gzipSync } from 'node:zlib';
|
|
12
12
|
import path from 'node:path';
|
|
13
13
|
import { EdfFile } from '../edf/reader.js';
|
|
14
|
-
import { describeFormat, formatRates, formatWallClock, startsFormula } from '../edf/header.js';
|
|
14
|
+
import { describeFormat, formatRate, formatRates, formatWallClock, startsFormula } from '../edf/header.js';
|
|
15
15
|
import { EdfError } from '../edf/errors.js';
|
|
16
16
|
import { BufferedLineWriter, DEFAULT_FLUSH_THRESHOLD, UTF8_BOM, csvRow, escapeCsvField, } from '../format/csv.js';
|
|
17
17
|
import { counted, grouped, listed } from '../format/list.js';
|
|
@@ -986,6 +986,27 @@ async function writeChannelsCsv(outputDir, file, plan, gzip, bom) {
|
|
|
986
986
|
for (const channel of group.channels)
|
|
987
987
|
fileFor.set(channel.signal.index, group.fileName);
|
|
988
988
|
}
|
|
989
|
+
/*
|
|
990
|
+
A rate rendered the way the file name beside it in the same row was rendered.
|
|
991
|
+
|
|
992
|
+
`sampling_rate_hz` and `output_file` are two cells of one row about one rate, and they were
|
|
993
|
+
written from different renderings of it — the cell from `String`, the name from
|
|
994
|
+
`formatRates` over the whole set. They agree on every rate `String` prints plainly and part
|
|
995
|
+
company on the ones it does not:
|
|
996
|
+
|
|
997
|
+
a,0,a,uV,1e-19,100,...,signals_1_000e-19hz.csv,yes
|
|
998
|
+
|
|
999
|
+
A reader joining that column against the files on disk finds `1e-19` naming
|
|
1000
|
+
`1_000e-19hz`, and `--info` printing a third thing again — except that `--info`'s RATE
|
|
1001
|
+
column is `1.000e-19 Hz`, which is the name's own form. channels.csv was the one surface
|
|
1002
|
+
rendering the rate for itself.
|
|
1003
|
+
|
|
1004
|
+
Rendered together because that is how the names are: two rates a sixth decimal apart round
|
|
1005
|
+
to one string, and `formatRates` widens the whole set when they do, so a per-rate rendering
|
|
1006
|
+
would disagree with the names again on exactly those files.
|
|
1007
|
+
*/
|
|
1008
|
+
const groupRates = plan.groups.map((group) => group.rate);
|
|
1009
|
+
const rateText = new Map(formatRates(groupRates).map((text, i) => [groupRates[i], text]));
|
|
989
1010
|
const lines = [
|
|
990
1011
|
csvRow([
|
|
991
1012
|
'column',
|
|
@@ -1028,10 +1049,9 @@ async function writeChannelsCsv(outputDir, file, plan, gzip, bom) {
|
|
|
1028
1049
|
signals.csv writing every one of those values out in full — and a channel calibrated
|
|
1029
1050
|
to ±100 in the row above it, so the column held both notations at once.
|
|
1030
1051
|
*/
|
|
1031
|
-
//
|
|
1032
|
-
//
|
|
1033
|
-
|
|
1034
|
-
String(signal.samplingRate),
|
|
1052
|
+
// Nor the rate, which is rendered above against the names it has to match. Nor
|
|
1053
|
+
// samples_per_record, which is a count.
|
|
1054
|
+
rateText.get(signal.samplingRate) ?? formatRate(signal.samplingRate),
|
|
1035
1055
|
String(signal.samplesPerRecord),
|
|
1036
1056
|
plain(signal.physicalMin),
|
|
1037
1057
|
plain(signal.physicalMax),
|