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 | |
ground_truth | |
├── images | |
└── masks | |
View matching_metrics.py
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 | |
np.random.seed(42) | |
def create_example(): | |
rand_gt = np.random.uniform(0,1,(8,8)) |
View label_image_from_rois.py
#@ 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() |
View stardist_noto_setup.sh
#!/usr/bin/env bash | |
source ~/.bashrc | |
git clone https://github.com/mpicbg-csbd/stardist | |
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 |
View invert.py
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 image_mse_normalization.py
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 | |
Parameters | |
---------- | |
gt: ndarray |