edf2csv 0.7.83 → 0.7.85

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.
@@ -150,3 +150,27 @@ export declare function auditStdout(): {
150
150
  * will not work is exactly what you asked.
151
151
  */
152
152
  export declare function stdoutRefusal(file: EdfFile, plan: ConversionPlan): ConversionError | null;
153
+ /**
154
+ * Asked for signal data and given none to put in a file.
155
+ *
156
+ * Every channel selected carries zero samples per record, so there is no table to make —
157
+ * `edf2csv rec.edf --channels unused` writes channels.csv and metadata.json and no signals.csv
158
+ * at all. The NO_SAMPLES warning explains the channel; nothing explained the missing file, and
159
+ * the documentation says signals.csv is written unless --annotations-only was passed. Someone
160
+ * looking for it should be told where it went.
161
+ *
162
+ * There are two ways to arrive with no groups, and one wording is only true of one of them. A
163
+ * recording that holds nothing but EDF+ annotations has no channel that could have been
164
+ * selected, its channels.csv is a header row and nothing else, and no channel of it carries
165
+ * samples — so "every channel selected", "channels.csv still describes them" and "which
166
+ * channels do carry samples" were three false statements in one warning, printed under a
167
+ * warning that had just said the file has no signal channels.
168
+ *
169
+ * Exported, and worded in the present tense, so `--info` can raise the same one. It was built
170
+ * inline here, which meant the one mode whose purpose is to say what a conversion will do said
171
+ * nothing about the file that conversion would not write: `--info --strict` on a recording of
172
+ * nothing but annotations reported one warning where converting it reported two, and
173
+ * `--info --json` carried the shorter list to whatever reads it. Everything the answer depends
174
+ * on is in the file and the plan, both of which `--info` already has.
175
+ */
176
+ export declare function noSignalFile(file: EdfFile, plan: ConversionPlan): Diagnostic | null;
@@ -131,40 +131,10 @@ export async function convert(inputPath, options = {}) {
131
131
  const signals = await writeSignalFiles(file, plan, outputDir, timing.starts, options);
132
132
  written.push(...signals);
133
133
  }
134
- else if (plan.writeSignals) {
135
- /*
136
- Asked for signal data and given none to write.
137
-
138
- Every channel selected carries zero samples per record, so there is no table to make
139
- — `edf2csv rec.edf --channels unused` writes channels.csv and metadata.json and no
140
- signals.csv at all. The NO_SAMPLES warning explains the channel; nothing explained the
141
- missing file, and the documentation says signals.csv is written unless
142
- --annotations-only was passed. Someone looking for it should be told where it went.
143
-
144
- There are two ways to arrive with no groups, and the wording above is only true of
145
- one of them. A recording that holds nothing but EDF+ annotations has no channel that
146
- could have been selected, its channels.csv is a header row and nothing else, and no
147
- channel of it carries samples — so "every channel selected", "channels.csv still
148
- describes them" and "which channels do carry samples" were three false statements in
149
- one warning, printed under a warning that had just said the file has no signal
150
- channels. `--stdout` distinguishes the two cases a few lines up and `--info` prints
151
- one accurate line; this path was the only one that did not.
152
- */
153
- const noChannelsAtAll = file.dataSignals.length === 0;
154
- plan.diagnostics.push({
155
- code: 'NO_SAMPLES',
156
- severity: 'warning',
157
- message: noChannelsAtAll
158
- ? 'No signal file was written: there is no signal data in this recording to put in ' +
159
- 'one.'
160
- : 'No signal file was written: every channel selected carries zero samples per data ' +
161
- 'record, so there is nothing to put in one.',
162
- hint: noChannelsAtAll
163
- ? 'annotations.csv holds whatever events it carries. channels.csv lists signal ' +
164
- 'channels, so it has none to list.'
165
- : 'channels.csv still describes them. Run with --info to see which channels do carry ' +
166
- 'samples.',
167
- });
134
+ else {
135
+ const missing = noSignalFile(file, plan);
136
+ if (missing)
137
+ plan.diagnostics.push(missing);
168
138
  }
169
139
  if (options.annotationsOnly === true && file.annotationSignals.length === 0) {
170
140
  plan.diagnostics.push({
@@ -1252,6 +1222,47 @@ export function stdoutRefusal(file, plan) {
1252
1222
  }
1253
1223
  return null;
1254
1224
  }
1225
+ /**
1226
+ * Asked for signal data and given none to put in a file.
1227
+ *
1228
+ * Every channel selected carries zero samples per record, so there is no table to make —
1229
+ * `edf2csv rec.edf --channels unused` writes channels.csv and metadata.json and no signals.csv
1230
+ * at all. The NO_SAMPLES warning explains the channel; nothing explained the missing file, and
1231
+ * the documentation says signals.csv is written unless --annotations-only was passed. Someone
1232
+ * looking for it should be told where it went.
1233
+ *
1234
+ * There are two ways to arrive with no groups, and one wording is only true of one of them. A
1235
+ * recording that holds nothing but EDF+ annotations has no channel that could have been
1236
+ * selected, its channels.csv is a header row and nothing else, and no channel of it carries
1237
+ * samples — so "every channel selected", "channels.csv still describes them" and "which
1238
+ * channels do carry samples" were three false statements in one warning, printed under a
1239
+ * warning that had just said the file has no signal channels.
1240
+ *
1241
+ * Exported, and worded in the present tense, so `--info` can raise the same one. It was built
1242
+ * inline here, which meant the one mode whose purpose is to say what a conversion will do said
1243
+ * nothing about the file that conversion would not write: `--info --strict` on a recording of
1244
+ * nothing but annotations reported one warning where converting it reported two, and
1245
+ * `--info --json` carried the shorter list to whatever reads it. Everything the answer depends
1246
+ * on is in the file and the plan, both of which `--info` already has.
1247
+ */
1248
+ export function noSignalFile(file, plan) {
1249
+ if (!plan.writeSignals || plan.groups.length > 0)
1250
+ return null;
1251
+ const noChannelsAtAll = file.dataSignals.length === 0;
1252
+ return {
1253
+ code: 'NO_SAMPLES',
1254
+ severity: 'warning',
1255
+ message: noChannelsAtAll
1256
+ ? 'No signal file is written: there is no signal data in this recording to put in one.'
1257
+ : 'No signal file is written: every channel selected carries zero samples per data ' +
1258
+ 'record, so there is nothing to put in one.',
1259
+ hint: noChannelsAtAll
1260
+ ? 'annotations.csv holds whatever events it carries. channels.csv lists signal ' +
1261
+ 'channels, so it has none to list.'
1262
+ : 'channels.csv still describes them. Run with --info to see which channels do carry ' +
1263
+ 'samples.',
1264
+ };
1265
+ }
1255
1266
  /** Raised when the input moved while it was being read. See where it is pushed. */
1256
1267
  function inputChanged(hadChecksum) {
1257
1268
  return {