Skip to content

Instantly share code, notes, and snippets.

View JoachimGoedhart's full-sized avatar
💡
Coding now and then

Joachim Goedhart JoachimGoedhart

💡
Coding now and then
View GitHub Profile
import numpy as np
from colorsys import rgb_to_hls, hls_to_rgb
def _rgb2hls(im):
return np.stack(np.vectorize(rgb_to_hls)(*im.transpose(2,0,1)/256), axis=-1)
def _hls2rgb(im):
return (255*np.stack(np.vectorize(hls_to_rgb)(*im.transpose(2,0,1)), axis=-1)).astype(np.uint8)
def invert(img):
@ekatrukha
ekatrukha / 3D_tilt_stack_v1.ijm
Created February 7, 2019 18:03
ImageJ macro making a tilted movie out of Z-stack
//ImageJ macro making a tilted movie out of stack
//uses shear transform + rotation
//Eugene Katrukha katpyxa at gmail.com
requires("1.48h");
sTitle=getTitle();
sMovieTitle=sTitle+"_tilt_movie";
setBatchMode(true);
//Dialog
@angelovangel
angelovangel / Using models from the drc package with ggplot
Last active June 23, 2023 13:43
Using models from the drc package (for dose-response curves) with ggplot
# the aim is to use the 'drc' package to fit models to data and then extract the data and use for plotting in ggplot
# the data could be growth curves, dose-response, Michaelis-Menten etc.
# here, the S.alba data from drc is used for dose-response
library(tidyverse)
library(broom)
library(drc)
library(modelr)
attach(S.alba) # the data used in this gist
library(egg)
@dracodoc
dracodoc / clip_generic.R
Last active June 19, 2023 14:24
R function for reading and writing to windows/mac clipboard
#' Read windows/mac clipboard into lines
#'
#' If windows, call \code{utils::readClipboard()}. If mac os, use
#' \code{pipe("pbpaste")}.
#'
#' @return character vector
#' @export
#' @examples
#' clip_read_lines()
clip_read_lines <- function(){
# somewhat hackish solution to:
# https://twitter.com/EamonCaddigan/status/646759751242620928
# based mostly on copy/pasting from ggplot2 geom_violin source:
# https://github.com/hadley/ggplot2/blob/master/R/geom-violin.r
library(ggplot2)
library(dplyr)
"%||%" <- function(a, b) {