NevNsx.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (c) Copyright 2012 Blackrock Microsystems
  4. //
  5. // $Workfile: NevNsx.h $
  6. // $Archive: /n2h5/NevNsx.h $
  7. // $Revision: 1 $
  8. // $Date: 11/1/12 1:00p $
  9. // $Author: Ehsan $
  10. //
  11. // $NoKeywords: $
  12. //
  13. //////////////////////////////////////////////////////////////////////////////
  14. #ifndef NEVNSX_H_
  15. #define NEVNSX_H_
  16. #include "cbhwlib.h"
  17. #pragma pack(push, 1)
  18. #ifndef WIN32
  19. typedef struct _SYSTEMTIME
  20. {
  21. uint16_t wYear;
  22. uint16_t wMonth;
  23. uint16_t wDayOfWeek;
  24. uint16_t wDay;
  25. uint16_t wHour;
  26. uint16_t wMinute;
  27. uint16_t wSecond;
  28. uint16_t wMilliseconds;
  29. } SYSTEMTIME;
  30. #endif
  31. // SQL time format
  32. typedef struct
  33. {
  34. char chYear[4];
  35. char ch4;
  36. char chMonth[2];
  37. char ch7;
  38. char chDay[2];
  39. char ch10;
  40. char chHour[2];
  41. char ch13;
  42. char chMinute[2];
  43. char ch16;
  44. char chSecond[2];
  45. char ch19;
  46. char chMicroSecond[6];
  47. char chNull;
  48. } TIMSTM;
  49. typedef struct
  50. {
  51. char achFileID[8]; // Always set to NEURALSG
  52. char szGroup[16]; // Label of the group
  53. uint32_t nPeriod; // How many ticks per sample (30,000 = rate)
  54. uint32_t cnChannels; // How many channels
  55. // Next comes
  56. // uint32_t // Which channels?
  57. // then
  58. // int16_t wData; // Data from each channel
  59. } Nsx21Hdr;
  60. typedef struct
  61. {
  62. char achFileID[8]; // Always set to NEURALCD
  63. unsigned char nMajor; // Major version number
  64. unsigned char nMinor; // Minor version number
  65. uint32_t nBytesInHdrs; // Bytes in all headers also pointer to first data pkt
  66. char szGroup[16]; // Label of the group
  67. char szComment[256]; // File comment
  68. uint32_t nPeriod; // How many ticks per sample (30,000 = rate)
  69. uint32_t nResolution; // Time resolution of time stamps
  70. SYSTEMTIME isAcqTime; // Windows time structure
  71. uint32_t cnChannels; // How many channels
  72. } Nsx22Hdr;
  73. typedef struct
  74. {
  75. char achExtHdrID[2]; // Always set to CC
  76. uint16_t id; // Which channel
  77. char label[16]; // What is the "name" of this electrode?
  78. uint8_t phys_connector; // Which connector (e.g. bank 1)
  79. uint8_t connector_pin; // Which pin on that collector
  80. int16_t digmin; // Minimum digital value
  81. int16_t digmax; // Maximum digital value
  82. int16_t anamin; // Minimum Analog Value
  83. int16_t anamax; // Maximum Analog Value
  84. char anaunit[16]; // Units for the Analog Value (e.g. "mV)
  85. uint32_t hpfreq;
  86. uint32_t hporder;
  87. int16_t hptype;
  88. uint32_t lpfreq;
  89. uint32_t lporder;
  90. int16_t lptype;
  91. } Nsx22ExtHdr;
  92. typedef struct
  93. {
  94. char nHdr; // Always set to 0x01
  95. uint32_t nTimestamp; // Which channel
  96. uint32_t nNumDatapoints; // Number of datapoints
  97. // Next comes
  98. // int16_t DataPoint // Data points
  99. } Nsx22DataHdr;
  100. // This is the basic header data structure as recorded in the NEV file
  101. typedef struct
  102. {
  103. char achFileType[8]; // should always be "NEURALEV"
  104. uint8_t byFileRevMajor; // Major version of the file
  105. uint8_t byFileRevMinor; // Minor version of the file
  106. uint16_t wFileFlags; // currently set to "0x01" to mean all data is 16 bit
  107. uint32_t dwStartOfData; // how many bytes are are ALL of the headers
  108. uint32_t dwBytesPerPacket; // All "data" is fixed length...what is that length
  109. uint32_t dwTimeStampResolutionHz; // How many counts per second for the global clock (now 30,000)
  110. uint32_t dwSampleResolutionHz; // How many counts per second for the samples (now 30,000 as well)
  111. SYSTEMTIME isAcqTime; // Greenwich Mean Time when data was collected
  112. char szApplication[32]; // Which application created this? NULL terminated
  113. char szComment[256]; // Comments (NULL terminated)
  114. uint32_t dwNumOfExtendedHeaders; // How many extended headers are there?
  115. } NevHdr;
  116. // This is the extra header data structure as recorded in the NEV file
  117. typedef struct
  118. {
  119. char achPacketID[8]; // "NEUWAV", "NEULABL", "NEUFLT", ...
  120. union {
  121. struct {
  122. uint16_t id;
  123. union {
  124. struct {
  125. uint8_t phys_connector;
  126. uint8_t connector_pin;
  127. uint16_t digital_factor;
  128. uint16_t energy_thresh;
  129. int16_t high_thresh;
  130. int16_t low_thresh;
  131. uint8_t sorted_count;
  132. uint8_t wave_bytes;
  133. uint16_t wave_samples;
  134. char achReserved[8];
  135. } neuwav;
  136. struct {
  137. char label[16];
  138. char achReserved[6];
  139. } neulabel;
  140. struct {
  141. uint32_t hpfreq;
  142. uint32_t hporder;
  143. int16_t hptype;
  144. uint32_t lpfreq;
  145. uint32_t lporder;
  146. int16_t lptype;
  147. char achReserved[2];
  148. } neuflt;
  149. struct {
  150. char label[16];
  151. float fFps;
  152. char achReserved[2];
  153. } videosyn;
  154. struct {
  155. uint16_t trackID;
  156. uint16_t maxPoints;
  157. char label[16];
  158. char achReserved[2];
  159. } trackobj;
  160. };
  161. };
  162. struct {
  163. char label[16];
  164. uint8_t mode;
  165. char achReserved[7];
  166. } diglabel;
  167. struct {
  168. char label[24];
  169. } mapfile;
  170. };
  171. } NevExtHdr;
  172. // This is the data structure as recorded in the NEV file
  173. // The size is larger than any packet to safely read them from file
  174. typedef struct
  175. {
  176. uint32_t dwTimestamp;
  177. uint16_t wPacketID;
  178. union {
  179. struct {
  180. uint8_t byInsertionReason;
  181. uint8_t byReserved;
  182. uint16_t wDigitalValue;
  183. char achReserved[260];
  184. } digital; // digital or serial data
  185. struct {
  186. uint8_t charset;
  187. uint8_t flags;
  188. uint32_t data;
  189. char comment[258];
  190. } comment; // comment data
  191. struct {
  192. uint16_t split;
  193. uint32_t frame;
  194. uint32_t etime;
  195. uint32_t id;
  196. char achReserved[250];
  197. } synch; // synchronization data
  198. struct {
  199. uint16_t parentID;
  200. uint16_t nodeID;
  201. uint16_t nodeCount;
  202. uint16_t coordsLength;
  203. uint16_t coords[cbMAX_TRACKCOORDS];
  204. } track; // tracking data
  205. struct {
  206. uint8_t unit;
  207. uint8_t res;
  208. int16_t wave[cbMAX_PNTS];
  209. char achReserved[6];
  210. } spike; // spike data
  211. };
  212. char achReserved[754];
  213. } NevData;
  214. #pragma pack(pop)
  215. #endif /* NEVNSX_H_ */