-
Notifications
You must be signed in to change notification settings - Fork 3
/
cmddefs.cpp
3387 lines (2629 loc) · 160 KB
/
cmddefs.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// --------------------------------------------------------------------
//
// This file is part of Luna.
//
// LUNA is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Luna is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Luna. If not, see <http://www.gnu.org/licenses/>.
//
// Please see LICENSE.txt for more details.
//
// --------------------------------------------------------------------
#include "luna.h"
#include <iomanip>
//#pragma GCC push_options
//#pragma GCC optimize ("O0")
#include "cmddefs.h"
extern globals global;
cmddefs_t::cmddefs_t()
{
//init();
}
void cmddefs_t::init()
{
//
// parameters
//
allz = false;
nonez = false;
/////////////////////////////////////////////////////////////////////////
//
// Document domains, commands, parameters, output tables and variables
//
/////////////////////////////////////////////////////////////////////////
//
// base URL
//
url_root = "http://zzz.bwh.harvard.edu/luna/ref/";
//
// Domains
//
add_domain( "summ" , "Summaries" , "Basic summary commands" );
add_domain( "annot" , "Annotations" , "Adding and displaying annotations" );
add_domain( "expr" , "Expressions" , "Evaluating more advanced annotation-based expressions" );
add_domain( "epoch" , "Epochs" , "Epoching signals and epoch-level annotations" );
add_domain( "mask" , "Masks" , "Masking epochs based on annotations and other criteria" );
add_domain( "manip" , "Manipulations" , "Manipulating signal data" );
add_domain( "output" , "Outputs" , "Commands to output signals in different formats" );
add_domain( "filter" , "FIR filters" , "FIR filter design and application" );
add_domain( "artifact" , "Artifacts" , "Artifacts detection/correction routines" );
add_domain( "hypno" , "Hypnograms" , "Characterizations of hypnograms" );
add_domain( "staging" , "Staging" , "Automated staging/stage evaluation" );
add_domain( "power" , "Power spectra" , "Power spectral density estimation" );
add_domain( "transients" , "Spindles and SO" , "Spindles and slow oscillations" );
add_domain( "topo" , "Cross-signal" , "Coherence and other topographical analyses" );
add_domain( "cfc" , "Cross-frequency" , "Phase-amplitude coupling" );
add_domain( "misc" , "Misc" , "Misc. commands" );
add_domain( "exp" , "Experimental" , "Experimental features: under heavy development, for internal use only" );
add_domain( "cmdline" , "Command-line" , "Functions that do not operate on EDFs" );
add_domain( "assoc" , "Association" , "Association models" );
add_domain( "predict" , "Prediction" , "Prediction models" );
/////////////////////////////////////////////////////////////////////////////////
//
// COMMAND-LINE OPTIONS
//
/////////////////////////////////////////////////////////////////////////////////
add_cmd( "cmdline" , "--build" , "Scan folders recursively to geneate a sample list" );
add_param( "--build" , "-edfid" , "" , "Use filename as ID, instead of looking in each EDF header" );
add_param( "--build" , "-nospan" , "" , "Do not match similarly-named files across folders" );
add_param( "--build" , "-ext" , "-ext=txt,eannot,annot" , "Consider these extensions as annotation files" );
add_cmd( "cmdline" , "--xml" , "Dump annotations from an XML annotation file (to console)" );
add_cmd( "cmdline" , "--xml2" , "Dump entire XML tree (to console)" );
add_cmd( "cmdline" , "--eval" , "" );
add_cmd( "cmdline" , "--pdlib" , "" );
add_cmd( "cmdline" , "--fir" , " Or --fir-design" );
add_cmd( "cmdline" , "--cwt" , "Or --cwt-design" );
add_cmd( "cmdline" , "--eval-verbose" , "" );
add_cmd( "cmdline" , "-h" , "Help functions" );
add_cmd( "cmdline" , "--version" , "Show version (or -v)" );
// -o
// -t
// -a
// -s
// @parameter file
// x=y ... including special variables
// ID
// 1 2
/////////////////////////////////////////////////////////////////////////////////
//
// SUMMARIES
//
/////////////////////////////////////////////////////////////////////////////////
//
// DESC
//
add_cmd( "summ" , "DESC" , "Simple description of an EDF, sent to the console" );
add_param( "DESC" , "channels" , "" , "Only write channel names, one-per-line" );
//
// SUMMARY
//
add_cmd( "summ" , "SUMMARY" , "More verbose description, sent to the console" );
//
// HEADERS
//
add_cmd( "summ" , "HEADERS" , "Tabulate (channel-specific) EDF header information" );
add_table( "HEADERS" , "" , "Basic EDF header information" );
add_var( "HEADERS" , "" , "NR" , "Number of records" );
add_var( "HEADERS" , "" , "NS" , "Number of signals/channels" );
add_var( "HEADERS" , "" , "EDF_ID" , "ID in the EDF header" );
add_var( "HEADERS" , "" , "START_TIME" , "Start time in the EDF header" );
add_var( "HEADERS" , "" , "STOP_TIME" , "Stop time" );
add_var( "HEADERS" , "" , "START_DATE" , "Start date in the EDF header" );
add_var( "HEADERS" , "" , "REC_DUR" , "Duration of each record (seconds)" );
add_var( "HEADERS" , "" , "TOT_DUR_SEC" , "Total duration of EDF (seconds)" );
add_var( "HEADERS" , "" , "TOT_DUR_HMS" , "Total duration of EDF (hh:mm:ss string)" );
add_table( "HEADERS" , "CH" , "Per-channel header information" );
add_var( "HEADERS" , "CH" , "DMAX" , "Digital max" );
add_var( "HEADERS" , "CH" , "DMIN" , "Digital min" );
add_var( "HEADERS" , "CH" , "PDIM", "Physical dimension" );
add_var( "HEADERS" , "CH" , "PMAX", "Physical min" );
add_var( "HEADERS" , "CH" , "PMIN", "Physical max" );
add_var( "HEADERS" , "CH" , "SR", "Sample rate (Hz)" );
add_var( "HEADERS" , "CH" , "SENS", "Sensitivity (unit/bit)" );
add_var( "HEADERS" , "CH" , "TRANS", "Transducer type" );
add_var( "HEADERS" , "CH" , "SENS", "Sensitivity (unit/bit)" );
add_var( "HEADERS" , "CH" , "SENS", "Sensitivity (unit/bit)" );
add_var( "HEADERS" , "CH" , "SENS", "Sensitivity (unit/bit)" );
//
// ALIASES
//
add_cmd( "summ" , "ALIASES" , "Tabulate channel and annotation alias replacements" );
add_table( "ALIASES" , "CH" , "Channel aliasing" );
add_var( "ALIASES" , "CH" , "ORIG" , "Original channel label in EDF" );
add_table( "ALIASES" , "ANNOT" , "Annotation aliasing" );
add_var( "ALIASES" , "ANNOT" , "ORIG" , "Original annotation label" );
//
// TAG
//
add_cmd( "summ" , "TAG" , "Generic command to add a tag (level/factor) to the output" );
add_param( "TAG" , "" , "RUN/L1" , "Add tag with level L1 to factor RUN in output" );
add_param( "TAG" , "tag" , "RUN/L1" , "Identical to the above, but explicitly using the tag option" );
//
// STATS
//
add_cmd( "summ" , "STATS" , "Basic signal statistics (min/max, mean, RMS, etc)" );
add_param( "STATS" , "sig" , "C3,C4" , "Restrict analysis to these channels" );
add_param( "STATS" , "epoch" , "" , "Calculate per-epoch statistics" );
add_table( "STATS" , "CH" , "Whole-night, per-channel statistics, based on all epochs" );
add_var( "STATS" , "CH" , "MIN" , "Signal minimum (from data, not EDF header)" );
add_var( "STATS" , "CH" , "MAX" , "Signal maximum (from data, not EDF header)" );
add_var( "STATS" , "CH" , "MEAN" , "Signal mean" );
add_var( "STATS" , "CH" , "MEDIAN" , "Signal median" );
add_var( "STATS" , "CH" , "RMS" , "Signal root mean square" );
add_var( "STATS" , "CH" , "P01" , "1st percentile" );
add_var( "STATS" , "CH" , "P02" , "2nd percentile" );
add_var( "STATS" , "CH" , "P05" , "5th percentile" );
add_var( "STATS" , "CH" , "P10" , "10th percentile" );
add_var( "STATS" , "CH" , "P20" , "20th percentile" );
add_var( "STATS" , "CH" , "P30" , "30th percentile" );
add_var( "STATS" , "CH" , "P40" , "40th percentile" );
add_var( "STATS" , "CH" , "P50" , "50th percentile" );
add_var( "STATS" , "CH" , "P60" , "60th percentile" );
add_var( "STATS" , "CH" , "P70" , "70th percentile" );
add_var( "STATS" , "CH" , "P80" , "80th percentile" );
add_var( "STATS" , "CH" , "P90" , "90th percentile" );
add_var( "STATS" , "CH" , "P95" , "95th percentile" );
add_var( "STATS" , "CH" , "P98" , "98th percentile" );
add_var( "STATS" , "CH" , "P99" , "99th percentile" );
add_var( "STATS" , "CH" , "MAX_ENCODING" , "Possible # of unique values" );
add_var( "STATS" , "CH" , "OBS_ENCODING" , "Observed # of unique values" );
add_var( "STATS" , "CH" , "PCT_ENCODING" , "Obs/possible unique values" );
add_table( "STATS" , "CH,VAL" , "Encoding value distribution [encoding]" );
add_var( "STATS" , "CH,VAL" , "CNT" , "Number of observations" );
add_var( "STATS" , "CH" , "NE" , "Total number of epochs in record [epoch]" );
add_var( "STATS" , "CH" , "NE1" , "Number of unmasked epochs actually used in calculations [epoch]" );
add_var( "STATS" , "CH" , "MEDIAN_MEAN" , "Median of all per-epoch means [epoch]" );
add_var( "STATS" , "CH" , "MEDIAN_MEDIAN" , "Median of all per-epoch medians [epoch]" );
add_var( "STATS" , "CH" , "MEDIAN_RMS" , "Median of all per-epoch RMS [epoch]" );
add_table( "STATS" , "CH,E" , "Per-epoch, per-channel statistics for unmasked epochs only" );
add_var( "STATS" , "CH,E" , "MIN" , "Signal minimum (from data, not EDF header)" );
add_var( "STATS" , "CH,E" , "MAX" , "Signal maximum (from data, not EDF header)" );
add_var( "STATS" , "CH,E" , "MEAN" , "Signal mean" );
add_var( "STATS" , "CH,E" , "MEDIAN" , "Signal median" );
add_var( "STATS" , "CH,E" , "RMS" , "Signal root mean square" );
add_var( "STATS" , "CH,E" , "P01" , "1st percentile" );
add_var( "STATS" , "CH,E" , "P02" , "2nd percentile" );
add_var( "STATS" , "CH,E" , "P05" , "5th percentile" );
add_var( "STATS" , "CH,E" , "P10" , "10th percentile" );
add_var( "STATS" , "CH,E" , "P20" , "20th percentile" );
add_var( "STATS" , "CH,E" , "P30" , "30th percentile" );
add_var( "STATS" , "CH,E" , "P40" , "40th percentile" );
add_var( "STATS" , "CH,E" , "P50" , "50th percentile" );
add_var( "STATS" , "CH,E" , "P60" , "60th percentile" );
add_var( "STATS" , "CH,E" , "P70" , "70th percentile" );
add_var( "STATS" , "CH,E" , "P80" , "80th percentile" );
add_var( "STATS" , "CH,E" , "P90" , "90th percentile" );
add_var( "STATS" , "CH,E" , "P95" , "95th percentile" );
add_var( "STATS" , "CH,E" , "P98" , "98th percentile" );
add_var( "STATS" , "CH,E" , "P99" , "99th percentile" );
//
// TLOCK
//
add_cmd( "summ" , "TLOCK" , "Time-locked signal summaries" );
add_param( "TLOCK" , "sig" , "C3,C4" , "Restrict analysis to these channels" );
add_param( "TLOCK" , "cache" , "" , "Sample-point peak cache (req.)" );
add_param( "TLOCK" , "tolog" , "" , "Take log of input signals" );
add_param( "TLOCK" , "verbose" , "" , "Output individual intervals" );
add_param( "TLOCK" , "w" , "2" , "Window size around peaks (seconds) (req.)");
add_param( "TLOCK" , "phase" , "20" , "Expect phase values (radians) and summarize in, e.g. 20 bins" );
// issue: hard to specify, as factors can appear on-the-fly (based on cache)
// so just hard code a couple of common scenarios here: CH and CH x F
// generic by channel
add_table( "TLOCK" , "CH,sCH" , "Spindle peak time-locked counts" );
add_var( "TLOCK" , "CH,sCH" , "N" , "Number of included peaks" );
add_var( "TLOCK" , "CH,sCH" , "N_ALL" , "Total number of included peaks" );
add_table( "TLOCK" , "CH,SEC,sCH" , "Spindle peak time-locked summaries" );
add_var( "TLOCK" , "CH,SEC,sCH" , "M" , "Signal mean" );
add_table( "TLOCK" , "N,SEC,CH,sCH" , "Spindle peak time-locked counts" );
add_var( "TLOCK" , "N,SEC,CH,sCH" , "V" , "Signal value" );
set_compressed( "TLOCK" , tfac_t( "N,SEC,CH,sCH" ) );
// spindle peaks ( by channel & freq)
add_table( "TLOCK" , "CH,sCH,sF" , "Spindle peak time-locked counts" );
add_var( "TLOCK" , "CH,sCH,sF" , "N" , "Number of included peaks" );
add_var( "TLOCK" , "CH,sCH,sF" , "N_ALL" , "Total number of included peaks" );
add_table( "TLOCK" , "CH,SEC,sCH,sF" , "Spindle peak time-locked summaries" );
add_var( "TLOCK" , "CH,SEC,sCH,sF" , "M" , "Signal mean" );
add_table( "TLOCK" , "N,SEC,CH,sCH,sF" , "Spindle peak time-locked counts" );
add_var( "TLOCK" , "N,SEC,CH,sCH,sF" , "V" , "Signal value" );
set_compressed( "TLOCK" , tfac_t( "N,SEC,CH,sCH,sF" ) );
//
// PEAKS
//
add_cmd( "misc" , "PEAKS" , "Peak finder (maxima)" );
add_param( "PEAKS" , "sig" , "C3,C4" , "Restrict analysis to these channels" );
add_param( "PEAKS" , "cache" , "c1" , "Sample-point peak cache (req.)" );
add_param( "PEAKS" , "epoch" , "" , "Also find minima" );
add_param( "PEAKS" , "clipped" , "3" , "Clipped regions = 3 consecutive points (0 = ignore clipping)" );
add_param( "PEAKS" , "min" , "" , "Also find minima" );
add_param( "PEAKS" , "min-only" , "" , "Only find minima" );
add_param( "PEAKS" , "percentile" , "20" , "Only report top 20% of peaks" );
/////////////////////////////////////////////////////////////////////////////////
//
// ANNOTATIONS
//
/////////////////////////////////////////////////////////////////////////////////
//
// --xml
//
add_cmd( "annot" , "--xml" , "Quickly view an NSRR XML annotation file" );
add_note( "--xml" , "Command line option\n luna --xml file.xml" );
//
// --xml2
//
add_cmd( "annot" , "--xml2" , "Verbose dump of XML tree" );
add_note( "--xml2" , "Command line option\n luna --xml2 file.xml" );
//
// ANNOTS
//
add_cmd( "annot" , "ANNOTS" , "Tabulate all annotations" );
add_url( "ANNOTS" , "annotations/#annots" );
// add_note( "ANNOTS" , "Any formatted free text goes here,\n shown at end of verbose help link\n");
add_param( "ANNOTS" , "epoch" , "" , "Show epoch-level summaries" );
add_param( "ANNOTS" , "show-masked" , "" , "Show masked annotations (default is not to do so)" );
add_param( "ANNOTS" , "any" , "" , "Keep annotations that have any overlap with one or more unmasked epochs (default)" );
add_param( "ANNOTS" , "all" , "" , "Only keep annotations that are completely within unmasked epochs" );
add_param( "ANNOTS" , "start" , "" , "Keep annotations that start in an unmasked epoch" );
add_table( "ANNOTS" , "ANNOT" , "Class-level annotation summary" );
add_var( "ANNOTS" , "ANNOT" , "COUNT" , "Number of instances of that annotation class" );
add_var( "ANNOTS" , "ANNOT" , "DUR" , "Combined duration (seconds) of all instances of that annotation class" );
add_table( "ANNOTS" , "ANNOT,INST" , "Instance-level annotation summary" );
add_var( "ANNOTS" , "ANNOT,INST" , "COUNT" , "Number of instances of that annotation class and instance ID" );
add_var( "ANNOTS" , "ANNOT,INST" , "DUR" , "Combined duration (seconds) of all instances of that annotation class and instance ID" );
add_table( "ANNOTS" , "ANNOT,INST,T" , "Instance-level annotation tabulation" );
add_var( "ANNOTS" , "ANNOT,INST,T" , "START" , "Start time (seconds) of this instance" );
add_var( "ANNOTS" , "ANNOT,INST,T" , "STOP" , "Stop time (seconds) of this instance" );
add_var( "ANNOTS" , "ANNOT,INST,T" , "VAL" , "The meta-data for this instance, if any exists (otherwise missing NA)" );
add_var( "ANNOTS" , "ANNOT,INST,T" , "ALL_MASKED" , "? [show-masked]" );
add_var( "ANNOTS" , "ANNOT,INST,T" , "ALL_UNMASKED" , "? [show-masked]" );
add_var( "ANNOTS" , "ANNOT,INST,T" , "SOME_MASKED" , "? [show-masked]" );
add_var( "ANNOTS" , "ANNOT,INST,T" , "SOME_UNMASKED" , "? [show-masked]" );
add_var( "ANNOTS" , "ANNOT,INST,T" , "START_MASKED" , "? [show-masked]" );
add_table( "ANNOTS" , "E,INTERVAL,INST" , "Per-epoch instance-level annotation tabulation" );
add_var( "ANNOTS" , "E,INTERVAL,INST" , "AMASK" , "Annotation instance mask status (1=masked/excluded) [epoch]" );
add_var( "ANNOTS" , "E,INTERVAL,INST" , "EMASK" , "Epoch mask status (1=masked/excluded) [epoch]" );
//
// SPANNING
//
add_cmd( "annot" , "SPANNING" , "Report duration spanned or not by group of annotations" );
add_url( "SPANNING" , "annotations/#spanning" );
add_param( "SPANNING" , "annot" , "N1,N2,N3,R,W" , "Spanning annotation group" );
add_table( "SPANNING" , "N" , "Invalid annotations" );
add_var( "SPANNING" , "N" , "ANNOT" , "Annotation class" );
add_var( "SPANNING" , "N" , "INST" , "Annotation instance" );
add_var( "SPANNING" , "N" , "START" , "Start (seconds)" );
add_var( "SPANNING" , "N" , "STOP" , "Stop (seconds)" );
add_table( "SPANNING" , "" , "Spanning summary report" );
add_var( "SPANNING" , "" , "REC_SEC" , "EDF recording duration (seconds)" );
add_var( "SPANNING" , "" , "REC_HMS" , "EDF recording duration (hh:mm:ss)" );
add_var( "SPANNING" , "" , "ANNOT_N" , "Number of annotations in group" );
add_var( "SPANNING" , "" , "ANNOT_SEC" , "Total (potentially overlapping) annotation duration (secs)" );
add_var( "SPANNING" , "" , "ANNOT_HMS" , "Total (potentially overlapping) annotation duration (hh:mm:ss)" );
add_var( "SPANNING" , "" , "ANNOT_OVERLAP" , "Do any annotations in group overlap w/ one another (0/1)?" );
add_var( "SPANNING" , "" , "INVALID_N" , "Number of annotations that over-extend EDF duration" );
add_var( "SPANNING" , "" , "VALID_N" , "Number of valid annotations, ANNOT_N - INVALID_N" );
add_var( "SPANNING" , "" , "INVALID_SEC" , "Total duration of all annotation beyond EDF end" );
add_var( "SPANNING" , "" , "SPANNED_PCT" , "% of EDF spanned by 1+ of these annotations" );
add_var( "SPANNING" , "" , "SPANNED_SEC" , "Duration of EDF spanned by 1+ of these annotations (secs)" );
add_var( "SPANNING" , "" , "SPANNED_HMS" , "Duration of EDF spanned by 1+ of these annotations (hh:mm:ss)" );
add_var( "SPANNING" , "" , "UNSPANNED_PCT" , "% of EDF unspanned by 1+ of these annotations" );
add_var( "SPANNING" , "" , "UNSPANNED_SEC" , "Duration of EDF unspanned by 1+ of these annotations (secs)" );
add_var( "SPANNING" , "" , "UNSPANNED_HMS" , "Duration of EDF unspanned by 1+ of these annotations (hh:mm:ss)" );
/////////////////////////////////////////////////////////////////////////////////
//
// EPOCHS
//
/////////////////////////////////////////////////////////////////////////////////
// EPOCH
add_cmd( "epoch" , "EPOCH" , "Set epochs" );
add_url ( "EPOCH" , "epochs/#epoch" );
add_param( "EPOCH" , "len" , "30" , "Epoch length (seconds), defaults to 30" );
add_param( "EPOCH" , "dur" , "30" , "Same as len" );
add_param( "EPOCH" , "inc" , "30" , "Epoch increment (seconds), defaults to len (i.e. no overlap)" );
add_param( "EPOCH" , "epoch" , "30,15" , "Same as len=30 inc=15" );
add_param( "EPOCH" , "require" , "10" , "Stop processing that EDF if there are not at least N epochs" );
add_param( "EPOCH" , "verbose" , "" , "Output epoch-level information" );
add_param( "EPOCH" , "clear" , "" , "Unepoch all signals" );
add_table( "EPOCH" , "" , "Epoch-level summaries" );
add_var( "EPOCH" , "" , "DUR" , "Epoch duration (seconds)" );
add_var( "EPOCH" , "" , "INC" , "Epoch increment (seconds)" );
add_var( "EPOCH" , "" , "NE" , "Number of epochs" );
add_table( "EPOCH" , "E" , "Per-epoch interval information [verbose]" );
add_var( "EPOCH" , "E" , "E1" , "Current epoch number (which may differ from E if the EDF has been restructured)" );
add_var( "EPOCH" , "E" , "HMS" , "Clock-time for epoch start (hh:mm:ss)" );
add_var( "EPOCH" , "E" , "INTERVAL" , "String label of epoch interval (seconds)" );
add_var( "EPOCH" , "E" , "MID" , "Midpoint of epoch (seconds elapsed from EDF start)" );
add_var( "EPOCH" , "E" , "START" , "Start of epoch (seconds elapsed from EDF start)" );
add_var( "EPOCH" , "E" , "STOP" , "Stop of epoch (seconds elapsed from EDF start)" );
add_var( "EPOCH" , "E" , "TP" , "Interval in time-points" );
// EPOCH-ANNOT
add_cmd( "epoch" , "EPOCH-ANNOT" , "Attach epoch-level annotations from a file, to an epoched EDF" );
add_url( "EPOCH-ANNOT" , "epochs/#epoch-annot" );
add_param( "EPOCH-ANNOT" , "file" , "annots/id1.epochs" , "File path/name to read annotations from [required]" );
add_param( "EPOCH-ANNOT" , "recode" , "NREM1=N1,NREM2=N2" , "Comma-delimited list of recodings (from=to)");
/////////////////////////////////////////////////////////////////////////////////
//
// MASKS
//
/////////////////////////////////////////////////////////////////////////////////
// MASK
add_cmd( "mask" , "MASK" , "Mask epochs based on annotations and other features" );
add_url( "MASK" , "masks/#mask" );
add_param( "MASK" , "if" , "NREM2" , "Mask NREM2 epochs, unmask all others" );
add_param( "MASK" , "ifnot" , "NREM2" , "Unmask NREM2 epochs, mask all others" );
add_param( "MASK" , "expr" , "A>2" , "Mask epochs with A>2, unmask all others" );
add_param( "MASK" , "not-expr" , "A>2" , "Unmask epochs with A>2, mask all others" );
add_param( "MASK" , "mask-if" , "NREM2" , "Mask NREM2 epochs" );
add_param( "MASK" , "mask-ifnot" , "NREM2" , "Mask non-NREM2 epochs" );
add_param( "MASK" , "mask-expr" , "A>2" , "Mask epochs with A>2" );
add_param( "MASK" , "unmask-if" , "NREM2" , "Unask NREM2 epochs" );
add_param( "MASK" , "unmask-ifnot" , "NREM2" , "Unask non-NREM2 epochs" );
add_param( "MASK" , "unmask-expr" , "A>2" , "Unmask epochs with A>2" );
add_param( "MASK" , "none" , "" , "Clear mask (i.e. unmask all)" );
add_param( "MASK" , "clear" , "" , "Clear mask (i.e. unmask all)" );
add_param( "MASK" , "include-all" , "" , "Clear mask (i.e. unmask all)" );
add_param( "MASK" , "all" , "" , "Mask all epochs" );
add_param( "MASK" , "total" , "" , "Mask all epochs" );
add_param( "MASK" , "exclude-all" , "" , "Mask all epochs" );
add_param( "MASK" , "epoch" , "1-10" , "Select epochs 1 to 10" );
add_param( "MASK" , "sec" , "60-120" , "Select epochs overlapping this interval" );
add_param( "MASK" , "hms" , "8:00-9:00" , "Select epochs overlapping this interval" );
add_param( "MASK" , "random" , "20" , "Select 20 random (currently unmasked) epochs" );
add_param( "MASK" , "flip" , "" , "Reverse all masks" );
add_param( "MASK" , "leading" , "W" , "Remove all leading epochs matching W" );
add_param( "MASK" , "flanked" , "REM,2" , "Select only REM epochs flanked by 2+ REM epochs before/after" );
add_table( "MASK" , "EMASK" , "Output stratified by mask" );
add_var( "MASK" , "EMASK", "N_MATCHES" , "Number of epochs that match the condition (e.g. having annotation A)");
add_var( "MASK" , "EMASK", "N_MASK_SET" , "Number of previously unmasked epochs that were masked by this operation");
add_var( "MASK" , "EMASK", "N_MASK_UNSET" , "Number of previously masked epochs that were unmasked by this operation");
add_var( "MASK" , "EMASK", "N_UNCHANGED" , "Number of epochs whose mask status was not changed by this operation");
add_var( "MASK" , "EMASK", "N_RETAINED" , "Number of epochs retained after this operation");
add_var( "MASK" , "EMASK", "N_TOTAL" , "Total number of epochs");
// DUMP-MASK
add_cmd( "mask" , "DUMP-MASK" , "Output epoch-level mask information" );
add_url( "DUMP-MASK" , "masks/#dump-mask" );
add_table( "DUMP-MASK" , "E" , "Epoch-level mask tabulation" );
add_var( "DUMP-MASK" , "E" , "EMASK" , "Mask status: 0=unmasked (included), 1=masked (excluded)" );
// RE (or RESTRUCTURE)
add_cmd( "mask" , "RE" , "Restructure an EDF (drop channels/epochs)" );
add_url( "RE" , "masks/#restructure" );
add_table( "RE" , "" , "Restructured data duration" );
add_var( "RE" , "" , "DUR1" , "Duration pre-restructuring (secs)");
add_var( "RE" , "" , "DUR2" , "Duration post-restructuring (secs)");
add_var( "RE" , "" , "NR1" , "Duration pre-restructuring (records)");
add_var( "RE" , "" , "NR2" , "Duration post-restructuring (records)");
add_cmd( "mask" , "RESTRUCTURE" , "Restructure an EDF (drop channels/epochs)" );
add_url( "RESTRUCTURE" , "masks/#restructure" );
add_table( "RESTRUCTURE" , "" , "Restructured data duration" );
add_var( "RESTRUCTURE" , "" , "DUR1" , "Duration pre-restructuring (secs)");
add_var( "RESTRUCTURE" , "" , "DUR2" , "Duration post-restructuring (secs)");
add_var( "RESTRUCTURE" , "" , "NR1" , "Duration pre-restructuring (records)");
add_var( "RESTRUCTURE" , "" , "NR2" , "Duration post-restructuring (records)");
//
// CHEP
//
add_cmd( "mask" , "CHEP" , "CHannel/EPoch masks" );
add_url( "CHEP" , "masks/#chep" );
add_param( "CHEP" , "clear" , "" , "Clear CHEP mask" );
add_param( "CHEP" , "load" , "file.txt" , "Load CHEP from file.txt" );
add_param( "CHEP" , "bad-channels" , "C3,C5" , "Manually specify bad channels" );
add_param( "CHEP" , "epochs" , "2,0.1" , "Mask epochs with 2 or more bad channels, or >10% bad channels" );
add_param( "CHEP" , "channels" , "10,0.5" , "Mask channels with 10 or more bad epochs, or >50% bad epochs" );
add_param( "CHEP" , "dump" , "" , "Write current CHEP mask to output" );
add_param( "CHEP" , "save" , "file.txt" , "Write CHEP mask to file.txt" );
// CHEP output....
add_table( "CHEP" , "CH" , "CHEP mask channel-wise summaries" );
add_var( "CHEP" , "CH" , "CHEP" , "Masked epochs" );
add_table( "CHEP" , "E" , "CHEP mask epoch-wise summaries" );
add_var( "CHEP" , "E" , "CHEP" , "Masked channels" );
add_table( "CHEP" , "CH,E" , "CHEP mask" );
add_var( "CHEP" , "CH,E" , "CHEP" , "CHannel/EPoch mask" );
/////////////////////////////////////////////////////////////////////////////////
//
// MANIPULATIONS
//
/////////////////////////////////////////////////////////////////////////////////
// SIGNALS
add_cmd( "manip" , "SIGNALS" , "Retain/remove specific EDF channels" );
add_url( "SIGNALS" , "manipulatons/#signals" );
add_param( "SIGNALS" , "drop" , "EMG,ECG" , "Drop channels EMG and ECG" );
add_param( "SIGNALS" , "keep" , "C3,C4" , "Drop all channels except C3 and C4" );
// CONTAINS
add_cmd( "manip" , "CONTAINS" , "Tests for particular signals/annotations/staging being present" );
add_url( "CONTAINS" , "manipulatons/#contains" );
add_param( "CONTAINS" , "sig" , "EMG,ECG" , "Test for these signals" );
add_param( "CONTAINS" , "annots" , "apnea,hypopnea" , "Test for these annotations" );
add_param( "CONTAINS" , "stages" , "" , "Test for valid staging" );
add_param( "CONTAINS" , "skip" , "" , "Skip to next EDF on failure" );
add_table( "CONTAINS" , "" , "Base" );
add_var( "CONTAINS" , "" , "STAGE_COUNTS" , "Sleep stage counts" );
add_var( "CONTAINS" , "" , "UNIQ_STAGES" , "Number of unique stage labels" );
add_var( "CONTAINS" , "" , "NA_REQ" , "Number of required annots" );
add_var( "CONTAINS" , "" , "NA_OBS" , "Number of observed annots" );
add_var( "CONTAINS" , "" , "NS_OBS" , "Number of required channels" );
add_var( "CONTAINS" , "" , "NS_REQ" , "Number of observed channels" );
add_var( "CONTAINS" , "" , "NS_TOT" , "Tot number of channels" );
add_table( "CONTAINS" , "ANNOT" , "Annotation informationm" );
add_var( "CONTAINS" , "CH" , "PRESENT" , "Annotation resent" );
add_table( "CONTAINS" , "CH" , "Channel informationm" );
add_var( "CONTAINS" , "CH" , "PRESENT" , "Channel present" );
// COPY
add_cmd( "manip" , "COPY" , "Duplicate one or more EDF channels" );
add_url( "COPY" , "manipulations/#copy" );
add_param( "COPY" , "sig" , "C3,C4" , "List of channels to duplicate" );
add_param( "COPY" , "tag" , "V2" , "Tag add to new channel names, e.g. C3_V2 [required] " );
// CANONICAL
add_cmd( "manip" , "CANONICAL" , "Create canonical signals" );
add_url( "CANONICAL" , "manipulations/#canonical" );
add_param( "CANONICAL" , "file" , "csfile.txt" , "File with canonical signal definitions" );
add_param( "CANONICAL" , "group" , "GRP1" , "Group (from csfile.txt)" );
add_param( "CANONICAL" , "cs" , "EEG,LOC,ROC" , "Optional: only calculate these CS" );
add_table( "CANONICAL" , "" , "Canonical signal summaries" );
add_var( "CANONICAL" , "" , "CS_SET" , "Number of canonical signals set" );
add_var( "CANONICAL" , "" , "CS_NOT" , "Number of canonical signals not set" );
add_var( "CANONICAL" , "" , "USED_CH" , "Number of used EDF channels" );
add_var( "CANONICAL" , "" , "UNUSED_CH" , "Number of ununsed EDF channels" );
add_table( "CANONICAL" , "CS" , "Canonical signal information" );
add_var( "CANONICAL" , "CS" , "DEFINED" , "Is canonical signal present/defined?" );
add_var( "CANONICAL" , "CS" , "SIG" , "Primary signal" );
add_var( "CANONICAL" , "CS" , "REF" , "Reference signal" );
add_var( "CANONICAL" , "CS" , "SR" , "Sample rate" );
add_var( "CANONICAL" , "CS" , "UNITS" , "Units for canonical signal" );
add_var( "CANONICAL" , "CS" , "NOTES" , "Optional, notes" );
add_table( "CANONICAL" , "CH" , "EDF channel information" );
add_var( "CANONICAL" , "CH" , "DROPPED" , "Original channel dropped" );
add_var( "CANONICAL" , "CH" , "USED" , "Not used in constructing canonical signals" );
// RESAMPLE
add_cmd( "manip" , "RESAMPLE" , "Resample signal(s)" );
add_url( "RESAMPLE" , "manipulations/#resample" );
add_param( "RESAMPLE" , "sig" , "C3,C4" , "List of channels to resample" );
add_param( "RESAMPLE" , "sr" , "200" , "New sampling rate (Hz) [required]" );
// REFERENCE
add_cmd( "manip" , "REFERENCE" , "Resample signal(s)" );
add_url( "REFERENCE" , "manipulations/#resample" );
add_param( "REFERENCE" , "sig" , "C3,C4" , "List of signals to re-reference" );
add_param( "REFERENCE" , "ref" , "A1,A2" , "Signal(s) providing the reference [required]" );
// uV
add_cmd( "manip" , "uV" , "Converts a signal to uV units" );
add_url( "uV" , "manipulations/#uv" );
add_param( "uV" , "sig" , "C3,C4" , "List of signals to convert" );
// mV
add_cmd( "manip" , "mV" , "Converts a signal to mV units" );
add_url( "mV" , "manipulations/#mv" );
add_param( "mV" , "sig" , "C3,C4" , "List of signals to convert" );
// FLIP
add_cmd( "manip" , "FLIP" , "Flips the polarity of a signal" );
add_url( "FLIP" , "manipulations/#flip" );
add_param( "FLIP" , "sig" , "C3,C4" , "List of signals to flip" );
add_table( "FLIP" , "CH" , "Tracking flipped channels" );
add_var( "FLIP" , "CH" , "FLIP" , "Channel flipped" );
// RECORD-SIZE
add_cmd( "manip" , "RECORD-SIZE" , "Alters the record size of an EDF, and writes a new EDF" );
add_url( "RECORD-SIZE" , "manipulations/#record-size" );
add_param( "RECORD-SIZE" , "dur" , "1" , "New EDF record/block size" );
add_param( "RECORD-SIZE" , "edf-dir" , "edfs/" , "Folder for writing new EDFs" );
add_param( "RECORD-SIZE" , "edf-tag" , "rec1" , "Tag added to new EDFs" );
add_param( "RECORD-SIZE" , "sample-list" , "s2.lst" , "Generate a sample-list pointing to the new EDFs" );
add_table( "RECORD-SIZE" , "" , "Restructured data duration" );
add_var( "RECORD-SIZE", "" , "NR1" , "Pre-restructure number of records" );
add_var( "RECORD-SIZE", "" , "NR2" , "Post-restructure number of records" );
add_var( "RECORD-SIZE", "" , "DUR1" , "Pre-restructure duration (seconds)" );
add_var( "RECORD-SIZE", "" , "DUR2" , "Post-restructure duration (seconds)" );
// ANON
add_cmd( "manip" , "ANON" , "Strips EDF ID and and Start Date headers" );
add_url( "ANON" , "manipulations/#anon" );
/////////////////////////////////////////////////////////////////////////////////
//
// OUTPUTS
//
/////////////////////////////////////////////////////////////////////////////////
// WRITE
add_cmd( "output" , "WRITE" , "Write a new EDF file" );
add_url( "WRITE" , "outputs/#write" );
add_param( "WRITE" , "edf-dir" , "edfs/" , "Set folder where new EDFs should be written" );
add_param( "WRITE" , "edf-tag" , "v2" , "Add a tag to each new EDF filename" );
add_param( "WRITE" , "sample-list" , "v2.lst" , "Name of the new sample-list" );
add_table( "WRITE", "" , "Misc output from pre-WRITE restructure" );
add_var( "WRITE", "" , "NR1" , "Pre-restructure number of records" );
add_var( "WRITE", "" , "NR2" , "Post-restructure number of records" );
add_var( "WRITE", "" , "DUR1" , "Pre-restructure duration (seconds)" );
add_var( "WRITE", "" , "DUR2" , "Post-restructure duration (seconds)" );
// MATRIX
add_cmd( "output" , "MATRIX" , "Dumps signal information to a file" );
add_url( "MATRIX" , "outputs/#matrix" );
add_param( "MATRIX" , "file" , "signals.txt" , "Required parameter, to specify the filename for the output" );
add_param( "MATRIX" , "sig" , "C3,C4" , "Restrict output to these signal(s)" );
add_param( "MATRIX" , "hms" , "" , "Add a clock-time column in hh:mm:ss format" );
add_param( "MATRIX" , "hms2" , "" , "Add a clock-time column in hh:mm:ss:microsecond format" );
add_param( "MATRIX" , "annot" , "X,Y" , "Add columns with values 1/0 to indicate the presence/absence of that annotation" );
add_param( "MATRIX" , "min" , "" , "Minimal output to show only signal information (no headers or lead columns)" );
// DUMP-RECORDS
add_cmd( "output" , "DUMP-RECORDS" , "Writes detailed annotation and signal data to standard output" );
add_url( "DUMP-RECORDS" , "outputs/#dump-records" );
add_param( "DUMP-RECORDS" , "no-signals" , "" , "Do not show signal data" );
add_param( "DUMP-RECORDS" , "no-annots" , "" , "Do not show annotation information" );
// RECS
add_cmd( "output" , "RECS" , "Dumps information on EDF record structure to standard out" );
add_url( "RECS" , "outputs/#recs" );
// SEGMENTS
add_cmd( "output" , "SEGMENTS" , "Report on contiguous segments in an EDF/EDF+" );
add_url( "SEGMENTS" , "outputs/#segments" );
add_table( "SEGMENTS" , "" , "Number of contiguous segments" );
add_var( "SEGMENTS" , "" , "NSEGS" , "Number of contiguous segments" );
add_table( "SEGMENTS" , "SEG" , "Information on each segment" );
add_var( "SEGMENTS" , "SEG" , "DUR_HR" , "Segment duration (hours)" );
add_var( "SEGMENTS" , "SEG" , "DUR_MIN" , "Segment duration (minutes)" );
add_var( "SEGMENTS" , "SEG" , "DUR_SEC" , "Segment duration (seconds)" );
add_var( "SEGMENTS" , "SEG" , "START" , "Segment start (seconds)" );
add_var( "SEGMENTS" , "SEG" , "START_HMS" , "Segment start (hh:mm:ss)" );
add_var( "SEGMENTS" , "SEG" , "STOP" , "Segment stop (seconds)" );
add_var( "SEGMENTS" , "SEG" , "STOP_HMS" , "Segment stop (hh:mm:ss)" );
// WRITE-ANNOTS
add_cmd( "output" , "WRITE-ANNOTS" , "Write all annotations to file" );
add_url( "WRITE-ANNOTS" , "outputs/#write-annots" );
add_param( "WRITE-ANNOTS" , "file" , "f1.xml" , "Required filename for output" );
add_param( "WRITE-ANNOTS" , "luna" , "" , "Output in Luna .annot format instead of XML" );
/////////////////////////////////////////////////////////////////////////////////
//
// FILTERS
//
/////////////////////////////////////////////////////////////////////////////////
// FILTER
add_cmd( "filter" , "FILTER" , "Apply a FIR filter to one or more signals");
add_url( "FILTER" , "fir-filters/#filter" );
add_param( "FILTER" , "sig" , "C3,C4" , "Restrict analysis to these channels" );
add_param( "FILTER" , "bandpass" , "0.3,35" , "Band-pass filter between 0.3 and 35 Hz" );
add_param( "FILTER" , "lowpass" , "35" , "Low-pass filter with cutoff of 35 Hz" );
add_param( "FILTER" , "highpass" , "0.3" , "High-pass filter with cutiff of 0.3 Hz" );
add_param( "FILTER" , "bandstop" , "55,65" , "Band-stop filter between 55 and 65 Hz" );
add_param( "FILTER" , "ripple" , "0.02" , "Ripple (as a proportion)" );
add_param( "FILTER" , "tw" , "1" , "Transition width (in Hz)" );
// FILTER-DESIGN
add_cmd( "filter" , "FILTER-DESIGN" , "Apply a FIR filter to one or more signals");
add_url( "FILTER-DESIGN" , "fir-filters/#filter-design" );
add_param( "FILTER-DESIGN" , "bandpass" , "0.3,35" , "Band-pass filter between 0.3 and 35 Hz" );
add_param( "FILTER-DESIGN" , "lowpass" , "35" , "Low-pass filter with cutoff of 35 Hz" );
add_param( "FILTER-DESIGN" , "highpass" , "0.3" , "High-pass filter with cutiff of 0.3 Hz" );
add_param( "FILTER-DESIGN" , "bandstop" , "55,65" , "Band-stop filter between 55 and 65 Hz" );
add_param( "FILTER-DESIGN" , "ripple" , "0.02" , "Ripple (as a proportion)" );
add_param( "FILTER-DESIGN" , "tw" , "1" , "Transition width (in Hz)" );
add_param( "FILTER-DESIGN" , "fs" , "200" , "Specify sample rate (in Hz)" );
/////////////////////////////////////////////////////////////////////////////////
//
// ARTIFACTS
//
/////////////////////////////////////////////////////////////////////////////////
// SIGSTATS
add_cmd( "artifact" , "SIGSTATS" , "Per-epoch outlier detection (RMS, Hjorth parameters, clipped signals)" );
add_url( "SIGSTATS" , "artifacts/#sigstats" );
add_param( "SIGSTATS" , "sig" , "C3,C4" , "Restrict analysis to these channels" );
add_param( "SIGSTATS" , "verbose" , "" , "Report epoch-level statistics" );
add_param( "SIGSTATS" , "epoch" , "" , "Report epoch-level statistics (same as verbose)" );
add_param( "SIGSTATS" , "chep" , "" , "Set CHEP mask for outlier epochs" );
add_param( "SIGSTATS" , "astats" , "3,3" , "Between-epoch, betwee-channel filtering" );
add_param( "SIGSTATS" , "cstats" , "2" , "Within-epoch, between-channel filtering" );
add_param( "SIGSTATS" , "rms" , "" , "Calculate/mask on RMS" );
add_param( "SIGSTATS" , "clipped" , "0.05" , "Calculate/mask on signal clipping" );
add_param( "SIGSTATS" , "flat" , "0.05" , "Calculate/mask on signal clipping" );
add_param( "SIGSTATS" , "max" , "0.05" , "Calculate/mask on signal clipping" );
add_param( "SIGSTATS" , "threshold" , "2,2" , "Set eppoch masks based on SD unit (iterative) outlier detection" );
add_param( "SIGSTATS" , "th" , "2,2" , "Same as 'threshold'" );
add_param( "SIGSTATS" , "cstats" , "2" , "Run channel-comparisons, with threshold in SD units" );
add_param( "SIGSTATS" , "cstats-unmasked-only" , "" , "Channel-comparisons only for unmasked epochs" );
add_table( "SIGSTATS" , "CH" , "Per-channel whole-signal statistics" );
add_var( "SIGSTATS" , "CH" , "CLIP" , "Proportion of clipped sample points" );
add_var( "SIGSTATS" , "CH" , "FLAT" , "Proportion of flat sample points" );
add_var( "SIGSTATS" , "CH" , "MAX" , "Proportion of max sample points" );
add_var( "SIGSTATS" , "CH" , "H1" , "First Hjorth parameter (activity)" );
add_var( "SIGSTATS" , "CH" , "H2" , "Second Hjorth parameter (mobility)" );
add_var( "SIGSTATS" , "CH" , "H3" , "Third Hjorth parameter (complexity)" );
add_var( "SIGSTATS" , "CH" , "RMS" , "Signal root mean square" );
add_var( "SIGSTATS" , "CH" , "P_H1" , "Proportion flagged epochs for H1 [cstats]" );
add_var( "SIGSTATS" , "CH" , "P_H2" , "Proportion flagged epochs for H2 [cstats]" );
add_var( "SIGSTATS" , "CH" , "P_H3" , "Proportion flagged epochs for H3 [cstats]" );
add_var( "SIGSTATS" , "CH" , "P_OUT" , "Proportion flagged epochs for H1, H2 or H3 [cstats]" );
add_var( "SIGSTATS" , "CH" , "Z_H1" , "Z score for H1 [cstats]" );
add_var( "SIGSTATS" , "CH" , "Z_H2" , "Z score for H2 [cstats]" );
add_var( "SIGSTATS" , "CH" , "Z_H3" , "Z score for H3 [cstats]" );
add_var( "SIGSTATS" , "CH" , "CNT_ACT" , "Number of epochs flagged based on H1 [mask]" );
add_var( "SIGSTATS" , "CH" , "CNT_MOB" , "Number of epochs flagged based on H2 [mask]" );
add_var( "SIGSTATS" , "CH" , "CNT_CMP" , "Number of epochs flagged based on H3 [mask]" );
add_var( "SIGSTATS" , "CH" , "CNT_CLP" , "Number of epochs flagged based on clipping metric" );
add_var( "SIGSTATS" , "CH" , "CNT_RMS" , "Number of epochs flagged based on RMS" );
add_var( "SIGSTATS" , "CH" , "FLAGGED_EPOCHS" , "Number of epochs flagged as outliers [mask]" );
add_var( "SIGSTATS" , "CH" , "ALTERED_EPOCHS" , "Number of epochs whose mask was altered [mask]" );
add_var( "SIGSTATS" , "CH" , "TOTAL_EPOCHS" , "Total number of masked epochs [mask]" );
add_table( "SIGSTATS" , "CH,E" , "Per-channel per-epoch statistics [epoch]" );
add_var( "SIGSTATS" , "CH,E" , "H1" , "First Hjorth parameter (activity)" );
add_var( "SIGSTATS" , "CH,E" , "H2" , "Second Hjorth parameter (mobility)" );
add_var( "SIGSTATS" , "CH,E" , "H3" , "Third Hjorth parameter (complexity)" );
hide_var( "SIGSTATS" , "CH,E" , "CLIP" , "Proportion of clipped sample points" );
hide_var( "SIGSTATS" , "CH,E" , "FLAT" , "Proportion of flat sample points" );
hide_var( "SIGSTATS" , "CH,E" , "MAX" , "Proportion of max sample points" );
hide_var( "SIGSTATS" , "CH,E" , "RMS" , "Signal root mean square" );
// ARTIFACTS
add_cmd( "artifact" , "ARTIFACTS" , "Detect EEG artifacts following Buckelmueller et al." );
add_url( "ARTIFACTS" , "artifacts/#artifacst" );
add_param( "ARTIFACTS" , "sig" , "C3,C4" , "Restrict analysis to these channels" );
add_param( "ARTIFACTS" , "verbose" , "" , "Report epoch-level statistics" );
add_param( "ARTIFACTS" , "no-mask" , "" , "Do not set mask for outlier epochs" );
add_table( "ARTIFACTS" , "CH" , "Per-channel output" );
add_var( "ARTIFACTS" , "CH" , "FLAGGED_EPOCHS" , "Number of epochs failing" );
add_var( "ARTIFACTS" , "CH" , "ALTERED_EPOCHS" , "Number of epochs actually masked" );
add_var( "ARTIFACTS" , "CH" , "TOTAL_EPOCHS" , "Number of epochs tested" );
add_table( "ARTIFACTS" , "CH,E" , "Per-channel per-epoch output [verbose]" );
add_var( "ARTIFACTS" , "CH,E" , "DELTA" , "Delta power" );
add_var( "ARTIFACTS" , "CH,E" , "DELTA_AVG" , "Local average delta power" );
add_var( "ARTIFACTS" , "CH,E" , "DELTA_FAC" , "Relative delta factor" );
add_var( "ARTIFACTS" , "CH,E" , "BETA" , "Beta power" );
add_var( "ARTIFACTS" , "CH,E" , "BETA_AVG" , "Local average beta power" );
add_var( "ARTIFACTS" , "CH,E" , "BETA_FAC" , "Relative beta factor" );
add_var( "ARTIFACTS" , "CH,E" , "DELTA_MASK" , "Masked based on delta power?" );
add_var( "ARTIFACTS" , "CH,E" , "BETA_MASK" , "Masked based on beta power?" );
add_var( "ARTIFACTS" , "CH,E" , "MASK" , "Is this epoch masked?" );
// SUPPRESS-ECG
add_cmd( "artifact" , "SUPPRESS-ECG" , "Detect/remove cardiac-contamination from the EEG" );
add_url( "SUPPRESS-ECG" , "artifacts/#suppress-ecg" );
add_param( "SUPPRESS-ECG" , "sig" , "C3,C4" , "Restrict analysis to these channels" );
add_param( "SUPPRESS-ECG" , "sr" , "125" , "Set sample rate for ECG/EEG channels" );
add_param( "SUPPRESS-ECG" , "no-suppress" , "" , "Do not alter any EEG channels" );
add_table( "SUPPRESS-ECG" , "" , "Individual-level summaries" );
add_var( "SUPPRESS-ECG" , "" , "BPM" , "Mean heart rate (bpm)" );
add_var( "SUPPRESS-ECG" , "" , "BPM_L95" , "Lower 95% confidence interval for mean HR" );
add_var( "SUPPRESS-ECG" , "" , "BPM_U95" , "Upper 95% confidence interval for mean HR" );
add_var( "SUPPRESS-ECG" , "" , "BPM_N_REMOVED" , "Number of epochs flagged as having invalid HR estimates" );
add_var( "SUPPRESS-ECG" , "" , "BPM_PCT_REMOVED" , "Proportion of epochs flagged as having invalid HR estimates" );
add_table( "SUPPRESS-ECG" , "E" , "Epoch-level metrics" );
add_var( "SUPPRESS-ECG" , "E" , "BPM" , "HR for this epoch" );
add_var( "SUPPRESS-ECG" , "E" , "BPM_MASK" , "Was this epoch invalid?" );
add_table( "SUPPRESS-ECG" , "CH" , "Channel-level metrics" );
add_var( "SUPPRESS-ECG" , "CH" , "ART_RMS" , "Root mean square of correction signature" );
add_table( "SUPPRESS-ECG" , "CH,SP" , "Details of artifact signature" );
add_var( "SUPPRESS-ECG" , "CH,SP" , "ART_RMS" , "Estimate correction factor, for each sample point in a 2-second window" );
// EMD
add_cmd( "power" , "EMD" , "Empirical mode decomposition" );
add_url( "EMD" , "power-spectra/#emd" );
add_param( "EMD" , "sig" , "C3,C4" , "Select signals for EMD" );
add_param( "EMD" , "tag" , "_C_" , "IMF channel tag, if not _IMF_" );
add_param( "EMD" , "sift" , "20" , "Maximum number of sifting operations" );
add_param( "EMD" , "imf" , "10" , "Maximum number of IMF to extract" );
// ALTER
add_cmd( "artifact" , "ALTER" , "Regression- or EMD-based artifact correction" );
add_url( "ALTER" , "artifacts/#alter" );
add_param( "ALTER" , "sig" , "C3,C4" , "Signals for analysis" );
add_param( "ALTER" , "corr" , "EOG-R,EOG-L" , "Template signal(s)" );
add_param( "ALTER" , "emd" , "" , "Use EMD instead of raw regression" );
add_param( "ALTER" , "th" , "0.9" , "Threshold" );
add_param( "ALTER" , "emd-corr" , "" , "Run EMD of corrector channels" );
add_param( "ALTER" , "segment-sec" , "4" , "Segment size" );
add_param( "ALTER" , "segment-step" , "2" , "Segment step (half size by default)" );
/////////////////////////////////////////////////////////////////////////////////
//
// HYPNOGRAMS
//
/////////////////////////////////////////////////////////////////////////////////
add_cmd( "hypno" , "STAGE" , "Output sleep stage annotations, per epoch" );
add_url( "STAGE" , "hypnograms/#stage" );
add_param( "STAGE" , "N1" , "NREM1" , "Set the annotation used for N1 sleep" );
add_param( "STAGE" , "N2" , "NREM2" , "Set the annotation used for N2 sleep" );
add_param( "STAGE" , "N3" , "NREM3" , "Set the annotation used for N3 sleep" );
add_param( "STAGE" , "REM" , "REM" , "Set the annotation used for REM sleep" );
add_param( "STAGE" , "wake" , "W" , "Set the annotation used for N3 sleep" );
add_param( "STAGE" , "?" , "-9" , "Set the annotation used for unknown/other" );
add_table( "STAGE" , "E" , "Stage annotations per-epoch" );
add_var( "STAGE" , "E" , "CLOCK_TIME" , "Clock time (hh:mm:ss)" );
add_var( "STAGE" , "E" , "MINS" , "Elapsed time from start of EDF (minutes)" );
add_var( "STAGE" , "E" , "STAGE" , "Sleep stage (text value)" );
add_var( "STAGE" , "E" , "STAGE_N" , "Numeric encoding of sleep stage" );
add_cmd( "hypno" , "HYPNO" , "Metrics based on sleep stage annotations" );
add_url( "HYPNO" , "hypnograms/#hypno" );
add_param( "HYPNO" , "file" , "stages.txt" , "Optionally, read stages from file" );
add_param( "HYPNO" , "N1" , "NREM1" , "Set the annotation used for N1 sleep" );
add_param( "HYPNO" , "N2" , "NREM2" , "Set the annotation used for N2 sleep" );
add_param( "HYPNO" , "N3" , "NREM3" , "Set the annotation used for N3 sleep" );
add_param( "HYPNO" , "REM" , "REM" , "Set the annotation used for REM sleep" );
add_param( "HYPNO" , "wake" , "W" , "Set the annotation used for N3 sleep" );
add_param( "HYPNO" , "?" , "-9" , "Set the annotation used for unknown/other" );
add_table( "HYPNO" , "" , "Individual-level output" );
add_var( "HYPNO" , "" , "TRT" , "Total sleep time" );
add_var( "HYPNO" , "" , "TST" , "Total sleep time" );
add_var( "HYPNO" , "" , "TST_PER" , "Total persistent sleep time" );
add_var( "HYPNO" , "" , "TIB" , "Time in bed" );
add_var( "HYPNO" , "" , "SPT" , "Sleep period time" );
add_var( "HYPNO" , "" , "SPT_PER" , "Persistent sleep period time" );
add_var( "HYPNO" , "" , "TWT" , "Total wake time" );
add_var( "HYPNO" , "" , "WASO" , "Wake after sleep onset" );
add_var( "HYPNO" , "" , "FWT" , "Final wake time" );
add_var( "HYPNO" , "" , "LOT" , "Lights On time" );
add_var( "HYPNO" , "" , "LOST" , "Lights On sleep time" );