Skip to content

Instantly share code, notes, and snippets.

View jasmainak's full-sized avatar

Mainak Jas jasmainak

View GitHub Profile
# %%
# %matplotlib widget
import matplotlib.pyplot as plt
from matplotlib.colors import SymLogNorm
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import numpy as np
from neuron import h
from hnn_core.network_builder import load_custom_mechanisms
from hnn_core.lfp import _LFPElectrode
@larsoner
larsoner / gist:4c964e21045fc499cb5e380dc79137c0
Created February 3, 2021 20:19
bems_brainsuite_fsl.py
# convert MGZ->NII
#
# $ bet T1.nii stripped.nii.gz -n -A -v -e
#
import numpy as np
import nibabel as nib
import pyvista as pv
import mne
img = nib.load('T1.mgz')
name: hnn
channels:
- defaults
dependencies:
- python>=3.6
- pip
- numpy
- scipy
- matplotlib
- cython
@0x4D31
0x4D31 / beautiful_idiomatic_python.md
Last active September 5, 2024 12:30 — forked from JeffPaine/beautiful_idiomatic_python.md
[Beautiful Idiomatic Python] Transforming Code into Beautiful, Idiomatic Python #python

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@raghavrv
raghavrv / undecorate_python.py
Last active June 27, 2017 11:54
Undecorate an object python2.7 or 3.5
from types import FunctionType
import inspect
def undecorate(func):
funcs = []
# python 3.5
if hasattr(func, '__wrapped__'):
while hasattr(func, '__wrapped__'):
func = func.__wrapped__
@wmvanvliet
wmvanvliet / haufe.ipynb
Last active July 14, 2017 09:25
Testing the Haufe trick
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jakevdp
jakevdp / convolution_matrix.py
Last active March 12, 2019 09:49
Convolution Matrix
# Author: Jake VanderPlas
# LICENSE: MIT
from __future__ import division
import numpy as np
def convolution_matrix(x, N=None, mode='full'):
"""Compute the Convolution Matrix
# -*- coding: utf-8 -*-
"""
PySurfer-like plotting using VisPy scene.
"""
import numpy as np
from vispy import scene, app
import mne
import nibabel