Exemplo n.º 1
0
    def OnFindObjects(self, event):
        threshold = float(self.tThreshold.GetValue())
        chnum = self.chChannel.GetSelection()

        from PYME.Analysis.ofind3d import ObjectIdentifier

        if not 'ofd' in dir(self) or not self.ofd.chnum == chnum:
            #create an object identifier
            self.ofd = ObjectIdentifier(self.image.data[:,:,:, chnum])
            self.ofd.chnum = chnum

        #and identify objects ...
        if self.chMethod.GetSelection() == 1: #don't detect objects in poisson noise
            fudgeFactor = 1 #to account for the fact that the blurring etc... in ofind doesn't preserve intensities - at the moment completely arbitrary so a threshold setting of 1 results in reasonable detection.
            threshold =  (numpy.sqrt(self.image.mdh.Camera.ReadNoise**2 + numpy.maximum(self.image.mdh.Camera.ElectronsPerCount*(self.image.mdh.Camera.NoiseFactor**2)*(self.image.data.astype('f') - self.image.mdh.Camera.ADOffset)*self.image.mdh.Camera.TrueEMGain, 1))/self.image.mdh.Camera.ElectronsPerCount)*fudgeFactor*threshold
            self.ofd.FindObjects(threshold, 0)
        elif self.chMethod.GetSelection() == 2:
            bs = float(self.tBlurSize.GetValue())
            self.ofd.FindObjects(threshold, blurRadius = bs, blurRadiusZ = bs)
        else:
            self.ofd.FindObjects(threshold,0)

        self.dsviewer.view.points = numpy.array([[p.x, p.y, p.z] for p in self.ofd])

        self.objPosRA = numpy.rec.fromrecords(self.dsviewer.view.points, names='x,y,z')

        if self.vObjPos == None:
            self.vObjPos = recArrayView.recArrayPanel(self.dsviewer, self.objPosRA)
            self.dsviewer.AddPage(self.vObjPos, caption='Object Positions')
        else:
            self.vObjPos.grid.SetData(self.objPosRA)

        self.dsviewer.update()
Exemplo n.º 2
0
    def OnObjMeasure(self, event):
        om = self.pipeline.measureObjects()
        if self.rav == None:
            self.rav = recArrayView.recArrayPanel(self, om)
            self.AddPage(self.rav, 'Measurements')
        else:
            self.rav.grid.SetData(om)

        self.cBlobColour.Clear()
        self.cBlobColour.Append('Index')

        for n in om.dtype.names:
            self.cBlobColour.Append(n)

        self.RefreshView()
Exemplo n.º 3
0
    def OnObjMeasure(self, event):
        om = self.pipeline.measureObjects()
        if self.rav == None:
            self.rav = recArrayView.recArrayPanel(self, om)
            self.AddPage(self.rav, 'Measurements')
        else:
            self.rav.grid.SetData(om)

        self.cBlobColour.Clear()
        self.cBlobColour.Append('Index')

        for n in om.dtype.names:
            self.cBlobColour.Append(n)

        self.RefreshView()
Exemplo n.º 4
0
    def OnFindObjects(self, event):
        threshold = float(self.tThreshold.GetValue())
        chnum = self.chChannel.GetSelection()

        from PYME.Analysis.ofind3d import ObjectIdentifier

        if not 'ofd' in dir(self) or not self.ofd.chnum == chnum:
            #create an object identifier
            self.ofd = ObjectIdentifier(self.image.data[:, :, :, chnum])
            self.ofd.chnum = chnum

        #and identify objects ...
        if self.chMethod.GetSelection(
        ) == 1:  #don't detect objects in poisson noise
            fudgeFactor = 1  #to account for the fact that the blurring etc... in ofind doesn't preserve intensities - at the moment completely arbitrary so a threshold setting of 1 results in reasonable detection.
            threshold = (
                numpy.sqrt(self.image.mdh.Camera.ReadNoise**2 + numpy.maximum(
                    self.image.mdh.Camera.ElectronsPerCount *
                    (self.image.mdh.Camera.NoiseFactor**2) *
                    (self.image.data.astype('f') - self.image.mdh.Camera.
                     ADOffset) * self.image.mdh.Camera.TrueEMGain, 1)) /
                self.image.mdh.Camera.ElectronsPerCount
            ) * fudgeFactor * threshold
            self.ofd.FindObjects(threshold, 0)
        elif self.chMethod.GetSelection() == 2:
            bs = float(self.tBlurSize.GetValue())
            self.ofd.FindObjects(threshold, blurRadius=bs, blurRadiusZ=bs)
        else:
            self.ofd.FindObjects(threshold, 0)

        self.dsviewer.view.points = numpy.array([[p.x, p.y, p.z]
                                                 for p in self.ofd])

        self.objPosRA = numpy.rec.fromrecords(self.dsviewer.view.points,
                                              names='x,y,z')

        if self.vObjPos == None:
            self.vObjPos = recArrayView.recArrayPanel(self.dsviewer,
                                                      self.objPosRA)
            self.dsviewer.AddPage(self.vObjPos, caption='Object Positions')
        else:
            self.vObjPos.grid.SetData(self.objPosRA)

        self.dsviewer.update()
Exemplo n.º 5
0
    def OnFitObjects(self, event):
        import PYME.Analysis.FitFactories.Gauss3DFitR as fitMod
        from PYME.Acquire import MetaDataHandler
        chnum = self.chChannel.GetSelection()

        mdh = MetaDataHandler.NestedClassMDHandler(self.image.mdh)
        mdh['tIndex'] = 0

        self.objFitRes = {}

        for chnum in range(self.image.data.shape[3]):
            data = self.image.data[:, :, :, chnum]

            if not 'Camera.ADOffset' in mdh.getEntryNames():
                mdh['Camera.ADOffset'] = data.min()

            fitFac = fitMod.FitFactory(data, mdh)

            self.objFitRes[chnum] = numpy.empty(len(self.ofd),
                                                fitMod.FitResultsDType)
            for i in range(len(self.ofd)):
                p = self.ofd[i]
                #try:
                self.objFitRes[chnum][i] = fitFac.FromPoint(
                    round(p.x), round(p.y), round(p.z), 8)
                #except:
                #    pass

            #if self.nObjFit == None:

            vObjFit = recArrayView.recArrayPanel(
                self.dsviewer, self.objFitRes[chnum]['fitResults'])
            self.dsviewer.AddPage(vObjFit,
                                  caption='Fitted Positions %d - %d' %
                                  (chnum, self.nObjFit))
        self.nObjFit += 1
        #else:
        #    self.vObjFit.grid.SetData(self.objFitRes['fitResults'])

        self.dsviewer.update()
Exemplo n.º 6
0
    def OnFitObjects(self, event):
        import PYME.Analysis.FitFactories.Gauss3DFitR as fitMod
        from PYME.Acquire import MetaDataHandler
        chnum = self.chChannel.GetSelection()
        
        mdh = MetaDataHandler.NestedClassMDHandler(self.image.mdh)
        mdh['tIndex'] = 0
        
        self.objFitRes = {}
        
        for chnum in range(self.image.data.shape[3]):
            data = self.image.data[:,:,:,chnum]  
            
            if not 'Camera.ADOffset' in mdh.getEntryNames():
                mdh['Camera.ADOffset'] = data.min()
    
            fitFac = fitMod.FitFactory(data, mdh)
    
            self.objFitRes[chnum] = numpy.empty(len(self.ofd), fitMod.FitResultsDType)
            for i in range(len(self.ofd)):
                p = self.ofd[i]
                #try:
                self.objFitRes[chnum][i] = fitFac.FromPoint(round(p.x), round(p.y), round(p.z), 8)
                #except:
                #    pass
    
    
            #if self.nObjFit == None:
                
                
            vObjFit = recArrayView.recArrayPanel(self.dsviewer, self.objFitRes[chnum]['fitResults'])
            self.dsviewer.AddPage(vObjFit, caption = 'Fitted Positions %d - %d' % (chnum, self.nObjFit))
        self.nObjFit += 1
        #else:
        #    self.vObjFit.grid.SetData(self.objFitRes['fitResults'])

        self.dsviewer.update()