" show=[Overlay Masks] exclude clear summarize add") print "ATP, Exclude edges" else: IJ.run( "Analyze Particles...", "size=" + str(uGsize) + "-Infinity pixel circularity=" + str(uGshape) + "-" + str(uGshapemax) + " show=[Overlay Masks] clear summarize add") print "ATP, include all" # ROI management rm.runCommand("Combine") rm.runCommand("Add") rct = rm.getCount() fullTitle = ImagePlus.getTitle(thisImage) shortTitle = ImagePlus.getShortTitle(thisImage) IJ.run("Invert LUT") ### Invert LUT rm.rename(rct - 1, str(shortTitle)) rm.select(rct - 1) if image == newPaths[0]: rm.runCommand( "Save", analysisOut + File.separatorChar + "ROIindividual_wt" + ".zip") if image == newPaths[1]: rm.runCommand( "Save", analysisOut + File.separatorChar + "ROIindividual_dic" + ".zip") if image == newPaths[2]: rm.runCommand( "Save", analysisOut + File.separatorChar + "ROIindividual_mut" + ".zip") if image == newPaths[3]: rm.runCommand(
def run(): IJ.run("Close All", "") IJ.log("\\Clear") IJ.log("Find_close_peaks") imp = IJ.run("Bio-Formats Importer") imp = IJ.getImage() Channel_1, Channel_2, radius_background, sigmaSmaller, sigmaLarger, minPeakValue, min_dist = getOptions() IJ.log("option used:" \ + "\n" + "channel 1:" + str(Channel_1) \ + "\n" + "channel 2:"+ str(Channel_2) \ + "\n" + "Radius Background:"+ str(radius_background) \ + "\n" + "Smaller Sigma:"+ str(sigmaSmaller) \ + "\n" + "Larger Sigma:"+str(sigmaLarger) \ + "\n" + "Min Peak Value:"+str(minPeakValue) \ + "\n" + "Min dist between peaks:"+str(min_dist)) IJ.log("Computing Max Intensity Projection") if imp.getDimensions()[3] > 1: imp_max = ZProjector.run(imp,"max") #imp_max = IJ.run("Z Project...", "projection=[Max Intensity]") #imp_max = IJ.getImage() else: imp_max = imp ip1, ip2 = extract_channel(imp_max, Channel_1, Channel_2) imp1, imp2 = back_substraction(ip1, ip2, radius_background) imp1.show() imp2.show() IJ.log("Finding Peaks") ip1_1, ip2_1, peaks_1, peaks_2 = find_peaks(imp1, imp2, sigmaSmaller, sigmaLarger, minPeakValue) # Create a PointRoi from the DoG peaks, for visualization roi_1 = PointRoi(0, 0) roi_2 = PointRoi(0, 0) roi_3 = PointRoi(0, 0) roi_4 = PointRoi(0, 0) # A temporary array of integers, one per dimension the image has p_1 = zeros(ip1_1.numDimensions(), 'i') p_2 = zeros(ip2_1.numDimensions(), 'i') # Load every peak as a point in the PointRoi for peak in peaks_1: # Read peak coordinates into an array of integers peak.localize(p_1) roi_1.addPoint(imp1, p_1[0], p_1[1]) for peak in peaks_2: # Read peak coordinates into an array of integers peak.localize(p_2) roi_2.addPoint(imp2, p_2[0], p_2[1]) # Chose minimum distance in pixel #min_dist = 20 for peak_1 in peaks_1: peak_1.localize(p_1) for peak_2 in peaks_2: peak_2.localize(p_2) d1 = distance(p_1, p_2) if d1 < min_dist: roi_3.addPoint(imp1, p_2[0], p_2[1]) break for peak_2 in peaks_2: peak_2.localize(p_2) for peak_1 in peaks_1: peak_1.localize(p_1) d2 = distance(p_2, p_1) if d2 < min_dist: roi_4.addPoint(imp1, p_2[0], p_2[1]) break rm = RoiManager.getInstance() if not rm: rm = RoiManager() rm.reset() rm.addRoi(roi_1) rm.addRoi(roi_2) rm.addRoi(roi_3) rm.addRoi(roi_4) rm.select(0) rm.rename(0, "ROI neuron") rm.runCommand("Set Color", "yellow") rm.select(1) rm.rename(1, "ROI glioma") rm.runCommand("Set Color", "blue") rm.select(2) rm.rename(2, "ROI glioma touching neurons") rm.runCommand("Set Color", "red") rm.select(3) rm.rename(3, "ROI neurons touching glioma") rm.runCommand("Set Color", "green") rm.runCommand(imp1, "Show All") #Change distance to be in um cal = imp.getCalibration() min_distance = str(round((cal.pixelWidth * min_dist),1)) table = ResultsTable() table.incrementCounter() table.addValue("Numbers of Neuron Markers", roi_1.getCount(0)) table.addValue("Numbers of Glioma Markers", roi_2.getCount(0)) table.addValue("Numbers of Glioma within %s um of Neurons" %(min_distance), roi_3.getCount(0)) table.addValue("Numbers of Neurons within %s um of Glioma" %(min_distance), roi_4.getCount(0)) table.show("Results Analysis")