Skip to content

Instantly share code, notes, and snippets.

@maweigert
Last active July 12, 2023 12:41
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save maweigert/8dd6ef139e1cd37b2307b35fb50dee4a to your computer and use it in GitHub Desktop.
Save maweigert/8dd6ef139e1cd37b2307b35fb50dee4a to your computer and use it in GitHub Desktop.
#@ 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)))
@uschmidt83
Copy link

@Bassetyabrag You cross-posted this also at the image.sc forum, where I replied to you.

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