MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / summarize

Method summarize

ij/src/main/java/ij/plugin/filter/Analyzer.java:892–931  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

890 }
891
892 public void summarize() {
893 if (rt==null || "Max".equals(rt.getLabel(rt.size()-1)))
894 return;
895 int n = rt.size();
896 if (n<2)
897 return;
898 String[] headings = rt.getHeadings();
899 int columns = headings.length;
900 if (columns==0)
901 return;
902 int first = "Label".equals(headings[0])?1:0;
903 double[] min = new double[columns];
904 double[] max = new double[columns];
905 double[] sum = new double[columns];
906 double[] sum2 = new double[columns];
907 for (int i=0; i<columns; i++) {
908 min[i] = Double.MAX_VALUE;
909 max[i] = -Double.MAX_VALUE;
910 }
911 for (int row=0; row<n; row++) {
912 for (int col=first; col<columns; col++) {
913 double v = rt.getValue(headings[col], row);
914 if (v<min[col]) min[col]=v;
915 if (v>max[col]) max[col]=v;
916 sum[col]+=v;
917 sum2[col]+=v*v;
918 }
919 }
920 rt.incrementCounter(); rt.setLabel("Mean", n+0);
921 rt.incrementCounter(); rt.setLabel("SD", n+1);
922 rt.incrementCounter(); rt.setLabel("Min", n+2);
923 rt.incrementCounter(); rt.setLabel("Max", n+3);
924 for (int col=first; col<columns; col++) {
925 rt.setValue(headings[col], n+0, sum[col]/n);
926 rt.setValue(headings[col], n+1, Math.sqrt((sum2[col]-sum[col]*sum[col]/n)/(n-1)));
927 rt.setValue(headings[col], n+2, min[col]);
928 rt.setValue(headings[col], n+3, max[col]);
929 }
930 rt.show(rt.getTitle());
931 }
932
933 /** Returns the current measurement count. */
934 public static int getCounter() {

Callers 3

setupMethod · 0.95
doCommandMethod · 0.95
addMenuBarMethod · 0.95

Calls 11

getHeadingsMethod · 0.80
getLabelMethod · 0.65
setLabelMethod · 0.65
getTitleMethod · 0.65
equalsMethod · 0.45
sizeMethod · 0.45
getValueMethod · 0.45
incrementCounterMethod · 0.45
setValueMethod · 0.45
sqrtMethod · 0.45
showMethod · 0.45

Tested by

no test coverage detected