EvoSpikeNet SDK Documentation
[!NOTE] 最新の実装状況は 機能実装ステータス (Remaining Functionality) を参照してください。
Overview
The EvoSpikeNet SDK provides a comprehensive Python interface for interacting with EvoSpikeNet's distributed brain simulation framework, including full EEG integration capabilities.
Installation
pip install evospikenet
Quick Start
from evospikenet.federated import EvoSpikeNetClient
from evospikenet.sdk import EvoSpikeNetAPIClient
# Federated client: distributed training / coordination
federated = EvoSpikeNetClient(base_url="http://localhost:8000")
# Management / EEG-related API client
api = EvoSpikeNetAPIClient(base_url="http://localhost:8000")
# Example: get system status
if hasattr(api, "get_status"):
status = api.get_status()
print(f"System status: {status}")
else:
print("API client: get_status() not available in this build.")
Core Features
1. Brain Simulation Management
- Create and manage distributed neural networks
- Configure spiking neuron models
- Monitor simulation performance
- Handle network topology and connectivity
2. EEG Integration
- Device discovery and connection
- Real-time EEG data streaming
- Brain Language translation
- Frequency spectrum analysis
- Experiment management
3. Data Processing
- Neural data conversion
- Brain Language processing
- Real-time analytics
- Data export and visualization
EEG Integration Guide
Device Connection
from evospikenet.sdk import EvoSpikeNetAPIClient
# Use the API client for EEG-related endpoints when available
api = EvoSpikeNetAPIClient(base_url="http://localhost:8000")
if hasattr(api, "get_eeg_devices"):
devices = api.get_eeg_devices()
print("Available EEG devices:", devices)
else:
print("EEG device discovery not available in this SDK build.")
# Example: guarded connect (may be implemented behind the API)
if hasattr(api, "connect_eeg_device"):
device_id = "Muse-1234"
result = api.connect_eeg_device(device_id, device_type="muse")
print(f"Connected to device: {result}")
Data Conversion and Translation
# Sample EEG data (replace with real data)
eeg_data = [0.5, -0.3, 0.8, 0.1, -0.6, 0.4, 0.9, -0.2]
# Convert EEG to Brain Language
brain_language = eeg_client.convert_eeg_to_brain_language(eeg_data, device_type="muse")
print("Brain Language representation:", brain_language)
# Translate to neural network inputs
neural_inputs = eeg_client.translate_brain_language(brain_language)
print("Neural network inputs:", neural_inputs)
Real-time Streaming
import asyncio
from evospikenet.sdk import EvoSpikeNetAPIClient
api = EvoSpikeNetAPIClient(base_url="http://localhost:8000")
async def stream_eeg():
# Guarded example: prefer API methods if provided
if hasattr(api, "stream_eeg"):
async for packet in api.stream_eeg(device_id="Muse-1234"):
print("Received EEG packet:", packet)
await asyncio.sleep(0)
else:
print("Streaming API not available; check sdk module for WebSocket utilities.")
asyncio.run(stream_eeg())
Experiment Management
# Configure experiment
experiment_config = {
"device_id": "Muse-1234",
"duration": 300, # 5 minutes
"sampling_rate": 256,
"channels": ["TP9", "AF7", "AF8", "TP10"],
"brain_language_enabled": True
}
# Start experiment
result = eeg_client.start_eeg_experiment(experiment_config)
experiment_id = result["experiment_id"]
print(f"Started experiment: {experiment_id}")
# Check status
status = eeg_client.get_experiment_status(experiment_id)
print(f"Experiment status: {status}")
# Stop experiment
eeg_client.stop_eeg_experiment(experiment_id)
print("Experiment stopped")
Frequency Spectrum Analysis
# Get frequency spectrum
spectrum = eeg_client.get_eeg_spectrum("Muse-1234")
print("EEG Frequency Spectrum:")
for band, power in spectrum.items():
print(f" {band}: {power}")
Advanced Usage
Custom Brain Language Processing
# Process raw Brain Language data
brain_data = {
"spike_patterns": [[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]],
"synaptic_weights": [0.8, 0.9, 0.7],
"temporal_encoding": "phase-locked"
}
translated = eeg_client.translate_brain_language(brain_data)
print("Translated neural inputs:", translated)
Error Handling
from evospikenet.sdk import EvoSpikeNetEEGClient
# Example: use EvoSpikeNetEEGClient as implemented in evospikenet.sdk
eeg_client = EvoSpikeNetEEGClient(base_url="http://localhost:8000")
try:
devices = eeg_client.get_eeg_devices()
print("Available EEG devices:", devices)
except Exception as e:
print("Failed to connect to EvoSpikeNet server:", e)
Authentication
# With API key authentication
eeg_client = EvoSpikeNetEEGClient(
base_url="https://your-evospikenet-server.com",
api_key="your-api-key-here"
)
# All subsequent requests will include authentication
devices = eeg_client.get_eeg_devices()
API Reference
EvoSpikeNetEEGClient
Methods
get_eeg_devices() -> Dict[str, Any]-
Returns list of available EEG devices
-
connect_eeg_device(device_id: str, device_type: str = "muse") -> Dict[str, Any] -
Connects to specified EEG device
-
disconnect_eeg_device(device_id: str) -> Dict[str, Any] -
Disconnects from EEG device
-
convert_eeg_to_brain_language(eeg_data: List[float], device_type: str = "muse") -> Dict[str, Any] -
Converts raw EEG data to Brain Language
-
translate_brain_language(brain_language_data: Dict[str, Any]) -> Dict[str, Any] -
Translates Brain Language to neural network inputs
-
get_eeg_spectrum(device_id: str) -> Dict[str, Any] -
Returns frequency spectrum analysis
-
start_eeg_experiment(config: Dict[str, Any]) -> Dict[str, Any] -
Starts EEG experiment with given configuration
-
stop_eeg_experiment(experiment_id: str) -> Dict[str, Any] -
Stops running EEG experiment
-
get_experiment_status(experiment_id: str) -> Dict[str, Any] - Returns current experiment status
EEGWebSocketStreamer
Methods
connect(device_id: str) -> None-
Connects to EEG streaming WebSocket
-
disconnect() -> None -
Disconnects from WebSocket
-
receive_eeg_data() -> Dict[str, Any] -
Receives next EEG data packet
-
send_command(command: Dict[str, Any]) -> None - Sends command to EEG stream
Troubleshooting
Common Issues
- Connection Failed
- Ensure EvoSpikeNet server is running
- Check network connectivity
-
Verify API endpoint URLs
-
Device Not Found
- Ensure EEG device is powered on and in pairing mode
- Check device compatibility (Muse, OpenBCI, etc.)
-
Verify device drivers are installed
-
Authentication Errors
- Ensure valid API key is provided
- Check token expiration
-
Verify user permissions
-
WebSocket Connection Issues
- Ensure WebSocket URL is correct (ws:// or wss://)
- Check firewall settings
- Verify server supports WebSocket connections
Debug Mode
Enable debug logging for detailed error information:
import logging
logging.basicConfig(level=logging.DEBUG)
# Your SDK code here
Examples
See the examples/ directory for complete working examples:
examples/eeg_basic_usage.py- Basic EEG device connectionexamples/eeg_streaming.py- Real-time EEG data streamingexamples/eeg_experiment.py- Complete experiment workflowexamples/brain_language_processing.py- Advanced Brain Language operationsexamples/spatial_generation_sdk_example.py- Spatial scene generation and quantum inference via SDK
Contributing
Contributions to the EvoSpikeNet SDK are welcome! Please see our contribution guidelines in the main repository.
License
This SDK is licensed under the same terms as EvoSpikeNet. See LICENSE file for details.