Ejemplo n.º 1
0
from plugins.ylemontag.histogram import Histogram

seq = Icy.getMainInterface().getFocusedSequence()

xls_out = '/tmp/icy_py_excel_test.xls'
wb = XLSUtil.createWorkbook(xls_out)     # create excel document
ws = XLSUtil.createNewPage(wb, "result")     # create new page
XLSUtil.setCellString(ws, 0, 0, "filename")  # set headers
XLSUtil.setCellString(ws, 1, 0, seq.name)

# hist = Histogram.compute(seq, 16, 0, 15)
hist = Histogram.compute(seq, 16, 7, 248)
overall = 0
for i in xrange(hist.getNbBins()):
	bin = hist.getBin(i)
	val = bin.getCentralValue()
	count = bin.getCount()
	print("%i: %i" % (val, count))
	XLSUtil.setCellNumber(ws, 0, i+3, val)
	XLSUtil.setCellNumber(ws, 1, i+3, count)
	overall += count

XLSUtil.saveAndClose(wb)  # close and save the excel file

numpixels = seq.getSizeX() * seq.getSizeY() * seq.getSizeZ()
diff = overall - numpixels
print('Number of pixels: %s x %s x %s = %s' %
	(seq.getSizeX(), seq.getSizeY(), seq.getSizeZ(), numpixels))
print('Overall count from bins: %s' % overall)
print('Difference bincount - pixels: %s' % diff)
Ejemplo n.º 2
0
new_xls_row(ws, ['X Dimension', seq.getSizeX()])
new_xls_row(ws, ['Y Dimension', seq.getSizeY()])
new_xls_row(ws, ['Z Dimension', seq.getSizeZ()])
numpixels = seq.getSizeX() * seq.getSizeY() * seq.getSizeZ()
new_xls_row(ws, ['Total number of pixels', numpixels])
print('Total number of pixels: %s' % numpixels)
new_xls_row(ws, ['Global min', val_min])
new_xls_row(ws, ['Global max', val_max])
row += 1
new_xls_row(ws, ['Number of Histogram bins', NUM_BINS])
new_xls_row(ws, ['Bin width', bwh*2])
row += 2

ch_hist = get_hist_allch(seq, NUM_BINS, val_min + bwh, val_max - bwh)
# ch_hist = get_hist_allch(seq, NUM_BINS, 0, 3)

new_xls_row(ws, ['Histogram'])
new_xls_row(ws, ['central bin value', ''] + ch_hist[0] + ['total'])

ci = 0
for ch in ch_hist[1]:
    new_xls_row(ws, ['channel', ci] + ch + [sum(ch)])
    ci += 1

# close and save the excel file
XLSUtil.saveAndClose(wb)

print('Wrote Excel file: "%s"' % XLS_FILE)
### compatibility for BLOCKS
output0 = XLS_FILE