neurocode


Nameneurocode JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/neurocode-ai/neurocode
Summary🧠 EEG/MEG self-supervised learning toolbox.
upload_time2023-11-19 15:49:06
maintainer
docs_urlNone
authorWilhelm Ã…gren
requires_python>=3.9,<3.13
licenseMIT
keywords deep-learning meg eeg self-supervised-learning simclr
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
<br/>
<div align="left">
<br/>
<p align="center">
<a href="https://github.com/neurocode-ai/neurocode">
<img align="center" width=40% src="https://github.com/neurocode-ai/neurocode/blob/main/docs/images/neurocode_logo.webp"></img>
</a>
</p>
</div>
  
[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
[![Lint style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![PyPi version](https://img.shields.io/pypi/v/neurocode.svg)](https://pypi.org/project/neurocode/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![codecov](https://codecov.io/gh/neurocode-ai/neurocode/graph/badge.svg?token=IQD60CY83U)](https://codecov.io/gh/neurocode-ai/neurocode)
[![CI](https://github.com/neurocode-ai/neurocode/actions/workflows/ci.yml/badge.svg)](https://github.com/neurocode-ai/neurocode/actions/workflows/ci.yml)
[![Tests](https://github.com/neurocode-ai/neurocode/actions/workflows/tests.yml/badge.svg)](https://github.com/neurocode-ai/neurocode/actions/workflows/tests.yml)

</div>

## 🔎 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.

```python
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](https://github.com/neurocode-ai/neurocode/blob/main/LICENSE) for specific information.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/neurocode-ai/neurocode",
    "name": "neurocode",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<3.13",
    "maintainer_email": "",
    "keywords": "deep-learning,meg,eeg,self-supervised-learning,simclr",
    "author": "Wilhelm \u00c5gren",
    "author_email": "wilhelmagren98@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/25/0a/58c4e297150550bd1f59a901a83a4296f761b7180294ec5795b77786cd63/neurocode-1.0.0.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n<br/>\n<div align=\"left\">\n<br/>\n<p align=\"center\">\n<a href=\"https://github.com/neurocode-ai/neurocode\">\n<img align=\"center\" width=40% src=\"https://github.com/neurocode-ai/neurocode/blob/main/docs/images/neurocode_logo.webp\"></img>\n</a>\n</p>\n</div>\n  \n[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)\n[![Lint style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![PyPi version](https://img.shields.io/pypi/v/neurocode.svg)](https://pypi.org/project/neurocode/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![codecov](https://codecov.io/gh/neurocode-ai/neurocode/graph/badge.svg?token=IQD60CY83U)](https://codecov.io/gh/neurocode-ai/neurocode)\n[![CI](https://github.com/neurocode-ai/neurocode/actions/workflows/ci.yml/badge.svg)](https://github.com/neurocode-ai/neurocode/actions/workflows/ci.yml)\n[![Tests](https://github.com/neurocode-ai/neurocode/actions/workflows/tests.yml/badge.svg)](https://github.com/neurocode-ai/neurocode/actions/workflows/tests.yml)\n\n</div>\n\n## \ud83d\udd0e Overview\nA minimalistic Python library for EEG/MEG deep learning research, primarely focused on self-supervised learning. \n\n## \ud83d\udce6 Installation\nEither clone this repository and perform a local install accordingly\n```\ngit clone https://github.com/neurocode-ai/neurocode.git\ncd neurocode\npoetry install\n```\nor install the most recent release from the Python Package Index (PyPI).\n```\npip install neurocode\n```\n\n## \ud83d\ude80 Example usage\nBelow you can see an example adapted for a SSL training workflow using the SimCLR framework.\n\n```python\nimport torch\n\nfrom pytorch_metric_learning import losses\nfrom neurocode.datasets import SimulatedDataset, RecordingDataset\nfrom neurocode.samplers import SignalSampler\nfrom neurocode.models import SignalNet\nfrom neurocode.training import SimCLR\nfrom neurocode.datautil import manifold_plot, history_plot\n\nsample_data = SimulatedDataset(\"sample\", seed=7815891891337)\nsample_data.read_from_file(\"MEG/sample/sample_audvis_raw.fif\")\n\n# create random extrapolated data from the raw MEG recording,\n# you need to provide a location to a forward solution (source space) to use\nsample_data.simulate(\"MEG/sample/sample_audvis-meg-eeg-oct-6-fwd.fif\")\n\ndataset = RecordingDataset(sample_data.data(), sample_data.labels(), sfreq=200)\ntrain, valid = dataset.train_valid_split(split=0.75)\n\nsamplers = {\n  'train': SignalSampler(train.data(), train.labels(), train.info(), ...),\n  'valid': SignalSampler(valid.data(), valid.labels(), valid.info(), ...),\n}\n\ndevice = \"cuda\" if torch.cuda.is_available() else \"cpu\"\nmodel = SignalNet(...)\noptimizer = torch.optim.Adam(model.parameters(), ...)\nscheduler = torch.optim.lr_scheduler.CosineAnnealingLR(optimizer, ...)\ncriterion = losses.NTXentLoss()\n\n# train the neural network using the self-supervised learning SimCLR framework,\n# save or plot the history to see training loss evolution\nsimclr = SimCLR(model, device, ...)\nhistory = simclr.fit(samplers, save_model=True)\n\n```\n\n## \ud83d\udccb License\nAll code is to be held under a general MIT license, please see [LICENSE](https://github.com/neurocode-ai/neurocode/blob/main/LICENSE) for specific information.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "\ud83e\udde0 EEG/MEG self-supervised learning toolbox.",
    "version": "1.0.0",
    "project_urls": {
        "Bug tracker": "https://github.com/neurocode-ai/neurocode/issues",
        "Homepage": "https://github.com/neurocode-ai/neurocode",
        "Repository": "https://github.com/neurocode-ai/neurocode"
    },
    "split_keywords": [
        "deep-learning",
        "meg",
        "eeg",
        "self-supervised-learning",
        "simclr"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e5b4b03c81b8cc0a3244cfa3b4ddad976c28f1e184e42bc496a57b63ca54a6c6",
                "md5": "df9437d5efcf31754f4b17ac47ea0e57",
                "sha256": "66d256484e44d8ace1f652c1a83c8532ce48f94f2614a23f046b4d2bcd637aaa"
            },
            "downloads": -1,
            "filename": "neurocode-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "df9437d5efcf31754f4b17ac47ea0e57",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<3.13",
            "size": 53087,
            "upload_time": "2023-11-19T15:49:04",
            "upload_time_iso_8601": "2023-11-19T15:49:04.755474Z",
            "url": "https://files.pythonhosted.org/packages/e5/b4/b03c81b8cc0a3244cfa3b4ddad976c28f1e184e42bc496a57b63ca54a6c6/neurocode-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "250a58c4e297150550bd1f59a901a83a4296f761b7180294ec5795b77786cd63",
                "md5": "24772f71bedbc4d014f0589400c4db72",
                "sha256": "e746837720a48169db9ffa3429f1c82108c60c988fa1e140fb9078e97d9b961b"
            },
            "downloads": -1,
            "filename": "neurocode-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "24772f71bedbc4d014f0589400c4db72",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<3.13",
            "size": 27711,
            "upload_time": "2023-11-19T15:49:06",
            "upload_time_iso_8601": "2023-11-19T15:49:06.679462Z",
            "url": "https://files.pythonhosted.org/packages/25/0a/58c4e297150550bd1f59a901a83a4296f761b7180294ec5795b77786cd63/neurocode-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-19 15:49:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "neurocode-ai",
    "github_project": "neurocode",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "neurocode"
}
        
Elapsed time: 0.22956s