Skip to content

Instantly share code, notes, and snippets.

View nickponvert's full-sized avatar

Nick Ponvert nickponvert

View GitHub Profile
@nickponvert
nickponvert / hboot.py
Created March 13, 2020 18:43
Hierarchical bootstrapping of pandas DataFrames
# @nickponvert
# Code for hierarchical bootstrapping
class HData():
def __init__(self, df, hierarchy, random_effect=None):
'''
A tree-structured representation of a DataFrame with hierarchical structure.
Can be resampled while respecting the hierarchy, allowing for bootstrap statistics that
take the structure of the data into account. Inspired by Saravanan et al. 2019
https://www.biorxiv.org/content/10.1101/819334v1.full.pdf+html
@nickponvert
nickponvert / dataframe_to_h5.py
Created April 24, 2019 21:19
Saving dataframes to HDF5 format
import h5py
import datetime
import pandas as pd
import numpy as np
import ast # To parse string representing a list
def save_hdf(dframe, filename):
'''
Save dataframe as HDF5, in a cleaner format than pandas.DataFrame.to_hdf()
Use load_hdf() to load these files.
from jaratoolbox import loadopenephys
#from jaratoolbox import spikesanalysis
import numpy as np
import matplotlib.pyplot as plt
import os
class Aligned_Spikes():
def __init__(self, directory, tetrode_number):
from pylab import *
from jaratoolbox import loadopenephys
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import numpy as np
# -- Load the required data --
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Cryopreservation, mounting and sectioning
Postfix specimen in PAF in phosphate buffer
Wash in fix buffer - .1 M phosphate buffer 3 times for 5 minutes each wash
Melt an aliquot of agar-sucrose solution (1.5% agar, 5% sucrose) and let cool to 40C
Immerse brain in agar inside mold and let cool until solidified (5-10 mins)
update_current_git_vars