🔎 Overview
A minimalistic Python library for EEG/MEG deep learning research, primarely focused on self-supervised learning.
📦 Installation
Either clone this repository and perform a local install accordingly
git clone https://github.com/neurocode-ai/neurocode.git
cd neurocode
poetry install
or install the most recent release from the Python Package Index (PyPI).
pip install neurocode
🚀 Example usage
Below you can see an example adapted for a SSL training workflow using the SimCLR framework.
import torch
from pytorch_metric_learning import losses
from neurocode.datasets import SimulatedDataset, RecordingDataset
from neurocode.samplers import SignalSampler
from neurocode.models import SignalNet
from neurocode.training import SimCLR
from neurocode.datautil import manifold_plot, history_plot
sample_data = SimulatedDataset("sample", seed=7815891891337)
sample_data.read_from_file("MEG/sample/sample_audvis_raw.fif")
# create random extrapolated data from the raw MEG recording,
# you need to provide a location to a forward solution (source space) to use
sample_data.simulate("MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif")
dataset = RecordingDataset(sample_data.data(), sample_data.labels(), sfreq=200)
train, valid = dataset.train_valid_split(split=0.75)
samplers = {
'train': SignalSampler(train.data(), train.labels(), train.info(), ...),
'valid': SignalSampler(valid.data(), valid.labels(), valid.info(), ...),
}
device = "cuda" if torch.cuda.is_available() else "cpu"
model = SignalNet(...)
optimizer = torch.optim.Adam(model.parameters(), ...)
scheduler = torch.optim.lr_scheduler.CosineAnnealingLR(optimizer, ...)
criterion = losses.NTXentLoss()
# train the neural network using the self-supervised learning SimCLR framework,
# save or plot the history to see training loss evolution
simclr = SimCLR(model, device, ...)
history = simclr.fit(samplers, save_model=True)
📋 License
All code is to be held under a general MIT license, please see LICENSE for specific information.
Metadata
Release files for neurocode 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| neurocode-1.0.0.tar.gz | 27.7 kB | Without provenance | Details for neurocode-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| neurocode-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for neurocode-1.0.0-py3-none-any.whl |
Total release size: 80.8 kB
Release files / neurocode-1.0.0.tar.gz
| Download URL | neurocode-1.0.0.tar.gz |
|---|---|
| Size | 27.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e746837720a48169db9ffa3429f1c82108c60c988fa1e140fb9078e97d9b961b
|
|
BLAKE2b-256 checksum How to use checksums |
250a58c4e297150550bd1f59a901a83a4296f761b7180294ec5795b77786cd63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.0 Linux/6.2.0-1016-azure
|
Release files / neurocode-1.0.0-py3-none-any.whl
| Download URL | neurocode-1.0.0-py3-none-any.whl |
|---|---|
| Size | 53.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66d256484e44d8ace1f652c1a83c8532ce48f94f2614a23f046b4d2bcd637aaa
|
|
BLAKE2b-256 checksum How to use checksums |
e5b4b03c81b8cc0a3244cfa3b4ddad976c28f1e184e42bc496a57b63ca54a6c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.0 Linux/6.2.0-1016-azure
|
Security for neurocode 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.