Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Müller-Komorowska danielmk

View GitHub Profile
@danielmk
danielmk / fitzhugh-nagumo_model_ramp_input.py
Created May 11, 2022
Fitzhugh-Nagumo dynamical system. With animation code.
View fitzhugh-nagumo_model_ramp_input.py
"""Fitzhugh-Nagumo dynamical system. With animation code.
Author: Daniel Müller-Komorowska @scidanm
"""
import numpy as np
from scipy.integrate import solve_ivp
from matplotlib.animation import FuncAnimation
import matplotlib.pyplot as plt
import matplotlib as mpl
@danielmk
danielmk / data_dashboard_covid19_remote.py
Last active Feb 7, 2022
Data dashboard in Jupyter visualizing Covid-19 hospitalization data from remote source.
View data_dashboard_covid19_remote.py
import pandas as pd
import numpy as np
from bokeh.plotting import figure, show, output_notebook
import ipywidgets as widgets
from IPython.display import display, clear_output
output_notebook()
"""Load Iris dataset and transform the pandas DataFrame"""
data = pd.read_csv("https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/hospitalizations/covid-hospitalizations.csv")
data['date'] = pd.to_datetime(data['date'])
@danielmk
danielmk / odeint_and_solve_ivp.py
Last active Feb 24, 2022
odeint and solve_ivp results diverge for yet unknown reasons
View odeint_and_solve_ivp.py
import numpy as np
from scipy.integrate import odeint, solve_ivp
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def lorenz(t, state, sigma, beta, rho):
x, y, z = state
dx = sigma * (y - x)
dy = x * (rho - z) - y
@danielmk
danielmk / balanced_spiking_network.py
Created May 4, 2021
Python implementation of a balanced spiking neural network.
View balanced_spiking_network.py
"""
NumPy implementation of a balanced spiking neural network. Inspired by MATLAB
code from Nicola & Clopath (2017): https://doi.org/10.1038/s41467-017-01827-3
"""
import numpy as np
from numpy.random import rand, randn
import matplotlib.pyplot as plt
@danielmk
danielmk / ann_titanic_challenge_torch.py
Created Feb 2, 2021
An artificial neural network for the Titanic challenge on Kaggle
View ann_titanic_challenge_torch.py
import torch
import pandas as pd
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
np.random.seed(10000)
@danielmk
danielmk / pca_reconstruction_animated.py
Created Jul 23, 2020
Animation showing MNIST samples reconstructed from an increasing number of principal components.
View pca_reconstruction_animated.py
"""
The functions in this code are taken from a Neuromatch Academy Tutorial about dimensionality
reduction by Alex Cayco Gajic & John Murray:
https://github.com/NeuromatchAcademy/course-content/tree/master/tutorials/W1D5_DimensionalityReduction
Neuromatch Academy content is licensed under a Creative Commons Attribution 4.0 International
https://github.com/NeuromatchAcademy/course-content/blob/master/LICENSE.md
I use these functions to create an animation showing a subset of MNIST samples
reconstructed from an increasing number of principal components.
@danielmk
danielmk / amp_crosscorr
Created Dec 29, 2019
A python port of a method described by Adhikari et al. 2010 to estimate the directionality and the lag between the eeg recordings from two brain areas.
View amp_crosscorr
# -*- coding: utf-8 -*-
"""
@author: Daniel Müller-Komorowska
"""
import numpy as np
import scipy.signal as signal
def amp_crosscorr(eeg1, eeg2, samp_freq, low_freq, high_freq):
"""
@danielmk
danielmk / animation_demo2_matplotlib.py
Created Nov 29, 2019
How to animate two plots with Matplotlib
View animation_demo2_matplotlib.py
import numpy as np
from matplotlib.animation import FuncAnimation
import matplotlib.pyplot as plt
x = np.arange(0, 10*np.pi, 0.01)
y_sin = np.sin(x)
y_cos = np.cos(x)
fig = plt.figure()
ax1 = plt.subplot(2, 1, 1)
@danielmk
danielmk / animation_demo_matplotlib.py
Created Nov 29, 2019
How to make animations with Matplotlib
View animation_demo_matplotlib.py
import numpy as np
from matplotlib.animation import FuncAnimation
import matplotlib.pyplot as plt
x = np.arange(0, 10*np.pi, 0.01)
y = np.sin(x)
fig = plt.figure()
ax = plt.subplot(1, 1, 1)
@danielmk
danielmk / hodgkin_huxley_animated.py
Last active Nov 27, 2019
The dynamical systems view of the Hodgkin-Huxley model
View hodgkin_huxley_animated.py
# -*- coding: utf-8 -*-
"""
Voltage spikes, also known as action potentials, are considered the key unit of information flow in
the nervous system. One of the first quantitative descriptions of the action potential is the
Hodgkin-Huxley Model, named after nobel prize winning physiologists Alan Lloyd Hodgkin and Andrew
Fielding Huxley. This matplotlib animation shows the result of simulating the Hodgkin-Huxley model
in python with parameters that are set in a way, that the model resembles a cortical pyramidal cell.
At 50ms a current is injected, making the model spike. The upper panel shows the dynamical systems
view of the action potential. Before the current injection, the model stays at the resting
potential. When the current is injected a bifurcation occurs. The system finds a limit cycle.