Skip to content

Instantly share code, notes, and snippets.

@shinwachi
Created August 17, 2020 22:30
Show Gist options
  • Select an option

  • Save shinwachi/44823769720fef142907a15087571648 to your computer and use it in GitHub Desktop.

Select an option

Save shinwachi/44823769720fef142907a15087571648 to your computer and use it in GitHub Desktop.
Fiji jython script to save particle analysis summary
Implementation of soultion listed here: https://forum.image.sc/t/solved-save-summary-in-headlessmode/26606/4
from ij import IJ
from ij import Prefs
from ij.measure import ResultsTable
from ij.plugin.filter import ParticleAnalyzer
rt = ResultsTable()
ParticleAnalyzer.setSummaryTable(rt)
imp = IJ.openImage("/home/jovyan/work/Images/some.JPG");
print imp
IJ.run(imp, "8-bit", "");
IJ.setRawThreshold(imp, 34, 255, None);
Prefs.blackBackground = True;
IJ.run(imp, "Convert to Mask", "");
IJ.run("Close");
IJ.run(imp, "Analyze Particles...", " circularity=0.20-1.00 show=Ellipses display clear summarize");
# this won't work in headless mode as there is no window (
#IJ.renameResults("Summary", "Results");
#IJ.saveAs("Results", "/home/jovyan/work/Summary.csv");
rt.save( "/home/jovyan/work/Summary.csv");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment