for filename, row, row_value in all_ydata: table.set(filename, row, row_value) uiservice.show("MergedFiles_%s" % data_identifier, table) log("Retrieving statistics for merged Y-data...") list_of_rows = defaultdict(list) for data in all_ydata: list_of_rows[data[1]].append(data[2]) row_stats = {} for row_key, row_values in list_of_rows.iteritems(): row_stats[row_key] = (mean(row_values), stdev(row_values), len(row_values)) table = newtable(xcolumn_header, xvalues) for key, value in row_stats.iteritems(): table.set("Mean", int(key), value[0]) table.set("StdDev", int(key), value[1]) table.set("N", int(key), value[2]) uiservice.show("Stats_%s" % data_identifier, table) plot = Plot("Mean Sholl Plot [%s]" % ycolumn_header, xcolumn_header, "N. of intersections") plot.setLegend("Mean"+ u'\u00B1' +"SD", Plot.LEGEND_TRANSPARENT + Plot.AUTO_POSITION) plot.setColor("cyan", "blue") plot.addPoints(table.get(0), table.get(1), table.get(2), Plot.CONNECTED_CIRCLES, data_identifier) plot.show() log("Parsing concluded.") main()
row=[ str(p[i]) for p in profiles ] row=",".join(row) f.write(row+"\n") # Generate a plot if doPlot: from ij.gui import Plot from java.awt import Color p = Plot('Profiles','Channel #','Intensity') p.setSize(640,480) maxP = len(profiles) maxV = 0 for iprofile,profile in enumerate(profiles): h = 0.66-(float(iprofile)/maxP) if h<0: h=h+1 p.setColor(Color.getHSBColor( h,.8,1)) p.addPoints(range(len(profile)),profile,p.LINE) maxV_=max(profile) if maxV < maxV_: maxV = maxV_ p.setLimits(0,len(profile)-1,0,maxV*1.2) p.setLegend("\n".join(names),p.TOP_LEFT|p.LEGEND_TRANSPARENT) p.show() # Save the plot as PNG if doSavePlot: imp = p.getImagePlus() IJ.saveAs(imp,'PNG',file.absolutePath + "_compensationPlot.png")