當前位置: 首頁>>代碼示例>>Python>>正文


Python RoiManager.add方法代碼示例

本文整理匯總了Python中ij.plugin.frame.RoiManager.add方法的典型用法代碼示例。如果您正苦於以下問題:Python RoiManager.add方法的具體用法?Python RoiManager.add怎麽用?Python RoiManager.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ij.plugin.frame.RoiManager的用法示例。


在下文中一共展示了RoiManager.add方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: OvalRoi

# 需要導入模塊: from ij.plugin.frame import RoiManager [as 別名]
# 或者: from ij.plugin.frame.RoiManager import add [as 別名]
                continue
            idx = tempvar.index(max(tempvar))
            start = frame[0]
            metaphase = frame[idx+3]
            
            if (division - start > 15 and division - start < 100):
                if start>0:
                    for spot in sortedTrack:

                        # Fetch spot features directly from spot.
                        x=spot.getFeature('POSITION_X')
                        y=spot.getFeature('POSITION_Y')
                        t=spot.getFeature('FRAME')
                        roi2 = OvalRoi(x/dx - (6*dx), y/dy - (6*dy), 12, 12)
                        roi2.setPosition(int(t))
                        rm.add(imp, roi2, nextRoi)
                        nextRoi = nextRoi+1
                    resultstable.setValue("IMAGE_NAME", trackrowNumber, filename)
                    resultstable.setValue("TRACK_ID", trackrowNumber, id)
                    resultstable.setValue("START", trackrowNumber, start)
                    resultstable.setValue("METAPHASE", trackrowNumber, metaphase)
                    resultstable.setValue("END", trackrowNumber, division)

                    trackrowNumber = trackrowNumber + 1
#                    plot = Plot(str(id), "slice", "mean", frame, var) 
#                    plot.show()
#                    break

#        imp.close()
resultstable.show("Results")     
開發者ID:bramalingam,項目名稱:Omero-Imagej-Scripts,代碼行數:32,代碼來源:Mitotic_Tracker_Final.py

示例2: StackCells

# 需要導入模塊: from ij.plugin.frame import RoiManager [as 別名]
# 或者: from ij.plugin.frame.RoiManager import add [as 別名]
class StackCells(swing.JFrame):
	def __init__(self): 
		swing.JFrame.__init__(self, title="Stack Cells")
		self.__impD = IJ.getImage()
		self.setDefaultCloseOperation(swing.JFrame.DISPOSE_ON_CLOSE)
		self.__n=0
		self.__widthl = "11"
		self.__iplist = []
		self.__init = False
		self.__initDIA = False
		self.__initFLUO = False
		self.__skip = False
		self.__avg = True
		self.__mosa = True
		self.__maxfinder = True
		self.__appmedian = True
		self.__fire = True
		self.__align = True
		self.__alignC = False
		self.__enlarge = True
		self.__measures = True
		self.__sens = []
		self.__listrois = []
		self.__cellsrois = []
		self.__Cutoff = 0
		self.__labels = []
		self.__maxraf = 100.0
		self.__minraf = 0.0
		self.__conEllipses = False

		self.__dictCells = {}
		
		self.__rm = RoiManager.getInstance()
		if (self.__rm==None): self.__rm = RoiManager()
		self.run()
		
	def run(self) :
		

		self.size=(1100, 400)
		self.contentPane.layout = awt.BorderLayout()
		self.__display = swing.JTextField(preferredSize=(400, 30), horizontalAlignment=swing.SwingConstants.LEFT)
		self.__setDisplay()
		line = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)
		northpanel1=swing.JPanel(awt.FlowLayout(awt.FlowLayout.LEFT))
		northpanel1.setBorder(line)
		northpanel1.add(self.__display)
		new = swing.JButton("New", size=(100, 70), actionPerformed=self.__new)
		northpanel1.add(new)
		add = swing.JButton("Add", size=(100, 70), actionPerformed=self.__add)
		northpanel1.add(add)
		roiman = swing.JButton("Add Roi manager", size=(100, 70), actionPerformed= self.__addroi)
		northpanel1.add(roiman)
		end = swing.JButton("End", size=(100, 70), actionPerformed= self.__end)
		northpanel1.add(end)

		#grid = awt.GridLayout()
		#grid.setRows(2)
		#northpanel=swing.JPanel(grid)
		#northpanel.add(northpanel1)

		#northpanel2=swing.JPanel(awt.FlowLayout(awt.FlowLayout.LEFT))

		grid0 = awt.GridLayout()
		grid0.setRows(6)
		northpanel2=swing.JPanel(grid0)
		
		northpanel2.setBorder(line)
		label=swing.JLabel("Label2")
		label.setText("Line width ?")
		northpanel2.add(label)
		self.__display2 = swing.JTextField(preferredSize=(50, 30), horizontalAlignment=swing.SwingConstants.LEFT)
		self.__display2.text = "11"
		northpanel2.add(self.__display2)

		label=swing.JLabel("Label3")
		label.setText("Noise for peaks ?")
		northpanel2.add(label)
		self.__display3 = swing.JTextField(preferredSize=(50, 30), horizontalAlignment=swing.SwingConstants.LEFT)
		self.__display3.text = "100"
		northpanel2.add(self.__display3)

		label=swing.JLabel("Label4")
		label.setText("Fluo threshold ?")
		northpanel2.add(label)
		self.__display4 = swing.JTextField(preferredSize=(50, 30), horizontalAlignment=swing.SwingConstants.LEFT)
		self.__display4.text = "170"
		northpanel2.add(self.__display4)
		
		#northpanel3=swing.JPanel(awt.FlowLayout(awt.FlowLayout.LEFT))
		#northpanel3.setBorder(line)

		label=swing.JLabel("Label5")
		label.setText("Min of length ?")
		northpanel2.add(label)
		self.__display5 = swing.JTextField(preferredSize=(50, 30), horizontalAlignment=swing.SwingConstants.LEFT)
		self.__display5.text = "50"
		northpanel2.add(self.__display5)

		label=swing.JLabel("Label6")
#.........這裏部分代碼省略.........
開發者ID:leec13,項目名稱:MorphoBactDev,代碼行數:103,代碼來源:Stack_Cells.py

示例3: RoiManager

# 需要導入模塊: from ij.plugin.frame import RoiManager [as 別名]
# 或者: from ij.plugin.frame.RoiManager import add [as 別名]
		manager = RoiManager()
	RoiManager(False) #sho the roi manager window, wierd interface
	i = 1
	for currPoint in pointList:
		#print "point " + str(i)
		x, y, z = currPoint.split(",")
		
		#composite is interleaved with ch1/ch2
		#if doComposite==1:
		#	z *= 2
		
		#a point roi (This seems to be in pixels???)
		pROI = PointRoi(int(x), int(y), imp1)
		
		imp1.setSliceWithoutUpdate(int(z))
		manager.add(imp1, pROI, int(z)) #add WITH slice, I want the pROI to be a 3D point
		#manager.addRoi(pROI) #add WITHOUT slice
		i += 1
	print "added " + str(i) + " pnts to roi manager"
	
if do3d==1:
	#see: http://www.ini.uzh.ch/~acardona/fiji-tutorial/
	ps = [] #list of Point3f (pointList)
	cps = [] #list of Point3f of connection points (cPointList)
	lps = [] #list of backbone centerline points (lPointList)
	
	cell_diameter = 3 #right now in pixels, eventually in um
	
	#print "Setting Spine Points..."
	for currPoint in pointList:
		x, y, z = currPoint.split(",")
開發者ID:cudmore,項目名稱:bob-fiji-plugins,代碼行數:33,代碼來源:bMergeChannelsv2_.py

示例4: segmentation

# 需要導入模塊: from ij.plugin.frame import RoiManager [as 別名]
# 或者: from ij.plugin.frame.RoiManager import add [as 別名]
def segmentation(imp, spot_data, channel, diameter_init, ES_tolerance, ES_area_max, ES_ctrl_pts, ES_iteration, repeat_max):
    # Open files
    cal = imp.getCalibration()
    manager = RoiManager.getInstance()
    if manager is None:
        manager = RoiManager()
    # Prepare log files for output
    options = IS.MEDIAN | IS.AREA | IS.MIN_MAX | IS.CENTROID | IS.PERIMETER | IS.ELLIPSE | IS.SKEWNESS
    convergence = []
    Sintensity = []
    for spot in spot_data:
        repeat = 0
        flag = False
        spotID = int(spot[0])
        Xcenter = (float(spot[1]) / cal.pixelWidth)
        Ycenter = (float(spot[2]) / cal.pixelHeight)
        Quality = float(spot[3])
        diameter_init = float(spot[4] / cal.pixelWidth) * 2.0
        while True:
            manager = RoiManager.getInstance()
            if manager is None:
                manager = RoiManager()
            Xcurrent = int(Xcenter - diameter_init / 2.0)
            Ycurrent = int(Ycenter - diameter_init / 2.0)
            Dcurrent1 = int(diameter_init * (1.2 - repeat / 10.0))
            Dcurrent2 = int(diameter_init * (0.8 + repeat / 10.0))
            roi = OvalRoi(Xcurrent, Ycurrent, Dcurrent1, Dcurrent2)
            imp.setPosition(channel)
            imp.setRoi(roi)
            Esnake_options1 = "target_brightness=Bright control_points=" + \
                str(ES_ctrl_pts) + " gaussian_blur=0 "
            Esnake_options2 = "energy_type=Contour alpha=2.0E-5 max_iterations=" + \
                str(ES_iteration) + " immortal=false"
            IJ.run(imp, "E-Snake", Esnake_options1 + Esnake_options2)
            roi_snake = manager.getRoisAsArray()
            roi_ind = len(roi_snake) - 1
            stats = IS.getStatistics(
                imp.getProcessor(), options, imp.getCalibration())
            perimeter = roi_snake[roi_ind].getLength() * cal.pixelWidth
            circularity = 4.0 * 3.1417 * (stats.area / (perimeter * perimeter))
            if stats.area > 17.0 and stats.area < ES_area_max and stats.skewness < -0.01 and circularity > 0.01 and stats.minor > 2.0 and boundaries(Xcenter, Ycenter, stats.xCentroid / cal.pixelWidth, stats.yCentroid / cal.pixelHeight, ES_tolerance):
                Sintensity = stats.median
                convergence.append(True)
                break
            if stats.median > 6000 and stats.area > 17.0 and stats.area < ES_area_max:
                Sintensity = stats.median
                convergence.append(True)
                break
            elif repeat > repeat_max:
                manager.select(imp, roi_ind)
                manager.runCommand(imp, 'Delete')
                roi = OvalRoi(Xcenter + 1.0 - diameter_init / 2.0, Ycenter +
                              1.0 - diameter_init / 2.0, diameter_init, diameter_init)
                imp.setRoi(roi)
                manager.add(imp, roi, spotID)
                roi_snake.append(roi)
                stats = IS.getStatistics(
                    imp.getProcessor(), options, imp.getCalibration())
                Sintensity = stats.median
                convergence.append(False)
                break
            else:
                IJ.log('Area=' + str(stats.area) + '  Skewness=' + str(stats.skewness) +
                       ' circularity=' + str(circularity) + ' Minor=' + str(stats.minor))
                manager.select(imp, roi_ind)
                manager.runCommand(imp, 'Delete')
                repeat += 1
        # End Spot-segmentation
    # End all Spots-segmentation
    manager.runCommand(imp, 'Show All')
    imp.setPosition(channel)
    color = imp.createImagePlus()
    ip = imp.getProcessor().duplicate()
    color.setProcessor("segmentation" + str(channel), ip)
    color.show()
    IJ.selectWindow("segmentation" + str(channel))
    manager.moveRoisToOverlay(color)
    spot_optimal = manager.getRoisAsArray()
    manager.reset()
    for i in xrange(0, len(spot_optimal)):
        spot = spot_optimal[i]
        spot.setStrokeWidth(2)
        if convergence[i]:
            spot.setStrokeColor(Color.GREEN)
        else:
            spot.setStrokeColor(Color.MAGENTA)
        imp.setRoi(spot)
        manager.add(imp, spot, i)
    manager.runCommand(imp, 'Show All')
    imp.setPosition(channel)
開發者ID:jpabbuehl,項目名稱:CSC_submission,代碼行數:92,代碼來源:processing_exemple.py

示例5: channel_segmentation

# 需要導入模塊: from ij.plugin.frame import RoiManager [as 別名]
# 或者: from ij.plugin.frame.RoiManager import add [as 別名]
def channel_segmentation(infile, diameter, tolerance, repeat_max, Zrepeat=10):
    # ROI optimization by Esnake optimisation
    default_options = "stack_order=XYCZT color_mode=Grayscale view=Hyperstack"
    IJ.run("Bio-Formats Importer", default_options + " open=[" + infile + "]")
    imp = IJ.getImage()
    cal = imp.getCalibration()
    channels = [i for i in xrange(1, imp.getNChannels() + 1)]

    log = filename(infile)
    log = re.sub('.ids', '.csv', log)
    XZdrift, YZdrift = retrieve_Zdrift(log)
    XZpt = [i * imp.getWidth() / Zrepeat for i in xrange(1, Zrepeat - 1)]
    YZpt = [i * imp.getHeight() / Zrepeat for i in xrange(1, Zrepeat - 1)]

    # Prepare head output file
    for ch in channels:
        csv_name = 'ch' + str(ch) + log
        with open(os.path.join(folder6, csv_name), 'wb') as outfile:
            SegLog = csv.writer(outfile, delimiter=',')
            SegLog.writerow(['spotID', 'Xpos', 'Ypos', 'Zpos',
                             'Quality', 'area', 'intensity', 'min', 'max', 'std'])

    # Retrieve seeds from SpotDetector
    options = IS.MEDIAN | IS.AREA | IS.MIN_MAX | IS.CENTROID
    spots = retrieve_seeds(log)
    for ch in channels:
        for spot in spots:
            repeat = 0
            # Spots positions are given according to calibration, need to
            # convert it to pixel coordinates
            spotID = int(spot[0])
            Xcenter = int(float(spot[2]) / cal.pixelWidth)
            Ycenter = int(float(spot[3]) / cal.pixelHeight)
            Zcenter = float(spot[4]) / cal.pixelDepth
            Quality = float(spot[5])
            # find closest grid location in Zdrift matrix
            Xpt = min(range(len(XZpt)), key=lambda i: abs(XZpt[i] - Xcenter))
            Ypt = min(range(len(YZpt)), key=lambda i: abs(YZpt[i] - Ycenter))
            # Calculate Z position according to SpotZ, calibration and
            # channel-specific Zdrift #
            Zshift = median([float(XZdrift[Xpt][ch - 1]),
                             float(YZdrift[Ypt][ch - 1])]) / cal.pixelDepth
            correctZ = int(Zcenter - Zshift)
            imp.setPosition(ch, correctZ, 1)
            imp.getProcessor().setMinAndMax(0, 3000)
            while True:
                manager = RoiManager.getInstance()
                if manager is None:
                    manager = RoiManager()
                roi = OvalRoi(Xcenter - diameter * (1.0 + repeat / 10.0) / 2.0, Ycenter - diameter * (
                    1.0 + repeat / 10.0) / 2.0, diameter * (1.0 + repeat / 10.0), diameter * (1.0 + repeat / 10.0))
                imp.setRoi(roi)
                IJ.run(imp, "E-Snake", "target_brightness=Bright control_points=3 gaussian_blur=0 energy_type=Mixture alpha=2.0E-5 max_iterations=20 immortal=false")
                roi_snake = manager.getRoisAsArray()[0]
                imp.setRoi(roi_snake)
                stats = IS.getStatistics(
                    imp.getProcessor(), options, imp.getCalibration())
                manager.reset()
                if stats.area > 20.0 and stats.area < 150.0 and boundaries(Xcenter, Ycenter, stats.xCentroid / cal.pixelWidth, stats.yCentroid / cal.pixelHeight, tolerance):
                    Sarea = stats.area
                    Sintensity = stats.median
                    Smin = stats.min
                    Smax = stats.max
                    Sstd = stats.stdDev
                    break
                elif repeat > repeat_max:
                    roi = OvalRoi(Xcenter - diameter / 2.0,
                                  Ycenter - diameter / 2.0, diameter, diameter)
                    imp.setRoi(roi)
                    manager.add(imp, roi, i)
                    stats = IS.getStatistics(
                        imp.getProcessor(), options, imp.getCalibration())
                    Sarea = stats.area
                    Sintensity = stats.median
                    Smin = stats.min
                    Smax = stats.max
                    Sstd = stats.stdDev
                    break
                else:
                    repeat += 1
            # Save results
            csv_name = 'ch' + str(ch) + log
            with open(os.path.join(folder6, csv_name), 'ab') as outfile:
                SegLog = csv.writer(outfile, delimiter=',')
                SegLog.writerow([spotID, Xcenter, Ycenter, correctZ,
                                 Quality, Sarea, Sintensity, Smin, Smax, Sstd])
            # End spot optimization
        # End spots
    # End channels
    IJ.selectWindow(filename(infile))
    IJ.run("Close")
開發者ID:jpabbuehl,項目名稱:CSC_submission,代碼行數:93,代碼來源:lightsheet_data_processing.py


注:本文中的ij.plugin.frame.RoiManager.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。