/** * Check if we have H&E staining, by checking the names of the first two stains and confirming that the third stain is a residual. * Note the order of the stains must be 1-Hematoxylin, 2-Eosin, 3-residual (missing) * @return */ public boolean isH_E() { return stain3.isResidual() && isHematoxylin(stain1) && isEosin(stain2); }
public static String getColorDeconvolutionStainsAsString(final ColorDeconvolutionStains stains, final int nDecimalPlaces) { if (stains == null) return ""; StringBuilder sb = new StringBuilder(); sb.append("{"); sb.append("\"Name").append("\" : \"").append(stains.getName()).append("\", "); for (int i = 1; i <= 3; i++) { StainVector stain = stains.getStain(i); // No need to add the residual stain if (i == 3 && stain.isResidual()) continue; sb.append("\"Stain ").append(i).append("\" : \"").append(stain.getName()).append("\", "); sb.append("\"Values ").append(i).append("\" : \"").append(stain.arrayAsString(Locale.US, nDecimalPlaces)).append("\", "); } sb.append("\"Background\" : \""); sb.append(" ").append(GeneralTools.arrayToString(Locale.US, new double[]{stains.getMaxRed(), stains.getMaxGreen(), stains.getMaxBlue()}, nDecimalPlaces)); // sb.append(String.format( "%.Nf %.Nf %.Nf".replace("N", Integer.toString(nDecimalPlaces)), stains.getMaxRed(), stains.getMaxGreen(), stains.getMaxBlue())); // sb.append(stains.getMaxRed()).append(" "); // sb.append(stains.getMaxGreen()).append(" "); // sb.append(stains.getMaxBlue()); sb.append("\"}"); return sb.toString(); }
/** * Create a new ColorDeconvolutionStains object, with all settings the same except one of the stains has been changed. * If the third stain was a residual, it will also be regenerated (i.e. it won't remain the same residual... which would be wrong, * as it would be orthogonal to the old stain rather than the new one). * * @param stains * @param stain * @param stainNumber * @return */ public static ColorDeconvolutionStains makeModifiedStains(ColorDeconvolutionStains stains, StainVector stainNew, int stainNumber) { StainVector[] stainVectors = new StainVector[3]; stainVectors[0] = stains.getStain(1); stainVectors[1] = stains.getStain(2); stainVectors[2] = stains.getStain(3); stainVectors[stainNumber - 1] = stainNew; if (stainVectors[2].isResidual()) stainVectors[2] = null; return new ColorDeconvolutionStains(stains.getName(), stainVectors[0], stainVectors[1], stainVectors[2], stains.getMaxRed(), stains.getMaxGreen(), stains.getMaxBlue()); }
double s22 = matInv[2][2]; discardResidual = discardResidual && stainsInput.getStain(3).isResidual();