Skip to content

Instantly share code, notes, and snippets.

@maweigert

maweigert/stardist_script.py Secret

Last active Jan 12, 2021
Embed
What would you like to do?
#@ DatasetIOService io
#@ CommandService command
""" This example runs stardist on all tif files in a folder
Full list of Parameters:
res = command.run(StarDist2D, False,
"input", imp, "modelChoice", "Versatile (fluorescent nuclei)",
"modelFile","/path/to/TF_SavedModel.zip",
"normalizeInput",True, "percentileBottom",1, "percentileTop",99.8,
"probThresh",0.5, "nmsThresh", 0.3, "outputType","Label Image",
"nTiles",1, "excludeBoundary",2, "verbose",1, "showCsbdeepProgress",1, "showProbAndDist",0).get();
"""
from de.csbdresden.stardist import StarDist2D
from glob import glob
import os
# run stardist on all tiff files in <indir> and save the label image to <outdir>
indir = os.path.expanduser("~/Tmp/images/")
outdir = os.path.expanduser("~/Tmp/labels/")
for f in sorted(glob(os.path.join(indir,"*.tif"))):
print "processing ", f
imp = io.open(f)
res = command.run(StarDist2D, False,
"input", imp,
"modelChoice", "Versatile (fluorescent nuclei)",
).get()
label = res.getOutput("label")
io.save(label, os.path.join(outdir,"label."+os.path.basename(f)))
@Cocomolch4000

This comment has been minimized.

Copy link

@Cocomolch4000 Cocomolch4000 commented Aug 5, 2020

hi there,
how can one apply all the settings (like "excludeBoundary" or "nmsThresh") with your current syntax, e.g.

model = StarDist2D.from_pretrained('2D_versatile_he')
img = normalize(X[image_ind], 1.8,97.5, axis=axis_norm)
labels, details = model.predict_instances(img)
coord, points, prob = details['coord'], details['points'], details['prob']

?
If it is not possible, where can one download the "de.csbdresden.stardist" module, i did not find it.
thanks in advance.
best
coco

@uschmidt83

This comment has been minimized.

Copy link

@uschmidt83 uschmidt83 commented Dec 1, 2020

how can one apply all the settings (like "excludeBoundary" or "nmsThresh") with your current syntax

You can see it in the comment here.

@afrendeiro

This comment has been minimized.

Copy link

@afrendeiro afrendeiro commented Jan 12, 2021

where can one download the "de.csbdresden.stardist" module, i did not find it.

This is an ImageJ plugin - even though it's Python - it is intended to be run by ImageJ after installing the stardist plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment