コード例 #1
0
def main():
	root = myDir.getPath() # get the root out the java file object
	print(root)
	
	import os, glob

	# set up bioformats
	from loci.plugins import BF
	from loci.plugins.in import ImporterOptions
	options = ImporterOptions()
	options.setColorMode(ImporterOptions.COLOR_MODE_COMPOSITE)
	options.setGroupFiles(True)  # if the files are named logically if will group them into a stack
  	
	# this will do the maximum intensity projection
	from ij.plugin import ZProjector
	Zproj = ZProjector()

	for path, subdirs, files in os.walk(root):
		print(path)
		# just get the one of the files that matches your image pattern
		flist = glob.glob(os.path.join(path,"*.tif"))
		print(len(flist))
		if( flist ):
			file = flist[0]
			print("Processing {}".format(file))
			options.setId(file)
			imp = BF.openImagePlus(options)[0]

			# show the image if you want to see it
			IJ.run(imp, "Grays", "")
			imp.show()

			imp_max = Zproj.run(imp,'max')
			IJ.run(imp_max, "Grays", "")
			imp_max.show()

			# save the Z projection
			IJ.save(imp_max,file.rsplit('_',1)[0]+'_processed.tif')