예제 #1
0
    def OnGenShiftmapQuad(self, event):
        from PYME.Analysis.points import twoColour, twoColourPlot
        from PYME.IO.MetaDataHandler import get_camera_roi_origin

        pipeline = self.visFr.pipeline

        vs = pipeline.mdh.voxelsize_nm
        
        roi_x0, roi_y0 = get_camera_roi_origin(pipeline.mdh)
        
        x0 = (roi_x0)*vs[0]
        y0 = (roi_y0)*vs[1]
        
        lx = len(pipeline.filter['x'])
        bbox = None#[0,(pipeline.mdh['Camera.ROIWidth'] + 1)*vs[0], 0,(pipeline.mdh['Camera.ROIHeight'] + 1)*vs[1]]
        dx, dy, spx, spy, good = twoColour.genShiftVectorFieldQ(pipeline.filter['x']+.1*np.random.randn(lx) + x0, pipeline.filter['y']+.1*np.random.randn(lx) + y0, pipeline.filter['fitResults_dx'], pipeline.filter['fitResults_dy'], pipeline.filter['fitError_dx'], pipeline.filter['fitError_dy'], bbox=bbox)
        #twoColourPlot.PlotShiftField(dx, dy, spx, spy)
        twoColourPlot.PlotShiftField2(spx, spy, pipeline.mdh['Splitter.Channel0ROI'][2:], voxelsize=vs)
        twoColourPlot.PlotShiftResiduals(pipeline['x'][good] + x0, pipeline['y'][good] + y0, pipeline['fitResults_dx'][good], pipeline['fitResults_dy'][good], spx, spy)

        from six.moves import cPickle

        defFile = os.path.splitext(os.path.split(self.visFr.GetTitle())[-1])[0] + '.sf'

        fdialog = wx.FileDialog(None, 'Save shift field as ...',
            wildcard='Shift Field file (*.sf)|*.sf', style=wx.FD_SAVE, defaultDir = nameUtils.genShiftFieldDirectoryPath(), defaultFile=defFile)
        succ = fdialog.ShowModal()
        if (succ == wx.ID_OK):
            fpath = fdialog.GetPath()
            #save as a pickle containing the data and voxelsize

            fid = open(fpath, 'wb')
            cPickle.dump((spx, spy), fid, 2)
            fid.close()
예제 #2
0
    def OnShowShiftMap(self, event=None):
        from PYME.Analysis.points import twoColour, twoColourPlot
        mdh = self.pipeline.mdh
        vs = [mdh['voxelsize.x']*1e3, mdh['voxelsize.y']*1e3, mdh['voxelsize.z']*1e3]
        dx = mdh.getEntry('chroma.dx')
        dy = mdh.getEntry('chroma.dy')

        shape = mdh['Splitter.Channel0ROI'][2:]

        twoColourPlot.PlotShiftField2(dx,dy,shape,vs)
예제 #3
0
    def OnGenShiftmapQuadz(self, event):
        from PYME.Analysis.points import twoColour, twoColourPlot

        pipeline = self.visFr.pipeline

        vs = [
            pipeline.mdh['voxelsize.x'] * 1e3,
            pipeline.mdh['voxelsize.y'] * 1e3, 200.
        ]

        z0 = (pipeline['z'] * pipeline['A']).sum() / pipeline['A'].sum()

        lx = len(pipeline.filter['x'])
        bbox = None  #[0,(pipeline.mdh['Camera.ROIWidth'] + 1)*vs[0], 0,(pipeline.mdh['Camera.ROIHeight'] + 1)*vs[1]]
        dx, dy, spx, spy, good = twoColour.genShiftVectorFieldQz(
            pipeline.filter['x'] + .1 * pylab.randn(lx),
            pipeline.filter['y'] + .1 * pylab.randn(lx),
            pipeline.filter['z'] - z0,
            pipeline.filter['fitResults_dx'],
            pipeline.filter['fitResults_dy'],
            pipeline.filter['fitError_dx'],
            pipeline.filter['fitError_dy'],
            bbox=bbox)
        #twoColourPlot.PlotShiftField(dx, dy, spx, spy)
        twoColourPlot.PlotShiftField2(spx,
                                      spy,
                                      pipeline.mdh['Splitter.Channel0ROI'][2:],
                                      voxelsize=vs)
        twoColourPlot.PlotShiftResiduals(pipeline['x'][good],
                                         pipeline['y'][good],
                                         pipeline['fitResults_dx'][good],
                                         pipeline['fitResults_dy'][good], spx,
                                         spy, pipeline.filter['z'][good] - z0)

        from six.moves import cPickle

        defFile = os.path.splitext(os.path.split(
            self.visFr.GetTitle())[-1])[0] + '.sf'

        fdialog = wx.FileDialog(
            None,
            'Save shift field as ...',
            wildcard='Shift Field file (*.sf)|*.sf',
            style=wx.FD_SAVE,
            defaultDir=nameUtils.genShiftFieldDirectoryPath(),
            defaultFile=defFile)
        succ = fdialog.ShowModal()
        if (succ == wx.ID_OK):
            fpath = fdialog.GetPath()
            #save as a pickle containing the data and voxelsize

            fid = open(fpath, 'wb')
            cPickle.dump((spx, spy), fid, 2)
            fid.close()
예제 #4
0
    def _loadSF(self, filename):
        self.mdh = MetaDataHandler.NestedClassMDHandler(MetaData.BareBones)
        self.mdh.setEntry('chroma.ShiftFilename', filename)
        dx, dy = numpy.load(filename)
        self.mdh.setEntry('chroma.dx', dx)
        self.mdh.setEntry('chroma.dy', dy)

        #Completely guessing dimensions as it it not logged in the file
        x = numpy.linspace(0, 256 * 70, 256)
        y = numpy.linspace(0, 512 * 70, 512)
        xs, ys = numpy.meshgrid(x, y)
        self.data = [
            dx.ev(xs.ravel(), ys.ravel()).reshape(xs.shape)[::-1, :].T,
            dy.ev(xs.ravel(), ys.ravel()).reshape(xs.shape)[::-1, :].T
        ]

        from PYME.Analysis.points import twoColourPlot
        twoColourPlot.PlotShiftField2(dx, dy, [256, 512])

        self.mode = 'default'