Skip to content

Commit a532884

Browse files
committed
Improve debugging logic
1 parent ccabe32 commit a532884

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

omero/util_scripts/Min_Max.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def channelGen():
107107
tile = pixels.getTile(*tileInfo)
108108
tile_min = min(tile_min, amin(tile))
109109
tile_max = max(tile_max, amax(tile))
110-
byte_count += len(tile)
110+
byte_count += tile.nbytes
111111
tile_count += 1
112112
rv[c] = (tile_min, tile_max)
113113
yield rv, byte_count, tile_count
@@ -116,7 +116,8 @@ def channelGen():
116116
for x, byte_count, tile_count in channelGen():
117117
statsInfos.update(x)
118118

119-
print "Loaded %s tile(s) (%s bytes)" % (tile_count, byte_count)
119+
if debug:
120+
print "Loaded %s tile(s) (%s bytes)" % (tile_count, byte_count)
120121
return statsInfos
121122

122123

@@ -156,7 +157,7 @@ def processImages(conn, scriptParams):
156157
c_max = globalmax[c]
157158
tb.row("Total: outer ", c, min(c_min), max(c_max))
158159
tb.row("Total: inner ", c, max(c_min), min(c_max))
159-
tb.row("Total: average", c, avg(c_min), avg(c_max))
160+
tb.row("Total: average", c, int(avg(c_min)), int(avg(c_max)))
160161

161162
if scriptParams["DryRun"]:
162163
print str(tb.build())
@@ -188,8 +189,9 @@ def processImages(conn, scriptParams):
188189
else:
189190
raise Exception("unknown combine: %s" % combine)
190191

191-
print "Image:%s(c=%s) - %s StatsInfo(%s, %s)" % (
192-
iId, c, action, si.globalMin.val, si.globalMax.val)
192+
if debug:
193+
print "Image:%s(c=%s) - %s StatsInfo(%s, %s)" % (
194+
iId, c, action, si.globalMin.val, si.globalMax.val)
193195
ch._obj.statsInfo = si
194196
ch.save()
195197

0 commit comments

Comments
 (0)