Beispiel #1
0
def MakeSubset(directory_load, directory_save, chl, frames, z_planes, loops,
               total, pat, title, imp2):
    subd = NonBlockingGenericDialog("Make subset")
    subd.addCheckbox("Duplicate only the current frames", False)
    subd.addCheckbox("Export XYTC of a subset of loops", False)

    subd.addSlider("Subset from loop number", 0, loops - 1, 0)
    subd.addSlider("Subset to loop number", 0, loops - 1, 0)
    subd.showDialog()

    slider_subd1 = subd.getSliders().get(0).getValue()
    slider_subd2 = subd.getSliders().get(1).getValue()
    checkbox_subd1 = subd.getNextBoolean()
    checkbox_subd2 = subd.getNextBoolean()

    if checkbox_subd1 == True:
        SliceNum = imp2.getCurrentSlice()
        FloorSlice50 = float(SliceNum) / frames
        S50 = (math.floor(FloorSlice50) * frames) + 1
        S100 = S50 + (frames - 1)
        print("Slice" + str(SliceNum) + "_FloorSlice_" + str(FloorSlice50) +
              "_frames_" + str(S50) + "-" + str(S100) + "")
        IJ.run(
            "Duplicate...", "title=Image_DUP duplicate range=" + str(S50) +
            "-" + str(S100) + "")
        impDup = WM.getImage("Image_DUP")
    if checkbox_subd2 == True:
        SubsetL(directory_load, directory_save, chl, frames, z_planes, loops,
                total, pat, title, slider_subd1, slider_subd2)
						dataImage = WindowManager.getImage("App Corrected")
						refCorrectedImage = WindowManager.getImage("Ref Corrected")
						refCorrectedImage.close()
				dataImage.setLut(LUT.createLutFromColor(Color.WHITE))
				dataImage.setCalibration(calib)
				dataImage.show()
				
				## Interface dialog for setting object finding parameters
				virginImage = dataImage.duplicate()
				gd10 = NonBlockingGenericDialog("Select size and threshold parameters...")
				gd10.addNumericField("Minimum_size:",100,0)
				gd10.addSlider("Threshold_intensity:",0,255,128)
				gd10.addCheckbox("Min_filter",False)
				gd10.addCheckbox("Med_filter",False)
				gd10.addCheckbox("Work_on_ROI",False)
				sliders = gd10.getSliders()
				boxes = gd10.getCheckboxes()
				texts = gd10.getNumericFields()
				sizeText = texts.elementAt(0)
				thresholdSlider = sliders.elementAt(0)
				thresholdSlider.addAdjustmentListener(ThresholdListener(dataImage))
				minFilterBox = boxes.elementAt(0)
				medFilterBox = boxes.elementAt(1)
				workROIBox = boxes.elementAt(2)
				minFilterBox.addItemListener(MinCheckboxListener(dataImage,virginImage,medFilterBox))
				medFilterBox.addItemListener(MedCheckboxListener(dataImage,virginImage,minFilterBox))
				workROIBox.addItemListener(WorkROICheckboxListener(dataImage,thresholdSlider,sizeText,workROIBox))
				gd10.showDialog()
				
				if (gd10.wasOKed()):
					sizeMin = gd10.getNextNumber()
Beispiel #3
0
	def showSettingsDialog(self):
		if self.__image.getOverlay() is not None : self.__image.getOverlay().clear()
		rm = RoiManager.getInstance()
		if (rm==None): rm = RoiManager()
		#rm.runCommand("Deselect")
		#for i in range(rm.getCount()) : 
		#	rm.select(i)
		#	rm.runCommand("Set Color", "0000FF", 2)
		
		
		IJ.resetThreshold(self.__image)

		rm.runCommand("Show All")
		
		self.__ranges.clear()
		#areas, means, majors, minors=[],[],[],[]

		#for roi in self.__roisArray:
		#	m=Morph(self.__image, roi)
		#	areas.append(m.Area)
		#	means.append(m.Mean)
		#	majors.append(m.Major)
		#	minors.append(m.Minor)
			
		#maxarea=max(areas)*1000
		#maxint=max(means)*10
		#maxline=max(majors)*100
		#maxminline=max(minors)*100
		#minline=min(minors)
		
		#namemeasures=["Area", "Mean", "Angle", "Major", "Minor", "Solidity", "AR", "Round", "Circ"]
		#maxmeasures=[maxarea, maxint, 180*10, maxline, maxminline, 1*1000, (maxline/minline), 1*1000, 1*1000]
		#set1000=Set(["Solidity", "Round", "Circ"])
		#set10=Set(["Angle"])
		
		def buttonPressed(event):
			temprois=self.getIncludeRois()
			for roi in temprois:
				m=Morph(self.__image, roi)
				IJ.log("----------------------------------")
				IJ.log(roi.getName())
				for r in self.__ranges.values():
					IJ.log(r[0]+" min= "+str(r[1])+" < val="+str(m.__getattribute__(r[0]))+" < max= "+str(r[2]))
			IJ.run(self.__image, "Remove Overlay", "")
			o=Overlay()
			for roi in temprois:
				o.addElement(roi)
			self.__image.killRoi()
			self.__image.setOverlay(o)
			self.__image.updateAndDraw()

		def updatepressed(event):
			self.__image=IJ.getImage()
			rm = RoiManager.getInstance()
			if (rm==None): rm = RoiManager()
			rm.runCommand("reset")
			self.__image.killRoi()
			IJ.run("Threshold...")
			IJ.setAutoThreshold(self.__image, "MaxEntropy")
			
			rt=ResultsTable()
			pa=ParticleAnalyzer(ParticleAnalyzer.ADD_TO_MANAGER+ParticleAnalyzer.CLEAR_WORKSHEET , Measurements.AREA+Measurements.ELLIPSE+Measurements.MEAN, rt, 0.00, 10000.00, 0.00, 1.00)
			pa.analyze(self.__image)
			self.__roisArray=[]
			self.__roisArray=rm.getRoisAsArray()
			#for i in range(rm.getCount()) : 
			#	rm.select(i)
			#	rm.runCommand("Set Color", "0000FF", 2)
				
			IJ.resetThreshold(self.__image)
			rt.show("tempRT")
			areas=rt.getColumn(ResultsTable.AREA)
			means=rt.getColumn(ResultsTable.MEAN)
			majors=rt.getColumn(ResultsTable.MAJOR)
			minors=rt.getColumn(ResultsTable.MINOR)
			#print 0
			if self.__slidersDict["Area_max"].getMaximum() <  int(max(areas)+1):
			#	print 1
				self.__slidersDict["Area_max"].setMaximum(int(max(areas))+1)
			if self.__slidersDict["Area_min"].getMaximum() < int(max(areas)+1):
			#	print 2
				self.__slidersDict["Area_min"].setMaximum(int(max(areas))+1)
			if self.__slidersDict["Mean_max"].getMaximum() < int(max(means)+1):
			#	print 3
				self.__slidersDict["Mean_max"].setMaximum(int(max(means))+1)
			if self.__slidersDict["Mean_min"].getMaximum() < int(max(means)+1):
			#	print 4
				self.__slidersDict["Mean_min"].setMaximum(int(max(means))+1)
			if self.__slidersDict["Major_max"].getMaximum() < int(max(majors)):
			#	print 5
				self.__slidersDict["Major_max"].setMaximum(int(max(majors))+1)
			if self.__slidersDict["Major_min"].getMaximum() < int(max(majors)+1):
			#	print 6
				self.__slidersDict["Major_min"].setMaximum(int(max(majors))+1)
			if self.__slidersDict["Minor_max"].getMaximum() < int(max(minors)+1):
			#	print 7
				self.__slidersDict["Minor_max"].setMaximum(int(max(minors))+1)
			if self.__slidersDict["Minor_min"].getMaximum() < int(max(minors)+1):
			#	print 8
				self.__slidersDict["Minor_min"].setMaximum(int(max(minors))+1)
			if self.__slidersDict["AR_max"].getMaximum() < int((max(majors)+1)/min(minors)+1):
			#	print 9
				self.__slidersDict["AR_max"].setMaximum(int((max(majors)+1)/(min(minors))))
			if self.__slidersDict["AR_min"].getMaximum() < int((max(majors)+1)/min(minors)):
			#	print 10
				self.__slidersDict["AR_min"].setMaximum(int((max(majors)+1)/(min(minors))))

			#print 11
				
			for sb in self.__slidersDict.values():
				sb.repaint()

			#rm.runCommand("reset")
			#temprois=self.getIncludeRois()
			#IJ.run(self.__image, "Remove Overlay", "")
			#o=Overlay()
			#for roi in temprois:
			#	o.addElement(roi)
			#self.__image.killRoi()
			#self.__image.setOverlay(o)
			self.__image.updateAndDraw()

		def resetpressed(event):
			self.__ranges.clear()
			self.__image=IJ.getImage()
			rm = RoiManager.getInstance()
			if (rm==None): rm = RoiManager()
			rm.runCommand("reset")
			self.__image.killRoi()
			IJ.setAutoThreshold(self.__image, "MaxEntropy")
			rt=ResultsTable()
			pa=ParticleAnalyzer(ParticleAnalyzer.ADD_TO_MANAGER+ParticleAnalyzer.CLEAR_WORKSHEET , Measurements.AREA+Measurements.ELLIPSE+Measurements.MEAN, rt, 0.00, 10000.00, 0.00, 1.00)
			pa.analyze(self.__image)
			self.__roisArray=[]
			self.__roisArray=rm.getRoisAsArray()
			#rm.runCommand("Show All")
			#rm.runCommand("Select All")
			#rm.runCommand("Set Color", "blue")
			
			IJ.resetThreshold(self.__image)
			
			keys=self.__slidersDict.keys()
			for k in keys:
				if k.endswith("min"): 
					self.__slidersDict[k].setValue(0)
					self.__slidersDict[k].repaint()
				else:
					self.__slidersDict[k].setValue(self.__slidersDict[k].getMaximum())
					self.__slidersDict[k].repaint()
			
		def valueChanged(event):
			name=event.getSource().getName()
			names=name.split("_")
			factor=1
			if names[0] in self.__set1000: factor=0.001
			if names[0] in self.__set10:factor=0.1
			value=event.getSource().getValue()*factor
			if names[1]=="min":
				self.__ranges[names[0]]=(names[0], value, self.__slidersDict[names[0]+"_max"].getValue()*factor, self.__boxesDict[names[0]].getState())
				#self.__ranges[names[0]]=(names[0], value, self.__slidersDict[names[0]+"_max"].getValue()*factor)
			else: self.__ranges[names[0]]=(names[0], self.__slidersDict[names[0]+"_min"].getValue()*factor, value, self.__boxesDict[names[0]].getState())
				#self.__ranges[names[0]]=(names[0], self.__slidersDict[names[0]+"_min"].getValue()*factor, value)
			temprois=self.getIncludeRois()
			IJ.run(self.__image, "Remove Overlay", "")
			o=Overlay()
			for roi in temprois:
				o.addElement(roi)
			self.__image.killRoi()
			self.__image.setOverlay(o)
			self.__image.updateAndDraw()

		def selectAll(event):
			name=event.getSource().getLabel()
			names=name.split("_")
			factor=1
			if names[0] in self.__set1000: factor=0.001
			if names[0] in self.__set10:factor=0.1
			name=event.getSource().getLabel()
			names=name.split("_")
			value=event.getSource().getState()
			self.__ranges[names[0]]=(names[0], self.__slidersDict[names[0]+"_min"].getValue()*factor, self.__slidersDict[names[0]+"_max"].getValue()*factor, value)
			

		gd0=NonBlockingGenericDialog("settings")
		gd0.setResizable(True)
		gd0.setFont(Font("Courrier", 1, 8))
		count=0
		self.__slidersDict={}
		self.__boxesDict={}
		self.__boxesDict.clear()
		self.__slidersDict.clear()
		for i in range(len(self.__namemeasures)):
			gd0.setInsets(-10,0,0)			
			gd0.addSlider("Min"+self.__namemeasures[i], 0, self.__maxmeasures[i], 0)
			gd0.getSliders().get(count).adjustmentValueChanged = valueChanged
			gd0.getSliders().get(count).setName(self.__namemeasures[i]+"_min")
			self.__slidersDict[self.__namemeasures[i]+"_min"]=gd0.getSliders().get(count)			
			gd0.addSlider("Max"+self.__namemeasures[i], 0, self.__maxmeasures[i], self.__maxmeasures[i])
			gd0.getSliders().get(count+1).adjustmentValueChanged = valueChanged
			gd0.getSliders().get(count+1).setName(self.__namemeasures[i]+"_max")
			self.__slidersDict[self.__namemeasures[i]+"_max"]=gd0.getSliders().get(count+1)
			gd0.addCheckbox("all", True)
			gd0.getCheckboxes().get(i).itemStateChanged = selectAll
			gd0.getCheckboxes().get(i).setLabel(self.__namemeasures[i]+"_all")
			self.__boxesDict[self.__namemeasures[i]]=gd0.getCheckboxes().get(i)
			gd0.setInsets(-10,0,0)
			#gd0.addMessage("...........................................................................")

			count=count+2
		
		panel0=Panel()
		#trybutton=Button("Try")
		#trybutton.setActionCommand("DrawOverlay")
		#trybutton.actionPerformed = buttonPressed
		#updatebutton=Button("Update")
		#updatebutton.setActionCommand("Update")
		#updatebutton.actionPerformed = updatepressed
		#resetbutton=Button("Reset")
		#resetbutton.setActionCommand("Reset")
		#resetbutton.actionPerformed = resetpressed
		
		
		#panel0.add(trybutton)
		#panel0.add(updatebutton)
		#panel0.add(resetbutton)
		#gd0.addPanel(panel0)

		gd0.setResizable(True) 
		
		gd0.showDialog()
		#self.__image.setSlice(self.__firstslice)
		#self.__image.updateAndDraw()
			
				
		if gd0.wasOKed():
			#for key in self.__ranges.keys(): IJ.log("Measure : "+str(self.__ranges[key][0])+" min = "+str(self.__ranges[key][1])+" max = "+str(self.__ranges[key][2]))
			return self.__ranges
Beispiel #4
0
            " frames=1 unit=micron pixel_width=2.3140 pixel_height=2.3140 voxel_depth=2.5005 frame=[0.02 sec]"
        )

    # The dialag has to be non-blocking to interact with the data, this dialog will access the controller classes and handle your images
    # The dialag needs to be out of a function to get global variables
    gd = NonBlockingGenericDialog("6D_processor")
    gd.addSlider("C", 1, ch, 1)
    gd.addSlider("Z", 0, zplanes - 1, 0)
    gd.addSlider("T", 0, frames - 1, 0)
    gd.addSlider("L", 0, loops - 1, 0)
    # Make checkboxes for output functions
    gd.addCheckbox("Make subset", False)
    gd.addCheckbox("Split into XYTC", False)
    gd.addCheckbox("Arg. csv BeatSync", False)
    # The UI elements for the above two inputs
    slider1 = gd.getSliders().get(0)  # the only one
    slider2 = gd.getSliders().get(1)
    slider3 = gd.getSliders().get(2)
    slider4 = gd.getSliders().get(3)

    # Set initial position for the two channels
    if ChCheck > 1:
        imp2.setPosition(1, 51, 1)

    #Access controller classes
    previewer1 = ControllerC(imp, slider1)
    previewer2 = ControllerZ(imp, slider2)
    previewer3 = ControllerT(imp, slider3)
    previewer4 = ControllerL(imp, slider4)

    #Get adjustment listeners for scrollbars