Skip to content

Instantly share code, notes, and snippets.

@miura
Last active December 22, 2015 03:49
Show Gist options
  • Select an option

  • Save miura/6412898 to your computer and use it in GitHub Desktop.

Select an option

Save miura/6412898 to your computer and use it in GitHub Desktop.
from fiji.threshold import Auto_Local_Threshold as ALT
# nucleus selection
#imp = IJ.getImage()
imp = IJ.openImage("/Users/miyanari/Desktop/EMBL_with Kota/FISH_data/DNA-FISH_Demo.tif")
#IJ.run(imp, "Split Channels", "")
imps = ChannelSplitter.split(imp)
nucimp = imps[0]
#nucimp.show()
#Z projection
zpnuc = ZProjector(nucimp)
zpnuc.setMethod(ZProjector.MAX_METHOD)
zpnuc.doProjection()
zpnucimp = zpnuc.getProjection()
zpnucimp.show()
#Gaussian blur
gbnuc = GaussianBlur()
ip = zpnucimp.getProcessor()
gbnuc.blurGaussian(ip, 3, 3, 0.01)
#Auto local threshold
#IJ.run(imp, "Auto Local Threshold", "method=Bernsen radius=45 parameter_1=0 parameter_2=0 white");
ALT().exec(zpnucimp, "Niblack", 30, 0, 0, True)
#print len(thimp)
#imps[0].show()
#thimp.show()
#thimp[0].show()
#analyze particle
rt = ResultsTable()
measopt = ParticleAnalyzer.AREA + ParticleAnalyzer.SHAPE_DESCRIPTORS
paopt = ParticleAnalyzer.EXCLUDE_EDGE_PARTICLES
paopt += ParticleAnalyzer.INCLUDE_HOLES
paopt += ParticleAnalyzer.SHOW_MASKS
paopt += ParticleAnalyzer.CLEAR_WORKSHEET
paopt += ParticleAnalyzer.SHOW_RESULTS
apnuc = ParticleAnalyzer(paopt, measopt, rt, 3000, 40000000, 0.6, 1.0)
apnuc.analyze(zpnucimp)
maskimp = apnuc.getOutputImage()
maskimp.show()
maskimp.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment