Skip to content

Instantly share code, notes, and snippets.

View willemolding's full-sized avatar

Willem Olding willemolding

  • Hobart, Tasmania
View GitHub Profile
@willemolding
willemolding / segment_assessment.py
Created August 17, 2015 01:25
Segmentation algorithm evaluation functions
from rasterio import features
from shapely.geometry import Polygon
from skimage.segmentation import find_boundaries
from skimage.morphology import binary_dilation, disk
import numpy as np
def undersegmentation_error(gt_segments, superpixels):
"""
Computes the undersegmentation error metric. An efficient implementation.
@willemolding
willemolding / norm.py
Created August 15, 2017 00:39
A much faster implementation of norm that scipy. Not feature complete
class norm:
def __init__(self, loc, scale):
self.loc=float(loc)
self.scale=float(scale)
def pdf(self, x):
coeff = 1./(np.sqrt(2*np.pi*self.scale**2))
return coeff * np.exp(-(x - self.loc)**2/(2.*self.scale**2))
def logpdf(self, x):
@willemolding
willemolding / ImageConverter.js
Created October 8, 2017 05:19
PNG to TXI javascript image converter (from Fitbit Studio)
/* eslint no-bitwise: 0 */
import PNGReader from 'png.js';
import TZ1200RLE from './TZ1200RLE';
export function readPNG(imageBytes) {
const reader = new PNGReader(imageBytes);
return new Promise((resolve, reject) => {
reader.parse((err, data) => {
@willemolding
willemolding / condition.py
Created October 24, 2017 01:51
Condition a multivariate Gaussian on observations
def condition(mu, sigma, observations):
"""
Condition on the observations to produce a new mean and covariance matrix
Parameters:
----------
mu - the mean vector
sigma - the covariance matrix
observations - the observed variables.
Variables that are not observed should be Nan in this vector.
The resulting distribution will be over these variables in the order they appear
@willemolding
willemolding / draft-luigi-post.md
Created February 1, 2018 04:02
A draft version of an article about Luigi for Research

Title: Luigi Pipelines for Academia (Part 1) Date: 2017-01-29 Category: Articles

I'm excited to share with you a tool I have been using to streamline the aspects of research that require processing and performing computations on data. I'm sure there are a not of researchers who, like me, have less than ideal data pipelines.

My previous setup looked something like this. I would keep the raw data untouched in a folder called data. Each level of data processing (e.g. reformatting, cleaning, fitting a model, cross-validating, plotting) has its own script or collection of scripts and would write it's output to a folder prefixed by a number. The directory structure might look like this:

Experiment 1
@willemolding
willemolding / get_first_index.py
Created February 15, 2018 01:46
[Find First Occurences] Finds the index of first occurences along a dimension of a true value. Returns nonevalue if none found #python #numpy
def get_first_index(bool_array, axis, nonevalue=-1):
"""
Returns the first index in each axis that is true. Returns nonevalue if none are found
"""
return np.choose(np.any(bool_array, axis=axis), [nonevalue, np.argmax(bool_array, axis=axis)])
@willemolding
willemolding / hide-code-jupyter-notebook.js
Created February 28, 2018 04:39
Add this as a raw cell to add a 'hide code' button to the notebook when exported to html
<script>
function code_toggle() {
if (code_shown){
$('div.input').hide('500');
$('#toggleButton').val('Show Code')
} else {
$('div.input').show('500');
$('#toggleButton').val('Hide Code')
}
code_shown = !code_shown
@willemolding
willemolding / improvement2.py
Last active March 8, 2018 02:57
lachie script improvements
def grab_prob(time_idx):
# make frame__idx an integer to avoid slicing errors
frame_idx = int(time_idx)
# get 'frame_time'
frame_time = grab_sst_time(frame_idx)
# set month of year
MoY_val = int(frame_time.month)
# get list of temperature and salinity values from subset
@willemolding
willemolding / holochain-mermaid-overrides.js
Last active May 11, 2018 08:16
Overrides the commit, get and message functions in Holochain to print debug messages. These messages are visualisable as mermaidjs sequence diagrams
/*==========================================
= function overrides =
==========================================*/
agentShortname = App.Agent.String.substr(0, App.Agent.String.indexOf('@'));
var oldCommit = commit;
commit = function(entryType, entryData) {
if(entryType.indexOf("private") !== -1) {
debug(agentShortname + '-->>' + agentShortname +': '+ entryType);
@willemolding
willemolding / Cargo.toml
Last active March 17, 2019 09:33
Valid holochain agent address generator
[package]
name = "agent-address-generator"
version = "0.1.0"
authors = ["willem <willemolding@gmail.com>"]
edition = "2018"
[dependencies]
holochain_core_types = { git = "https://github.com/holochain/holochain-rust", branch="develop" }