This repository serves as a working space for the RealTune project of the ReTune Hackathon 2023.
The aim is to create a common ReTune-wide interface for real-time decoding of neural signals.
Previous work has been done in the following repositories:
- py_neuromodulation, which is already being used to calculate features from neural signals by multiple people of the ReTune community.
- py_neuromodulation also provides some ideas on how to implement decoding and a real-time stream.
Some of the specific aims of this project are to:
- Define common use cases
- Create a flexible interface that can be used across species, tasks, and recording modalities (iEEG, spiking data etc.)
- Integrate easily with py_neuromodulation
- Be lightweight (minimal dependencies), fast and easy to use
An example on how the API could look like:
pip install realtune
import time
import numpy as np
import py_neuromodulation as pn
import realtune
import sklearn
sfreq = 1000
model = sklearn.linear_model.LogisticRegression()
processor = pn.DataProcessor(
sfreq=sfreq,
settings=settings,
nm_channels=nm_channels,
)
decoder = realtune.Decoder(model=model)
for i in range(12):
timestamp = time.time()
features = processor.process(data=np.random.rand(sfreq, 1))
label = 0 if i < 5 else 1
group = i % 2
decoder.add_features(
features=features,
timestamp=timestamp,
label=label,
group=group,
)
decoder.cross_validate()
decoder.fit_model()
features = processor.process(data=np.random.rand(sfreq, 1))
prediction = decoder.predict(features=features)