private String addMean(int column, String line, int start) { if (start == -1) { line += "\tNaN"; summaryHdr += "\t" + ResultsTable.getDefaultHeading(column); } else { float[] c = column >= 0 ? rt.getColumn(column) : null; if (c != null) { ImageProcessor ip = new FloatProcessor(c.length, 1, c, null); if (ip == null) return line; ip.setRoi(start, 0, ip.getWidth() - start, 1); ip = ip.crop(); ImageStatistics stats = new FloatStatistics(ip); if (stats == null) return line; line += n(stats.mean); } else line += "\tNaN"; summaryHdr += "\t" + rt.getColumnHeading(column); } return line; }
public static void main(String[] args) { String mriImage = args[0]; String outImage = args[1]; String segArgs = args[2]; String outTable = args[3]; String pdxArgs = args[4]; System.out.println("Open: " + mriImage); IJ.open(mriImage); COPD_LungSegment tjPlug = new COPD_LungSegment(); ImagePlus cImage = IJ.getImage(); tjPlug.setup(segArgs, cImage); tjPlug.run(cImage.getProcessor()); IJ.save(cImage, outImage); COPD_PDxLAAx pdxPlug = new COPD_PDxLAAx(); pdxPlug.setup("", cImage); pdxPlug.run(cImage.getProcessor()); ResultsTable rt = Analyzer.getResultsTable(); try { rt.saveAs(outTable); } catch (IOException e) { e.printStackTrace(); } System.out.println("Results Table\n"); String prefix = "rtout, "; for (int i = 0; i < ResultsTable.MAX_COLUMNS; i++) { if (!rt.columnExists(i)) break; String tempOut = rt.getColumnHeading(i); for (double d : rt.getColumnAsDoubles(i)) { tempOut += ", " + d; } System.out.println(prefix + tempOut); } }