def processImage(self, imgdata, filtarray):
		imgarray = imgdata['image']

		looptdiff = time.time()-self.proct0
		self.proct0 = time.time()
		dogarrays = apDog.diffOfGaussParam(filtarray, self.params)
		proctdiff = time.time()-self.proct0
		f = open("dog_image_timing.dat", "a")
		datstr = "%d\t%.5f\t%.5f\n"%(self.stats['count'], proctdiff, looptdiff)
		f.write(datstr)
		f.close()

		apDisplay.printMsg("finished DoG filter")
		peaktree  = apPeaks.findPeaks(imgdata, dogarrays, self.params, maptype="dogmap")
		return peaktree
Example #2
0
        def processImage(self, imgdata, filtarray):
                imgarray = imgdata['image']

                looptdiff = time.time()-self.proct0
                self.proct0 = time.time()
                dogarrays = apDog.diffOfGaussParam(filtarray, self.params)
                proctdiff = time.time()-self.proct0
                f = open("dog_image_timing.dat", "a")
                datstr = "%d\t%.5f\t%.5f\n"%(self.stats['count'], proctdiff, looptdiff)
                f.write(datstr)
                f.close()

                apDisplay.printMsg("finished DoG filter")
                peaktree  = apPeaks.findPeaks(imgdata, dogarrays, self.params, maptype="dogmap")
                return peaktree
 def findPeaks(self, imgdata, ccmaplist):
     return apPeaks.findPeaks(imgdata, ccmaplist, self.params)
        def onRunDogPicker(self, evt):
                apDisplay.printColor("===============\nRunning experimental DoGPicker","cyan")

                ### remove existing maps
                lefts = glob.glob("maps/leftimage.dogmap*.jpg")
                for imgname in lefts:
                        apFile.removeFile(imgname, warn=False)
                rights = glob.glob("maps/rightimage.dogmap*.jpg")
                for imgname in rights:
                        apFile.removeFile(imgname, warn=False)

                pixdiam = self.diam.GetValue()
                sizerange = self.srange.GetValue()
                minthresh = self.minthresh.GetValue()
                maxthresh = self.maxthresh.GetValue()
                peakarea = self.peakarea.GetValue()
                invert = self.partContrast(None)
                maxpeaks = self.maxpeaks.GetValue()
                numslices = self.numslices.GetValue()

                if invert is True:
                        apDisplay.printMsg("Picking dark particles on light backgound, i.e. ice")
                else:
                        apDisplay.printMsg("Picking light particles on dark backgound, i.e. stain")

                self.Close()

                apParam.createDirectory("maps")
                #1. set DoG parameters / hack to use existing pipeline function
                dogparams = {
                        'apix': 1.0, # set to 1 because we are using pixels
                        'bin': 1.0, # set to 1 because we are using pixels
                        'diam': pixdiam, # diameter of particles
                        'sizerange': sizerange, # diameter range of particles
                        'numslices': numslices, # number of slices to perform
                        'kfactor': 1.2, # does not matter

                        'overlapmult': 1.5,
                        'rundir': os.getcwd(),
                        'maxpeaks': maxpeaks,
                        'maxthresh': maxthresh,
                        'thresh': minthresh,
                        'maxsize': peakarea,
                        'peaktype': 'maximum',
                        'background': False,
                        'doubles': False,
                }

                #2a. get image 1
                img1 = numpy.asarray(self.parent.panel1.imagedata, dtype=numpy.float32)
                if invert is True:
                        img1 = apImage.invertImage(img1)

                #3a. run DoG picker on image 1
                dogarrays1 = apDog.diffOfGaussParam(img1, dogparams)

                #4a: threshold & find peaks image 1
                imgdict1 = { 'filename': 'leftimage', 'image': img1, }
                peaktree1 = apPeaks.findPeaks(imgdict1, dogarrays1, dogparams, maptype="dogmap", pikfile=False)

                #5a: insert into self.parent.picks1
                self.parent.picks1 = self.peaktreeToPicks(peaktree1)

                #===

                #2b: get image 2
                img2 = numpy.asarray(self.parent.panel2.imagedata, dtype=numpy.float32)
                if invert is True:
                        img2 = apImage.invertImage(img2)

                #3b. run DoG picker on image 2
                dogarrays2 = apDog.diffOfGaussParam(img2, dogparams)

                #4b: threshold & find peaks image 2
                imgdict2 = { 'filename': 'rightimage', 'image': img2, }
                peaktree2 = apPeaks.findPeaks(imgdict2, dogarrays2, dogparams, maptype="dogmap", pikfile=False)

                #5b: insert into self.parent.picks2
                self.parent.picks2 = self.peaktreeToPicks(peaktree2)

                self.parent.onImportPicks(None, pixdiam, showmaps=True)
                apDisplay.printColor("Finished DoGPicker\n===================","cyan")
Example #5
0
    def onRunDogPicker(self, evt):
        apDisplay.printColor("===============\nRunning experimental DoGPicker",
                             "cyan")

        ### remove existing maps
        lefts = glob.glob("maps/leftimage.dogmap*.jpg")
        for imgname in lefts:
            apFile.removeFile(imgname, warn=False)
        rights = glob.glob("maps/rightimage.dogmap*.jpg")
        for imgname in rights:
            apFile.removeFile(imgname, warn=False)

        pixdiam = self.diam.GetValue()
        sizerange = self.srange.GetValue()
        minthresh = self.minthresh.GetValue()
        maxthresh = self.maxthresh.GetValue()
        peakarea = self.peakarea.GetValue()
        invert = self.partContrast(None)
        maxpeaks = self.maxpeaks.GetValue()
        numslices = self.numslices.GetValue()

        if invert is True:
            apDisplay.printMsg(
                "Picking dark particles on light backgound, i.e. ice")
        else:
            apDisplay.printMsg(
                "Picking light particles on dark backgound, i.e. stain")

        self.Close()

        apParam.createDirectory("maps")
        #1. set DoG parameters / hack to use existing pipeline function
        dogparams = {
            'apix': 1.0,  # set to 1 because we are using pixels
            'bin': 1.0,  # set to 1 because we are using pixels
            'diam': pixdiam,  # diameter of particles
            'sizerange': sizerange,  # diameter range of particles
            'numslices': numslices,  # number of slices to perform
            'kfactor': 1.2,  # does not matter
            'overlapmult': 1.5,
            'rundir': os.getcwd(),
            'maxpeaks': maxpeaks,
            'maxthresh': maxthresh,
            'thresh': minthresh,
            'maxsize': peakarea,
            'peaktype': 'maximum',
            'background': False,
            'doubles': False,
        }

        #2a. get image 1
        img1 = numpy.asarray(self.parent.panel1.imagedata, dtype=numpy.float32)
        if invert is True:
            img1 = apImage.invertImage(img1)

        #3a. run DoG picker on image 1
        dogarrays1 = apDog.diffOfGaussParam(img1, dogparams)

        #4a: threshold & find peaks image 1
        imgdict1 = {
            'filename': 'leftimage',
            'image': img1,
        }
        peaktree1 = apPeaks.findPeaks(imgdict1,
                                      dogarrays1,
                                      dogparams,
                                      maptype="dogmap",
                                      pikfile=False)

        #5a: insert into self.parent.picks1
        self.parent.picks1 = self.peaktreeToPicks(peaktree1)

        #===

        #2b: get image 2
        img2 = numpy.asarray(self.parent.panel2.imagedata, dtype=numpy.float32)
        if invert is True:
            img2 = apImage.invertImage(img2)

        #3b. run DoG picker on image 2
        dogarrays2 = apDog.diffOfGaussParam(img2, dogparams)

        #4b: threshold & find peaks image 2
        imgdict2 = {
            'filename': 'rightimage',
            'image': img2,
        }
        peaktree2 = apPeaks.findPeaks(imgdict2,
                                      dogarrays2,
                                      dogparams,
                                      maptype="dogmap",
                                      pikfile=False)

        #5b: insert into self.parent.picks2
        self.parent.picks2 = self.peaktreeToPicks(peaktree2)

        self.parent.onImportPicks(None, pixdiam, showmaps=True)
        apDisplay.printColor("Finished DoGPicker\n===================", "cyan")
 def findPeaks(self,imgdata,ccmaplist):
         return apPeaks.findPeaks(imgdata, ccmaplist, self.params)