Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

CCFUtilsBinary.h 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921
  1. /* =STS=> CCFUtilsBinary.h[4875].aa02 open SMID:2 */
  2. //////////////////////////////////////////////////////////////////////
  3. //
  4. // (c) Copyright 2012 - 2013 Blackrock Microsystems
  5. //
  6. // $Workfile: CCFUtilsBinary.h $
  7. // $Archive: /Cerebus/Human/WindowsApps/cbhwlib/CCFUtilsBinary.h $
  8. // $Revision: 1 $
  9. // $Date: 4/10/12 1:40p $
  10. // $Author: Ehsan $
  11. //
  12. // $NoKeywords: $
  13. //
  14. //////////////////////////////////////////////////////////////////////
  15. //
  16. // Purpose: Read anything up to 3.9 binary CCF file
  17. //
  18. #ifndef CCFUTILSBINARY_H_INCLUDED
  19. #define CCFUTILSBINARY_H_INCLUDED
  20. #include "CCFUtils.h"
  21. #include <stdio.h>
  22. #define cbLEGACY_MAXCHANS 160
  23. #define cbLEGACY_NUM_ANALOG_CHANS 144
  24. #define cbLEGACY_MAXUNITS 5
  25. #define cbLEGACY_MAXHOOPS 4
  26. #define cbLEGACY_MAXNTRODES (cbLEGACY_NUM_ANALOG_CHANS / 2) // minimum is stereotrode so max n-trodes is max chans / 2
  27. #define cbLEGACY_MAXSITES 4 // maximum number of electrodes that can be included in an n-trode group
  28. #define cbLEGACY_MAXSITEPLOTS ((cbLEGACY_MAXSITES - 1) * cbLEGACY_MAXSITES / 2) // combination of 2 out of n is n!/((n-2)!2!)
  29. ///////////////////////////////////////////////////////////////////////////////////////////////////
  30. // Some of the string length constants
  31. #define cbLEGACY_LEN_STR_UNIT 8
  32. #define cbLEGACY_LEN_STR_LABEL 16
  33. // Namespace for Cerebus Config Files
  34. namespace ccf
  35. {
  36. enum {CCFUTILSBINARY_LASTVERSION = 11};
  37. // Generic Cerebus packet data structure (1024 bytes total)
  38. typedef struct {
  39. uint32_t time; // system clock timestamp
  40. uint16_t chid; // channel identifier
  41. uint8_t type; // packet type
  42. uint8_t dlen; // length of data field in 32-bit chunks
  43. uint32_t data[254]; // data buffer (up to 1016 bytes)
  44. } cbPKT_GENERIC_CB2003_10;
  45. typedef struct {
  46. int16_t digmin; // digital value that cooresponds with the anamin value
  47. int16_t digmax; // digital value that cooresponds with the anamax value
  48. int32_t anamin; // the minimum analog value present in the signal
  49. int32_t anamax; // the maximum analog value present in the signal
  50. char anaunit[cbLEGACY_LEN_STR_UNIT]; // the unit for the analog signal (eg, "uV" or "MPa")
  51. } cbSCALING_NO_ANAGAIN;
  52. typedef struct {
  53. int16_t digmin; // digital value that cooresponds with the anamin value
  54. int16_t digmax; // digital value that cooresponds with the anamax value
  55. int32_t anamin; // the minimum analog value present in the signal
  56. int32_t anamax; // the maximum analog value present in the signal
  57. int32_t anagain; // the gain applied to the default analog values to get the analog values
  58. char anaunit[cbLEGACY_LEN_STR_UNIT]; // the unit for the analog signal (eg, "uV" or "MPa")
  59. } cbSCALING_30;
  60. typedef struct {
  61. uint16_t nOverride;
  62. int16_t xOrigin;
  63. int16_t yOrigin;
  64. uint16_t radius;
  65. } cbMANUALUNITMAPPING_31;
  66. typedef struct {
  67. uint32_t nOverride;
  68. float afOrigin[2];
  69. float afShape[2][2];
  70. float aPhi;
  71. uint32_t bValid; // is this unit in use at this time?
  72. // BOOL implemented as UINT2 - for structure alignment at paragraph boundary
  73. } cbMANUALUNITMAPPING_34;
  74. typedef struct {
  75. uint32_t nOverride;
  76. float afOrigin[3];
  77. float afShape[3][3];
  78. float aPhi;
  79. uint32_t bValid; // is this unit in use at this time?
  80. // BOOL implemented as UINT2 - for structure alignment at paragraph boundary
  81. } cbMANUALUNITMAPPING_36;
  82. typedef struct {
  83. int16_t nOverride;
  84. int16_t afOrigin[3];
  85. int16_t afShape[3][3];
  86. int16_t aPhi;
  87. uint32_t bValid; // is this unit in use at this time?
  88. // BOOL implemented as uint32_t - for structure alignment at paragraph boundary
  89. } cbMANUALUNITMAPPING_37;
  90. typedef struct {
  91. char label[cbLEGACY_LEN_STR_LABEL];
  92. uint32_t hpfreq; // high-pass corner frequency in milliHertz
  93. uint32_t hporder; // high-pass filter order
  94. uint32_t hptype; // high-pass filter type
  95. uint32_t lpfreq; // low-pass frequency in milliHertz
  96. uint32_t lporder; // low-pass filter order
  97. uint32_t lptype; // low-pass filter type
  98. } cbFILTDESC_10;
  99. typedef struct {
  100. uint16_t valid; // 0=undefined, 1 for valid
  101. int16_t time; // time offset into spike window
  102. int16_t min; // minimum value for the hoop window
  103. int16_t max; // maximum value for the hoop window
  104. } cbHOOP_10;
  105. typedef struct {
  106. uint32_t time; // system clock timestamp
  107. uint16_t chid; // 0x8000
  108. uint8_t type; // cbPKTTYPE_AINP*
  109. uint8_t dlen; // cbPKT_DLENCHANINFO
  110. uint32_t chan; // actual channel id of the channel being configured
  111. uint32_t proc; // the address of the processor on which the channel resides
  112. uint32_t bank; // the address of the bank on which the channel resides
  113. uint32_t term; // the terminal number of the channel within it's bank
  114. uint32_t chancaps; // general channel capablities (given by cbCHAN_* flags)
  115. uint32_t doutcaps; // digital output capablities (composed of cbDOUT_* flags)
  116. uint32_t dinpcaps; // digital input capablities (composed of cbDINP_* flags)
  117. uint32_t aoutcaps; // analog input capablities (composed of cbAOUT_* flags)
  118. uint32_t ainpcaps; // analog input capablities (composed of cbAINP_* flags)
  119. uint32_t spkcaps; // spike processing capabilities
  120. cbSCALING_NO_ANAGAIN physcalin; // physical channel scaling information
  121. cbFILTDESC_10 phyfiltin; // physical channel filter definition
  122. cbSCALING_NO_ANAGAIN physcalout; // physical channel scaling information
  123. cbFILTDESC_10 phyfiltout; // physical channel filter definition
  124. char label[cbLEGACY_LEN_STR_LABEL]; // Label of the channel (null terminated if <16 characters)
  125. uint32_t userflags; // User flags for the channel state
  126. int32_t position[4]; // reserved for future position information
  127. cbSCALING_NO_ANAGAIN scalin; // user-defined scaling information
  128. cbSCALING_NO_ANAGAIN scalout; // user-defined scaling information
  129. uint32_t doutopts; // digital output options (composed of cbDOUT_* flags)
  130. uint32_t dinpopts; // digital input options (composed of cbDINP_* flags)
  131. uint32_t aoutopts; // analog output options
  132. uint32_t eopchar; // digital input capablities (given by cbDINP_* flags)
  133. uint32_t monsource; // address of channel to monitor
  134. int32_t outvalue; // output value
  135. uint32_t lncmode; // line noise cancellation filter mode
  136. uint32_t lncrate; // line noise cancellation filter adaptation rate
  137. uint32_t smpfilter; // continuous-time pathway filter id
  138. uint32_t smpgroup; // continuous-time pathway sample group
  139. int32_t smpdispmin; // continuous-time pathway display factor
  140. int32_t smpdispmax; // continuous-time pathway display factor
  141. uint32_t spkfilter; // spike pathway filter id
  142. int32_t spkdispmax; // spike pathway display factor
  143. uint32_t spkopts; // spike processing options
  144. int32_t spkthrlevel; // spike threshold level
  145. int32_t spkthrlimit; //
  146. uint32_t spkgroup; // placeholder for future multi-trode processing group
  147. cbHOOP_10 spkhoops[cbLEGACY_MAXUNITS][cbLEGACY_MAXHOOPS]; // spike hoop sorting set
  148. } cbPKT_CHANINFO_CB2003_10A;
  149. typedef struct {
  150. uint32_t time; // system clock timestamp
  151. uint16_t chid; // 0x8000
  152. uint8_t type; // cbPKTTYPE_AINP*
  153. uint8_t dlen; // cbPKT_DLENCHANINFO
  154. uint32_t chan; // actual channel id of the channel being configured
  155. uint32_t proc; // the address of the processor on which the channel resides
  156. uint32_t bank; // the address of the bank on which the channel resides
  157. uint32_t term; // the terminal number of the channel within it's bank
  158. uint32_t chancaps; // general channel capablities (given by cbCHAN_* flags)
  159. uint32_t doutcaps; // digital output capablities (composed of cbDOUT_* flags)
  160. uint32_t dinpcaps; // digital input capablities (composed of cbDINP_* flags)
  161. uint32_t aoutcaps; // analog input capablities (composed of cbAOUT_* flags)
  162. uint32_t ainpcaps; // analog input capablities (composed of cbAINP_* flags)
  163. uint32_t spkcaps; // spike processing capabilities
  164. cbSCALING_NO_ANAGAIN physcalin; // physical channel scaling information
  165. cbFILTDESC_10 phyfiltin; // physical channel filter definition
  166. cbSCALING_NO_ANAGAIN physcalout; // physical channel scaling information
  167. cbFILTDESC_10 phyfiltout; // physical channel filter definition
  168. char label[cbLEGACY_LEN_STR_LABEL]; // Label of the channel (null terminated if <16 characters)
  169. uint32_t userflags; // User flags for the channel state
  170. int32_t position[4]; // reserved for future position information
  171. cbSCALING_NO_ANAGAIN scalin; // user-defined scaling information
  172. cbSCALING_NO_ANAGAIN scalout; // user-defined scaling information
  173. uint32_t doutopts; // digital output options (composed of cbDOUT_* flags)
  174. uint32_t dinpopts; // digital input options (composed of cbDINP_* flags)
  175. uint32_t aoutopts; // analog output options
  176. uint32_t eopchar; // digital input capablities (given by cbDINP_* flags)
  177. uint32_t monsource; // address of channel to monitor
  178. int32_t outvalue; // output value
  179. uint32_t lncmode; // line noise cancellation filter mode
  180. uint32_t lncrate; // line noise cancellation filter adaptation rate
  181. uint32_t smpfilter; // continuous-time pathway filter id
  182. uint32_t smpgroup; // continuous-time pathway sample group
  183. int32_t smpdispmin; // continuous-time pathway display factor
  184. int32_t smpdispmax; // continuous-time pathway display factor
  185. uint32_t spkfilter; // spike pathway filter id
  186. int32_t spkdispmax; // spike pathway display factor
  187. uint32_t spkopts; // spike processing options
  188. int32_t spkthrlevel; // spike threshold level
  189. int32_t spkthrlimit; //
  190. cbHOOP_10 spkhoops[cbLEGACY_MAXUNITS][cbLEGACY_MAXHOOPS]; // spike hoop sorting set
  191. } cbPKT_CHANINFO_CB2005_25;
  192. typedef struct {
  193. uint32_t time; // system clock timestamp
  194. uint16_t chid; // 0x8000
  195. uint8_t type; // cbPKTTYPE_AINP*
  196. uint8_t dlen; // cbPKT_DLENCHANINFO
  197. uint32_t chan; // actual channel id of the channel being configured
  198. uint32_t proc; // the address of the processor on which the channel resides
  199. uint32_t bank; // the address of the bank on which the channel resides
  200. uint32_t term; // the terminal number of the channel within it's bank
  201. uint32_t chancaps; // general channel capablities (given by cbCHAN_* flags)
  202. uint32_t doutcaps; // digital output capablities (composed of cbDOUT_* flags)
  203. uint32_t dinpcaps; // digital input capablities (composed of cbDINP_* flags)
  204. uint32_t aoutcaps; // analog input capablities (composed of cbAOUT_* flags)
  205. uint32_t ainpcaps; // analog input capablities (composed of cbAINP_* flags)
  206. uint32_t spkcaps; // spike processing capabilities
  207. cbSCALING_30 physcalin; // physical channel scaling information
  208. cbFILTDESC_10 phyfiltin; // physical channel filter definition
  209. cbSCALING_30 physcalout; // physical channel scaling information
  210. cbFILTDESC_10 phyfiltout; // physical channel filter definition
  211. char label[cbLEGACY_LEN_STR_LABEL]; // Label of the channel (null terminated if <16 characters)
  212. uint32_t userflags; // User flags for the channel state
  213. int32_t position[4]; // reserved for future position information
  214. cbSCALING_30 scalin; // user-defined scaling information
  215. cbSCALING_30 scalout; // user-defined scaling information
  216. uint32_t doutopts; // digital output options (composed of cbDOUT_* flags)
  217. uint32_t dinpopts; // digital input options (composed of cbDINP_* flags)
  218. uint32_t aoutopts; // analog output options
  219. uint32_t eopchar; // digital input capablities (given by cbDINP_* flags)
  220. uint32_t monsource; // address of channel to monitor
  221. int32_t outvalue; // output value
  222. uint32_t lncmode; // line noise cancellation filter mode
  223. uint32_t lncrate; // line noise cancellation filter adaptation rate
  224. uint32_t smpfilter; // continuous-time pathway filter id
  225. uint32_t smpgroup; // continuous-time pathway sample group
  226. int32_t smpdispmin; // continuous-time pathway display factor
  227. int32_t smpdispmax; // continuous-time pathway display factor
  228. uint32_t spkfilter; // spike pathway filter id
  229. int32_t spkdispmax; // spike pathway display factor
  230. uint32_t spkopts; // spike processing options
  231. int32_t spkthrlevel; // spike threshold level
  232. int32_t spkthrlimit; //
  233. uint32_t spkgroup; // placeholder for future multi-trode processing group
  234. cbHOOP_10 spkhoops[cbLEGACY_MAXUNITS][cbLEGACY_MAXHOOPS]; // spike hoop sorting set
  235. } cbPKT_CHANINFO_CB2005_30;
  236. typedef struct {
  237. uint32_t time; // system clock timestamp
  238. uint16_t chid; // 0x8000
  239. uint8_t type; // cbPKTTYPE_AINP*
  240. uint8_t dlen; // cbPKT_DLENCHANINFO
  241. uint32_t chan; // actual channel id of the channel being configured
  242. uint32_t proc; // the address of the processor on which the channel resides
  243. uint32_t bank; // the address of the bank on which the channel resides
  244. uint32_t term; // the terminal number of the channel within it's bank
  245. uint32_t chancaps; // general channel capablities (given by cbCHAN_* flags)
  246. uint32_t doutcaps; // digital output capablities (composed of cbDOUT_* flags)
  247. uint32_t dinpcaps; // digital input capablities (composed of cbDINP_* flags)
  248. uint32_t aoutcaps; // analog input capablities (composed of cbAOUT_* flags)
  249. uint32_t ainpcaps; // analog input capablities (composed of cbAINP_* flags)
  250. uint32_t spkcaps; // spike processing capabilities
  251. cbSCALING_30 physcalin; // physical channel scaling information
  252. cbFILTDESC_10 phyfiltin; // physical channel filter definition
  253. cbSCALING_30 physcalout; // physical channel scaling information
  254. cbFILTDESC_10 phyfiltout; // physical channel filter definition
  255. char label[cbLEGACY_LEN_STR_LABEL]; // Label of the channel (null terminated if <16 characters)
  256. uint32_t userflags; // User flags for the channel state
  257. int32_t position[4]; // reserved for future position information
  258. cbSCALING_30 scalin; // user-defined scaling information
  259. cbSCALING_30 scalout; // user-defined scaling information
  260. uint32_t doutopts; // digital output options (composed of cbDOUT_* flags)
  261. uint32_t dinpopts; // digital input options (composed of cbDINP_* flags)
  262. uint32_t aoutopts; // analog output options
  263. uint32_t eopchar; // digital input capablities (given by cbDINP_* flags)
  264. uint32_t monsource; // address of channel to monitor
  265. int32_t outvalue; // output value
  266. uint32_t lncmode; // line noise cancellation filter mode
  267. uint32_t lncrate; // line noise cancellation filter adaptation rate
  268. uint32_t smpfilter; // continuous-time pathway filter id
  269. uint32_t smpgroup; // continuous-time pathway sample group
  270. int32_t smpdispmin; // continuous-time pathway display factor
  271. int32_t smpdispmax; // continuous-time pathway display factor
  272. uint32_t spkfilter; // spike pathway filter id
  273. int32_t spkdispmax; // spike pathway display factor
  274. uint32_t spkopts; // spike processing options
  275. int32_t spkthrlevel; // spike threshold level
  276. int32_t spkthrlimit; //
  277. uint32_t spkgroup; // placeholder for future multi-trode processing group
  278. cbMANUALUNITMAPPING_31 unitmapping[cbLEGACY_MAXUNITS]; // manual unit mapping
  279. cbHOOP_10 spkhoops[cbLEGACY_MAXUNITS][cbLEGACY_MAXHOOPS]; // spike hoop sorting set
  280. } cbPKT_CHANINFO_CB2005_31;
  281. typedef struct {
  282. uint32_t time; // system clock timestamp
  283. uint16_t chid; // 0x8000
  284. uint8_t type; // cbPKTTYPE_AINP*
  285. uint8_t dlen; // cbPKT_DLENCHANINFO
  286. uint32_t chan; // actual channel id of the channel being configured
  287. uint32_t proc; // the address of the processor on which the channel resides
  288. uint32_t bank; // the address of the bank on which the channel resides
  289. uint32_t term; // the terminal number of the channel within it's bank
  290. uint32_t chancaps; // general channel capablities (given by cbCHAN_* flags)
  291. uint32_t doutcaps; // digital output capablities (composed of cbDOUT_* flags)
  292. uint32_t dinpcaps; // digital input capablities (composed of cbDINP_* flags)
  293. uint32_t aoutcaps; // analog input capablities (composed of cbAOUT_* flags)
  294. uint32_t ainpcaps; // analog input capablities (composed of cbAINP_* flags)
  295. uint32_t spkcaps; // spike processing capabilities
  296. cbSCALING_30 physcalin; // physical channel scaling information
  297. cbFILTDESC_10 phyfiltin; // physical channel filter definition
  298. cbSCALING_30 physcalout; // physical channel scaling information
  299. cbFILTDESC_10 phyfiltout; // physical channel filter definition
  300. char label[cbLEGACY_LEN_STR_LABEL]; // Label of the channel (null terminated if <16 characters)
  301. uint32_t userflags; // User flags for the channel state
  302. int32_t position[4]; // reserved for future position information
  303. cbSCALING_30 scalin; // user-defined scaling information
  304. cbSCALING_30 scalout; // user-defined scaling information
  305. uint32_t doutopts; // digital output options (composed of cbDOUT_* flags)
  306. uint32_t dinpopts; // digital input options (composed of cbDINP_* flags)
  307. uint32_t aoutopts; // analog output options
  308. uint32_t eopchar; // digital input capablities (given by cbDINP_* flags)
  309. uint32_t monsource; // address of channel to monitor
  310. int32_t outvalue; // output value
  311. uint32_t lncmode; // line noise cancellation filter mode
  312. uint32_t lncrate; // line noise cancellation filter adaptation rate
  313. uint32_t smpfilter; // continuous-time pathway filter id
  314. uint32_t smpgroup; // continuous-time pathway sample group
  315. int32_t smpdispmin; // continuous-time pathway display factor
  316. int32_t smpdispmax; // continuous-time pathway display factor
  317. uint32_t spkfilter; // spike pathway filter id
  318. int32_t spkdispmax; // spike pathway display factor
  319. uint32_t spkopts; // spike processing options
  320. int32_t spkthrlevel; // spike threshold level
  321. int32_t spkthrlimit; //
  322. uint32_t spkgroup; // placeholder for future multi-trode processing group
  323. cbMANUALUNITMAPPING_34 unitmapping[cbLEGACY_MAXUNITS]; // manual unit mapping
  324. cbHOOP_10 spkhoops[cbLEGACY_MAXUNITS][cbLEGACY_MAXHOOPS]; // spike hoop sorting set
  325. } cbPKT_CHANINFO_CB2005_34;
  326. typedef struct {
  327. uint32_t time; // system clock timestamp
  328. uint16_t chid; // 0x8000
  329. uint8_t type; // cbPKTTYPE_AINP*
  330. uint8_t dlen; // cbPKT_DLENCHANINFO
  331. uint32_t chan; // actual channel id of the channel being configured
  332. uint32_t proc; // the address of the processor on which the channel resides
  333. uint32_t bank; // the address of the bank on which the channel resides
  334. uint32_t term; // the terminal number of the channel within it's bank
  335. uint32_t chancaps; // general channel capablities (given by cbCHAN_* flags)
  336. uint32_t doutcaps; // digital output capablities (composed of cbDOUT_* flags)
  337. uint32_t dinpcaps; // digital input capablities (composed of cbDINP_* flags)
  338. uint32_t aoutcaps; // analog output capablities (composed of cbAOUT_* flags)
  339. uint32_t ainpcaps; // analog input capablities (composed of cbAINP_* flags)
  340. uint32_t spkcaps; // spike processing capabilities
  341. cbSCALING_30 physcalin; // physical channel scaling information
  342. cbFILTDESC_10 phyfiltin; // physical channel filter definition
  343. cbSCALING_30 physcalout; // physical channel scaling information
  344. cbFILTDESC_10 phyfiltout; // physical channel filter definition
  345. char label[cbLEGACY_LEN_STR_LABEL]; // Label of the channel (null terminated if <16 characters)
  346. uint32_t userflags; // User flags for the channel state
  347. int32_t position[4]; // reserved for future position information
  348. cbSCALING_30 scalin; // user-defined scaling information
  349. cbSCALING_30 scalout; // user-defined scaling information
  350. uint32_t doutopts; // digital output options (composed of cbDOUT_* flags)
  351. uint32_t dinpopts; // digital input options (composed of cbDINP_* flags)
  352. uint32_t aoutopts; // analog output options
  353. uint32_t eopchar; // digital input capablities (given by cbDINP_* flags)
  354. union {
  355. struct {
  356. uint32_t monsource; // address of channel to monitor
  357. int32_t outvalue; // output value
  358. };
  359. struct {
  360. uint16_t lowsamples; // address of channel to monitor
  361. uint16_t highsamples; // address of channel to monitor
  362. int32_t offset; // output value
  363. };
  364. };
  365. uint32_t lncmode; // line noise cancellation filter mode
  366. uint32_t lncrate; // line noise cancellation filter adaptation rate
  367. uint32_t smpfilter; // continuous-time pathway filter id
  368. uint32_t smpgroup; // continuous-time pathway sample group
  369. int32_t smpdispmin; // continuous-time pathway display factor
  370. int32_t smpdispmax; // continuous-time pathway display factor
  371. uint32_t spkfilter; // spike pathway filter id
  372. int32_t spkdispmax; // spike pathway display factor
  373. uint32_t spkopts; // spike processing options
  374. int32_t spkthrlevel; // spike threshold level
  375. int32_t spkthrlimit; //
  376. uint32_t spkgroup; // NTrodeGroup this electrode belongs to - 0 is single unit, non-0 indicates a multi-trode grouping
  377. int16_t amplrejpos; // Amplitude rejection positive value
  378. int16_t amplrejneg; // Amplitude rejection negative value
  379. cbMANUALUNITMAPPING_34 unitmapping[cbLEGACY_MAXUNITS]; // manual unit mapping
  380. cbHOOP_10 spkhoops[cbLEGACY_MAXUNITS][cbLEGACY_MAXHOOPS]; // spike hoop sorting set
  381. } cbPKT_CHANINFO_CB2005_35;
  382. typedef struct {
  383. uint32_t time; // system clock timestamp
  384. uint16_t chid; // 0x8000
  385. uint8_t type; // cbPKTTYPE_AINP*
  386. uint8_t dlen; // cbPKT_DLENCHANINFO
  387. uint32_t chan; // actual channel id of the channel being configured
  388. uint32_t proc; // the address of the processor on which the channel resides
  389. uint32_t bank; // the address of the bank on which the channel resides
  390. uint32_t term; // the terminal number of the channel within it's bank
  391. uint32_t chancaps; // general channel capablities (given by cbCHAN_* flags)
  392. uint32_t doutcaps; // digital output capablities (composed of cbDOUT_* flags)
  393. uint32_t dinpcaps; // digital input capablities (composed of cbDINP_* flags)
  394. uint32_t aoutcaps; // analog output capablities (composed of cbAOUT_* flags)
  395. uint32_t ainpcaps; // analog input capablities (composed of cbAINP_* flags)
  396. uint32_t spkcaps; // spike processing capabilities
  397. cbSCALING_30 physcalin; // physical channel scaling information
  398. cbFILTDESC_10 phyfiltin; // physical channel filter definition
  399. cbSCALING_30 physcalout; // physical channel scaling information
  400. cbFILTDESC_10 phyfiltout; // physical channel filter definition
  401. char label[cbLEGACY_LEN_STR_LABEL]; // Label of the channel (null terminated if <16 characters)
  402. uint32_t userflags; // User flags for the channel state
  403. int32_t position[4]; // reserved for future position information
  404. cbSCALING_30 scalin; // user-defined scaling information for AINP
  405. cbSCALING_30 scalout; // user-defined scaling information for AOUT
  406. uint32_t doutopts; // digital output options (composed of cbDOUT_* flags)
  407. uint32_t dinpopts; // digital input options (composed of cbDINP_* flags)
  408. uint32_t aoutopts; // analog output options
  409. uint32_t eopchar; // digital input capablities (given by cbDINP_* flags)
  410. union {
  411. struct {
  412. uint32_t monsource; // address of channel to monitor
  413. int32_t outvalue; // output value
  414. };
  415. struct {
  416. uint16_t lowsamples; // address of channel to monitor
  417. uint16_t highsamples; // address of channel to monitor
  418. int32_t offset; // output value
  419. };
  420. };
  421. uint32_t ainpopts; // analog input options (composed of cbAINP* flags)
  422. uint32_t lncrate; // line noise cancellation filter adaptation rate
  423. uint32_t smpfilter; // continuous-time pathway filter id
  424. uint32_t smpgroup; // continuous-time pathway sample group
  425. int32_t smpdispmin; // continuous-time pathway display factor
  426. int32_t smpdispmax; // continuous-time pathway display factor
  427. uint32_t spkfilter; // spike pathway filter id
  428. int32_t spkdispmax; // spike pathway display factor
  429. int32_t lncdispmax; // Line Noise pathway display factor
  430. uint32_t spkopts; // spike processing options
  431. int32_t spkthrlevel; // spike threshold level
  432. int32_t spkthrlimit; //
  433. uint32_t spkgroup; // NTrodeGroup this electrode belongs to - 0 is single unit, non-0 indicates a multi-trode grouping
  434. int16_t amplrejpos; // Amplitude rejection positive value
  435. int16_t amplrejneg; // Amplitude rejection negative value
  436. uint32_t refelecchan; // Software reference electrode channel
  437. cbMANUALUNITMAPPING_36 unitmapping[cbLEGACY_MAXUNITS]; // manual unit mapping
  438. cbHOOP_10 spkhoops[cbLEGACY_MAXUNITS][cbLEGACY_MAXHOOPS]; // spike hoop sorting set
  439. } cbPKT_CHANINFO_CB2005_36;
  440. typedef struct {
  441. uint32_t time; // system clock timestamp
  442. uint16_t chid; // 0x8000
  443. uint8_t type; // cbPKTTYPE_AINP*
  444. uint8_t dlen; // cbPKT_DLENCHANINFO
  445. uint32_t chan; // actual channel id of the channel being configured
  446. uint32_t proc; // the address of the processor on which the channel resides
  447. uint32_t bank; // the address of the bank on which the channel resides
  448. uint32_t term; // the terminal number of the channel within it's bank
  449. uint32_t chancaps; // general channel capablities (given by cbCHAN_* flags)
  450. uint32_t doutcaps; // digital output capablities (composed of cbDOUT_* flags)
  451. uint32_t dinpcaps; // digital input capablities (composed of cbDINP_* flags)
  452. uint32_t aoutcaps; // analog output capablities (composed of cbAOUT_* flags)
  453. uint32_t ainpcaps; // analog input capablities (composed of cbAINP_* flags)
  454. uint32_t spkcaps; // spike processing capabilities
  455. cbSCALING_30 physcalin; // physical channel scaling information
  456. cbFILTDESC_10 phyfiltin; // physical channel filter definition
  457. cbSCALING_30 physcalout; // physical channel scaling information
  458. cbFILTDESC_10 phyfiltout; // physical channel filter definition
  459. char label[cbLEGACY_LEN_STR_LABEL]; // Label of the channel (null terminated if <16 characters)
  460. uint32_t userflags; // User flags for the channel state
  461. int32_t position[4]; // reserved for future position information
  462. cbSCALING_30 scalin; // user-defined scaling information for AINP
  463. cbSCALING_30 scalout; // user-defined scaling information for AOUT
  464. uint32_t doutopts; // digital output options (composed of cbDOUT_* flags)
  465. uint32_t dinpopts; // digital input options (composed of cbDINP_* flags)
  466. uint32_t aoutopts; // analog output options
  467. uint32_t eopchar; // digital input capablities (given by cbDINP_* flags)
  468. union {
  469. struct {
  470. uint32_t monsource; // address of channel to monitor
  471. int32_t outvalue; // output value
  472. };
  473. struct {
  474. uint16_t lowsamples; // address of channel to monitor
  475. uint16_t highsamples; // address of channel to monitor
  476. int32_t offset; // output value
  477. };
  478. };
  479. uint32_t ainpopts; // analog input options (composed of cbAINP* flags)
  480. uint32_t lncrate; // line noise cancellation filter adaptation rate
  481. uint32_t smpfilter; // continuous-time pathway filter id
  482. uint32_t smpgroup; // continuous-time pathway sample group
  483. int32_t smpdispmin; // continuous-time pathway display factor
  484. int32_t smpdispmax; // continuous-time pathway display factor
  485. uint32_t spkfilter; // spike pathway filter id
  486. int32_t spkdispmax; // spike pathway display factor
  487. int32_t lncdispmax; // Line Noise pathway display factor
  488. uint32_t spkopts; // spike processing options
  489. int32_t spkthrlevel; // spike threshold level
  490. int32_t spkthrlimit; //
  491. uint32_t spkgroup; // NTrodeGroup this electrode belongs to - 0 is single unit, non-0 indicates a multi-trode grouping
  492. int16_t amplrejpos; // Amplitude rejection positive value
  493. int16_t amplrejneg; // Amplitude rejection negative value
  494. uint32_t refelecchan; // Software reference electrode channel
  495. cbMANUALUNITMAPPING_37 unitmapping[cbLEGACY_MAXUNITS]; // manual unit mapping
  496. cbHOOP_10 spkhoops[cbLEGACY_MAXUNITS][cbLEGACY_MAXHOOPS]; // spike hoop sorting set
  497. } cbPKT_CHANINFO_CB2005_37;
  498. #define cbPKTDLEN_CHANINFO_CB2005_37 ((sizeof(cbPKT_CHANINFO_CB2005_37)/4)-2)
  499. typedef struct {
  500. uint32_t time; // system clock timestamp
  501. uint16_t chid; // 0x8000
  502. uint8_t type; // cbPKTTYPE_AINP*
  503. uint8_t dlen; // cbPKT_DLENCHANINFO
  504. uint32_t chan; // actual channel id of the channel being configured
  505. uint32_t proc; // the address of the processor on which the channel resides
  506. uint32_t bank; // the address of the bank on which the channel resides
  507. uint32_t term; // the terminal number of the channel within it's bank
  508. uint32_t chancaps; // general channel capablities (given by cbCHAN_* flags)
  509. uint32_t doutcaps; // digital output capablities (composed of cbDOUT_* flags)
  510. uint32_t dinpcaps; // digital input capablities (composed of cbDINP_* flags)
  511. uint32_t aoutcaps; // analog output capablities (composed of cbAOUT_* flags)
  512. uint32_t ainpcaps; // analog input capablities (composed of cbAINP_* flags)
  513. uint32_t spkcaps; // spike processing capabilities
  514. cbSCALING physcalin; // physical channel scaling information
  515. cbFILTDESC phyfiltin; // physical channel filter definition
  516. cbSCALING physcalout; // physical channel scaling information
  517. cbFILTDESC phyfiltout; // physical channel filter definition
  518. char label[cbLEN_STR_LABEL]; // Label of the channel (null terminated if <16 characters)
  519. uint32_t userflags; // User flags for the channel state
  520. int32_t position[4]; // reserved for future position information
  521. cbSCALING scalin; // user-defined scaling information for AINP
  522. cbSCALING scalout; // user-defined scaling information for AOUT
  523. uint32_t doutopts; // digital output options (composed of cbDOUT_* flags)
  524. uint32_t dinpopts; // digital input options (composed of cbDINP_* flags)
  525. uint32_t aoutopts; // analog output options
  526. uint32_t eopchar; // digital input capablities (given by cbDINP_* flags)
  527. union {
  528. struct {
  529. uint32_t monsource; // address of channel to monitor
  530. int32_t outvalue; // output value
  531. };
  532. struct {
  533. uint16_t lowsamples; // address of channel to monitor
  534. uint16_t highsamples; // address of channel to monitor
  535. int32_t offset; // output value
  536. };
  537. };
  538. uint8_t trigtype; // trigger type (see cbDOUT_TRIGGER_*)
  539. uint16_t trigchan; // trigger channel
  540. uint16_t trigval; // trigger value
  541. uint32_t ainpopts; // analog input options (composed of cbAINP* flags)
  542. uint32_t lncrate; // line noise cancellation filter adaptation rate
  543. uint32_t smpfilter; // continuous-time pathway filter id
  544. uint32_t smpgroup; // continuous-time pathway sample group
  545. int32_t smpdispmin; // continuous-time pathway display factor
  546. int32_t smpdispmax; // continuous-time pathway display factor
  547. uint32_t spkfilter; // spike pathway filter id
  548. int32_t spkdispmax; // spike pathway display factor
  549. int32_t lncdispmax; // Line Noise pathway display factor
  550. uint32_t spkopts; // spike processing options
  551. int32_t spkthrlevel; // spike threshold level
  552. int32_t spkthrlimit; //
  553. uint32_t spkgroup; // NTrodeGroup this electrode belongs to - 0 is single unit, non-0 indicates a multi-trode grouping
  554. int16_t amplrejpos; // Amplitude rejection positive value
  555. int16_t amplrejneg; // Amplitude rejection negative value
  556. uint32_t refelecchan; // Software reference electrode channel
  557. cbMANUALUNITMAPPING unitmapping[cbMAXUNITS]; // manual unit mapping
  558. cbHOOP spkhoops[cbMAXUNITS][cbMAXHOOPS]; // spike hoop sorting set
  559. } cbPKT_CHANINFO_CB2005_310;
  560. #define cbPKTDLEN_CHANINFO_CB2005_310 ((sizeof(cbPKT_CHANINFO_CB2005_310)/4)-2)
  561. typedef struct {
  562. uint32_t time; // system clock timestamp
  563. uint16_t chid; // 0x8000
  564. uint8_t type; // cbPKTTYPE_REPNTRODEINFO or cbPKTTYPE_SETNTRODEINFO
  565. uint8_t dlen; // cbPKTDLEN_NTRODEGRPINFO
  566. uint32_t ntrode; // ntrode with which we are working (1-based)
  567. char label[cbLEGACY_LEN_STR_LABEL]; // Label of the Ntrode (null terminated if < 16 characters)
  568. cbMANUALUNITMAPPING_37 ellipses[cbLEGACY_MAXSITEPLOTS][cbLEGACY_MAXUNITS]; // unit mapping
  569. uint16_t nSite; // number channels in this NTrode ( 0 <= nSite <= cbLEGACY_MAXSITES)
  570. uint16_t fs; // NTrode feature space cbNTRODEINFO_FS_*
  571. uint16_t nChan[cbLEGACY_MAXSITES]; // group of channels in this NTrode
  572. } cbPKT_NTRODEINFO_CB2005_37; // ntrode information packet
  573. typedef struct {
  574. uint32_t time; // system clock timestamp
  575. uint16_t chid; // 0x8000
  576. uint8_t type; // cbPKTTYPE_SS_DETECTREP or cbPKTTYPE_SS_DETECTSET depending on the direction
  577. uint8_t dlen; // cbPKTDLEN_SS_DETECT
  578. float fThreshold; // current detection threshold
  579. float fMultiplier; // multiplier
  580. } cbPKT_SS_DETECT_CB2005_37;
  581. typedef struct {
  582. uint32_t time; // system clock timestamp
  583. uint16_t chid; // 0x8000
  584. uint8_t type; // cbPKTTYPE_SS_ARTIF_REJECTREP or cbPKTTYPE_SS_ARTIF_REJECTSET depending on the direction
  585. uint8_t dlen; // cbPKTDLEN_SS_ARTIF_REJECT
  586. uint32_t nMaxSimulChans; // how many channels can fire exactly at the same time???
  587. uint32_t nRefractoryCount; // for how many samples (30 kHz) is a neuron refractory, so can't re-trigger
  588. } cbPKT_SS_ARTIF_REJECT_CB2005_37;
  589. typedef struct {
  590. uint32_t nMode; // 0-do not adapt at all, 1-always adapt, 2-adapt if timer not timed out
  591. float fTimeOutMinutes; // how many minutes until time out
  592. float fElapsedMinutes; // the amount of time that has elapsed
  593. } cbAdaptControl_37;
  594. typedef struct {
  595. uint32_t time; // system clock timestamp
  596. uint16_t chid; // 0x8000
  597. uint8_t type; // cbPKTTYPE_SS_STATUSREP or cbPKTTYPE_SS_STATUSSET depending on the direction
  598. uint8_t dlen; // cbPKTDLEN_SS_STATUS
  599. cbAdaptControl_37 cntlUnitStats;
  600. cbAdaptControl_37 cntlNumUnits;
  601. } cbPKT_SS_STATUS_CB2005_37;
  602. typedef struct {
  603. uint32_t time; // system clock timestamp
  604. uint16_t chid; // 0x8000
  605. uint8_t type; // cbPKTTYPE_SS_STATISTICSREP or cbPKTTYPE_SS_STATISTICSSET depending on the direction
  606. uint8_t dlen; // cbPKTDLEN_SS_STATISTICS
  607. uint32_t nUpdateSpikes; // update rate in spike counts
  608. float fMinClusterSpreadFactor; // larger number = more apt to combine 2 clusters into 1
  609. float fMaxSubclusterSpreadFactor; // larger number = less apt to split because of 2 clusers
  610. uint32_t nReserved; // reserved for future use
  611. } cbPKT_SS_STATISTICS_CB2005_30;
  612. typedef struct {
  613. uint32_t time; // system clock timestamp
  614. uint16_t chid; // 0x8000
  615. uint8_t type; // cbPKTTYPE_SS_STATISTICSREP or cbPKTTYPE_SS_STATISTICSSET depending on the direction
  616. uint8_t dlen; // cbPKTDLEN_SS_STATISTICS
  617. uint32_t nUpdateSpikes; // update rate in spike counts
  618. uint32_t nAutoalg; // automatic sorting algorithm (0=spread, 1=hist_corr_maj, 2=hist_peak_count_maj)
  619. float fMinClusterPairSpreadFactor; // larger number = more apt to combine 2 clusters into 1
  620. float fMaxSubclusterSpreadFactor; // larger number = less apt to split because of 2 clusers
  621. float fMinClusterHistCorrMajMeasure; // larger number = more apt to split 1 cluster into 2
  622. float fMaxClusterPairHistCorrMajMeasure; // larger number = less apt to combine 2 clusters into 1
  623. float fClusterHistMajValleyPercentage; // larger number = less apt to split nearby clusters
  624. float fClusterHistMajPeakPercentage; // larger number = less apt to split separated clusters
  625. } cbPKT_SS_STATISTICS_CB2005_31;
  626. typedef struct {
  627. uint32_t time; // system clock timestamp
  628. uint16_t chid; // 0x8000
  629. uint8_t type; // cbPKTTYPE_SS_STATISTICSREP or cbPKTTYPE_SS_STATISTICSSET depending on the direction
  630. uint8_t dlen; // cbPKTDLEN_SS_STATISTICS
  631. uint32_t nUpdateSpikes; // update rate in spike counts
  632. uint32_t nAutoalg; // automatic sorting algorithm (0=spread, 1=hist_corr_maj, 2=hist_peak_count_maj)
  633. float fMinClusterPairSpreadFactor; // larger number = more apt to combine 2 clusters into 1
  634. float fMaxSubclusterSpreadFactor; // larger number = less apt to split because of 2 clusers
  635. float fMinClusterHistCorrMajMeasure; // larger number = more apt to split 1 cluster into 2
  636. float fMaxClusterPairHistCorrMajMeasure; // larger number = less apt to combine 2 clusters into 1
  637. float fClusterHistValleyPercentage; // larger number = less apt to split nearby clusters
  638. float fClusterHistClosePeakPercentage; // larger number = less apt to split nearby clusters
  639. float fClusterHistMinPeakPercentage; // larger number = less apt to split separated clusters
  640. } cbPKT_SS_STATISTICS_CB2005_32;
  641. typedef struct {
  642. uint32_t time; // system clock timestamp
  643. uint16_t chid; // 0x8000
  644. uint8_t type; // cbPKTTYPE_SS_STATISTICSREP or cbPKTTYPE_SS_STATISTICSSET depending on the direction
  645. uint8_t dlen; // cbPKTDLEN_SS_STATISTICS
  646. uint32_t nUpdateSpikes; // update rate in spike counts
  647. uint32_t nAutoalg; // sorting algorithm (0=none 1=spread, 2=hist_corr_maj, 3=hist_peak_count_maj, 4=hist_peak_count_maj_fisher, 5=pca, 6=hoops)
  648. uint32_t nMode; // cbAUTOALG_MODE_SETTING,
  649. float fMinClusterPairSpreadFactor; // larger number = more apt to combine 2 clusters into 1
  650. float fMaxSubclusterSpreadFactor; // larger number = less apt to split because of 2 clusers
  651. float fMinClusterHistCorrMajMeasure; // larger number = more apt to split 1 cluster into 2
  652. float fMaxClusterPairHistCorrMajMeasure; // larger number = less apt to combine 2 clusters into 1
  653. float fClusterHistValleyPercentage; // larger number = less apt to split nearby clusters
  654. float fClusterHistClosePeakPercentage; // larger number = less apt to split nearby clusters
  655. float fClusterHistMinPeakPercentage; // larger number = less apt to split separated clusters
  656. uint32_t nWaveBasisSize; // number of wave to collect to calculate the basis,
  657. // must be greater than spike length
  658. uint32_t nWaveSampleSize; // number of samples sorted with the same basis before re-calculating the basis
  659. // 0=manual re-calculation
  660. // nWaveBasisSize * nWaveSampleSize is the number of waves/spikes to run against
  661. // the same PCA basis before next
  662. #ifdef __cplusplus
  663. void set(uint32_t nUpdateSpikes, uint32_t nAutoalg, uint32_t nMode, float fMinClusterPairSpreadFactor, float fMaxSubclusterSpreadFactor,
  664. float fMinClusterHistCorrMajMeasure, float fMaxClusterPairHistCorrMajMeasure,
  665. float fClusterHistValleyPercentage, float fClusterHistClosePeakPercentage, float fClusterHistMinPeakPercentage,
  666. uint32_t nWaveBasisSize, uint32_t nWaveSampleSize)
  667. {
  668. chid = cbPKTCHAN_CONFIGURATION;
  669. type = cbPKTTYPE_SS_STATISTICSSET;
  670. dlen = ((sizeof(*this) / 4) - 2);
  671. this->nUpdateSpikes = nUpdateSpikes;
  672. this->nAutoalg = nAutoalg;
  673. this->nMode = nMode;
  674. this->fMinClusterPairSpreadFactor = fMinClusterPairSpreadFactor;
  675. this->fMaxSubclusterSpreadFactor = fMaxSubclusterSpreadFactor;
  676. this->fMinClusterHistCorrMajMeasure = fMinClusterHistCorrMajMeasure;
  677. this->fMaxClusterPairHistCorrMajMeasure = fMaxClusterPairHistCorrMajMeasure;
  678. this->fClusterHistValleyPercentage = fClusterHistValleyPercentage;
  679. this->fClusterHistClosePeakPercentage = fClusterHistClosePeakPercentage;
  680. this->fClusterHistMinPeakPercentage = fClusterHistMinPeakPercentage;
  681. this->nWaveBasisSize = nWaveBasisSize;
  682. this->nWaveSampleSize = nWaveSampleSize;
  683. }
  684. #endif
  685. } cbPKT_SS_STATISTICS_CB2005_37;
  686. typedef struct {
  687. uint32_t time; // system clock timestamp
  688. uint16_t chid; // 0x8000
  689. uint8_t type; // cbPKTTYPE_SS_NOISE_BOUNDARYREP or cbPKTTYPE_SS_NOISE_BOUNDARYSET depending on the direction
  690. uint8_t dlen; // cbPKTDLEN_SS_ARTIF_REJECT
  691. float afc[2]; // the center of an ellipse
  692. float afS[2][2]; // the shape and size of an ellipse
  693. } cbPKT_SS_NOISE_BOUNDARY_CB2005_31;
  694. typedef struct {
  695. uint32_t time; // system clock timestamp
  696. uint16_t chid; // 0x8000
  697. uint8_t type; // cbPKTTYPE_SS_NOISE_BOUNDARYREP or cbPKTTYPE_SS_NOISE_BOUNDARYSET depending on the direction
  698. uint8_t dlen; // cbPKTDLEN_SS_ARTIF_REJECT
  699. float afc[2]; // the center of an ellipse
  700. float afS[2][2]; // the shape and size of an ellipse
  701. float aTheta; // the angle of rotation for the Noise Boundary (ellipse)
  702. } cbPKT_SS_NOISE_BOUNDARY_CB2005_33;
  703. typedef struct {
  704. uint32_t time; // system clock timestamp
  705. uint16_t chid; // 0x8000
  706. uint8_t type; // cbPKTTYPE_SS_NOISE_BOUNDARYREP or cbPKTTYPE_SS_NOISE_BOUNDARYSET depending on the direction
  707. uint8_t dlen; // cbPKTDLEN_SS_ARTIF_REJECT
  708. uint32_t chan; // which channel we belong to
  709. float afc[2]; // the center of an ellipse
  710. float afS[2][2]; // the shape and size of an ellipse
  711. float aTheta; // the angle of rotation for the Noise Boundary (ellipse)
  712. } cbPKT_SS_NOISE_BOUNDARY_CB2005_34;
  713. typedef struct {
  714. uint32_t time; // system clock timestamp
  715. uint16_t chid; // 0x8000
  716. uint8_t type; // cbPKTTYPE_SS_NOISE_BOUNDARYREP or cbPKTTYPE_SS_NOISE_BOUNDARYSET depending on the direction
  717. uint8_t dlen; // cbPKTDLEN_SS_ARTIF_REJECT
  718. uint32_t chan; // which channel we belong to
  719. float afc[3]; // the center of the ellipsoid
  720. float afS[3][3]; // an array of the axes for the ellipsoid
  721. #ifdef __cplusplus
  722. void set(uint32_t chan, float afc1, float afc2, float afS11, float afS12, float afS21, float afS22, float /*theta = 0*/)
  723. {// theta is ignored, but kept for backward compatibility
  724. set(chan, afc1, afc2, 0, afS11, afS12, 0, afS21, afS22, 0, 0, 0, 50);
  725. }
  726. void set(uint32_t chan, float cen1,float cen2, float cen3, float maj1, float maj2, float maj3,
  727. float min11, float min12, float min13, float min21, float min22, float min23)
  728. {
  729. chid = cbPKTCHAN_CONFIGURATION;
  730. type = cbPKTTYPE_SS_NOISE_BOUNDARYSET;
  731. dlen = ((sizeof(*this) / 4) - 2);
  732. this->chan = chan;
  733. this->afc[0] = cen1;
  734. this->afc[1] = cen2;
  735. this->afc[2] = cen3;
  736. this->afS[0][0] = maj1;
  737. this->afS[0][1] = maj2;
  738. this->afS[0][2] = maj3;
  739. this->afS[1][0] = min11;
  740. this->afS[1][1] = min12;
  741. this->afS[1][2] = min13;
  742. this->afS[2][0] = min21;
  743. this->afS[2][1] = min22;
  744. this->afS[2][2] = min23;
  745. }
  746. // The information obtained by these functions is implicit within the structure data,
  747. // but they are provided for convenience
  748. void GetAxisLengths(float afAxisLen[3])const;
  749. void GetRotationAngles(float afTheta[3])const;
  750. #endif
  751. } cbPKT_SS_NOISE_BOUNDARY_CB2005_37;
  752. typedef struct {
  753. uint32_t time; // system clock timestamp
  754. uint16_t chid; // 0x8000
  755. uint8_t type; // PKTTYPE_SYS*
  756. uint8_t dlen; // cbPKT_SYSINFODLEN
  757. uint32_t sysfreq; // System clock frequency in Hz
  758. uint32_t spikelen; // The length of the spike events
  759. uint32_t spikepre; // Spike pre-trigger samples
  760. uint32_t resetque; // The channel for the reset to que on
  761. uint32_t runlevel; // System runlevel
  762. uint32_t runflags;
  763. } cbPKT_SYSINFO_CB2005_37;
  764. typedef struct {
  765. uint32_t time; // system clock timestamp
  766. uint16_t chid; // 0x8000
  767. uint8_t type; // cbPKTTYPE_ADAPTFILTSET or cbPKTTYPE_ADAPTFILTREP
  768. uint8_t dlen; // cbPKTDLEN_ADAPTFILTINFO
  769. uint32_t chan; // Ignored
  770. uint32_t nMode; // 0=disabled, 1=filter continuous & spikes, 2=filter spikes
  771. float dLearningRate; // speed at which adaptation happens. Very small. e.g. 5e-12
  772. uint32_t nRefChan1; // The first reference channel (1 based).
  773. uint32_t nRefChan2; // The second reference channel (1 based).
  774. } cbPKT_ADAPTFILTINFO_CB2005_37;
  775. typedef struct {
  776. cbPKT_CHANINFO isChan[cbLEGACY_MAXCHANS];
  777. cbPKT_ADAPTFILTINFO_CB2005_37 isAdaptInfo;
  778. cbPKT_SS_DETECT_CB2005_37 isSS_Detect;
  779. cbPKT_SS_ARTIF_REJECT_CB2005_37 isSS_ArtifactReject;
  780. cbPKT_SS_NOISE_BOUNDARY_CB2005_37 isSS_NoiseBoundary[cbLEGACY_NUM_ANALOG_CHANS];
  781. cbPKT_SS_STATISTICS_CB2005_37 isSS_Statistics;
  782. cbPKT_SS_STATUS_CB2005_37 isSS_Status;
  783. cbPKT_SYSINFO_CB2005_37 isSysInfo;
  784. cbPKT_NTRODEINFO_CB2005_37 isNTrodeInfo[cbLEGACY_MAXNTRODES];
  785. } ccfBinaryData;
  786. }; // namespace ccf
  787. // A snapshot of the binary CCF in the last binary version (3.9)
  788. class CCFUtilsBinary : public CCFUtils
  789. {
  790. public:
  791. CCFUtilsBinary();
  792. public:
  793. // Purpose: load the channel configuration from the file
  794. ccf::ccfResult ReadCCF(LPCSTR szFileName, bool bConvert);
  795. ccf::ccfResult ReadVersion(LPCSTR szFileName); // Read the version alone
  796. public:
  797. // We give it public access to make it easy
  798. ccf::ccfBinaryData m_data; // Internal structure holding actual config parameters
  799. protected:
  800. // Convert from old config (generic)
  801. virtual CCFUtils * Convert(CCFUtils * pOldConfig);
  802. // Keep old binary writing for possible backward porting
  803. virtual ccf::ccfResult WriteCCFNoPrompt(LPCSTR szFileName);
  804. private:
  805. // Used as identifiers in the channel configuration files
  806. static const char m_szConfigFileHeader[7];
  807. static const char m_szConfigFileVersion[11];
  808. static const int m_iPreviousHeaderSize = 9;
  809. inline void cpyScaling(cbSCALING &dest, ccf::cbSCALING_NO_ANAGAIN &src)
  810. {
  811. dest.anagain = 1;
  812. dest.anamax = src.anamax;
  813. dest.anamin = src.anamin;
  814. memcpy(dest.anaunit, src.anaunit, sizeof(dest.anaunit));
  815. dest.digmax = src.digmax;
  816. dest.digmin = src.digmin;
  817. }
  818. void SetChannelDefaults(cbPKT_CHANINFO &isChan);
  819. uint32_t TranslateAutoFilter(uint32_t filter);
  820. void ReadSpikeSortingPackets(ccf::cbPKT_GENERIC_CB2003_10 *pPkt);
  821. // Purpose: after reading channel info from the config file, read the rest of the
  822. // data as individual packets to the binary settings
  823. void ReadAsPackets(FILE * hFile);
  824. // Purpose: load the channel configuration from different binary file versions
  825. ccf::ccfResult ReadCCFData_cb2003_10(FILE * hFile);
  826. ccf::ccfResult ReadCCFData_cb2003_10_a(FILE * hFile);
  827. ccf::ccfResult ReadCCFData_cb2003_10_b(FILE * hFile);
  828. ccf::ccfResult ReadCCFData_cb2005_25(FILE * hFile);
  829. ccf::ccfResult ReadCCFData_cb2005_30(FILE * hFile);
  830. ccf::ccfResult ReadCCFData_cb2005_31(FILE * hFile);
  831. ccf::ccfResult ReadCCFData_cb2005_34(FILE * hFile);
  832. ccf::ccfResult ReadCCFData_cb2005_35(FILE * hFile);
  833. ccf::ccfResult ReadCCFData_cb2005_36(FILE * hFile);
  834. ccf::ccfResult ReadCCFData_cb2005_37(FILE * hFile);
  835. ccf::ccfResult ReadCCFData_cb2005_310(FILE * hFile);
  836. };
  837. #endif // include guard