pybopu 0.1.0__py3-none-any.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.
- pybopu/__init__.py +329 -0
- pybopu/backends/__init__.py +61 -0
- pybopu/backends/base.py +107 -0
- pybopu/backends/cloud/__init__.py +39 -0
- pybopu/backends/cloud/backend.py +313 -0
- pybopu/backends/cloud/client.py +462 -0
- pybopu/backends/cloud/cluster.py +580 -0
- pybopu/backends/cloud/corticallabs.py +418 -0
- pybopu/backends/cloud/dashboard.py +668 -0
- pybopu/backends/cloud/finalspark.py +346 -0
- pybopu/backends/cloud/server.py +461 -0
- pybopu/backends/cpu.py +446 -0
- pybopu/backends/fpga/__init__.py +27 -0
- pybopu/backends/fpga/driver.py +848 -0
- pybopu/backends/fpga/protocol.py +565 -0
- pybopu/backends/gpu.py +651 -0
- pybopu/backends/jit_kernels.py +271 -0
- pybopu/backends/maxwell/__init__.py +14 -0
- pybopu/backends/maxwell/backend.py +188 -0
- pybopu/backends/maxwell/maxone.py +338 -0
- pybopu/backends/maxwell/maxtwo.py +173 -0
- pybopu/backends/maxwell/replay.py +346 -0
- pybopu/config.py +76 -0
- pybopu/gym/__init__.py +36 -0
- pybopu/gym/active_inference.py +421 -0
- pybopu/gym/env.py +604 -0
- pybopu/gym/spaces.py +335 -0
- pybopu/interfaces/__init__.py +20 -0
- pybopu/interfaces/base.py +128 -0
- pybopu/interfaces/hybrid.py +369 -0
- pybopu/interfaces/mea.py +544 -0
- pybopu/interfaces/opto.py +435 -0
- pybopu/metrics/__init__.py +49 -0
- pybopu/metrics/criticality.py +394 -0
- pybopu/metrics/info_theory.py +561 -0
- pybopu/metrics/memory_capacity.py +228 -0
- pybopu/opu.py +137 -0
- pybopu/robotics/__init__.py +43 -0
- pybopu/robotics/decoders.py +454 -0
- pybopu/robotics/ros2_node.py +538 -0
- pybopu/signals/__init__.py +112 -0
- pybopu/signals/bursts.py +457 -0
- pybopu/signals/detection.py +15 -0
- pybopu/signals/detectors.py +397 -0
- pybopu/signals/filters.py +298 -0
- pybopu/signals/io.py +345 -0
- pybopu/signals/lfp.py +238 -0
- pybopu/signals/sorting.py +348 -0
- pybopu/signals/visual.py +309 -0
- pybopu/stimulation/__init__.py +41 -0
- pybopu/stimulation/encoders.py +699 -0
- pybopu/stimulation/pulses.py +331 -0
- pybopu/stimulation/sensory.py +354 -0
- pybopu/tissue/__init__.py +47 -0
- pybopu/tissue/assembloid.py +506 -0
- pybopu/tissue/glia/__init__.py +20 -0
- pybopu/tissue/glia/astrocytes.py +219 -0
- pybopu/tissue/glia/base.py +70 -0
- pybopu/tissue/glia/microglia.py +169 -0
- pybopu/tissue/glia/oligodendrocytes.py +224 -0
- pybopu/tissue/models/__init__.py +13 -0
- pybopu/tissue/models/adex.py +164 -0
- pybopu/tissue/models/base.py +94 -0
- pybopu/tissue/models/izhikevich.py +151 -0
- pybopu/tissue/models/lif.py +131 -0
- pybopu/tissue/network.py +297 -0
- pybopu/tissue/neurons/__init__.py +69 -0
- pybopu/tissue/neurons/base.py +153 -0
- pybopu/tissue/neurons/interneurons_pv.py +59 -0
- pybopu/tissue/neurons/interneurons_sst.py +59 -0
- pybopu/tissue/neurons/pyramidal.py +58 -0
- pybopu/tissue/profile.py +748 -0
- pybopu/tissue/synapses/__init__.py +38 -0
- pybopu/tissue/synapses/ampa_nmda.py +421 -0
- pybopu/tissue/synapses/base.py +361 -0
- pybopu/tissue/synapses/gaba.py +319 -0
- pybopu/tissue/synapses/r_stdp.py +237 -0
- pybopu/tissue/synapses/stdp.py +249 -0
- pybopu/tissue/synapses/stp.py +297 -0
- pybopu/types.py +208 -0
- pybopu-0.1.0.dist-info/METADATA +74 -0
- pybopu-0.1.0.dist-info/RECORD +85 -0
- pybopu-0.1.0.dist-info/WHEEL +5 -0
- pybopu-0.1.0.dist-info/licenses/LICENSE +190 -0
- pybopu-0.1.0.dist-info/top_level.txt +1 -0
pybopu/__init__.py
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
"""pybopu: Organoid Processing Unit for Python.
|
|
2
|
+
|
|
3
|
+
A modular, type-annotated biocomputing framework for simulating, programming,
|
|
4
|
+
and interfacing with 3D neural organoids, in vitro wetware, and digital twins.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from pybopu.config import Config, PhysicalUnits, UNITS, default_config
|
|
8
|
+
from pybopu.opu import BOPU, OPU
|
|
9
|
+
from pybopu.types import SpikeArray, StimulusPacket, VoltageTrace
|
|
10
|
+
from pybopu.backends.base import BaseBackend
|
|
11
|
+
from pybopu.backends.cpu import CPUBackend
|
|
12
|
+
from pybopu.backends.gpu import GPUBackend
|
|
13
|
+
from pybopu.backends.fpga import FPGABackend, FPGADriver, FPGAProtocol
|
|
14
|
+
from pybopu.backends.maxwell import (
|
|
15
|
+
MaxOneDriver,
|
|
16
|
+
MaxTwoDriver,
|
|
17
|
+
MaxWellReplayEngine,
|
|
18
|
+
MaxWellBackend,
|
|
19
|
+
)
|
|
20
|
+
from pybopu.backends.cloud import (
|
|
21
|
+
ClusterNodeInfo,
|
|
22
|
+
CorticalLabsAdapter,
|
|
23
|
+
FinalSparkAdapter,
|
|
24
|
+
IncubatorChamber,
|
|
25
|
+
LifeSupportTelemetry,
|
|
26
|
+
MotorReadout,
|
|
27
|
+
OaaSBackend,
|
|
28
|
+
OaaSClient,
|
|
29
|
+
OaaSServer,
|
|
30
|
+
OrganoidBank,
|
|
31
|
+
get_dashboard_html,
|
|
32
|
+
)
|
|
33
|
+
from pybopu.tissue.models import AdExModel, BaseNeuronModel, IzhikevichModel, LIFModel
|
|
34
|
+
from pybopu.tissue.neurons import BaseNeuron, PyramidalNeuron, PVInterneuron, SSTInterneuron
|
|
35
|
+
from pybopu.tissue.synapses import (
|
|
36
|
+
BaseSynapse,
|
|
37
|
+
AMPASynapse,
|
|
38
|
+
NMDASynapse,
|
|
39
|
+
DualExcitatorySynapse,
|
|
40
|
+
GABAASynapse,
|
|
41
|
+
GABABSynapse,
|
|
42
|
+
DualInhibitorySynapse,
|
|
43
|
+
BasePlasticity,
|
|
44
|
+
TsodyksMarkramSTP,
|
|
45
|
+
STDPPlasticity,
|
|
46
|
+
RewardModulatedSTDP,
|
|
47
|
+
)
|
|
48
|
+
from pybopu.tissue.glia import (
|
|
49
|
+
BaseGlia,
|
|
50
|
+
Astrocyte,
|
|
51
|
+
Oligodendrocyte,
|
|
52
|
+
Microglia,
|
|
53
|
+
)
|
|
54
|
+
from pybopu.tissue.network import NetworkGraph
|
|
55
|
+
from pybopu.tissue.profile import (
|
|
56
|
+
BaseGeometry,
|
|
57
|
+
SphereGeometry,
|
|
58
|
+
EllipsoidGeometry,
|
|
59
|
+
CylinderGeometry,
|
|
60
|
+
BaseDistanceKernel,
|
|
61
|
+
ExponentialDistanceKernel,
|
|
62
|
+
GaussianDistanceKernel,
|
|
63
|
+
ConnectionRule,
|
|
64
|
+
PopulationSpec,
|
|
65
|
+
TissueProfile,
|
|
66
|
+
)
|
|
67
|
+
from pybopu.tissue.assembloid import (
|
|
68
|
+
AxonTunnel,
|
|
69
|
+
AssembloidRegion,
|
|
70
|
+
Assembloid,
|
|
71
|
+
)
|
|
72
|
+
from pybopu.interfaces import (
|
|
73
|
+
BaseInterface,
|
|
74
|
+
MEAInterface,
|
|
75
|
+
OpsinKinetics,
|
|
76
|
+
OptoInterface,
|
|
77
|
+
HybridInterface,
|
|
78
|
+
)
|
|
79
|
+
from pybopu.stimulation import (
|
|
80
|
+
SHANNON_SAFETY_LIMIT_K,
|
|
81
|
+
BiphasicPulse,
|
|
82
|
+
check_shannon_criterion,
|
|
83
|
+
create_biphasic_pulse,
|
|
84
|
+
create_biphasic_train,
|
|
85
|
+
BaseEncoder,
|
|
86
|
+
RateEncoder,
|
|
87
|
+
TTFSEncoder,
|
|
88
|
+
PopulationVectorEncoder,
|
|
89
|
+
DeltaEncoder,
|
|
90
|
+
AudioTransducer,
|
|
91
|
+
VisualTransducer,
|
|
92
|
+
)
|
|
93
|
+
from pybopu.signals import (
|
|
94
|
+
ButterworthBandpass,
|
|
95
|
+
NotchFilter,
|
|
96
|
+
filter_trace,
|
|
97
|
+
extract_lfp,
|
|
98
|
+
compute_psd,
|
|
99
|
+
compute_band_powers,
|
|
100
|
+
SpectralBands,
|
|
101
|
+
SpikeDetector,
|
|
102
|
+
SignalProcessor,
|
|
103
|
+
estimate_quiroga_noise_std,
|
|
104
|
+
BaseSpikeSorter,
|
|
105
|
+
PCASpikeSorter,
|
|
106
|
+
SpikeSortResult,
|
|
107
|
+
compute_cluster_snr,
|
|
108
|
+
compute_refractory_violations,
|
|
109
|
+
compute_isolation_distance,
|
|
110
|
+
BurstEvent,
|
|
111
|
+
NetworkBurstEvent,
|
|
112
|
+
BurstDetector,
|
|
113
|
+
NetworkSynchronyDetector,
|
|
114
|
+
compute_fano_factor,
|
|
115
|
+
compute_synchrony_index,
|
|
116
|
+
plot_raster,
|
|
117
|
+
plot_sorted_waveforms,
|
|
118
|
+
plot_pca_features,
|
|
119
|
+
plot_network_burst_profile,
|
|
120
|
+
BaseElectrophysiologyStorage,
|
|
121
|
+
NWBStorage,
|
|
122
|
+
HDF5Storage,
|
|
123
|
+
save_to_nwb,
|
|
124
|
+
load_from_nwb,
|
|
125
|
+
)
|
|
126
|
+
from pybopu.metrics import (
|
|
127
|
+
AvalancheEvent,
|
|
128
|
+
CriticalityEvaluator,
|
|
129
|
+
InfoTheory,
|
|
130
|
+
JaegerMemoryEvaluator,
|
|
131
|
+
active_information_storage,
|
|
132
|
+
bin_spike_train,
|
|
133
|
+
compute_avalanche_distributions,
|
|
134
|
+
compute_branching_ratio,
|
|
135
|
+
compute_memory_capacity,
|
|
136
|
+
compute_nonlinear_memory_capacity,
|
|
137
|
+
compute_transfer_entropy_matrix,
|
|
138
|
+
conditional_entropy,
|
|
139
|
+
detect_avalanches,
|
|
140
|
+
discretize_multi_channel,
|
|
141
|
+
fit_power_law,
|
|
142
|
+
joint_entropy,
|
|
143
|
+
mutual_information,
|
|
144
|
+
shannon_entropy,
|
|
145
|
+
transfer_entropy,
|
|
146
|
+
)
|
|
147
|
+
from pybopu.gym import (
|
|
148
|
+
ActiveInferenceController,
|
|
149
|
+
DishBrainPongEnv,
|
|
150
|
+
ElectrophysiologyObservationSpace,
|
|
151
|
+
FreeEnergyMetrics,
|
|
152
|
+
OPUEnv,
|
|
153
|
+
SensoryMotorPartition,
|
|
154
|
+
StimulusActionSpace,
|
|
155
|
+
VariationalFreeEnergyEstimator,
|
|
156
|
+
)
|
|
157
|
+
from pybopu.robotics import (
|
|
158
|
+
BaseMotorDecoder,
|
|
159
|
+
DifferentialDriveDecoder,
|
|
160
|
+
GeorgopoulosPopulationDecoder,
|
|
161
|
+
HybrotArenaSimulator,
|
|
162
|
+
LaserScanPacket,
|
|
163
|
+
LeakyIntegratorTorqueDecoder,
|
|
164
|
+
LidarSensoryTransducer,
|
|
165
|
+
OPURos2ControllerNode,
|
|
166
|
+
OdometryState,
|
|
167
|
+
VelocityCommand,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
__version__ = "0.1.0"
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
__all__ = [
|
|
174
|
+
"__version__",
|
|
175
|
+
"OPU",
|
|
176
|
+
"BOPU",
|
|
177
|
+
"Config",
|
|
178
|
+
"PhysicalUnits",
|
|
179
|
+
"UNITS",
|
|
180
|
+
"default_config",
|
|
181
|
+
"SpikeArray",
|
|
182
|
+
"VoltageTrace",
|
|
183
|
+
"StimulusPacket",
|
|
184
|
+
"BaseBackend",
|
|
185
|
+
"CPUBackend",
|
|
186
|
+
"GPUBackend",
|
|
187
|
+
"FPGABackend",
|
|
188
|
+
"FPGADriver",
|
|
189
|
+
"FPGAProtocol",
|
|
190
|
+
"MaxOneDriver",
|
|
191
|
+
"MaxTwoDriver",
|
|
192
|
+
"MaxWellReplayEngine",
|
|
193
|
+
"MaxWellBackend",
|
|
194
|
+
"OaaSBackend",
|
|
195
|
+
"OaaSServer",
|
|
196
|
+
"ClusterNodeInfo",
|
|
197
|
+
"IncubatorChamber",
|
|
198
|
+
"OrganoidBank",
|
|
199
|
+
"get_dashboard_html",
|
|
200
|
+
"OaaSClient",
|
|
201
|
+
"FinalSparkAdapter",
|
|
202
|
+
"CorticalLabsAdapter",
|
|
203
|
+
"LifeSupportTelemetry",
|
|
204
|
+
"MotorReadout",
|
|
205
|
+
"BaseNeuronModel",
|
|
206
|
+
"LIFModel",
|
|
207
|
+
"AdExModel",
|
|
208
|
+
"IzhikevichModel",
|
|
209
|
+
"BaseNeuron",
|
|
210
|
+
"PyramidalNeuron",
|
|
211
|
+
"PVInterneuron",
|
|
212
|
+
"SSTInterneuron",
|
|
213
|
+
"BaseSynapse",
|
|
214
|
+
"AMPASynapse",
|
|
215
|
+
"NMDASynapse",
|
|
216
|
+
"DualExcitatorySynapse",
|
|
217
|
+
"GABAASynapse",
|
|
218
|
+
"GABABSynapse",
|
|
219
|
+
"DualInhibitorySynapse",
|
|
220
|
+
"BasePlasticity",
|
|
221
|
+
"TsodyksMarkramSTP",
|
|
222
|
+
"STDPPlasticity",
|
|
223
|
+
"RewardModulatedSTDP",
|
|
224
|
+
"BaseGlia",
|
|
225
|
+
"Astrocyte",
|
|
226
|
+
"Oligodendrocyte",
|
|
227
|
+
"Microglia",
|
|
228
|
+
"NetworkGraph",
|
|
229
|
+
"BaseGeometry",
|
|
230
|
+
"SphereGeometry",
|
|
231
|
+
"EllipsoidGeometry",
|
|
232
|
+
"CylinderGeometry",
|
|
233
|
+
"BaseDistanceKernel",
|
|
234
|
+
"ExponentialDistanceKernel",
|
|
235
|
+
"GaussianDistanceKernel",
|
|
236
|
+
"ConnectionRule",
|
|
237
|
+
"PopulationSpec",
|
|
238
|
+
"TissueProfile",
|
|
239
|
+
"AxonTunnel",
|
|
240
|
+
"AssembloidRegion",
|
|
241
|
+
"Assembloid",
|
|
242
|
+
"BaseInterface",
|
|
243
|
+
"MEAInterface",
|
|
244
|
+
"OpsinKinetics",
|
|
245
|
+
"OptoInterface",
|
|
246
|
+
"HybridInterface",
|
|
247
|
+
"SHANNON_SAFETY_LIMIT_K",
|
|
248
|
+
"BiphasicPulse",
|
|
249
|
+
"check_shannon_criterion",
|
|
250
|
+
"create_biphasic_pulse",
|
|
251
|
+
"create_biphasic_train",
|
|
252
|
+
"BaseEncoder",
|
|
253
|
+
"RateEncoder",
|
|
254
|
+
"TTFSEncoder",
|
|
255
|
+
"PopulationVectorEncoder",
|
|
256
|
+
"DeltaEncoder",
|
|
257
|
+
"AudioTransducer",
|
|
258
|
+
"VisualTransducer",
|
|
259
|
+
"ButterworthBandpass",
|
|
260
|
+
"NotchFilter",
|
|
261
|
+
"filter_trace",
|
|
262
|
+
"extract_lfp",
|
|
263
|
+
"compute_psd",
|
|
264
|
+
"compute_band_powers",
|
|
265
|
+
"SpectralBands",
|
|
266
|
+
"SpikeDetector",
|
|
267
|
+
"SignalProcessor",
|
|
268
|
+
"estimate_quiroga_noise_std",
|
|
269
|
+
"BaseSpikeSorter",
|
|
270
|
+
"PCASpikeSorter",
|
|
271
|
+
"SpikeSortResult",
|
|
272
|
+
"compute_cluster_snr",
|
|
273
|
+
"compute_refractory_violations",
|
|
274
|
+
"compute_isolation_distance",
|
|
275
|
+
"BurstEvent",
|
|
276
|
+
"NetworkBurstEvent",
|
|
277
|
+
"BurstDetector",
|
|
278
|
+
"NetworkSynchronyDetector",
|
|
279
|
+
"compute_fano_factor",
|
|
280
|
+
"compute_synchrony_index",
|
|
281
|
+
"plot_raster",
|
|
282
|
+
"plot_sorted_waveforms",
|
|
283
|
+
"plot_pca_features",
|
|
284
|
+
"plot_network_burst_profile",
|
|
285
|
+
"BaseElectrophysiologyStorage",
|
|
286
|
+
"NWBStorage",
|
|
287
|
+
"HDF5Storage",
|
|
288
|
+
"save_to_nwb",
|
|
289
|
+
"load_from_nwb",
|
|
290
|
+
"InfoTheory",
|
|
291
|
+
"AvalancheEvent",
|
|
292
|
+
"CriticalityEvaluator",
|
|
293
|
+
"JaegerMemoryEvaluator",
|
|
294
|
+
"active_information_storage",
|
|
295
|
+
"bin_spike_train",
|
|
296
|
+
"compute_avalanche_distributions",
|
|
297
|
+
"compute_branching_ratio",
|
|
298
|
+
"compute_memory_capacity",
|
|
299
|
+
"compute_nonlinear_memory_capacity",
|
|
300
|
+
"compute_transfer_entropy_matrix",
|
|
301
|
+
"conditional_entropy",
|
|
302
|
+
"detect_avalanches",
|
|
303
|
+
"discretize_multi_channel",
|
|
304
|
+
"fit_power_law",
|
|
305
|
+
"joint_entropy",
|
|
306
|
+
"mutual_information",
|
|
307
|
+
"shannon_entropy",
|
|
308
|
+
"transfer_entropy",
|
|
309
|
+
"OPUEnv",
|
|
310
|
+
"DishBrainPongEnv",
|
|
311
|
+
"SensoryMotorPartition",
|
|
312
|
+
"StimulusActionSpace",
|
|
313
|
+
"ElectrophysiologyObservationSpace",
|
|
314
|
+
"ActiveInferenceController",
|
|
315
|
+
"VariationalFreeEnergyEstimator",
|
|
316
|
+
"FreeEnergyMetrics",
|
|
317
|
+
"VelocityCommand",
|
|
318
|
+
"BaseMotorDecoder",
|
|
319
|
+
"DifferentialDriveDecoder",
|
|
320
|
+
"GeorgopoulosPopulationDecoder",
|
|
321
|
+
"LeakyIntegratorTorqueDecoder",
|
|
322
|
+
"LaserScanPacket",
|
|
323
|
+
"OdometryState",
|
|
324
|
+
"LidarSensoryTransducer",
|
|
325
|
+
"OPURos2ControllerNode",
|
|
326
|
+
"HybrotArenaSimulator",
|
|
327
|
+
]
|
|
328
|
+
|
|
329
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Execution backends: CPU digital twin, GPU batches, FPGA, MaxWell HD-MEA, and Cloud OaaS."""
|
|
2
|
+
|
|
3
|
+
from pybopu.backends.base import BaseBackend
|
|
4
|
+
from pybopu.backends.cpu import CPUBackend
|
|
5
|
+
from pybopu.backends.gpu import GPUBackend, HAS_TORCH
|
|
6
|
+
from pybopu.backends.fpga import FPGABackend, FPGADriver, FPGAProtocol
|
|
7
|
+
from pybopu.backends.maxwell import (
|
|
8
|
+
MaxOneDriver,
|
|
9
|
+
MaxTwoDriver,
|
|
10
|
+
MaxWellReplayEngine,
|
|
11
|
+
MaxWellBackend,
|
|
12
|
+
)
|
|
13
|
+
from pybopu.backends.cloud import (
|
|
14
|
+
ClusterNodeInfo,
|
|
15
|
+
CorticalLabsAdapter,
|
|
16
|
+
FinalSparkAdapter,
|
|
17
|
+
IncubatorChamber,
|
|
18
|
+
LifeSupportTelemetry,
|
|
19
|
+
MotorReadout,
|
|
20
|
+
OaaSAuthenticationError,
|
|
21
|
+
OaaSBackend,
|
|
22
|
+
OaaSClient,
|
|
23
|
+
OaaSConnectionError,
|
|
24
|
+
OaaSServer,
|
|
25
|
+
OaaSTimeoutError,
|
|
26
|
+
OrganoidBank,
|
|
27
|
+
SessionInfo,
|
|
28
|
+
get_dashboard_html,
|
|
29
|
+
)
|
|
30
|
+
from pybopu.backends.jit_kernels import HAS_NUMBA
|
|
31
|
+
|
|
32
|
+
__all__ = [
|
|
33
|
+
"BaseBackend",
|
|
34
|
+
"CPUBackend",
|
|
35
|
+
"GPUBackend",
|
|
36
|
+
"FPGABackend",
|
|
37
|
+
"FPGADriver",
|
|
38
|
+
"FPGAProtocol",
|
|
39
|
+
"MaxOneDriver",
|
|
40
|
+
"MaxTwoDriver",
|
|
41
|
+
"MaxWellReplayEngine",
|
|
42
|
+
"MaxWellBackend",
|
|
43
|
+
"OaaSBackend",
|
|
44
|
+
"OaaSServer",
|
|
45
|
+
"ClusterNodeInfo",
|
|
46
|
+
"IncubatorChamber",
|
|
47
|
+
"OrganoidBank",
|
|
48
|
+
"get_dashboard_html",
|
|
49
|
+
"OaaSClient",
|
|
50
|
+
"FinalSparkAdapter",
|
|
51
|
+
"CorticalLabsAdapter",
|
|
52
|
+
"LifeSupportTelemetry",
|
|
53
|
+
"MotorReadout",
|
|
54
|
+
"SessionInfo",
|
|
55
|
+
"OaaSConnectionError",
|
|
56
|
+
"OaaSAuthenticationError",
|
|
57
|
+
"OaaSTimeoutError",
|
|
58
|
+
"HAS_NUMBA",
|
|
59
|
+
"HAS_TORCH",
|
|
60
|
+
]
|
|
61
|
+
|
pybopu/backends/base.py
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"""Abstract base execution backend for pybopu.
|
|
2
|
+
|
|
3
|
+
This module formalizes the contract for all computational and physical execution
|
|
4
|
+
engines in the pybopu ecosystem (CPU, GPU, FPGA, MaxWell HD-MEA, and Cloud OaaS).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from abc import ABC, abstractmethod
|
|
8
|
+
from typing import Any, Dict, Optional, Tuple
|
|
9
|
+
|
|
10
|
+
from pybopu.types import SpikeArray, StimulusPacket, VoltageTrace
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class BaseBackend(ABC):
|
|
14
|
+
"""Abstract base class establishing the execution engine contract.
|
|
15
|
+
|
|
16
|
+
All backends must adhere to this uniform interface to allow seamless
|
|
17
|
+
interchangeability across CPU digital twins, GPU batches, FPGA hardware-in-the-loop,
|
|
18
|
+
and physical living wetware.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
name : str, default="BaseBackend"
|
|
23
|
+
Human-readable descriptor of the backend engine.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(self, name: str = "BaseBackend") -> None:
|
|
27
|
+
self._name: str = name
|
|
28
|
+
self._current_time_ms: float = 0.0
|
|
29
|
+
self._is_initialized: bool = False
|
|
30
|
+
self._step_count: int = 0
|
|
31
|
+
|
|
32
|
+
@property
|
|
33
|
+
def name(self) -> str:
|
|
34
|
+
"""Return the unique backend name."""
|
|
35
|
+
return self._name
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def current_time_ms(self) -> float:
|
|
39
|
+
"""Current biological simulation/recording clock in milliseconds."""
|
|
40
|
+
return self._current_time_ms
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def is_initialized(self) -> bool:
|
|
44
|
+
"""Return True if the backend has been initialized with tissue and interface."""
|
|
45
|
+
return self._is_initialized
|
|
46
|
+
|
|
47
|
+
@property
|
|
48
|
+
def step_count(self) -> int:
|
|
49
|
+
"""Total number of execution steps completed."""
|
|
50
|
+
return self._step_count
|
|
51
|
+
|
|
52
|
+
@abstractmethod
|
|
53
|
+
def initialize(self, tissue: Any = None, interface: Any = None) -> None:
|
|
54
|
+
"""Initialize backend state variables, memory buffers, or hardware links.
|
|
55
|
+
|
|
56
|
+
Parameters
|
|
57
|
+
----------
|
|
58
|
+
tissue : Any, optional
|
|
59
|
+
Tissue specifications (e.g., TissueProfile, NetworkGraph).
|
|
60
|
+
interface : Any, optional
|
|
61
|
+
Hardware probe configuration (e.g., MEAInterface, OptoInterface).
|
|
62
|
+
"""
|
|
63
|
+
pass
|
|
64
|
+
|
|
65
|
+
@abstractmethod
|
|
66
|
+
def step(
|
|
67
|
+
self,
|
|
68
|
+
duration_ms: float,
|
|
69
|
+
stimulus: Optional[StimulusPacket] = None
|
|
70
|
+
) -> Tuple[SpikeArray, VoltageTrace]:
|
|
71
|
+
"""Execute a single simulation or acquisition step.
|
|
72
|
+
|
|
73
|
+
Parameters
|
|
74
|
+
----------
|
|
75
|
+
duration_ms : float
|
|
76
|
+
Duration of the step to advance in milliseconds. Must be positive.
|
|
77
|
+
stimulus : Optional[StimulusPacket], default=None
|
|
78
|
+
Optional sensory or actuation stimulus to deliver during this step.
|
|
79
|
+
|
|
80
|
+
Returns
|
|
81
|
+
-------
|
|
82
|
+
spikes : SpikeArray
|
|
83
|
+
Spike occurrences recorded or simulated during this step.
|
|
84
|
+
voltages : VoltageTrace
|
|
85
|
+
Continuous local field potentials or extracellular voltages.
|
|
86
|
+
"""
|
|
87
|
+
pass
|
|
88
|
+
|
|
89
|
+
@abstractmethod
|
|
90
|
+
def reset(self) -> None:
|
|
91
|
+
"""Reset internal simulation clocks, synaptic weights, and dynamic state variables."""
|
|
92
|
+
pass
|
|
93
|
+
|
|
94
|
+
def get_status(self) -> Dict[str, Any]:
|
|
95
|
+
"""Return an operational telemetry snapshot of the backend state.
|
|
96
|
+
|
|
97
|
+
Returns
|
|
98
|
+
-------
|
|
99
|
+
Dict[str, Any]
|
|
100
|
+
Dictionary containing backend name, clock, initialization status, and step count.
|
|
101
|
+
"""
|
|
102
|
+
return {
|
|
103
|
+
"name": self._name,
|
|
104
|
+
"current_time_ms": self._current_time_ms,
|
|
105
|
+
"is_initialized": self._is_initialized,
|
|
106
|
+
"step_count": self._step_count,
|
|
107
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Organoid as a Service (OaaS) cloud adapters and backends.
|
|
2
|
+
|
|
3
|
+
Provides remote network connectivity and simulation adapters for cloud-hosted
|
|
4
|
+
living neural organoids and in vitro wetware systems, including FinalSpark
|
|
5
|
+
Neuroplatform and Cortical Labs CL1.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from pybopu.backends.cloud.client import (
|
|
9
|
+
OaaSAuthenticationError,
|
|
10
|
+
OaaSClient,
|
|
11
|
+
OaaSConnectionError,
|
|
12
|
+
OaaSTimeoutError,
|
|
13
|
+
SessionInfo,
|
|
14
|
+
)
|
|
15
|
+
from pybopu.backends.cloud.finalspark import FinalSparkAdapter, LifeSupportTelemetry
|
|
16
|
+
from pybopu.backends.cloud.corticallabs import CorticalLabsAdapter, MotorReadout
|
|
17
|
+
from pybopu.backends.cloud.backend import OaaSBackend
|
|
18
|
+
from pybopu.backends.cloud.cluster import IncubatorChamber, OrganoidBank
|
|
19
|
+
from pybopu.backends.cloud.dashboard import get_dashboard_html
|
|
20
|
+
from pybopu.backends.cloud.server import ClusterNodeInfo, OaaSServer
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"OaaSClient",
|
|
24
|
+
"SessionInfo",
|
|
25
|
+
"OaaSConnectionError",
|
|
26
|
+
"OaaSAuthenticationError",
|
|
27
|
+
"OaaSTimeoutError",
|
|
28
|
+
"FinalSparkAdapter",
|
|
29
|
+
"LifeSupportTelemetry",
|
|
30
|
+
"CorticalLabsAdapter",
|
|
31
|
+
"MotorReadout",
|
|
32
|
+
"OaaSBackend",
|
|
33
|
+
"OaaSServer",
|
|
34
|
+
"ClusterNodeInfo",
|
|
35
|
+
"IncubatorChamber",
|
|
36
|
+
"OrganoidBank",
|
|
37
|
+
"get_dashboard_html",
|
|
38
|
+
]
|
|
39
|
+
|