Ejemplo n.º 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()
Ejemplo n.º 2
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()