Skip to content

Commit 84b5df6

Browse files
authored
Merge pull request #20 from vncntprvst/SI-container
Spike Interface container
2 parents 1021699 + 74dd802 commit 84b5df6

9 files changed

Lines changed: 173 additions & 0 deletions

File tree

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Force batch scripts to always use CRLF line endings so that if a repo is accessed
5+
# in Windows via a file share from Linux, the scripts will work.
6+
*.{cmd,[cC][mM][dD]} text eol=crlf
7+
*.{bat,[bB][aA][tT]} text eol=crlf
8+
9+
# Force bash scripts to always use LF line endings so that if a repo is accessed
10+
# in Unix via a file share from Windows, the scripts will work.
11+
*.sh text eol=lf

kilosort_with_license/matlab_for_kilosort/docker1/build.sh

100755100644
File mode changed.

spikeinterface/Dockerfile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
FROM jupyter/datascience-notebook:hub-1.5.0
2+
3+
LABEL maintainer="Vincent Prevosto <prevosto@mit.edu>"
4+
5+
USER root
6+
# APT packages
7+
RUN apt update && \
8+
apt install -y --no-install-recommends \
9+
libgl1-mesa-glx \
10+
datalad && \
11+
apt clean && \
12+
rm -rf /var/lib/apt/lists/*
13+
14+
# copy repo
15+
WORKDIR /srv
16+
RUN git clone https://github.com/SpikeInterface/spikeinterface.git
17+
18+
RUN fix-permissions $CONDA_DIR && \
19+
fix-permissions /home/$NB_USER && \
20+
fix-permissions /srv/spikeinterface
21+
22+
#Switch to user
23+
USER $NB_UID
24+
25+
# update Anaconda and install pip
26+
RUN conda update -y conda && \
27+
conda install -y pip
28+
29+
# Conda installs
30+
# RUN conda config --set channel_priority flexible && \
31+
RUN conda install -y -c conda-forge \
32+
nb_conda_kernels \
33+
jupyterlab-git \
34+
pynwb && \
35+
conda clean -tipy
36+
37+
# Install jupyter_contrib_nbextensions with pip (conda install has major conflicts)
38+
RUN pip install https://github.com/ipython-contrib/jupyter_contrib_nbextensions/tarball/master
39+
40+
# Create environment
41+
RUN ln -s /srv/spikeinterface /home/$NB_USER/
42+
WORKDIR /home/$NB_USER/spikeinterface/installation_tips/
43+
RUN conda env create -f full_spikeinterface_environment_mac.yml
44+
45+
# Make kernels available
46+
SHELL ["conda","run","-n","si_env","/bin/bash","-c"]
47+
RUN conda install --quiet --yes ipykernel && \
48+
conda install --quiet --yes -c conda-forge datalad && \
49+
python -m ipykernel install --user --name si_env --display-name "spikeinterface"
50+
RUN pip install jupytext
51+
52+
# Configure git (required by datalad)
53+
WORKDIR /home/$NB_USER/spikeinterface/
54+
RUN git config --global --add user.name "Jovyan" && \
55+
git config --global --add user.email jovyan@example.net
56+
57+
# Create "getting started" notebook in home directory
58+
WORKDIR /home/$NB_USER/spikeinterface/examples/getting_started/
59+
RUN jupytext --to notebook plot_getting_started.py && \
60+
cp ~/spikeinterface/examples/getting_started/plot_getting_started.ipynb ~/getting_started.ipynb
61+
62+
# Make sure to switch back to user (avoid running ui containers as root)
63+
USER $NB_UID
64+
WORKDIR /home/$NB_USER

spikeinterface/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
2+
### How to run the spikeinterface container
3+
**Method 1: drag and drop** (Windows only for now)
4+
Drag and drop the data folder on either `.bat` file (see `launch_scripts` folder). For convenience, create a shortcut and put it on your desktop.
5+
6+
![Drag and Drop](images/DragAndDropDemo.gif)
7+
8+
_Which launch script should you pick?_
9+
10+
`SpikeInterface_OneOff.bat` will start a one-off sesssion. The container will self-destroy upon shutdown (not just closing the tab though). If the tab is closed, go back to your session at this address: http://localhost:8888/lab?token=mytoken.
11+
12+
`SpikeInterface_Persist.bat` will start a persistent container that can be reused. The drawback is that data folder will stay the same until the container is stopped and remove (which can be done following instructions below).
13+
In the `.bat`, please replace "mytoken" by some other word of your choice.
14+
15+
To add files and notebooks to your session, drag and drop them on the left side mneu.
16+
Files can be downloaded with right-click > download.
17+
18+
**Method 2: manual start**
19+
1. Open a terminal and navigate to the data directory. Then follow these instructions.
20+
2. Start the container
21+
*On Linux/MacOS*
22+
`export JUPYTER_TOKEN='mytoken'`
23+
`docker run -d --rm --name spikeinterface -v "${PWD}":/home/jovyan/data -p 8888:8888 -e JUPYTER_TOKEN spikeinterface/spikeinterface:0.2`
24+
*On Windows*
25+
`set JUPYTER_TOKEN=mytoken`
26+
`docker run -d --rm --name spikeinterface -v "%CD%":/home/jovyan/data -p 8888:8888 -e JUPYTER_TOKEN spikeinterface/spikeinterface:0.2`
27+
28+
* Replace "mytoken" by some other word.
29+
* If you built the image (see below), remove `spikeinterface/` or replace it with your docker handle.
30+
31+
3. Then open http://localhost:8888/lab?token=mytoken in a browser.
32+
33+
34+
35+
**Important Note**
36+
The `--rm` flag means the container is a one-off (will self-destroy upon closure).
37+
To make the container persitant, remove the `--rm flag` from the docker call. In which case, the container will persist. To start a stopped container, run `docker start spikeinterface` in a terminal, or use the Docker Desktop interface to start it.
38+
39+
### How to build this image
40+
The container image is [available on DockerHub](https://hub.docker.com/repository/docker/spikeinterface/spikeinterface/). Providing you have Docker installed, it will automatically download when starting the container.
41+
42+
If you want to build it, follow the instructions below.
43+
Open a terminal, navigate to the spikeinterface directory, then run:
44+
`docker build -t spikeinterface:0.2 .`
45+
On Linux systems, you can also use the build script (after making it executable `chmod +x build.sh`):
46+
`./build.sh`
47+
48+
49+
50+
51+
52+
53+
54+

spikeinterface/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker build -t spikeinterface/spikeinterface:0.2 .
2.27 MB
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@echo off
2+
Title Drag and drop a data folder
3+
Mode con cols=60 lines=3
4+
IF [%1] EQU [] Goto:Error
5+
set JUPYTER_TOKEN=mytoken
6+
docker run -d --rm --name spikeinterface -v "%~1":/home/jovyan/data -p 8888:8888 -e JUPYTER_TOKEN spikeinterface/spikeinterface:0.2
7+
TIMEOUT /T 2
8+
START /W "" http://localhost:8888/lab?token=mytoken
9+
ECHO Spike Interface started
10+
TIMEOUT /T 2
11+
Exit /b
12+
13+
::**********************************************************
14+
:Error
15+
Color 0C & echo(
16+
ECHO You must drag and drop a folder on this batch program
17+
Timeout /T 5 /NoBreak >nul
18+
Exit /b
19+
::**********************************************************
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@echo off
2+
Title Drag and drop a data folder
3+
Mode con cols=60 lines=3
4+
IF [%1] EQU [] Goto:Error
5+
set JUPYTER_TOKEN=mytoken
6+
docker run -d --rm --name spikeinterface -v "%~1":/home/jovyan/data -p 8888:8888 -e JUPYTER_TOKEN spikeinterface/spikeinterface:0.2
7+
TIMEOUT /T 2
8+
START /W "" http://localhost:8888/lab?token=mytoken
9+
ECHO Spike Interface started
10+
TIMEOUT /T 2
11+
Exit /b
12+
13+
::**********************************************************
14+
:Error
15+
Color 0C & echo(
16+
ECHO You must drag and drop a folder on this batch program
17+
Timeout /T 5 /NoBreak >nul
18+
Exit /b
19+
::**********************************************************

spikeinterface/push.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker push spikeinterface/spikeinterface:0.2 .

0 commit comments

Comments
 (0)