public static List<TMACoreObject> getTMACoreList() { PathObjectHierarchy hierarchy = getCurrentHierarchy(); if (hierarchy == null || hierarchy.getTMAGrid() == null) return Collections.emptyList(); return hierarchy.getTMAGrid().getTMACoreList(); }
/** * Get the TMA core that contains the specified x & y coordinate, or null if no core is available for the coordinates give. * * @param hierarchy * @param x * @param y * @return */ public static TMACoreObject getTMACoreForLocation(final PathObjectHierarchy hierarchy, final double x, final double y) { TMAGrid tmaGrid = hierarchy.getTMAGrid(); if (tmaGrid == null) return null; return tmaGrid.getTMACoreForPixel(x, y); }
@Override protected Collection<? extends PathObject> getParentObjects(PluginRunner<T> runner) { PathObject selected = runner.getSelectedObject(); if (selected instanceof TMACoreObject) return Collections.singleton(selected); if (runner.getHierarchy().getTMAGrid() != null) return runner.getHierarchy().getTMAGrid().getTMACoreList(); else return Collections.emptyList(); }
/** * Returns true if TMA cores are available. * @return */ public static boolean isTMADearrayed() { ImageData<?> imageData = getCurrentImageData(); if (imageData == null) return false; return imageData.getHierarchy().getTMAGrid() != null && imageData.getHierarchy().getTMAGrid().nCores() > 0; }
public static void resetTMAMetadata(final PathObjectHierarchy hierarchy, final boolean includeMeasurements) { if (hierarchy == null || hierarchy.getTMAGrid() == null) return; for (TMACoreObject core : hierarchy.getTMAGrid().getTMACoreList()) { core.clearMetadata(); if (includeMeasurements) { core.getMeasurementList().clear(); } } hierarchy.fireObjectsChangedEvent(QP.class, hierarchy.getTMAGrid().getTMACoreList()); }
@Override protected Collection<PathObject> getParentObjects(final PluginRunner<T> runner) { PathObjectHierarchy hierarchy = runner.getImageData().getHierarchy(); List<PathObject> parents = new ArrayList<>(); if (hierarchy.getTMAGrid() != null) { logger.info("Smoothing using TMA cores"); for (TMACoreObject core : hierarchy.getTMAGrid().getTMACoreList()) { if (core.hasChildren()) parents.add(core); } } else { for (PathObject pathObject : hierarchy.getSelectionModel().getSelectedObjects()) { if (pathObject.isAnnotation() && pathObject.hasChildren()) parents.add(pathObject); } if (!parents.isEmpty()) logger.warn("Smoothing using annotations"); } return parents; }
private static boolean writeImageDataZipped(final File file, final ImageData<?> imageData) { if (imageData.getHierarchy().getTMAGrid() == null) return writeImageDataSerialized(file, imageData); writer.write("width="+hierarchy.getTMAGrid().getGridWidth()); writer.newLine(); writer.write("height="+hierarchy.getTMAGrid().getGridHeight()); } catch (IOException e) { e.printStackTrace(); hierarchy.getTMAGrid().getTMACoreList().parallelStream().forEach(core -> { int count = hierarchy.getTMAGrid().getTMACoreList().indexOf(core); Path corePath = fsZip.getPath("hierarchy", "core_" + count + ".qpobj"); try (ObjectOutputStream stream = new ObjectOutputStream(new BufferedOutputStream(Files.newOutputStream(corePath)))) {
/** * Extract a list of TMA cores from an object hierarchy. If no cores are present, an empty list is returned. * * @param hierarchy * @param includeMissingCores * @return */ public static List<TMACoreObject> getTMACoreObjects(final PathObjectHierarchy hierarchy, final boolean includeMissingCores) { TMAGrid tmaGrid = hierarchy.getTMAGrid(); if (tmaGrid == null || tmaGrid.nCores() == 0) return Collections.emptyList(); // If we have a TMA grid, add all the objects if (includeMissingCores) return tmaGrid.getTMACoreList(); List<TMACoreObject> cores = new ArrayList<>(); for (TMACoreObject core : tmaGrid.getTMACoreList()) { if (!core.isMissing()) cores.add(core); } return cores; }
public static void runClassifier(final PathObjectHierarchy hierarchy, final PathObjectClassifier classifier) { // Apply classifier to everything // If we have a TMA grid, do one core at a time long startTime = System.currentTimeMillis(); TMAGrid tmaGrid = hierarchy.getTMAGrid(); List<PathObject> pathObjects = new ArrayList<>(); int nClassified = 0; // tmaGrid = null; if (tmaGrid != null) { for (TMACoreObject core : tmaGrid.getTMACoreList()) { pathObjects = hierarchy.getDescendantObjects(core, pathObjects, PathDetectionObject.class); nClassified += classifier.classifyPathObjects(pathObjects); pathObjects.clear(); } } else { pathObjects = hierarchy.getObjects(null, PathDetectionObject.class); nClassified = classifier.classifyPathObjects(pathObjects); } long endTime = System.currentTimeMillis(); logger.info(String.format("Classification time: %.2f seconds", (endTime-startTime)/1000.)); // Fire a change event for all detection objects if (nClassified > 0) hierarchy.fireObjectClassificationsChangedEvent(classifier, hierarchy.getObjects(null, PathDetectionObject.class)); else logger.warn("No objects classified!"); }
static int importFromCSV(final Map<String, List<String>> map, final PathObjectHierarchy hierarchy) { TMAGrid tmaGrid = hierarchy.getTMAGrid(); if (tmaGrid == null || tmaGrid.nCores() == 0) { logger.error("No TMA grid found!");
if (hierarchy == null || hierarchy.getTMAGrid() == null) { logger.error("Cannot relabel TMA grid - no grid found!"); return false; TMAGrid grid = hierarchy.getTMAGrid(); String[] columnLabels = PathObjectTools.parseTMALabelString(labelsHorizontal); String[] rowLabels = PathObjectTools.parseTMALabelString(labelsVertical);