You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Doc_BoxAlgorithm_CSVFileWriter.rst 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. .. _Doc_BoxAlgorithm_CSVFileWriter:
  2. CSV File Writer
  3. ===============
  4. .. container:: attribution
  5. :Author:
  6. Victor Herlin
  7. :Company:
  8. Mensia Technologies SA
  9. .. image:: images/Doc_BoxAlgorithm_CSVFileWriter.png
  10. This box writes incoming time series along with a stimulation stream into a text file using the
  11. Comma Separated Values format conforming to the RFC 4180 format.
  12. The header of the CSV file contains some additional information that enables additional features
  13. during subsequent reading. This format is described in the :ref:`Doc_BoxAlgorithm_CSVFileWriter_Miscellaneous`
  14. section.
  15. Inputs
  16. ------
  17. .. csv-table::
  18. :header: "Input Name", "Stream Type"
  19. "Input stream", "Signal"
  20. "Stimulations stream", "Stimulations"
  21. Input stream
  22. ~~~~~~~~~~~~
  23. Time series input, this can be either a Signal, Streamed Matrix, Spectrum, Covariance Matrix or Feature Vector stream.
  24. Stimulations stream
  25. ~~~~~~~~~~~~~~~~~~~
  26. Stimulations to be written alongside the signal.
  27. .. _Doc_BoxAlgorithm_CSVFileWriter_Settings:
  28. Settings
  29. --------
  30. .. csv-table::
  31. :header: "Setting Name", "Type", "Default Value"
  32. "Filename", "Filename", ""
  33. "Precision", "Integer", "10"
  34. "Append data", "Boolean", "false"
  35. "Only last matrix", "Boolean", "false"
  36. Filename
  37. ~~~~~~~~
  38. Path of the CSV file to be written.
  39. - Default value : [ *record-[$core{date}-$core{time}].csv* ]
  40. Precision
  41. ~~~~~~~~~
  42. Precision, in number of decimal digits, of the resulting data. For longer data the precision can significantly impact the file size.
  43. Append data
  44. ~~~~~~~~~~~
  45. By default this box will overwrite data in the file if it exists. If this setting is set to true, the box will append data to the file instead. If the file is empty a header will be added as well. It is up to the user to ensure herself that the data written is of the same type and dimensions.
  46. Only last matrix
  47. ~~~~~~~~~~~~~~~~
  48. If this setting is activated, only the last received matrix will be written to the file. This can be used, for example, with cumulative average box.
  49. .. _Doc_BoxAlgorithm_CSVFileWriter_Examples:
  50. Examples
  51. --------
  52. Example of writing a spectrum into a CSV file:
  53. .. figure:: images/csv-file-writer-example.png
  54. :alt: Writing a CSV file
  55. :align: center
  56. Writing a CSV file
  57. .. _Doc_BoxAlgorithm_CSVFileWriter_Miscellaneous:
  58. Miscellaneous
  59. -------------
  60. The CSV Format
  61. ## Example file containing Signal data and Stimulations
  62. Signal file sampled at 8Hz, with epochs of 0.5s length. Note that the timestamps do not have an end time which is implicit.
  63. In this example each x represents an arbitrary floating point value. The header contains the following rows:
  64. - Time:8Hz - contains the timestamp of each sample, this label also encodes the original sampling rate
  65. - Epoch - contains the number of the epoch in which each sample is contained, this allows encoding even overlapping signal
  66. - O1, O2, Pz, P3, P4 - channels containing EEG data
  67. - Event Id - contains a colon separated list of StimulationIds
  68. - Event Date - contains the same number of timestamps
  69. - Event Duration - is constructed in the same manner as Event Date
  70. .. code::
  71. Time:8Hz,Epoch,O1,O2,Pz,P3,P4,Event Id,Event Date,Event Duration
  72. 0.00000,0,x,x,x,x,x,,,
  73. 0.12500,0,x,x,x,x,x,,,
  74. 0.25000,0,x,x,x,x,x,32000:32010,0.25000:0.25000,0:0
  75. 0.37500,0,x,x,x,x,x,,,
  76. 0.50000,1,x,x,x,x,x,,,
  77. 0.62500,1,x,x,x,x,x,,,
  78. 0.75000,1,x,x,x,x,x,35000,0.75250,0
  79. 0.87500,1,x,x,x,x,x,,,
  80. ## Example file containing a three dimensional matrix
  81. This example file contains 2x2x2 matrices produced every 0.125 seconds and spanning one second.
  82. The labels for this matrix are:
  83. - for first dimension "LA", "LB"
  84. - for second dimension "1", "2"
  85. - for third dimension "X", "Y"
  86. .. code::
  87. Time:2x2x2,End Time,LA:1:X,LA:1:Y,LA:2:X,LA:2:Y,LB:1:X,...,LB:2:Y,Event Id,Event Date,Event Duration
  88. 0.00000,1.00000,x,x,x,x,x,...,x,,,
  89. 0.12500,1.12500,x,x,x,x,x,...,x,,,
  90. 0.25000,1.25000,x,x,x,x,x,...,x,,,
  91. 0.37500,1.37500,x,x,x,x,x,...,x,,,
  92. 0.50000,1.50000,x,x,x,x,x,...,x,,,
  93. 0.62500,1.62500,x,x,x,x,x,...,x,,,
  94. 0.75000,1.75000,x,x,x,x,x,...,x,,,
  95. 0.87500,1.62500,x,x,x,x,x,...,x,,,
  96. 1.00000,2.00000,x,x,x,x,x,...,x,,,
  97. 1.12500,2.12500,x,x,x,x,x,...,x,,,
  98. \note
  99. A label can be an empty string. If second dimension had an empty label then the first column would have label "LA::X", if it were the third dimension the column would have label "LA:1:"
  100. ## Example file containing a spectrum
  101. Spectrum file with 2 channels, 128Hz signal and spectra calculated on periods of 1 second every 0.125 seconds. The last element in the Time column (128) represents the original sampling rate.
  102. .. code::
  103. Time:2x64:128,End Time,O1:0,O1:1.015873,...,O1:64,O2:0,...,O2:64,Event Id,Event Date,Event Duration
  104. 0.00000,1.00000,x,x,...,x,x,...,x,,,
  105. 0.12500,1.12500,x,x,...,x,x,...,x,,,
  106. 0.25000,1.25000,x,x,...,x,x,...,x,,,
  107. 0.37500,1.37500,x,x,...,x,x,...,x,,,
  108. 0.50000,1.50000,x,x,...,x,x,...,x,,,
  109. 0.62500,1.62500,x,x,...,x,x,...,x,,,
  110. 0.75000,1.75000,x,x,...,x,x,...,x,,,
  111. 0.87500,1.87500,x,x,...,x,x,...,x,,,
  112. 1.00000,2.00000,x,x,...,x,x,...,x,,,
  113. 1.12500,2.12500,x,x,...,x,x,...,x,,,