Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
source ~/.bashrc
git clone
my_venvs_create stardist_env
my_venvs_activate stardist_env
pip install tifffile==2019.7.2 # as newer versions somehow wont install on noto
pip install stardist
import numpy as np
from csbdeep.utils import normalize
def norm_minmse(gt, x, normalize_gt=True):
normalizes and affinely scales an image pair such that the MSE is minimized
gt: ndarray
import numpy as np
import matplotlib.pyplot as plt
from scipy.ndimage import label, zoom
from stardist.matching import matching
from stardist.plot import render_label, render_label_pred
def create_example():
rand_gt = np.random.uniform(0,1,(8,8))
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):
View qupath_export_annotations.groovy
/* QuPath-Script to export annotations to label tif images (e.g. to be used for stardist)
Use "Run for project" to export annotations for all images within a QuPath project
Afterwards both images and mask tiffs will be stored in the project subfolder
├── images
└── masks
maweigert /
Last active Mar 30, 2021
Generate label image from rois in Fiji
#@ ImagePlus imp
#@ OUTPUT ImagePlus result
from ij import IJ
from ij.plugin.frame import RoiManager
result = IJ.createImage("Labeling", "16-bit black", imp.getWidth(), imp.getHeight(), 1)
ip = result.getProcessor()
rm = RoiManager.getInstance()