n2h5.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (c) Copyright 2012 Blackrock Microsystems
  4. //
  5. // $Workfile: n2h5.h $
  6. // $Archive: /n2h5/n2h5.h $
  7. // $Revision: 1 $
  8. // $Date: 11/1/12 1:00p $
  9. // $Author: Ehsan $
  10. //
  11. // $NoKeywords: $
  12. //
  13. //////////////////////////////////////////////////////////////////////////////
  14. //
  15. // Note:
  16. // for simple tools to better understand the format keep variable length types to the end
  17. //
  18. #ifndef N2H5_H_
  19. #define N2H5_H_
  20. #include "cbhwlib.h"
  21. #include "hdf5.h"
  22. #include "hdf5_hl.h"
  23. //
  24. // Basic channel attributes
  25. //
  26. typedef struct {
  27. uint16_t id; // channel id
  28. char szLabel[64]; // Channel label
  29. } BmiChanAttr_t;
  30. hid_t CreateChanAttrType(hid_t loc);
  31. //
  32. // Sample rate attributes
  33. //
  34. typedef struct {
  35. float fClock; // global clock used for this data set
  36. float fSampleRate; // sampling done for this channel
  37. uint8_t nSampleBits; // Number of bits in each sample
  38. } BmiSamplingAttr_t;
  39. hid_t CreateSamplingAttrType(hid_t loc);
  40. //
  41. // Channel filter attributes
  42. //
  43. typedef struct {
  44. // High pass filter info
  45. uint32_t hpfreq; // Filter frequency in mHz
  46. uint32_t hporder; // Filter order
  47. uint16_t hptype; // Filter type
  48. // Low pass filter info
  49. uint32_t lpfreq; // Filter frequency in mHz
  50. uint32_t lporder; // Filter order
  51. uint16_t lptype; // Filter type
  52. } BmiFiltAttr_t;
  53. hid_t CreateFiltAttrType(hid_t loc);
  54. //
  55. // Channel extra attributes addition 1
  56. //
  57. typedef struct {
  58. // These may only appear in NEV extra headers
  59. uint8_t sortCount; // Number of sorted units
  60. uint32_t energy_thresh;
  61. int32_t high_thresh;
  62. int32_t low_thresh;
  63. } BmiChanExt1Attr_t;
  64. hid_t CreateChanExt1AttrType(hid_t loc);
  65. //
  66. // Channel extra attributes addition 2
  67. //
  68. typedef struct {
  69. // These may only appear in NSx extra headers
  70. int32_t digmin; // Minimum digital value
  71. int32_t digmax; // Maximum digital value
  72. int32_t anamin; // Minimum analog Value
  73. int32_t anamax; // Maximum analog Value
  74. char anaunit[16]; // Units for the Analog Value (e.g. "mV)
  75. } BmiChanExt2Attr_t;
  76. hid_t CreateChanExt2AttrType(hid_t loc);
  77. //
  78. // Channel extra attributes
  79. //
  80. typedef struct {
  81. double dFactor; // nano volts per LSB (used in conversion between digital and analog values)
  82. uint8_t phys_connector;
  83. uint8_t connector_pin;
  84. } BmiChanExtAttr_t;
  85. hid_t CreateChanExtAttrType(hid_t loc);
  86. //
  87. // Header may not change with each experiment
  88. // and thus root-group attribute
  89. //
  90. typedef struct {
  91. uint32_t nMajorVersion;
  92. uint32_t nMinorVersion;
  93. uint32_t nFlags;
  94. uint32_t nGroupCount; // Number of data groups withing this file
  95. char szDate[64]; // File creation date-time in SQL format
  96. char szApplication[64]; // Which application created this file
  97. char szComment[1024]; // File Comment
  98. } BmiRootAttr_t;
  99. hid_t CreateRootAttrType(hid_t loc);
  100. //
  101. // Synch general information
  102. //
  103. typedef struct {
  104. uint16_t id; // video source ID
  105. float fFps;
  106. char szLabel[64]; // Name of the video source
  107. } BmiSynchAttr_t;
  108. hid_t CreateSynchAttrType(hid_t loc);
  109. //
  110. // Video source general information
  111. //
  112. typedef struct {
  113. uint16_t type; // trackable type
  114. uint16_t trackID; // trackable ID
  115. uint16_t maxPoints;
  116. char szLabel[128]; // Name of the trackable
  117. } BmiTrackingAttr_t;
  118. hid_t CreateTrackingAttrType(hid_t loc);
  119. // Spike data (of int16_t samples)
  120. typedef struct {
  121. uint32_t dwTimestamp;
  122. uint8_t unit;
  123. uint8_t res;
  124. // This must be the last
  125. int16_t wave[cbMAX_PNTS]; // Currently up to cbMAX_PNTS
  126. } BmiSpike16_t;
  127. hid_t CreateSpike16Type(hid_t loc, uint16_t spikeLength);
  128. // Digital/serial data (of int16_t samples)
  129. typedef struct {
  130. uint32_t dwTimestamp;
  131. uint16_t value;
  132. } BmiDig16_t;
  133. hid_t CreateDig16Type(hid_t loc);
  134. // Video synchronization
  135. typedef struct {
  136. uint32_t dwTimestamp;
  137. uint16_t split;
  138. uint32_t frame;
  139. uint32_t etime; // Elapsed time in milli-seconds
  140. } BmiSynch_t;
  141. hid_t CreateSynchType(hid_t loc);
  142. // Video tracking
  143. typedef struct {
  144. uint32_t dwTimestamp;
  145. uint16_t parentID;
  146. uint16_t nodeCount;
  147. // This must be the last
  148. hvl_t coords;
  149. } BmiTracking_t;
  150. // Video tracking
  151. typedef struct {
  152. uint32_t dwTimestamp;
  153. uint16_t parentID;
  154. uint16_t nodeCount;
  155. uint32_t etime;
  156. // This must be the last
  157. uint16_t coords[cbMAX_TRACKCOORDS];
  158. } BmiTracking_fl_t;
  159. hid_t CreateTrackingType(hid_t loc, int dim, int width);
  160. #define BMI_COMMENT_LEN 256
  161. // Comment or user event
  162. typedef struct {
  163. uint32_t dwTimestamp;
  164. uint8_t flags;
  165. uint32_t data;
  166. char szComment[BMI_COMMENT_LEN];
  167. } BmiComment_t;
  168. hid_t CreateCommentType(hid_t loc);
  169. #endif /* N2H5_H_ */