-
-
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))) |
how can one apply all the settings (like "excludeBoundary" or "nmsThresh") with your current syntax
You can see it in the comment here.
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.
@uschmidt83 Hi,
I'm trying to run the code above, but I need the get out the ROI (number of cells and the area) from the results.
I tried to find what strings I can give the getOutput()
https://gist.github.com/maweigert/8dd6ef139e1cd37b2307b35fb50dee4a#file-stardist_script-py-L34 method, but I couldn't find any info about that!
I see that I can give it "label", but what else?
I'm trying to run the code above, but I need the get out the ROI (number of cells and the area) from the results.
If you use "outputType", "ROI Manager"
, StarDist will populate ImageJ's Roi Manager, which can give you access to number of cells and some measurements of your choice. However, this will not show up as something that you can access with getOutput()
and I don't know how to automate this in a script. I think it can be done, and I'd ask at the image.sc forum about it.
Hello!
I am trying to use this code to run stardist on all the pics in the directory but I am getting this error,
SyntaxError: no viable alternative at input ‘=’
does anyone know how to fix it.
thank you
`#@ DatasetIOService io
#@ CommandService command
theinput = "C:\Users\abdel\Downloads\8bitgreen";
output = "C:\Users\abdel\Downloads\try";
print (theinput)
setBatchMode(true);
list = getFileList(theinput);
print (list)
for (i = 0; i < lengthof(list); i+=){
IJ.run(list[i], "8-bit", "");
run("Command From Macro", "command=[de.csbdresden.stardist.StarDist2D], args=['input':'list[i]', 'modelChoice':'Versatile (fluorescent nuclei)', 'normalizeInput':'true', 'percentileBottom':'1.0', 'percentileTop':'99.8', 'probThresh':'0.15000000000000002', 'nmsThresh':'0.3', 'outputType':'Both', 'modelFile':'C:\\Users\\abdel\\Downloads\\dsb2018_heavy_augment.zip', 'nTiles':'5', 'excludeBoundary':'2', 'roiPosition':'Automatic', 'verbose':'false', 'showCsbdeepProgress':'false', 'showProbAndDist':'false'], process=[false]");
rm.runCommand(list[i],"Measure");
IJ.saveAs("Results", output + filename);
}
setBatchMode(false);
`
@Bassetyabrag You cross-posted this also at the image.sc forum, where I replied to you.
hi there,
how can one apply all the settings (like "excludeBoundary" or "nmsThresh") with your current syntax, e.g.
?
If it is not possible, where can one download the "de.csbdresden.stardist" module, i did not find it.
thanks in advance.
best
coco