Skip to content

Instantly share code, notes, and snippets.

View llandsmeer's full-sized avatar
💡

Lennart Landsmeer llandsmeer

💡
View GitHub Profile
@llandsmeer
llandsmeer / npio.py
Created November 28, 2022 13:40
Single file numpy implementation of IO network
import numpy as np
import matplotlib.pyplot as plt
import numba
import time
NUM_STATE_VARS = 14
def main():
n = 5
s = make_initial_neuron_state(n ** 3, V_soma=None, V_axon=None)
@llandsmeer
llandsmeer / main.py
Last active November 16, 2022 23:53
Class-based custom mechanisms for arbor in python and C++ (DONT TRY THIS AT HOME!)
import sys
sys.path.insert(0, '/home/llandsmeer/repos/llandsmeer/arbor/build-debug/prefix/lib/python3.10/site-packages')
sys.path.append('/home/llandsmeer/repos/llandsmeer/nmlcc-cat')
import arbor
import matplotlib.pyplot as plt
import nmlcat
cat = nmlcat.Catalogue.make()
@llandsmeer
llandsmeer / Dockerfile
Created October 17, 2022 14:48
Arbor GUI in the browser via noVNC
# docker build -t arbor-gui . && docker run -it -p 5999:5999 arbor-gui
# then visit http://localhost:5999/vnc.html?host=localhost&port=5999&autoconnect=true
FROM ubuntu:latest
EXPOSE 5999
ENV DEBIAN_FRONTEND=noninteractive
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
ENV TZ=Europe/Amsterdam
RUN apt-get update && apt-get install -y xvfb x11vnc wget novnc git wmctrl
# git clone --depth 1 --recursive --branch=SDE 'https://github.com/boeschf/arbor'
# cd arbor ; mkdir build ; cd build
# cmake -DCMAKE_INSTALL_PREFIX=$(realpath prefix) -DARB_USE_BUNDLED_LIBS=ON -DARB_WITH_PYTHON=ON ..
# make -j 12 && make install
import sys
import importlib.util
import os.path
#### IF INSTALLED USING PIP:
import os.path
import numpy as np
import re
import subprocess
import tempfile
import arbor
from math import sqrt
import matplotlib.pyplot as plt
ARBOR_BUILD_CATALOGUE = 'arbor-build-catalogue'
import sympy as sm
import lark
parser = lark.Lark(r'''
%import common.SIGNED_NUMBER -> NUMBER
%import common.WS
%ignore WS
%ignore /\?.*\n/
%ignore /:.*\n/
@llandsmeer
llandsmeer / ledfxmidi.py
Created September 23, 2022 22:37
Control LedFX using midi controller
import os
import time
import json
import requests
import rtmidi
# pip install python-rtmidi
midi = rtmidi.MidiIn()
ports = midi.get_ports()
import sys
import pyte
import struct
import select
import time
import fcntl
import os
import pty
import subprocess
import termios
@llandsmeer
llandsmeer / pyqt5_numpy.py
Created May 28, 2022 11:25
pyqt5 show numpy arrays in a loop
import sys
import numpy as np
from PyQt5 import QtGui, QtWidgets, QtCore
class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.imshow = Grayscale()
self.setCentralWidget(self.imshow)
self.update_timer = QtCore.QTimer()
@llandsmeer
llandsmeer / iocell.py
Created April 14, 2022 16:46
interactive io in qt
import matplotlib.pyplot as plt
import numba
import numpy as np
@numba.jit(fastmath=True, cache=True, nopython=True)
def simulate(skip_initial_transient_seconds=0, sim_seconds=10, delta=0.005, record_every=20,
# Parameters
g_int = 0.13, # Cell internal conductance -- now a parameter (0.13)
p1 = 0.25, # Cell surface ratio soma/dendrite
p2 = 0.15, # Cell surface ratio axon(hillock)/soma