Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
weiglszonja committed Nov 14, 2024
1 parent 0d27f87 commit 0408fad
Show file tree
Hide file tree
Showing 18 changed files with 758 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .github/workflows/add-to-dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Add Issue or Pull Request to Dashboard

on:
issues:
types:
- opened
pull_request:
types:
- opened

jobs:
add-to-project:
name: Add issue or pull request to project
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
project-url: https://github.com/orgs/catalystneuro/projects/3
github-token: ${{ secrets.PROJECT_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/auto-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# For the template repo, we simply won't specify a PYPI token. We also won't do any actual releases.
# For your actual conversion project using this template, add the PYPI_API_TOKEN to your secrets.

name: Upload Package to PyPI

on:
release:
types: [published]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: pypi-publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

name: Installation
on:
workflow_dispatch:
schedule:
- cron: "0 0 1 * *" # First day of the month

jobs:
run:
name: Installation on (${{ matrix.os }} with Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v3
- run: git fetch --prune --unshallow --tags
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install pip
run: |
python -m pip install --upgrade pip
pip3 install packaging
- name: Install package
run: pip install -e .
- name: Test module load
run: python -c "import kind_lab_to_nwb"
149 changes: 149 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder repo_name settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# vscode
.vscode/*
.vscode/settings.json
.vscode/tasks.json
.vscode/launch.json
.vscode/extensions.json
*.code-workspace

# pycharm
.idea/*

# Local History for Visual Studio Code
.history/

#Mac
.DS_Store

# NWB files
**.nwb
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
exclude: ^docs/

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies:
- tomli

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
args: [ --fix ]
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include *.yml
include *.json
include *.txt
107 changes: 106 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,107 @@
# kind-lab-to-nwb
NWB Conversion project for the Kind lab.
NWB conversion scripts for Kind lab data to the
[Neurodata Without Borders](https://nwb-overview.readthedocs.io/) data format.


## Installation
## Basic installation

You can install the latest release of the package with pip:

```
pip install kind-lab-to-nwb
```

We recommend that you install the package inside a [virtual environment](https://docs.python.org/3/tutorial/venv.
html). A simple way of doing this is to use a [conda environment](https://docs.conda.
io/projects/conda/en/latest/user-guide/concepts/environments.html) from the `conda` package manager ([installation
instructions](https://docs.conda.io/en/latest/miniconda.html)). Detailed instructions on how to use conda
environments can be found in their [documentation](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html).

### Running a specific conversion
Once you have installed the package with pip, you can run any of the conversion scripts in a notebook or a python file:

https://github.com/catalystneuro/kind-lab-to-nwb//tree/main/src/arc_ecephys_2024/convert_session.py

Copy or download this file run the script with the following command:

```
python convert_session.py
```

## Installation from GitHub
Another option is to install the package directly from GitHub. This option has the advantage that the source code
can be modified if you need to amend some of the code we originally provided to adapt to future experimental
differences. To install the conversion from GitHub you will need to use `git` ([installation instructions] (https://github.com/git-guides/install-git)).
We also recommend the installation of `conda` ([installation instructions](https://docs.conda.io/en/latest/miniconda.html)) as it contains all the required
machinery in a single and simple install.

From a terminal (note that conda should install one in your system) you can do the following:

```
git clone https://github.com/catalystneuro/kind-lab-to-nwb
cd kind-lab-to-nwb
conda env create --file make_env.yml
conda activate kind_lab_to_nwb_env
```

This creates a [conda environment](https://docs.conda.io/projects/conda/en/latest/user-guide/concepts/environments.html) which isolates the conversion code from your system libraries. We recommend that you run all your conversion related tasks and analysis from the created environment in order to minimize issues related to package dependencies.

Alternatively, if you want to avoid conda altogether (for example if you use another virtual environment tool) you
can install the repository with the following commands using only pip:

```
git clone https://github.com/catalystneuro/kind-lab-to-nwb
cd kind-lab-to-nwb
pip install --editable .
```

Note:
both of the methods above install the repository in [editable mode](https://pip.pypa.io/en/stable/cli/pip_install/#editable-installs).

### Running a specific conversion
If the project has more than one conversion, you can install the requirements for a specific conversion with the following command:
```
pip install --editable .[arc_ecephys_2024]
```

You can run a specific conversion with the following command:
```
python src/kind_lab_to_nwb/arc_ecephys_2024/convert_session.py
```

## Repository structure
Each conversion is organized in a directory of its own in the `src` directory:

kind-lab-to-nwb/
├── LICENSE
├── make_env.yml
├── pyproject.toml
├── README.md
├── requirements.txt
├── setup.py
└── src
├── kind_lab_to_nwb
│ └── arc_ecephys_2024
│ ├── notes.md
│ ├── behaviorinterface.py
│ ├── convert_session.py
│ ├── metadata.yml
│ ├── nwbconverter.py
│ ├── notes.md
│ └── __init__.py
│ ├── conversion_directory_b

└── __init__.py

For example, for the conversion `arc_ecephys_2024` you can find a directory located in `src/kind-lab-to-nwb/arc_ecephys_2024`.
Inside each conversion directory you can find the following files:


* `convert_sesion.py`: this script defines the function to convert one full session of the conversion.
* `metadata.yml`: metadata in yaml format for this specific conversion.
* `behaviorinterface.py`: the behavior interface. Usually ad-hoc for each conversion.
* `nwbconverter.py`: the place where the `NWBConverter` class is defined.
* `notes.md`: notes and comments concerning this specific conversion.

The directory might contain other files that are necessary for the conversion but those are the central ones.
9 changes: 9 additions & 0 deletions make_env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: kind_lab_to_nwb_env
channels:
- conda-forge
- defaults
dependencies:
- python>=3.11
- pip
- pip:
- --editable . # This calls the setup and therefore requirements minimal
Loading

0 comments on commit 0408fad

Please sign in to comment.