cerelink 8.0.1__cp311-cp311-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cerelink/__init__.py +5 -0
- cerelink/__version__.py +34 -0
- cerelink/cbpy.cpython-311-darwin.so +0 -0
- cerelink/cbpy.pyx +1157 -0
- cerelink/cbsdk_cython.pxd +458 -0
- cerelink/cbsdk_helper.cpp +112 -0
- cerelink/cbsdk_helper.h +54 -0
- cerelink-8.0.1.dist-info/METADATA +59 -0
- cerelink-8.0.1.dist-info/RECORD +11 -0
- cerelink-8.0.1.dist-info/WHEEL +5 -0
- cerelink-8.0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,458 @@
|
|
1
|
+
"""
|
2
|
+
@date March 9, 2014
|
3
|
+
|
4
|
+
@author: dashesy
|
5
|
+
|
6
|
+
Purpose: Cython interface for cbsdk_small
|
7
|
+
|
8
|
+
"""
|
9
|
+
|
10
|
+
from libc.stdint cimport uint32_t, int32_t, uint16_t, int16_t, uint8_t
|
11
|
+
from libcpp cimport bool
|
12
|
+
|
13
|
+
cdef extern from "stdint.h":
|
14
|
+
ctypedef unsigned long long uint64_t
|
15
|
+
|
16
|
+
cdef extern from "cerelink/cbproto.h":
|
17
|
+
ctypedef uint64_t PROCTIME # Will be uint32_t or uint64_t depending on CBPROTO_311, but we detect size at runtime
|
18
|
+
|
19
|
+
cdef char* cbNET_UDP_ADDR_INST "cbNET_UDP_ADDR_INST" # Cerebus default address
|
20
|
+
cdef char* cbNET_UDP_ADDR_CNT "cbNET_UDP_ADDR_CNT" # NSP default control address
|
21
|
+
cdef char* cbNET_UDP_ADDR_BCAST "cbNET_UDP_ADDR_BCAST" # NSP default broadcast address
|
22
|
+
cdef int cbNET_UDP_PORT_BCAST "cbNET_UDP_PORT_BCAST" # Neuroflow Data Port
|
23
|
+
cdef int cbNET_UDP_PORT_CNT "cbNET_UDP_PORT_CNT" # Neuroflow Control Port
|
24
|
+
|
25
|
+
# Have to put constants that are used as array sizes in an enum,
|
26
|
+
# otherwise they are considered non-const and can't be used.
|
27
|
+
cdef enum cbhwlib_consts:
|
28
|
+
cbNUM_FE_CHANS = 256
|
29
|
+
cbNUM_ANAIN_CHANS = 16
|
30
|
+
cbNUM_ANALOG_CHANS = (cbNUM_FE_CHANS + cbNUM_ANAIN_CHANS)
|
31
|
+
cbNUM_ANAOUT_CHANS = 4
|
32
|
+
cbNUM_AUDOUT_CHANS = 2
|
33
|
+
cbNUM_ANALOGOUT_CHANS = (cbNUM_ANAOUT_CHANS + cbNUM_AUDOUT_CHANS)
|
34
|
+
cbNUM_DIGIN_CHANS = 1
|
35
|
+
cbNUM_SERIAL_CHANS = 1
|
36
|
+
cbNUM_DIGOUT_CHANS = 4
|
37
|
+
cbMAXCHANS = (cbNUM_ANALOG_CHANS + cbNUM_ANALOGOUT_CHANS + cbNUM_DIGIN_CHANS + cbNUM_SERIAL_CHANS + cbNUM_DIGOUT_CHANS)
|
38
|
+
cbMAXUNITS = 5
|
39
|
+
# MAX_CHANS_DIGITAL_IN = (cbNUM_ANALOG_CHANS + cbNUM_ANALOGOUT_CHANS + cbNUM_DIGIN_CHANS)
|
40
|
+
# MAX_CHANS_SERIAL = (MAX_CHANS_DIGITAL_IN + cbNUM_SERIAL_CHANS)
|
41
|
+
cbMAXTRACKOBJ = 20 # maximum number of trackable objects
|
42
|
+
cbMAXHOOPS = 4
|
43
|
+
cbPKT_SPKCACHEPKTCNT = 400
|
44
|
+
cbMAX_PNTS = 128 # make large enough to track longest possible spike width in samples
|
45
|
+
|
46
|
+
cdef enum cbwlib_strconsts:
|
47
|
+
cbLEN_STR_UNIT = 8
|
48
|
+
cbLEN_STR_LABEL = 16
|
49
|
+
#cbLEN_STR_FILT_LABEL = 16
|
50
|
+
cbLEN_STR_IDENT = 64
|
51
|
+
|
52
|
+
cdef enum cbStateCCF:
|
53
|
+
CCFSTATE_READ = 0 # Reading in progress
|
54
|
+
CCFSTATE_WRITE = 1 # Writing in progress
|
55
|
+
CCFSTATE_SEND = 2 # Sendign in progress
|
56
|
+
CCFSTATE_CONVERT = 3 # Conversion in progress
|
57
|
+
CCFSTATE_THREADREAD = 4 # Total threaded read progress
|
58
|
+
CCFSTATE_THREADWRITE = 5 # Total threaded write progress
|
59
|
+
CCFSTATE_UNKNOWN = 6 # (Always the last) unknown state
|
60
|
+
|
61
|
+
# TODO: use cdef for each item instead?
|
62
|
+
cdef enum cbhwlib_cbFILECFG:
|
63
|
+
cbFILECFG_OPT_NONE = 0x00000000
|
64
|
+
cbFILECFG_OPT_KEEPALIVE = 0x00000001
|
65
|
+
cbFILECFG_OPT_REC = 0x00000002
|
66
|
+
cbFILECFG_OPT_STOP = 0x00000003
|
67
|
+
cbFILECFG_OPT_NMREC = 0x00000004
|
68
|
+
cbFILECFG_OPT_CLOSE = 0x00000005
|
69
|
+
cbFILECFG_OPT_SYNCH = 0x00000006
|
70
|
+
cbFILECFG_OPT_OPEN = 0x00000007
|
71
|
+
|
72
|
+
cdef enum cbhwlib_cbCHANCAPS:
|
73
|
+
cbCHAN_EXISTS = 0x00000001 # Channel id is allocated
|
74
|
+
cbCHAN_CONNECTED = 0x00000002 # Channel is connected and mapped and ready to use
|
75
|
+
cbCHAN_ISOLATED = 0x00000004 # Channel is electrically isolated
|
76
|
+
cbCHAN_AINP = 0x00000100 # Channel has analog input capabilities
|
77
|
+
cbCHAN_AOUT = 0x00000200 # Channel has analog output capabilities
|
78
|
+
cbCHAN_DINP = 0x00000400 # Channel has digital input capabilities
|
79
|
+
cbCHAN_DOUT = 0x00000800 # Channel has digital output capabilities
|
80
|
+
|
81
|
+
cdef enum cbhwlib_cbCHANTYPES:
|
82
|
+
cbCHANTYPE_ANAIN = 0x01
|
83
|
+
cbCHANTYPE_ANAOUT = 0x02
|
84
|
+
cbCHANTYPE_AUDOUT = 0x04
|
85
|
+
cbCHANTYPE_DIGIN = 0x10
|
86
|
+
cbCHANTYPE_SERIAL = 0x20
|
87
|
+
cbCHANTYPE_DIGOUT = 0x40
|
88
|
+
|
89
|
+
ctypedef struct cbSCALING:
|
90
|
+
int16_t digmin # digital value that cooresponds with the anamin value
|
91
|
+
int16_t digmax # digital value that cooresponds with the anamax value
|
92
|
+
int32_t anamin # the minimum analog value present in the signal
|
93
|
+
int32_t anamax # the maximum analog value present in the signal
|
94
|
+
int32_t anagain # the gain applied to the default analog values to get the analog values
|
95
|
+
char anaunit[cbLEN_STR_UNIT+0] # the unit for the analog signal (eg, "uV" or "MPa")
|
96
|
+
|
97
|
+
ctypedef struct cbFILTDESC:
|
98
|
+
char label[cbLEN_STR_LABEL+0]
|
99
|
+
uint32_t hpfreq # high-pass corner frequency in milliHertz
|
100
|
+
uint32_t hporder # high-pass filter order
|
101
|
+
uint32_t hptype # high-pass filter type
|
102
|
+
uint32_t lpfreq # low-pass frequency in milliHertz
|
103
|
+
uint32_t lporder # low-pass filter order
|
104
|
+
uint32_t lptype # low-pass filter type
|
105
|
+
|
106
|
+
ctypedef struct cbMANUALUNITMAPPING:
|
107
|
+
int16_t nOverride
|
108
|
+
int16_t afOrigin[3]
|
109
|
+
int16_t afShape[3][3]
|
110
|
+
int16_t aPhi
|
111
|
+
uint32_t bValid # is this unit in use at this time?
|
112
|
+
|
113
|
+
ctypedef struct cbHOOP:
|
114
|
+
uint16_t valid # 0=undefined, 1 for valid
|
115
|
+
int16_t time # time offset into spike window
|
116
|
+
int16_t min # minimum value for the hoop window
|
117
|
+
int16_t max # maximum value for the hoop window
|
118
|
+
|
119
|
+
ctypedef struct cbPKT_HEADER:
|
120
|
+
PROCTIME time # system clock timestamp
|
121
|
+
uint16_t chid # channel identifier
|
122
|
+
uint16_t type # packet type
|
123
|
+
uint16_t dlen # length of data field in 32-bit chunks
|
124
|
+
uint8_t instrument # instrument number to transmit this packets
|
125
|
+
uint8_t reserved # reserved for future
|
126
|
+
|
127
|
+
ctypedef struct cbPKT_CHANINFO:
|
128
|
+
cbPKT_HEADER cbpkt_header
|
129
|
+
uint32_t chan # actual channel id of the channel being configured
|
130
|
+
uint32_t proc # the address of the processor on which the channel resides
|
131
|
+
uint32_t bank # the address of the bank on which the channel resides
|
132
|
+
uint32_t term # the terminal number of the channel within it's bank
|
133
|
+
uint32_t chancaps # general channel capablities (given by cbCHAN_* flags)
|
134
|
+
uint32_t doutcaps # digital output capablities (composed of cbDOUT_* flags)
|
135
|
+
uint32_t dinpcaps # digital input capablities (composed of cbDINP_* flags)
|
136
|
+
uint32_t aoutcaps # analog output capablities (composed of cbAOUT_* flags)
|
137
|
+
uint32_t ainpcaps # analog input capablities (composed of cbAINP_* flags)
|
138
|
+
uint32_t spkcaps # spike processing capabilities
|
139
|
+
cbSCALING physcalin # physical channel scaling information
|
140
|
+
cbFILTDESC phyfiltin # physical channel filter definition
|
141
|
+
cbSCALING physcalout # physical channel scaling information
|
142
|
+
cbFILTDESC phyfiltout # physical channel filter definition
|
143
|
+
char label[cbLEN_STR_LABEL+0]# Label of the channel (null terminated if <16 characters)
|
144
|
+
uint32_t userflags # User flags for the channel state
|
145
|
+
int32_t position[4] # reserved for future position information
|
146
|
+
cbSCALING scalin # user-defined scaling information for AINP
|
147
|
+
cbSCALING scalout # user-defined scaling information for AOUT
|
148
|
+
uint32_t doutopts # digital output options (composed of cbDOUT_* flags)
|
149
|
+
uint32_t dinpopts # digital input options (composed of cbDINP_* flags)
|
150
|
+
uint32_t aoutopts # analog output options
|
151
|
+
uint32_t eopchar # digital input capablities (given by cbDINP_* flags)
|
152
|
+
uint16_t moninst
|
153
|
+
uint16_t monchan
|
154
|
+
int32_t outvalue # output value
|
155
|
+
# uint16_t lowsamples # address of channel to monitor
|
156
|
+
# uint16_t highsamples # address of channel to monitor
|
157
|
+
# int32_t offset
|
158
|
+
uint8_t trigtype # trigger type (see cbDOUT_TRIGGER_*)
|
159
|
+
uint8_t reserved[2] # 2 bytes reserved
|
160
|
+
uint8_t triginst # instrument of the trigger channel
|
161
|
+
uint16_t trigchan # trigger channel
|
162
|
+
uint16_t trigval # trigger value
|
163
|
+
uint32_t ainpopts # analog input options (composed of cbAINP* flags)
|
164
|
+
uint32_t lncrate # line noise cancellation filter adaptation rate
|
165
|
+
uint32_t smpfilter # continuous-time pathway filter id
|
166
|
+
uint32_t smpgroup # continuous-time pathway sample group
|
167
|
+
int32_t smpdispmin # continuous-time pathway display factor
|
168
|
+
int32_t smpdispmax # continuous-time pathway display factor
|
169
|
+
uint32_t spkfilter # spike pathway filter id
|
170
|
+
int32_t spkdispmax # spike pathway display factor
|
171
|
+
int32_t lncdispmax # Line Noise pathway display factor
|
172
|
+
uint32_t spkopts # spike processing options
|
173
|
+
int32_t spkthrlevel # spike threshold level
|
174
|
+
int32_t spkthrlimit
|
175
|
+
uint32_t spkgroup # NTrodeGroup this electrode belongs to - 0 is single unit, non-0 indicates a multi-trode grouping
|
176
|
+
int16_t amplrejpos # Amplitude rejection positive value
|
177
|
+
int16_t amplrejneg # Amplitude rejection negative value
|
178
|
+
uint32_t refelecchan # Software reference electrode channel
|
179
|
+
cbMANUALUNITMAPPING unitmapping[cbMAXUNITS+0] # manual unit mapping
|
180
|
+
cbHOOP spkhoops[cbMAXUNITS+0][cbMAXHOOPS+0] # spike hoop sorting set
|
181
|
+
|
182
|
+
ctypedef struct cbFILTDESC:
|
183
|
+
char label[cbLEN_STR_LABEL+0]
|
184
|
+
uint32_t hpfreq # high-pass corner frequency in milliHertz
|
185
|
+
uint32_t hporder # high-pass filter order
|
186
|
+
uint32_t hptype # high-pass filter type
|
187
|
+
uint32_t lpfreq # low-pass frequency in milliHertz
|
188
|
+
uint32_t lporder # low-pass filter order
|
189
|
+
uint32_t lptype # low-pass filter type
|
190
|
+
|
191
|
+
ctypedef struct cbPKT_SPK:
|
192
|
+
cbPKT_HEADER cbpkt_header
|
193
|
+
float fPattern[3] # values of the pattern space (Normal uses only 2, PCA uses third)
|
194
|
+
int16_t nPeak
|
195
|
+
int16_t nValley
|
196
|
+
int16_t wave[cbMAX_PNTS+0] # Room for all possible points collected
|
197
|
+
# wave must be the last item in the structure because it can be variable length to a max of cbMAX_PNTS
|
198
|
+
|
199
|
+
ctypedef struct cbSPKCACHE:
|
200
|
+
uint32_t chid # ID of the Channel
|
201
|
+
uint32_t pktcnt # # of packets which can be saved
|
202
|
+
uint32_t pktsize # Size of an individual packet
|
203
|
+
uint32_t head # Where (0 based index) in the circular buffer to place the NEXT packet.
|
204
|
+
uint32_t valid # How many packets have come in since the last configuration
|
205
|
+
cbPKT_SPK spkpkt[cbPKT_SPKCACHEPKTCNT+0] # Circular buffer of the cached spikes
|
206
|
+
|
207
|
+
cdef extern from "cerelink/cbsdk.h":
|
208
|
+
|
209
|
+
cdef int cbSdk_CONTINUOUS_DATA_SAMPLES = 102400
|
210
|
+
cdef int cbSdk_EVENT_DATA_SAMPLES = (2 * 8192)
|
211
|
+
cdef int cbSdk_MAX_UPOLOAD_SIZE = (1024 * 1024 * 1024)
|
212
|
+
cdef float cbSdk_TICKS_PER_SECOND = 30000.0
|
213
|
+
cdef float cbSdk_SECONDS_PER_TICK = 1.0 / cbSdk_TICKS_PER_SECOND
|
214
|
+
|
215
|
+
ctypedef enum cbSdkResult:
|
216
|
+
CBSDKRESULT_WARNCONVERT = 3 # If file conversion is needed
|
217
|
+
CBSDKRESULT_WARNCLOSED = 2 # Library is already closed
|
218
|
+
CBSDKRESULT_WARNOPEN = 1 # Library is already opened
|
219
|
+
CBSDKRESULT_SUCCESS = 0 # Successful operation
|
220
|
+
CBSDKRESULT_NOTIMPLEMENTED = -1 # Not implemented
|
221
|
+
CBSDKRESULT_UNKNOWN = -2 # Unknown error
|
222
|
+
CBSDKRESULT_INVALIDPARAM = -3 # Invalid parameter
|
223
|
+
CBSDKRESULT_CLOSED = -4 # Interface is closed cannot do this operation
|
224
|
+
CBSDKRESULT_OPEN = -5 # Interface is open cannot do this operation
|
225
|
+
CBSDKRESULT_NULLPTR = -6 # Null pointer
|
226
|
+
CBSDKRESULT_ERROPENCENTRAL = -7 # Unable to open Central interface
|
227
|
+
CBSDKRESULT_ERROPENUDP = -8 # Unable to open UDP interface (might happen if default)
|
228
|
+
CBSDKRESULT_ERROPENUDPPORT = -9 # Unable to open UDP port
|
229
|
+
CBSDKRESULT_ERRMEMORYTRIAL = -10 # Unable to allocate RAM for trial cache data
|
230
|
+
CBSDKRESULT_ERROPENUDPTHREAD = -11 # Unable to open UDP timer thread
|
231
|
+
CBSDKRESULT_ERROPENCENTRALTHREAD = -12 # Unable to open Central communication thread
|
232
|
+
CBSDKRESULT_INVALIDCHANNEL = -13 # Invalid channel number
|
233
|
+
CBSDKRESULT_INVALIDCOMMENT = -14 # Comment too long or invalid
|
234
|
+
CBSDKRESULT_INVALIDFILENAME = -15 # Filename too long or invalid
|
235
|
+
CBSDKRESULT_INVALIDCALLBACKTYPE = -16 # Invalid callback type
|
236
|
+
CBSDKRESULT_CALLBACKREGFAILED = -17 # Callback register/unregister failed
|
237
|
+
CBSDKRESULT_ERRCONFIG = -18 # Trying to run an unconfigured method
|
238
|
+
CBSDKRESULT_INVALIDTRACKABLE = -19 # Invalid trackable id, or trackable not present
|
239
|
+
CBSDKRESULT_INVALIDVIDEOSRC = -20 # Invalid video source id, or video source not present
|
240
|
+
CBSDKRESULT_ERROPENFILE = -21 # Cannot open file
|
241
|
+
CBSDKRESULT_ERRFORMATFILE = -22 # Wrong file format
|
242
|
+
CBSDKRESULT_OPTERRUDP = -23 # Socket option error (possibly permission issue)
|
243
|
+
CBSDKRESULT_MEMERRUDP = -24 # Socket memory assignment error
|
244
|
+
CBSDKRESULT_INVALIDINST = -25 # Invalid range or instrument address
|
245
|
+
CBSDKRESULT_ERRMEMORY = -26 # library memory allocation error
|
246
|
+
CBSDKRESULT_ERRINIT = -27 # Library initialization error
|
247
|
+
CBSDKRESULT_TIMEOUT = -28 # Conection timeout error
|
248
|
+
CBSDKRESULT_BUSY = -29 # Resource is busy
|
249
|
+
CBSDKRESULT_ERROFFLINE = -30 # Instrument is offline
|
250
|
+
CBSDKRESULT_INSTOUTDATED = -31 # The instrument runs an outdated protocol version
|
251
|
+
CBSDKRESULT_LIBOUTDATED = -32 # The library is outdated
|
252
|
+
|
253
|
+
ctypedef enum cbSdkConnectionType:
|
254
|
+
CBSDKCONNECTION_DEFAULT = 0 # Try Central then UDP
|
255
|
+
CBSDKCONNECTION_CENTRAL = 1 # Use Central
|
256
|
+
CBSDKCONNECTION_UDP = 2 # Use UDP
|
257
|
+
CBSDKCONNECTION_CLOSED = 3 # Closed
|
258
|
+
|
259
|
+
ctypedef enum cbSdkInstrumentType:
|
260
|
+
CBSDKINSTRUMENT_NSP = 0 # NSP
|
261
|
+
CBSDKINSTRUMENT_NPLAY = 1 # Local nPlay
|
262
|
+
CBSDKINSTRUMENT_LOCALNSP = 2 # Local NSP
|
263
|
+
CBSDKINSTRUMENT_REMOTENPLAY = 3 # Remote nPlay
|
264
|
+
|
265
|
+
# cbSdkCCFEvent. Skipping because it depends on cbStateCCF
|
266
|
+
|
267
|
+
ctypedef enum cbSdkTrialType:
|
268
|
+
CBSDKTRIAL_CONTINUOUS = 0
|
269
|
+
CBSDKTRIAL_EVENTS = 1
|
270
|
+
CBSDKTRIAL_COMMENTS = 2
|
271
|
+
CBSDKTRIAL_TRACKING = 3
|
272
|
+
|
273
|
+
ctypedef enum cbSdkWaveformType:
|
274
|
+
cbSdkWaveform_NONE = 0
|
275
|
+
cbSdkWaveform_PARAMETERS = 1
|
276
|
+
cbSdkWaveform_SINE = 2
|
277
|
+
cbSdkWaveform_COUNT = 3
|
278
|
+
|
279
|
+
ctypedef enum cbSdkWaveformTriggerType:
|
280
|
+
cbSdkWaveformTrigger_NONE = 0 # Instant software trigger
|
281
|
+
cbSdkWaveformTrigger_DINPREG = 1 # digital input rising edge trigger
|
282
|
+
cbSdkWaveformTrigger_DINPFEG = 2 # digital input falling edge trigger
|
283
|
+
cbSdkWaveformTrigger_SPIKEUNIT = 3 # spike unit
|
284
|
+
cbSdkWaveformTrigger_COMMENTCOLOR = 4 # custom colored event (e.g. NeuroMotive event)
|
285
|
+
cbSdkWaveformTrigger_SOFTRESET = 5 # Soft-reset trigger (e.g. file recording start)
|
286
|
+
cbSdkWaveformTrigger_EXTENSION = 6 # Extension trigger
|
287
|
+
cbSdkWaveformTrigger_COUNT = 7 # Always the last value
|
288
|
+
|
289
|
+
ctypedef struct cbSdkVersion:
|
290
|
+
# Library version
|
291
|
+
uint32_t major
|
292
|
+
uint32_t minor
|
293
|
+
uint32_t release
|
294
|
+
uint32_t beta
|
295
|
+
# Protocol version
|
296
|
+
uint32_t majorp
|
297
|
+
uint32_t minorp
|
298
|
+
# NSP version
|
299
|
+
uint32_t nspmajor
|
300
|
+
uint32_t nspminor
|
301
|
+
uint32_t nsprelease
|
302
|
+
uint32_t nspbeta
|
303
|
+
# NSP protocol version
|
304
|
+
uint32_t nspmajorp
|
305
|
+
uint32_t nspminorp
|
306
|
+
|
307
|
+
ctypedef struct cbSdkCCFEvent:
|
308
|
+
cbStateCCF state # CCF state
|
309
|
+
cbSdkResult result # Last result
|
310
|
+
const char * szFileName # CCF filename under operation
|
311
|
+
uint8_t progress # Progress (in percent)
|
312
|
+
|
313
|
+
ctypedef struct cbSdkTrialEvent:
|
314
|
+
PROCTIME trial_start_time
|
315
|
+
uint32_t num_events
|
316
|
+
PROCTIME * timestamps # [num_events]
|
317
|
+
uint16_t * channels # [num_events]
|
318
|
+
uint16_t * units # [num_events]
|
319
|
+
void * waveforms # [num_events][cbMAX_PNTS]
|
320
|
+
|
321
|
+
ctypedef struct cbSdkConnection:
|
322
|
+
int nInPort # Client port number
|
323
|
+
int nOutPort # Instrument port number
|
324
|
+
int nRecBufSize # Receive buffer size (0 to ignore altogether)
|
325
|
+
const char * szInIP # Client IPv4 address
|
326
|
+
const char * szOutIP # Instrument IPv4 address
|
327
|
+
cdef cbSdkConnection cbSdkConnection_DEFAULT = {cbNET_UDP_PORT_BCAST, cbNET_UDP_PORT_CNT, (4096 * 2048), "", ""}
|
328
|
+
|
329
|
+
# Trial continuous data
|
330
|
+
ctypedef struct cbSdkTrialCont:
|
331
|
+
PROCTIME trial_start_time # Trial start time (device timestamp when trial started)
|
332
|
+
uint8_t group # Sample group to retrieve (0-7, set by user before Init)
|
333
|
+
uint16_t count # Number of valid channels in this group (output from Init)
|
334
|
+
uint16_t chan[cbNUM_ANALOG_CHANS+0] # channel numbers (1-based, output from Init)
|
335
|
+
uint16_t sample_rate # Sample rate for this group (Hz, output from Init)
|
336
|
+
uint32_t num_samples # Number of samples: input = max to read, output = actual read
|
337
|
+
void * samples # Pointer to contiguous [num_samples][count] array
|
338
|
+
PROCTIME * timestamps # Pointer to array of [num_samples] timestamps
|
339
|
+
|
340
|
+
ctypedef struct cbSdkTrialComment:
|
341
|
+
PROCTIME trial_start_time # Trial start time (device timestamp when trial started)
|
342
|
+
uint16_t num_samples # Number of comments
|
343
|
+
uint8_t * charsets # Buffer to hold character sets
|
344
|
+
uint32_t * rgbas # Buffer to hold rgba values
|
345
|
+
uint8_t * * comments # Pointer to comments
|
346
|
+
PROCTIME * timestamps # Buffer to hold time stamps
|
347
|
+
|
348
|
+
# Trial video tracking data
|
349
|
+
ctypedef struct cbSdkTrialTracking:
|
350
|
+
PROCTIME trial_start_time # Trial start time (device timestamp when trial started)
|
351
|
+
uint16_t count # Number of valid trackable objects (up to cbMAXTRACKOBJ)
|
352
|
+
uint16_t ids[cbMAXTRACKOBJ+0] # Node IDs (holds count elements)
|
353
|
+
uint16_t max_point_counts[cbMAXTRACKOBJ+0] # Maximum point counts (holds count elements)
|
354
|
+
uint16_t types[cbMAXTRACKOBJ+0] # Node types (can be cbTRACKOBJ_TYPE_* and determines coordinate counts) (holds count elements)
|
355
|
+
uint8_t names[cbMAXTRACKOBJ+0][16 + 1] # Node names (holds count elements)
|
356
|
+
uint16_t num_samples[cbMAXTRACKOBJ+0] # Number of samples
|
357
|
+
uint16_t * point_counts[cbMAXTRACKOBJ+0] # Buffer to hold number of valid points (up to max_point_counts) (holds count*num_samples elements)
|
358
|
+
void * * coords[cbMAXTRACKOBJ+0] # Buffer to hold tracking points (holds count*num_samples tarackables, each of max_point_counts points
|
359
|
+
uint32_t * synch_frame_numbers[cbMAXTRACKOBJ+0] # Buffer to hold synch frame numbers (holds count*num_samples elements)
|
360
|
+
uint32_t * synch_timestamps[cbMAXTRACKOBJ+0] # Buffer to hold synchronized tracking time stamps (in milliseconds) (holds count*num_samples elements)
|
361
|
+
PROCTIME * timestamps[cbMAXTRACKOBJ+0] # Buffer to hold tracking time stamps (holds count*num_samples elements)
|
362
|
+
|
363
|
+
ctypedef struct cbSdkAoutMon:
|
364
|
+
uint16_t chan # (1-based) channel to monitor
|
365
|
+
bint bTrack # If should monitor last tracked channel
|
366
|
+
bint bSpike # If spike or continuous should be monitored
|
367
|
+
|
368
|
+
ctypedef struct cbSdkWaveformData:
|
369
|
+
cbSdkWaveformType type
|
370
|
+
uint32_t repeats
|
371
|
+
cbSdkWaveformTriggerType trig
|
372
|
+
uint16_t trigChan
|
373
|
+
uint16_t trigValue
|
374
|
+
uint8_t trigNum
|
375
|
+
int16_t offset
|
376
|
+
uint16_t sineFrequency
|
377
|
+
int16_t sineAmplitude
|
378
|
+
uint16_t phases
|
379
|
+
uint16_t* duration
|
380
|
+
int16_t* amplitude
|
381
|
+
|
382
|
+
cbSdkResult cbSdkGetVersion(uint32_t nInstance, cbSdkVersion * version)
|
383
|
+
# Read and write CCF requires a lot of baggage from cbhwlib.h. Skipping.
|
384
|
+
cbSdkResult cbSdkOpen(uint32_t nInstance, cbSdkConnectionType conType, cbSdkConnection con) nogil
|
385
|
+
cbSdkResult cbSdkGetType(uint32_t nInstance, cbSdkConnectionType * conType, cbSdkInstrumentType * instType) # Get connection and instrument type
|
386
|
+
cbSdkResult cbSdkClose(uint32_t nInstance) # Close the library
|
387
|
+
cbSdkResult cbSdkGetTime(uint32_t nInstance, PROCTIME * cbtime) # Get the instrument sample clock time
|
388
|
+
cbSdkResult cbSdkGetSpkCache(uint32_t nInstance, uint16_t channel, cbSPKCACHE **cache)
|
389
|
+
cbSdkResult cbSdkUnsetTrialConfig(uint32_t nInstance, cbSdkTrialType type)
|
390
|
+
cbSdkResult cbSdkGetChannelLabel(int nInstance, uint16_t channel, uint32_t * bValid, char * label, uint32_t * userflags, int32_t * position)
|
391
|
+
cbSdkResult cbSdkSetChannelLabel(uint32_t nInstance, uint16_t channel, const char * label, uint32_t userflags, int32_t * position)
|
392
|
+
# cbSdkResult cbSdkGetChannelType(uint32_t nInstance, uint16_t channel, uint8_t* ch_type)
|
393
|
+
# TODO: wrap Get channel capabilities section from cbsdk.h
|
394
|
+
cbSdkResult cbSdkIsChanAnyDigIn(uint32_t nInstance, uint16_t channel, uint32_t * bResult)
|
395
|
+
cbSdkResult cbSdkIsChanSerial(uint32_t nInstance, uint16_t channel, uint32_t * bResult);
|
396
|
+
# Retrieve data of a trial (NULL means ignore), user should allocate enough buffers beforehand, and trial should not be closed during this call
|
397
|
+
cbSdkResult cbSdkGetTrialData( uint32_t nInstance,
|
398
|
+
uint32_t seek, cbSdkTrialEvent * trialevent, cbSdkTrialCont * trialcont,
|
399
|
+
cbSdkTrialComment * trialcomment, cbSdkTrialTracking * trialtracking)
|
400
|
+
# Initialize the structures (and fill with information about active channels, comment pointers and samples in the buffer)
|
401
|
+
cbSdkResult cbSdkInitTrialData( uint32_t nInstance, uint32_t resetClock,
|
402
|
+
cbSdkTrialEvent * trialevent, cbSdkTrialCont * trialcont,
|
403
|
+
cbSdkTrialComment * trialcomment, cbSdkTrialTracking * trialtracking, unsigned long wait_for_comment_msec)
|
404
|
+
cbSdkResult cbSdkSetFileConfig(uint32_t nInstance, const char * filename, const char * comment, uint32_t start, uint32_t options) # Also see cbsdk_file_config in helper
|
405
|
+
cbSdkResult cbSdkGetFileConfig(uint32_t nInstance, char * filename, char * username, bool * pbRecording)
|
406
|
+
cbSdkResult cbSdkSetPatientInfo(uint32_t nInstance, const char * ID, const char * firstname, const char * lastname, uint32_t DOBMonth, uint32_t DOBDay, uint32_t DOBYear)
|
407
|
+
cbSdkResult cbSdkInitiateImpedance(uint32_t nInstance)
|
408
|
+
#cbSdkResult cbSdkSendPoll(uint32_t nInstance, const char* appname, uint32_t mode, uint32_t flags, uint32_t extra)
|
409
|
+
cbSdkResult cbSdkSendPoll(uint32_t nInstance, void * ppckt)
|
410
|
+
#cbSdkSendPacket
|
411
|
+
#cbSdkSetSystemRunLevel
|
412
|
+
cbSdkResult cbSdkSetDigitalOutput(uint32_t nInstance, uint16_t channel, uint16_t value)
|
413
|
+
cbSdkResult cbSdkSetSynchOutput(uint32_t nInstance, uint16_t channel, uint32_t nFreq, uint32_t nRepeats)
|
414
|
+
#cbSdkExtDoCommand
|
415
|
+
cbSdkResult cbSdkSetAnalogOutput(uint32_t nInstance, uint16_t channel, cbSdkWaveformData* wf, cbSdkAoutMon* mon)
|
416
|
+
cbSdkResult cbSdkSetChannelMask(uint32_t nInstance, uint16_t channel, uint32_t bActive)
|
417
|
+
cbSdkResult cbSdkSetComment(uint32_t nInstance, uint32_t rgba, uint8_t charset, const char * comment)
|
418
|
+
cbSdkResult cbSdkSetChannelConfig(uint32_t nInstance, uint16_t channel, cbPKT_CHANINFO * chaninfo)
|
419
|
+
cbSdkResult cbSdkGetChannelConfig(uint32_t nInstance, uint16_t channel, cbPKT_CHANINFO * chaninfo)
|
420
|
+
cbSdkResult cbSdkGetFilterDesc(uint32_t nInstance, uint32_t proc, uint32_t filt, cbFILTDESC * filtdesc)
|
421
|
+
cbSdkResult cbSdkGetSampleGroupList(uint32_t nInstance, uint32_t proc, uint32_t group, uint32_t *length, uint16_t *list)
|
422
|
+
cbSdkResult cbSdkGetSampleGroupInfo(uint32_t nInstance, uint32_t proc, uint32_t group, char *label, uint32_t *period, uint32_t *length)
|
423
|
+
cbSdkResult cbSdkSetSpikeConfig(uint32_t nInstance, uint32_t spklength, uint32_t spkpretrig)
|
424
|
+
cbSdkResult cbSdkGetSysConfig(uint32_t nInstance, uint32_t * spklength, uint32_t * spkpretrig, uint32_t * sysfreq)
|
425
|
+
|
426
|
+
|
427
|
+
cdef extern from "cbsdk_helper.h":
|
428
|
+
|
429
|
+
ctypedef struct cbSdkConfigParam:
|
430
|
+
uint32_t bActive
|
431
|
+
uint16_t Begchan
|
432
|
+
uint32_t Begmask
|
433
|
+
uint32_t Begval
|
434
|
+
uint16_t Endchan
|
435
|
+
uint32_t Endmask
|
436
|
+
uint32_t Endval
|
437
|
+
uint32_t uWaveforms
|
438
|
+
uint32_t uConts
|
439
|
+
uint32_t uEvents
|
440
|
+
uint32_t uComments
|
441
|
+
uint32_t uTrackings
|
442
|
+
|
443
|
+
cbSdkResult cbsdk_get_trial_config(int nInstance, cbSdkConfigParam * pcfg_param)
|
444
|
+
cbSdkResult cbsdk_set_trial_config(int nInstance, const cbSdkConfigParam * pcfg_param)
|
445
|
+
|
446
|
+
cbSdkResult cbsdk_init_trial_event(int nInstance, int clock_reset, cbSdkTrialEvent * trialevent)
|
447
|
+
cbSdkResult cbsdk_get_trial_event(int nInstance, int seek, cbSdkTrialEvent * trialevent)
|
448
|
+
|
449
|
+
cbSdkResult cbsdk_init_trial_cont(int nInstance, int clock_reset, cbSdkTrialCont * trialcont)
|
450
|
+
cbSdkResult cbsdk_get_trial_cont(int nInstance, int seek, cbSdkTrialCont * trialcont)
|
451
|
+
|
452
|
+
cbSdkResult cbsdk_init_trial_data(int nInstance, int clock_reset, cbSdkTrialEvent * trialevent, cbSdkTrialCont * trialcont, cbSdkTrialComment * trialcomm, unsigned long wait_for_comment_msec)
|
453
|
+
cbSdkResult cbsdk_get_trial_data(int nInstance, int seek, cbSdkTrialEvent * trialevent, cbSdkTrialCont * trialcont, cbSdkTrialComment * trialcomm)
|
454
|
+
|
455
|
+
cbSdkResult cbsdk_init_trial_comment(int nInstance, int clock_reset, cbSdkTrialComment * trialcomm, unsigned long wait_for_comment_msec)
|
456
|
+
cbSdkResult cbsdk_get_trial_comment(int nInstance, int seek, cbSdkTrialComment * trialcomm)
|
457
|
+
|
458
|
+
cbSdkResult cbsdk_file_config(int instance, const char * filename, const char * comment, int start, unsigned int options)
|
@@ -0,0 +1,112 @@
|
|
1
|
+
/*
|
2
|
+
* Implementation of helper API for easy Cython wrapping.
|
3
|
+
*
|
4
|
+
* @date March 9, 2014
|
5
|
+
* @author: dashesy
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include <string.h>
|
9
|
+
|
10
|
+
#include "cbsdk_helper.h"
|
11
|
+
|
12
|
+
cbSdkResult cbsdk_get_trial_config(const uint32_t nInstance, cbSdkConfigParam * pcfg_param)
|
13
|
+
{
|
14
|
+
const cbSdkResult sdk_result = cbSdkGetTrialConfig(nInstance, &pcfg_param->bActive,
|
15
|
+
&pcfg_param->Begchan, &pcfg_param->Begmask, &pcfg_param->Begval,
|
16
|
+
&pcfg_param->Endchan, &pcfg_param->Endmask, &pcfg_param->Endval,
|
17
|
+
&pcfg_param->uWaveforms,
|
18
|
+
&pcfg_param->uConts, &pcfg_param->uEvents, &pcfg_param->uComments,
|
19
|
+
&pcfg_param->uTrackings);
|
20
|
+
|
21
|
+
return sdk_result;
|
22
|
+
}
|
23
|
+
|
24
|
+
cbSdkResult cbsdk_set_trial_config(const uint32_t nInstance, const cbSdkConfigParam * pcfg_param)
|
25
|
+
{
|
26
|
+
const cbSdkResult sdk_result = cbSdkSetTrialConfig(nInstance, pcfg_param->bActive,
|
27
|
+
pcfg_param->Begchan,pcfg_param->Begmask, pcfg_param->Begval,
|
28
|
+
pcfg_param->Endchan, pcfg_param->Endmask, pcfg_param->Endval,
|
29
|
+
pcfg_param->uWaveforms,
|
30
|
+
pcfg_param->uConts, pcfg_param->uEvents, pcfg_param->uComments,
|
31
|
+
pcfg_param->uTrackings);
|
32
|
+
|
33
|
+
return sdk_result;
|
34
|
+
}
|
35
|
+
|
36
|
+
|
37
|
+
cbSdkResult cbsdk_init_trial_event(const uint32_t nInstance, const int clock_reset, cbSdkTrialEvent * trialevent)
|
38
|
+
{
|
39
|
+
memset(trialevent, 0, sizeof(*trialevent));
|
40
|
+
const cbSdkResult sdk_result = cbSdkInitTrialData(nInstance, clock_reset, trialevent, nullptr, nullptr, nullptr);
|
41
|
+
|
42
|
+
return sdk_result;
|
43
|
+
}
|
44
|
+
|
45
|
+
cbSdkResult cbsdk_get_trial_event(const uint32_t nInstance, const int seek, cbSdkTrialEvent * trialevent)
|
46
|
+
{
|
47
|
+
const cbSdkResult sdk_result = cbSdkGetTrialData(nInstance, seek, trialevent, nullptr, nullptr, nullptr);
|
48
|
+
|
49
|
+
return sdk_result;
|
50
|
+
}
|
51
|
+
|
52
|
+
cbSdkResult cbsdk_init_trial_cont(const uint32_t nInstance, const int clock_reset, cbSdkTrialCont * trialcont)
|
53
|
+
{
|
54
|
+
memset(trialcont, 0, sizeof(*trialcont));
|
55
|
+
const cbSdkResult sdk_result = cbSdkInitTrialData(nInstance, clock_reset, nullptr, trialcont, nullptr, nullptr);
|
56
|
+
|
57
|
+
return sdk_result;
|
58
|
+
}
|
59
|
+
|
60
|
+
cbSdkResult cbsdk_get_trial_cont(const uint32_t nInstance, const int seek, cbSdkTrialCont * trialcont)
|
61
|
+
{
|
62
|
+
const cbSdkResult sdk_result = cbSdkGetTrialData(nInstance, seek, nullptr, trialcont, nullptr, nullptr);
|
63
|
+
|
64
|
+
return sdk_result;
|
65
|
+
}
|
66
|
+
|
67
|
+
cbSdkResult cbsdk_init_trial_data(const uint32_t nInstance, const int clock_reset, cbSdkTrialEvent * trialevent, cbSdkTrialCont * trialcont, cbSdkTrialComment * trialcomm, unsigned long wait_for_comment_msec)
|
68
|
+
{
|
69
|
+
if(trialevent)
|
70
|
+
{
|
71
|
+
memset(trialevent, 0, sizeof(*trialevent));
|
72
|
+
}
|
73
|
+
if (trialcont)
|
74
|
+
{
|
75
|
+
memset(trialcont, 0, sizeof(*trialcont));
|
76
|
+
}
|
77
|
+
if (trialcomm)
|
78
|
+
{
|
79
|
+
memset(trialcomm, 0, sizeof(*trialcomm));
|
80
|
+
}
|
81
|
+
const cbSdkResult sdk_result = cbSdkInitTrialData(nInstance, clock_reset, trialevent, trialcont, trialcomm, nullptr, wait_for_comment_msec);
|
82
|
+
|
83
|
+
return sdk_result;
|
84
|
+
}
|
85
|
+
|
86
|
+
cbSdkResult cbsdk_get_trial_data(const uint32_t nInstance, const int seek, cbSdkTrialEvent * trialevent, cbSdkTrialCont * trialcont, cbSdkTrialComment * trialcomm)
|
87
|
+
{
|
88
|
+
const cbSdkResult sdk_result = cbSdkGetTrialData(nInstance, seek, trialevent, trialcont, trialcomm, nullptr);
|
89
|
+
|
90
|
+
return sdk_result;
|
91
|
+
}
|
92
|
+
|
93
|
+
cbSdkResult cbsdk_init_trial_comment(const uint32_t nInstance, const int clock_reset, cbSdkTrialComment * trialcomm, const unsigned long wait_for_comment_msec)
|
94
|
+
{
|
95
|
+
memset(trialcomm, 0, sizeof(*trialcomm));
|
96
|
+
const cbSdkResult sdk_result = cbSdkInitTrialData(nInstance, clock_reset, nullptr, nullptr, trialcomm, nullptr, wait_for_comment_msec);
|
97
|
+
|
98
|
+
return sdk_result;
|
99
|
+
}
|
100
|
+
|
101
|
+
cbSdkResult cbsdk_get_trial_comment(const uint32_t nInstance, const int seek, cbSdkTrialComment * trialcomm)
|
102
|
+
{
|
103
|
+
const cbSdkResult sdk_result = cbSdkGetTrialData(nInstance, seek, nullptr, nullptr, trialcomm, nullptr);
|
104
|
+
|
105
|
+
return sdk_result;
|
106
|
+
}
|
107
|
+
|
108
|
+
cbSdkResult cbsdk_file_config(const uint32_t instance, const char * filename, const char * comment, const int start, const unsigned int options)
|
109
|
+
{
|
110
|
+
const cbSdkResult sdk_result = cbSdkSetFileConfig(instance, filename == nullptr ? "" : filename, comment == nullptr ? "" : comment, start, options);
|
111
|
+
return sdk_result;
|
112
|
+
}
|
cerelink/cbsdk_helper.h
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
/*
|
2
|
+
* API to add to cbsdk. This wraps some main API functions in simpler (C-only)
|
3
|
+
* code. This in turn can be more easily wrapped (e.g. Cython)
|
4
|
+
*
|
5
|
+
*
|
6
|
+
* @date March 9, 2014
|
7
|
+
* @author: dashesy
|
8
|
+
*/
|
9
|
+
|
10
|
+
#ifndef CBHELPER_H
|
11
|
+
#define CBHELPER_H
|
12
|
+
|
13
|
+
#include <cerelink/cbsdk.h>
|
14
|
+
|
15
|
+
/* The following are already defined in cbsdk.h
|
16
|
+
// #define cbSdk_CONTINUOUS_DATA_SAMPLES 102400 // multiple of 4096
|
17
|
+
/// The default number of events that will be stored per channel in the trial buffer
|
18
|
+
// #define cbSdk_EVENT_DATA_SAMPLES (2 * 8192) // multiple of 4096
|
19
|
+
*/
|
20
|
+
|
21
|
+
typedef struct _cbSdkConfigParam {
|
22
|
+
uint32_t bActive;
|
23
|
+
uint16_t Begchan;
|
24
|
+
uint32_t Begmask;
|
25
|
+
uint32_t Begval;
|
26
|
+
uint16_t Endchan;
|
27
|
+
uint32_t Endmask;
|
28
|
+
uint32_t Endval;
|
29
|
+
bool bDouble;
|
30
|
+
uint32_t uWaveforms;
|
31
|
+
uint32_t uConts;
|
32
|
+
uint32_t uEvents;
|
33
|
+
uint32_t uComments;
|
34
|
+
uint32_t uTrackings;
|
35
|
+
} cbSdkConfigParam;
|
36
|
+
|
37
|
+
cbSdkResult cbsdk_get_trial_config(uint32_t nInstance, cbSdkConfigParam * pcfg_param);
|
38
|
+
cbSdkResult cbsdk_set_trial_config(uint32_t nInstance, const cbSdkConfigParam * pcfg_param);
|
39
|
+
|
40
|
+
cbSdkResult cbsdk_init_trial_event(uint32_t nInstance, int clock_reset, cbSdkTrialEvent * trialevent);
|
41
|
+
cbSdkResult cbsdk_get_trial_event(uint32_t nInstance, int seek, cbSdkTrialEvent * trialevent);
|
42
|
+
|
43
|
+
cbSdkResult cbsdk_init_trial_data(uint32_t nInstance, int clock_reset, cbSdkTrialEvent * trialevent, cbSdkTrialCont * trialcont, cbSdkTrialComment * trialcomm, unsigned long wait_for_comment_msec = 250);
|
44
|
+
cbSdkResult cbsdk_get_trial_data(uint32_t nInstance, int seek, cbSdkTrialEvent * trialevent, cbSdkTrialCont * trialcont, cbSdkTrialComment * trialcomm);
|
45
|
+
|
46
|
+
cbSdkResult cbsdk_init_trial_cont(uint32_t nInstance, int clock_reset, cbSdkTrialCont * trialcont);
|
47
|
+
cbSdkResult cbsdk_get_trial_cont(uint32_t nInstance, int seek, cbSdkTrialCont * trialcont);
|
48
|
+
|
49
|
+
cbSdkResult cbsdk_init_trial_comment(uint32_t nInstance, int clock_reset, cbSdkTrialComment * trialcomm, unsigned long wait_for_comment_msec = 250);
|
50
|
+
cbSdkResult cbsdk_get_trial_comment(uint32_t nInstance, int seek, cbSdkTrialComment * trialcomm);
|
51
|
+
|
52
|
+
cbSdkResult cbsdk_file_config(uint32_t instance, const char * filename, const char * comment, int start, unsigned int options);
|
53
|
+
|
54
|
+
#endif // CBHELPER_H
|