// Histology GAG Analysis // Quantify the area of GAGs in Cervical Os epithelium (dark purple) from stromal tissue // Runs on the selected open window image. Can be run as batch process for full folders. // Written be Wilson R Adams | Vanderbilt Biophotonics Center | 25 Jan 2021 raw = getTitle(); PurpSeg(raw); function PurpSeg(img) { roiManager("reset"); // Segment out purpple stuff in image. quantify area. selectWindow(img); run("Duplicate...", " "); wrkimg = getTitle(); // Split channels to RGB - Keep red channel run("Split Channels"); close(wrkimg+" (green)"); close(wrkimg+" (blue)"); selectWindow(wrkimg+" (red)"); // Threshold image with huang threshold method - no erosion/dilation //setAutoThreshold("Otsu"); setThreshold(0, 146); setOption("BlackBackground", false); run("Convert to Mask"); // Get ROI // 'Create Selection' doesnt have size exculsion // 'Analyze Particles' does. So i used that to get the main big ROI run("Analyze Particles...", "size=500-Infinity add"); if (roiManager("count") > 1) { // Always condense to 1 ROI count = roiManager("count"); sel = newArray(count); for (i = 0; i < count; i++) { sel[i] = i; } roiManager("select", sel); roiManager("combine"); roiManager("add"); roiManager("select", sel); roiManager("delete"); } // Run 'Analyze Particles' against AND('Create Selection') output // to keep voids in mask run("Create Selection"); roiManager("add"); roiManager("select", newArray(0, 1)); roiManager("and"); roiManager("add"); roiManager("select", newArray(0, 1)); roiManager("delete"); // Measure area of ROI in pixels on original image run("Set Measurements...", "area mean integrated redirect=None decimal=6"); selectWindow(img); roiManager("show all"); roiManager("Measure"); // Measured values are Area, Intensity Mean, and Integrated Density close("\\Others"); }