edfcore 0.2.0 → 0.2.2
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/CHANGELOG.md +10 -0
- package/dist/cli-run.d.ts +1 -0
- package/dist/cli-run.d.ts.map +1 -1
- package/dist/cli-run.js +28 -1
- package/dist/cli-run.js.map +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/package.json +1 -1
- package/src/cli-run.ts +31 -1
- package/src/constants.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,16 @@ 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.2.2
|
|
10
|
+
|
|
11
|
+
- **Added** `edfcore signals <file>`: one tab-separated line per signal. `header` is for reading;
|
|
12
|
+
this is for grep and awk.
|
|
13
|
+
|
|
14
|
+
## 0.2.1
|
|
15
|
+
|
|
16
|
+
- **Added** `--version` / `-v` to the CLI. Handled before the command check, so a bare
|
|
17
|
+
`--version` does not fall through to usage and exit 2.
|
|
18
|
+
|
|
9
19
|
## 0.2.0
|
|
10
20
|
|
|
11
21
|
Marks the feature set that accumulated across 0.1.7–0.1.19 — envelope decimation, the CLI,
|
package/dist/cli-run.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface Args {
|
|
|
16
16
|
readonly command: string | undefined;
|
|
17
17
|
readonly file: string | undefined;
|
|
18
18
|
readonly patient: boolean;
|
|
19
|
+
readonly version: boolean;
|
|
19
20
|
readonly limit: number | undefined;
|
|
20
21
|
}
|
|
21
22
|
export declare function parseArgs(argv: readonly string[]): Args;
|
package/dist/cli-run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-run.d.ts","sourceRoot":"","sources":["../src/cli-run.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"cli-run.d.ts","sourceRoot":"","sources":["../src/cli-run.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH,iDAAiD;AACjD,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC5C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAmBD,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAsBvD;AAQD,wBAAsB,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CA2GnE"}
|
package/dist/cli-run.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* binary. This way the exit codes and the output are ordinary unit tests.
|
|
8
8
|
*/
|
|
9
9
|
import { countAnnotationsByText } from './annotations-query.js';
|
|
10
|
+
import { VERSION } from './constants.js';
|
|
10
11
|
import { formatDiagnostics } from './diagnostics/format.js';
|
|
11
12
|
import { formatHeader } from './format-header.js';
|
|
12
13
|
import { formatValidationReport } from './format-report.js';
|
|
@@ -18,22 +19,28 @@ const USAGE = `edfcore — read EDF, EDF+, BDF and BDF+ files
|
|
|
18
19
|
npx edfcore header <file> the header, the signals, and any diagnostics
|
|
19
20
|
npx edfcore validate <file> a full conformance sweep, scanning every sample
|
|
20
21
|
npx edfcore events <file> the annotations, counted by text
|
|
22
|
+
npx edfcore signals <file> one line per signal, for grep and awk
|
|
21
23
|
npx edfcore json <file> the header as JSON, for piping into jq
|
|
22
24
|
|
|
23
25
|
Options
|
|
24
26
|
--patient include patient identification (header, json)
|
|
25
27
|
--limit <n> individual diagnostics to print (default 20)
|
|
26
28
|
|
|
29
|
+
--version print the version and exit
|
|
30
|
+
|
|
27
31
|
Exit codes: 0 success, 1 the file is unreadable or failed validation, 2 bad usage.
|
|
28
32
|
`;
|
|
29
33
|
export function parseArgs(argv) {
|
|
30
34
|
const positional = [];
|
|
31
35
|
let patient = false;
|
|
36
|
+
let version = false;
|
|
32
37
|
let limit;
|
|
33
38
|
for (let i = 0; i < argv.length; i += 1) {
|
|
34
39
|
const arg = argv[i];
|
|
35
40
|
if (arg === '--patient')
|
|
36
41
|
patient = true;
|
|
42
|
+
else if (arg === '--version' || arg === '-v')
|
|
43
|
+
version = true;
|
|
37
44
|
else if (arg === '--limit') {
|
|
38
45
|
const value = Number(argv[i + 1]);
|
|
39
46
|
// A NaN limit would disable the cap silently, which is the opposite of what was asked for.
|
|
@@ -46,7 +53,7 @@ export function parseArgs(argv) {
|
|
|
46
53
|
else if (arg !== undefined && !arg.startsWith('-'))
|
|
47
54
|
positional.push(arg);
|
|
48
55
|
}
|
|
49
|
-
return { command: positional[0], file: positional[1], patient, limit };
|
|
56
|
+
return { command: positional[0], file: positional[1], patient, version, limit };
|
|
50
57
|
}
|
|
51
58
|
async function open(io, file) {
|
|
52
59
|
// Read whole rather than fileSource: a CLI invocation is one pass over one file, and holding
|
|
@@ -55,6 +62,12 @@ async function open(io, file) {
|
|
|
55
62
|
}
|
|
56
63
|
export async function runCli(args, io) {
|
|
57
64
|
const { command, file } = args;
|
|
65
|
+
// Before the command check: `edfcore --version` has no command, and a bare --version must not
|
|
66
|
+
// fall through to the usage text and exit 2.
|
|
67
|
+
if (args.version) {
|
|
68
|
+
io.out(`${VERSION}\n`);
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
58
71
|
if (command === undefined || command === 'help' || command === '--help') {
|
|
59
72
|
io.out(USAGE);
|
|
60
73
|
return command === undefined ? 2 : 0;
|
|
@@ -95,6 +108,20 @@ export async function runCli(args, io) {
|
|
|
95
108
|
}
|
|
96
109
|
return 0;
|
|
97
110
|
}
|
|
111
|
+
case 'signals': {
|
|
112
|
+
// Tab-separated and one line per signal: `header` is for reading, this is for piping.
|
|
113
|
+
const recording = await open(io, file);
|
|
114
|
+
for (const signal of recording.header.signals) {
|
|
115
|
+
io.out([
|
|
116
|
+
signal.index,
|
|
117
|
+
signal.label,
|
|
118
|
+
signal.kind,
|
|
119
|
+
signal.sampleRateHz ?? '',
|
|
120
|
+
signal.physicalDimension.trim(),
|
|
121
|
+
].join('\t') + '\n');
|
|
122
|
+
}
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
98
125
|
case 'json': {
|
|
99
126
|
const recording = await open(io, file);
|
|
100
127
|
const { header } = recording;
|
package/dist/cli-run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-run.js","sourceRoot":"","sources":["../src/cli-run.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AASlD,MAAM,KAAK,GAAG
|
|
1
|
+
{"version":3,"file":"cli-run.js","sourceRoot":"","sources":["../src/cli-run.ts"],"names":[],"mappings":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,OAAO,CAAC,CAAC;IACb,CAAC;AACH,CAAC"}
|
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.2.
|
|
112
|
+
export declare const VERSION = "0.2.2";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
package/package.json
CHANGED
package/src/cli-run.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { countAnnotationsByText } from './annotations-query.js';
|
|
11
|
+
import { VERSION } from './constants.js';
|
|
11
12
|
import { formatDiagnostics } from './diagnostics/format.js';
|
|
12
13
|
import { formatHeader } from './format-header.js';
|
|
13
14
|
import { formatValidationReport } from './format-report.js';
|
|
@@ -27,12 +28,15 @@ const USAGE = `edfcore — read EDF, EDF+, BDF and BDF+ files
|
|
|
27
28
|
npx edfcore header <file> the header, the signals, and any diagnostics
|
|
28
29
|
npx edfcore validate <file> a full conformance sweep, scanning every sample
|
|
29
30
|
npx edfcore events <file> the annotations, counted by text
|
|
31
|
+
npx edfcore signals <file> one line per signal, for grep and awk
|
|
30
32
|
npx edfcore json <file> the header as JSON, for piping into jq
|
|
31
33
|
|
|
32
34
|
Options
|
|
33
35
|
--patient include patient identification (header, json)
|
|
34
36
|
--limit <n> individual diagnostics to print (default 20)
|
|
35
37
|
|
|
38
|
+
--version print the version and exit
|
|
39
|
+
|
|
36
40
|
Exit codes: 0 success, 1 the file is unreadable or failed validation, 2 bad usage.
|
|
37
41
|
`;
|
|
38
42
|
|
|
@@ -40,17 +44,20 @@ export interface Args {
|
|
|
40
44
|
readonly command: string | undefined;
|
|
41
45
|
readonly file: string | undefined;
|
|
42
46
|
readonly patient: boolean;
|
|
47
|
+
readonly version: boolean;
|
|
43
48
|
readonly limit: number | undefined;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
export function parseArgs(argv: readonly string[]): Args {
|
|
47
52
|
const positional: string[] = [];
|
|
48
53
|
let patient = false;
|
|
54
|
+
let version = false;
|
|
49
55
|
let limit: number | undefined;
|
|
50
56
|
|
|
51
57
|
for (let i = 0; i < argv.length; i += 1) {
|
|
52
58
|
const arg = argv[i];
|
|
53
59
|
if (arg === '--patient') patient = true;
|
|
60
|
+
else if (arg === '--version' || arg === '-v') version = true;
|
|
54
61
|
else if (arg === '--limit') {
|
|
55
62
|
const value = Number(argv[i + 1]);
|
|
56
63
|
// A NaN limit would disable the cap silently, which is the opposite of what was asked for.
|
|
@@ -62,7 +69,7 @@ export function parseArgs(argv: readonly string[]): Args {
|
|
|
62
69
|
} else if (arg !== undefined && !arg.startsWith('-')) positional.push(arg);
|
|
63
70
|
}
|
|
64
71
|
|
|
65
|
-
return { command: positional[0], file: positional[1], patient, limit };
|
|
72
|
+
return { command: positional[0], file: positional[1], patient, version, limit };
|
|
66
73
|
}
|
|
67
74
|
|
|
68
75
|
async function open(io: CliIo, file: string) {
|
|
@@ -73,6 +80,12 @@ async function open(io: CliIo, file: string) {
|
|
|
73
80
|
|
|
74
81
|
export async function runCli(args: Args, io: CliIo): Promise<number> {
|
|
75
82
|
const { command, file } = args;
|
|
83
|
+
// Before the command check: `edfcore --version` has no command, and a bare --version must not
|
|
84
|
+
// fall through to the usage text and exit 2.
|
|
85
|
+
if (args.version) {
|
|
86
|
+
io.out(`${VERSION}\n`);
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
|
76
89
|
if (command === undefined || command === 'help' || command === '--help') {
|
|
77
90
|
io.out(USAGE);
|
|
78
91
|
return command === undefined ? 2 : 0;
|
|
@@ -121,6 +134,23 @@ export async function runCli(args: Args, io: CliIo): Promise<number> {
|
|
|
121
134
|
return 0;
|
|
122
135
|
}
|
|
123
136
|
|
|
137
|
+
case 'signals': {
|
|
138
|
+
// Tab-separated and one line per signal: `header` is for reading, this is for piping.
|
|
139
|
+
const recording = await open(io, file);
|
|
140
|
+
for (const signal of recording.header.signals) {
|
|
141
|
+
io.out(
|
|
142
|
+
[
|
|
143
|
+
signal.index,
|
|
144
|
+
signal.label,
|
|
145
|
+
signal.kind,
|
|
146
|
+
signal.sampleRateHz ?? '',
|
|
147
|
+
signal.physicalDimension.trim(),
|
|
148
|
+
].join('\t') + '\n',
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
return 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
124
154
|
case 'json': {
|
|
125
155
|
const recording = await open(io, file);
|
|
126
156
|
const { header } = recording;
|
package/src/constants.ts
CHANGED