/** * Test whether a PathObject has a specified measurement in its measurement list. * * @param pathObject * @param name * @return */ public static boolean hasMeasurement(final PathObject pathObject, final String measurementName) { return pathObject != null && pathObject.getMeasurementList().containsNamedMeasurement(measurementName); }
/** * Extract the specified measurement from a PathObject. * * @param pathObject * @param name * @return */ public static double measurement(final PathObject pathObject, final String measurementName) { return pathObject == null ? Double.NaN : pathObject.getMeasurementList().getMeasurementValue(measurementName); }
public static double[] getMeasurementValues(final Collection<PathObject> pathObjects, final String measurementName) { double[] values = new double[pathObjects.size()]; int ind = 0; for (PathObject pathObject : pathObjects) { values[ind] = pathObject.getMeasurementList().getMeasurementValue(measurementName); ind++; } return values; }
public static Set<String> getAvailableFeatures(final Collection<PathObject> pathObjects) { LinkedHashSet<String> featureSet = new LinkedHashSet<>(); // This has a small optimization that takes into consideration the fact that many objects share references to exactly the same MeasurementLists - // so by checking the last list that was added, there is no need to bother the set to add the same thing again. List<String> lastNames = null; for (PathObject pathObject : pathObjects) { if (!pathObject.hasMeasurements()) continue; List<String> list = pathObject.getMeasurementList().getMeasurementNames(); if (lastNames == null || !lastNames.equals(list)) featureSet.addAll(list); lastNames = list; } return featureSet; }
public double[] normalizeMeanStdDev(final PathObject pathObject, final List<String> measurements, final double nanValue, double[] results) { if (results == null || results.length < measurements.size()) results = new double[measurements.size()]; MeasurementList list = pathObject.getMeasurementList(); for (int i = 0; i < measurements.size(); i++) { String name = measurements.get(i); RunningStatistics stats = statsMap.get(name); double val = list.getMeasurementValue(name); if (Double.isNaN(val)) results[i] = nanValue; else if (stats == null) results[i] = val; else results[i] = (val - stats.getMean()) / stats.getStdDev(); } return results; }
public static void removeMeasurements(final Collection<PathObject> pathObjects, String... measurementName) { for (PathObject pathObject : pathObjects) { MeasurementList list = pathObject.getMeasurementList(); list.removeMeasurements(measurementName); list.closeList(); } }
public static void removeMeasurements(final PathObjectHierarchy hierarchy, final Class<? extends PathObject> cls, final String... measurementNames) { if (hierarchy == null) return; List<PathObject> pathObjects = hierarchy.getObjects(null, cls); for (PathObject pathObject : pathObjects) { // A little check, to handle possible subclasses being returned if (pathObject.getClass() != cls) continue; // Remove the measurements pathObject.getMeasurementList().removeMeasurements(measurementNames); pathObject.getMeasurementList().closeList(); } hierarchy.fireObjectMeasurementsChangedEvent(null, pathObjects); }
@Override public void addMeasurements(PathObject pathObject, String name, ParameterList params) { // Check if we have a median we can use if (histogram == null || histogram.length == 0) return; // Start from the end & update double total = 0; double[] proportions = new double[histogram.length]; for (int i = histogram.length-1; i >= 0; i--) { total += histogram[i] / (double)n; proportions[i] = total; } // Add the measurements MeasurementList measurementList = pathObject.getMeasurementList(); double binWidth = (maxBin - minBin) / (nBins - 1); NumberFormat formatter = GeneralTools.createFormatter(3); for (int i = 0; i < histogram.length; i++) { double value = minBin + i * binWidth; measurementList.putMeasurement(name + " >= " + formatter.format(value), proportions[i]); } }
MeasurementList measurementList = pathObject.getMeasurementList(); measurementList.putMeasurement(name + " Median", median);
public MeasurementNormalizer(final Collection<PathObject> pathObjects) { for (PathObject pathObject : pathObjects) { MeasurementList list = pathObject.getMeasurementList(); for (int i = 0; i < list.size(); i++) { double value = list.getMeasurementValue(i); if (Double.isNaN(value)) continue; String name = list.getMeasurementName(i); RunningStatistics stats = statsMap.get(name); if (stats == null) { stats = new RunningStatistics(); statsMap.put(name, stats); } stats.addValue(value); } } }
@Override public void addMeasurements(PathObject pathObject, String name, ParameterList params) { if (matrices == null) return; MeasurementList measurementList = pathObject.getMeasurementList(); HaralickFeatures haralickFeatures = matrices.getMeanFeatures(); for (int i = 0; i < haralickFeatures.nFeatures(); i++) { measurementList.putMeasurement(String.format("%s Haralick %s (F%d)", name, haralickFeatures.getFeatureName(i), i), haralickFeatures.getFeature(i)); } }
@Override public void run() { try { if (store != null) store.addTileListener(this); processObject(parentObject, params, server, stains, store); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (store != null) store.removeTileListener(this); parentObject.getMeasurementList().closeList(); server = null; params = null; store = null; } }
@Override public void run() { try { if (store != null) store.addTileListener(this); processObject(parentObject, params, server, stains, store); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (store != null) store.removeTileListener(this); parentObject.getMeasurementList().closeList(); server = null; params = null; store = null; } }
@Override public void run() { try { MeasurementList measurementList = parentObject.getMeasurementList(); ROI roi; if (parentObject instanceof PathCellObject) { roi = ((PathCellObject)parentObject).getNucleusROI(); if (roi instanceof PathArea) addMeasurements(measurementList, (PathArea)roi, "Nucleus Shape: ", pixelWidth, pixelHeight, unit, doArea, doPerimeter, doCircularity); roi = parentObject.getROI(); if (roi instanceof PathArea) addMeasurements(measurementList, (PathArea)roi, "Cell Shape: ", pixelWidth, pixelHeight, unit, doArea, doPerimeter, doCircularity); } else { roi = parentObject.getROI(); if (roi instanceof PathArea) addMeasurements(measurementList, (PathArea)roi, "ROI Shape: ", pixelWidth, pixelHeight, unit, doArea, doPerimeter, doCircularity); } measurementList.closeList(); } catch (Exception e) { e.printStackTrace(); throw(e); } } });
@Override public void run() { try { if (store != null) store.addTileListener(this); processObject(parentObject, params, server, stains, store); // } catch (InterruptedException e) { // // TODO Auto-generated catch block // e.printStackTrace(); } finally { if (store != null) store.removeTileListener(this); parentObject.getMeasurementList().closeList(); server = null; params = null; store = null; } }
@Override public void run() { try { if (store != null) store.addTileListener(this); processObject(parentObject, params, server, stains, store); // } catch (InterruptedException e) { // // TODO Auto-generated catch block // e.printStackTrace(); } finally { if (store != null) store.removeTileListener(this); parentObject.getMeasurementList().closeList(); server = null; params = null; store = null; } }
@Override public void addMeasurements(PathObject pathObject, String name, ParameterList params) { // Handle Hue special case if (hueStats != null) { pathObject.getMeasurementList().putMeasurement(name + " Mean", hueStats.getMeanHue()); return; } // Handle everything else if (stats == null) return; MeasurementList measurementList = pathObject.getMeasurementList(); if (params.getBooleanParameterValue(Feature.MEAN.key)) measurementList.putMeasurement(name + " Mean", stats.getMean()); if (params.getBooleanParameterValue(Feature.STD_DEV.key)) measurementList.putMeasurement(name + " Std.dev.", stats.getStdDev()); if (params.getBooleanParameterValue(Feature.MIN_MAX.key)) { measurementList.putMeasurement(name + " Min", stats.getMin()); measurementList.putMeasurement(name + " Max", stats.getMax()); } logger.trace("Measured pixel count: {}", stats.nPixels()); }
SimpleModifiableImage pxImg = new FloatArraySimpleImage(pixels, w, h); MeasurementList measurementList = pathObject.getMeasurementList();
double estimatedSpots = pathObject.getMeasurementList().getMeasurementValue(measurementName);
Object value = pathObjectTemp.getMeasurementList().getMeasurementValue(intensityMeasurement); if (!(value instanceof Number)) continue;