Skip to content

Instantly share code, notes, and snippets.

@thesamovar
thesamovar / ccn23_analysis.ipynb
Created May 17, 2023 15:51
CCN 2023 analysis notebook
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thesamovar
thesamovar / publishing_decisions_model.py
Created August 17, 2022 16:11
Publishing decisions model
import numpy as np
from scipy.stats import norm
# Assumptions:
# True score of a paper is x normally distributed with mean 0, variance 1
# Want to publish papers where x>z some threshold (e.g. choose top 5% of papers)
# Each reviewer gives a score y=x+eps where eps is normally distributed with mean 0, variance sigma^2
# n reviewers, take the mean score yn
# Publish the paper if yn>z
# Compute each of the following:
@thesamovar
thesamovar / extract_fitness_data_tcx.py
Created November 20, 2021 19:18
Extract fitness data from tcx files
from pathlib import Path
import xml.etree.ElementTree as ET
import dateutil
import matplotlib.pyplot as plt
import numpy as np
dates = []
distances_km = []
durations_min = []
speeds_km_h = []
@thesamovar
thesamovar / run-jupyter-notebook-here.md
Created October 18, 2020 11:38
Instructions on how to add a Jupyter notebook context menu on Windows

I don't know about you, but I find myself launching juptyer notebooks often enough now that typing the command is annoying. Here's how to add a context menu on Windows to open one in the current directory or the directory you're right clicking on.

First, make a .bat file like this, mine is C:\Users\dgoodman\Scripts\jupyter-here.bat:

	if NOT [%1]==[] (
		cd "%1"
	)
	call conda activate jupyter
	call jupyter notebook
@thesamovar
thesamovar / legend2d.ipynb
Created August 18, 2020 15:42
2D Legend for matplotlib
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thesamovar
thesamovar / pathlib_hack_manis_data.py
Created August 14, 2020 13:22
Hack to load pickled file in Manis et al. 2019 cochlear nucleus data on Windows
# obscene hack to load the data from https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0223137
from pathlib import WindowsPath, PosixPath, Path
def hacked_new(cls, *args, **kwargs):
if cls is Path:
cls = WindowsPath if os.name == 'nt' else PosixPath
self = cls._from_parts(args, init=False)
# this line causes a problem
# if not self._flavour.is_supported:
# raise NotImplementedError("cannot instantiate %r on your system"
# % (cls.__name__,))
@thesamovar
thesamovar / membrane_time_constants.py
Created August 12, 2020 16:28
Membrane time constant distribution with Allen SDK
import numpy as np
import matplotlib.pyplot as plt
from allensdk.core.cell_types_cache import CellTypesCache
ctc = CellTypesCache()
ephys = ctc.get_ephys_features(dataframe=True)
time_constants = ephys.tau.as_matrix()
plt.hist(time_constants, bins=np.linspace(0, 100, 40));
plt.xlabel(r'Membrane time constant (ms)')
plt.yticks([]);
@thesamovar
thesamovar / Automatic scientific axes layout for matplotlib.ipynb
Last active August 14, 2024 22:35
Automatic scientific axes layout for matplotlib.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thesamovar
thesamovar / wrapping_with_cython.ipynb
Created January 31, 2020 18:01
wrapping_with_cython.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thesamovar
thesamovar / playing_with_pybind11.ipynb
Created January 31, 2020 16:35
/playing_with_pybind11.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.