Ejemplo n.º 1
0
    def OnSpecAdd(self, event):
        #key = self.lFluorSpecies.GetItem(self.currentFilterItem).GetText()

        dlg = specAddDialog(self)

        ret = dlg.ShowModal()

        if ret == wx.ID_OK:
            val = float(dlg.tVal.GetValue())

            key = dlg.tKey.GetValue().encode()

            if key == "":
                return

            self.pipeline.fluorSpecies[key] = val

            ind = self.lFluorSpecies.InsertStringItem(sys.maxint, key)
            self.lFluorSpecies.SetStringItem(ind,1, '%3.2f' % val)
            #print val, (255*numpy.array(cm.gist_rainbow(val)))[:3]
            self.lFluorSpecies.SetItemTextColour(ind, wx.Colour(*((128*numpy.array(cm.jet_r(val)))[:3])))

            #self.visFr.mapping.setMapping('p_%s' % key, 'exp(-(%f*A - fitResults_Ag)**2/(2*fitError_Ag**2))*exp(-(%f*A - fitResults_Ar)**2/(2*fitError_Ar**2))' % (1- val, val))
            #self.visFr.mapping.setMapping('p_%s' % key, 'exp(-(%f - gFrac)**2/(2*error_gFrac**2))' % (val))
            #self.pipeline.mapping.setMapping('p_%s' % key, '(1.0/(ColourNorm*2*numpy.pi*fitError_Ag*fitError_Ar))*exp(-(fitResults_Ag - %f*A)**2/(2*fitError_Ag**2) - (fitResults_Ar - %f*A)**2/(2*fitError_Ar**2))' % (val, 1-val))
            self.mapping.setMapping('p_%s' % key, 'exp(-(%f - gFrac)**2/(2*error_gFrac**2))/(error_gFrac*sqrt(2*numpy.pi))' % val)

            self.visFr.UpdatePointColourChoices()
            self.visFr.colourFilterPane.UpdateColourFilterChoices()
            

        dlg.Destroy()
        self.refresh()
Ejemplo n.º 2
0
    def SpecFromMetadata(self, mdh):
        labels = mdh.getEntry('Sample.Labelling')

        structures = []
        for structure, dye in labels:
            if structure in structures:  #duplicate structure
                structure += ' A'
            structures.append(structure)
            ratio = dyeRatios.getRatio(dye, mdh)

            if not ratio is None:
                self.pipeline.colour_mapper.species_ratios[structure] = float(
                    ratio)
                ind = self.lFluorSpecies.InsertStringItem(
                    UI_MAXSIZE, structure)
                self.lFluorSpecies.SetStringItem(ind, 1, '%3.3f' % ratio)
                self.lFluorSpecies.SetItemTextColour(
                    ind,
                    wx.Colour(*((128 * numpy.array(cm.jet_r(ratio)))[:3])))

                #self.visFr.mapping.setMapping('p_%s' % key, 'exp(-(%f*A - fitResults_Ag)**2/(2*fitError_Ag**2))*exp(-(%f*A - fitResults_Ar)**2/(2*fitError_Ar**2))' % (1- val, val))
                #self.visFr.mapping.setMapping('p_%s' % structure, 'exp(-(%f - gFrac)**2/(2*error_gFrac**2))' % (ratio))
                #self.pipeline.mapping.setMapping('p_%s' % structure, '(1.0/(ColourNorm*2*numpy.pi*fitError_Ag*fitError_Ar))*exp(-(fitResults_Ag - %f*A)**2/(2*fitError_Ag**2) - (fitResults_Ar - %f*A)**2/(2*fitError_Ar**2))' % (ratio, 1-ratio))
                #self.pipeline.mapping.setMapping('p_%s' % structure, 'exp(-(%f - gFrac)**2/(2*error_gFrac**2))/(error_gFrac*sqrt(2*numpy.pi))' % ratio)

        self.pipeline.Rebuild()

        self.visFr.UpdatePointColourChoices()
        self.visFr.colourFilterPane.UpdateColourFilterChoices()

        self.refresh()
Ejemplo n.º 3
0
    def OnSpecGuess(self, event):
        import scipy.cluster

        #count number of peaks in gFrac histogram
        n = (numpy.diff(
            numpy.sign(
                numpy.diff(
                    numpy.histogram(self.pipeline.filter['gFrac'],
                                    numpy.linspace(0, 1, 20))[0]))) < 0).sum()

        guesses = scipy.cluster.vq.kmeans(self.pipeline.filter['gFrac'], n)[0]

        for g, i in zip(guesses, range(n)):
            key = '%c' % (65 + i)
            self.pipeline.colour_mapper.species_ratios[key] = float(g)
            ind = self.lFluorSpecies.InsertStringItem(UI_MAXSIZE, key)
            self.lFluorSpecies.SetStringItem(ind, 1, '%3.3f' % g)
            self.lFluorSpecies.SetItemTextColour(
                ind, wx.Colour(*((128 * numpy.array(cm.jet_r(g)))[:3])))

            #self.visFr.mapping.setMapping('p_%s' % key, 'exp(-(%f*A - fitResults_Ag)**2/(2*fitError_Ag**2))*exp(-(%f*A - fitResults_Ar)**2/(2*fitError_Ar**2))' % (1- val, val))
            #self.visFr.mapping.setMapping('p_%s' % key, 'exp(-(%f - gFrac)**2/(2*error_gFrac**2))' % (g))
            #self.pipeline.mapping.setMapping('p_%s' % key, '(1.0/(ColourNorm*2*numpy.pi*fitError_Ag*fitError_Ar))*exp(-(fitResults_Ag - %f*A)**2/(2*fitError_Ag**2) - (fitResults_Ar - %f*A)**2/(2*fitError_Ar**2))' % (val, 1-val))
            #self.pipeline.mapping.setMapping('p_%s' % key, 'exp(-(%f - gFrac)**2/(2*error_gFrac**2))/(error_gFrac*sqrt(2*numpy.pi))' % val)

        self.pipeline.Rebuild()

        try:
            self.visFr.UpdatePointColourChoices()

            self.visFr.colourFilterPane.UpdateColourFilterChoices()
        except AttributeError:
            pass

        self.refresh()
Ejemplo n.º 4
0
    def OnSpecChange(self, event=None):
        it = self.lFluorSpecies.GetItem(event.m_itemIndex)

        val = float(event.m_item.GetText())

        col = event.GetColumn()

        if col == 1:  #frac
            self.pipeline.fluorSpecies[str(it.GetText())] = val
            self.lFluorSpecies.SetItemTextColour(
                event.m_itemIndex,
                wx.Colour(*((128 * numpy.array(cm.jet_r(val)))[:3])))

            #self.visFr.mapping.setMapping('p_%s' % it.GetText(), 'exp(-(%f*A - fitResults_Ag)**2/(4*fitError_Ag**2 + 2*fitError_Ar**2))*exp(-(%f*A - fitResults_Ar)**2/(2*fitError_Ag**2 +4*fitError_Ar**2))' % (1- val, val))
            #self.visFr.mapping.setMapping('p_%s' % it.GetText(), 'exp(-(%f - gFrac)**2/(2*error_gFrac**2))' % (val))
            #self.pipeline.mapping.setMapping('p_%s' % it.GetText(), '(1.0/(ColourNorm*2*numpy.pi*fitError_Ag*fitError_Ar))*exp(-(fitResults_Ag - %f*A)**2/(2*fitError_Ag**2) - (fitResults_Ar - %f*A)**2/(2*fitError_Ar**2))' % (val, 1-val))
            #self.pipeline.mapping.setMapping('p_%s' % it.GetText(), 'exp(-(%f - gFrac)**2/(2*error_gFrac**2))/(error_gFrac*sqrt(2*numpy.pi))' % val)

            self.pipeline.Rebuild()

            self.refresh()
        else:  #shift
            axis = ['x', 'y', 'z'][col - 3]
            specName = str(it.GetText())
            if not specName in self.pipeline.chromaticShifts.keys():
                self.pipeline.chromaticShifts[specName] = {}

            self.pipeline.chromaticShifts[specName][axis] = val
            self.visFr.RefreshView()
Ejemplo n.º 5
0
    def refresh(self):
        if not self.IsShown():
            return

        self.colPlotPan.draw()

        self.lFluorSpecies.DeleteAllItems()

        for key in self.pipeline.colour_mapper.species_ratios.keys():
            ind = self.lFluorSpecies.InsertStringItem(UI_MAXSIZE, key)

            ratio = self.pipeline.colour_mapper.species_ratios[key]
            self.lFluorSpecies.SetStringItem(ind, 1, '%3.3f' % ratio)
            self.lFluorSpecies.SetItemTextColour(
                ind, wx.Colour(*((128 * numpy.array(cm.jet_r(ratio)))[:3])))

            num_dyes = sum(self.pipeline.colourFilter._index(key))

            self.lFluorSpecies.SetStringItem(ind, 2, '%d' % num_dyes)
Ejemplo n.º 6
0
    def OnSpecGuess(self, event):
        import scipy.cluster
        
        #count number of peaks in gFrac histogram
        n = (numpy.diff(numpy.sign(numpy.diff(numpy.histogram(self.pipeline.filter['gFrac'], numpy.linspace(0, 1, 20))[0]))) < 0).sum()

        guesses = scipy.cluster.vq.kmeans(self.pipeline.filter['gFrac'], n)[0]

        for g, i in zip(guesses, range(n)):
            key = '%c' % (65 + i)
            self.pipeline.fluorSpecies[key] = g
            ind = self.lFluorSpecies.InsertStringItem(sys.maxint, key)
            self.lFluorSpecies.SetStringItem(ind,1, '%3.3f' % g)
            self.lFluorSpecies.SetItemTextColour(ind, wx.Colour(*((128*numpy.array(cm.jet_r(g)))[:3])))

            #self.visFr.mapping.setMapping('p_%s' % key, 'exp(-(%f*A - fitResults_Ag)**2/(2*fitError_Ag**2))*exp(-(%f*A - fitResults_Ar)**2/(2*fitError_Ar**2))' % (1- val, val))
            #self.visFr.mapping.setMapping('p_%s' % key, 'exp(-(%f - gFrac)**2/(2*error_gFrac**2))' % (g))
            #self.pipeline.mapping.setMapping('p_%s' % key, '(1.0/(ColourNorm*2*numpy.pi*fitError_Ag*fitError_Ar))*exp(-(fitResults_Ag - %f*A)**2/(2*fitError_Ag**2) - (fitResults_Ar - %f*A)**2/(2*fitError_Ar**2))' % (val, 1-val))
            self.mapping.setMapping('p_%s' % key, 'exp(-(%f - gFrac)**2/(2*error_gFrac**2))/(error_gFrac*sqrt(2*numpy.pi))' % val)

        self.visFr.UpdatePointColourChoices()
        self.visFr.colourFilterPane.UpdateColourFilterChoices()

        self.refresh()
Ejemplo n.º 7
0
    def draw(self):
        if self.IsShownOnScreen():
            #print self.IsShownOnScreen()
            print('d')
            """Draw data."""
            if self.visFrame.refv and not self.pipeline.ready or len(
                    self.pipeline.filter['x']) == 0:
                return

            print('vd')
            if not hasattr(self, 'subplot1'):
                self.subplot1 = self.figure.add_axes([.1, .1, .89, .89])
                #self.subplot2 = self.figure.add_subplot( 122 )

            self.subplot1.cla()

            x, y = self.pipeline.filter['fitResults_Ag'], self.pipeline.filter[
                'fitResults_Ar']
            n, xedge, yedge = numpy.histogram2d(x,
                                                y,
                                                bins=[100, 100],
                                                range=[(x.min(), x.max()),
                                                       (y.min(), y.max())])

            l_x = len(x)
            x = x[::int(max(l_x / 1e4, 1))]
            y = y[::int(max(l_x / 1e4, 1))]

            #facsPlot.facsPlotContour(x, y, 100)

            c = -5e3 * numpy.ones(x.shape)
            #            print (c < -1).sum(), c.min()

            cf = self.pipeline.colourFilter

            for k, v in self.pipeline.fluorSpecies.items():
                p_dye = self.pipeline.filter['p_%s' %
                                             k][::int(max(l_x / 1e4, 1))]

                p_other = numpy.zeros(x.shape)
                #p_tot = numpy.zeros(p_dye.shape)
                p_tot = cf.t_p_background * self.pipeline.filter[
                    'ColourNorm'][::int(max(l_x / 1e4, 1))]

                for k2 in self.pipeline.fluorSpecies.keys():
                    p_tot += self.pipeline.filter['p_%s' %
                                                  k2][::int(max(l_x / 1e4, 1))]
                    if not k2 == k:
                        p_other = numpy.maximum(
                            p_other,
                            self.pipeline.filter['p_%s' %
                                                 k2][::int(max(l_x / 1e4, 1))])

                p_dye = p_dye / p_tot
                p_other = p_other / p_tot

                c[(p_dye > cf.t_p_dye) * (p_other < cf.t_p_other)] = v

            cs = 0.75 * cm.jet_r(c.copy())[:, :3]

            cs[c < -1, :] = (0.3 * numpy.ones(cs.shape))[c < -1, :]

            #            print (c < -1).sum(), c.min()
            #            print (c < -1).sum(), cs[c < -1, :].shape

            self.subplot1.scatter(x, y, s=2, c=cs, edgecolor='none')
            #self.subplot1.plot(x, y, '.', ms=1, c=cs)

            #n, xedge, yedge = numpy.histogram2d(x, y, bins = [100,100], range=[(x.min(), x.max()), (y.min(), y.max())])

            self.subplot1.contour((xedge[:-1] + xedge[1:]) / 2,
                                  (yedge[:-1] + yedge[1:]) / 2,
                                  numpy.log2(n.T + .5),
                                  7,
                                  cmap=cm.copper_r,
                                  linewidths=2)
            self.subplot1.axis('image')
            self.subplot1.set_xlabel('Channel 1')
            self.subplot1.set_ylabel('Channel 2')

            x.sort()
            y.sort()

            xl = x[int(.997 * len(x))]
            yl = y[int(.997 * len(x))]

            self.subplot1.set_xlim((0, xl))
            self.subplot1.set_ylim((0, yl))

            for k, v in self.pipeline.fluorSpecies.items():
                self.subplot1.plot([0, xl], [0, ((1 - v) / v) * xl],
                                   lw=2,
                                   c=cm.jet_r(v))

            self.canvas.draw()
Ejemplo n.º 8
0
    def __init__(self, parent, pipeline, visFrame, id=-1):
        wx.Panel.__init__(self, parent, id)
        bsizer = wx.BoxSizer(wx.VERTICAL)

        self.visFr = visFrame
        self.pipeline = pipeline

        self.colPlotPan = colourPlotPanel(self, pipeline, visFrame)
        bsizer.Add(self.colPlotPan, 4,
                   wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5)

        #        hsizer = wx.BoxSizer(wx.HORIZONTAL)
        #        hsizer.Add(wx.StaticText(self, -1, "x' = "), 0,wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
        #
        #        self.tXExpr = wx.TextCtrl(self, -1, self.driftExprX, size=(130, -1))
        #        hsizer.Add(self.tXExpr, 2,wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5)
        #
        #        bsizer.Add(hsizer, 0, wx.ALL, 0)
        #
        #        hsizer = wx.BoxSizer(wx.HORIZONTAL)
        #        hsizer.Add(wx.StaticText(self, -1, "y' = "), 0,wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
        #
        #        self.tYExpr = wx.TextCtrl(self, -1, self.driftExprY, size=(130,-1))
        #        hsizer.Add(self.tYExpr, 2,wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5)
        #
        #        bsizer.Add(hsizer, 0, wx.ALL, 0)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        vsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, 'Fluorophores'),
                                   wx.VERTICAL)

        self.lFluorSpecies = editList.EditListCtrl(
            self,
            -1,
            style=wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.SUNKEN_BORDER,
            size=(450, 100))
        vsizer.Add(self.lFluorSpecies, 0, wx.ALL, 5)

        self.lFluorSpecies.InsertColumn(0, 'Name')
        self.lFluorSpecies.InsertColumn(1, 'Ag/(Ag + Ar)')
        self.lFluorSpecies.InsertColumn(2, '# Events')
        self.lFluorSpecies.InsertColumn(3, 'dx')
        self.lFluorSpecies.InsertColumn(4, 'dy')
        self.lFluorSpecies.InsertColumn(5, 'dz')
        self.lFluorSpecies.makeColumnEditable(1)
        self.lFluorSpecies.makeColumnEditable(3)
        self.lFluorSpecies.makeColumnEditable(4)
        self.lFluorSpecies.makeColumnEditable(5)

        for key, value in self.pipeline.fluorSpecies.items():
            ind = self.lFluorSpecies.InsertStringItem(UI_MAXSIZE, key)
            self.lFluorSpecies.SetStringItem(ind, 1, '%3.2f' % value)
            self.lFluorSpecies.SetItemTextColour(
                ind, wx.Colour(*((128 * numpy.array(cm.jet_r(value)))[:3])))

        self.lFluorSpecies.SetColumnWidth(3, 60)
        self.lFluorSpecies.SetColumnWidth(4, 60)
        self.lFluorSpecies.SetColumnWidth(5, 60)

        ## only do this part the first time so the events are only bound once
        #if not hasattr(self, "ID_FILT_ADD"):
        self.ID_SPEC_ADD = wx.NewId()
        self.ID_SPEC_DELETE = wx.NewId()
        #self.ID_FILT_EDIT = wx.NewId()

        self.Bind(wx.EVT_MENU, self.OnSpecAdd, id=self.ID_SPEC_ADD)
        self.Bind(wx.EVT_MENU, self.OnSpecDelete, id=self.ID_SPEC_DELETE)
        #self.Bind(wx.EVT_MENU, self.OnFilterEdit, id=self.ID_FILT_EDIT)

        # for wxMSW
        self.lFluorSpecies.Bind(wx.EVT_COMMAND_RIGHT_CLICK,
                                self.OnSpecListRightClick)

        # for wxGTK
        self.lFluorSpecies.Bind(wx.EVT_RIGHT_UP, self.OnSpecListRightClick)

        #        self.lFluorSpecies.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSpecItemSelected)
        #        self.lFluorSpecies.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnSpecItemDeselected)
        #self.lFluorSpecies.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnFilterEdit)

        self.lFluorSpecies.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnSpecChange)

        self.bGuess = wx.Button(self, -1, 'Guess')
        self.bGuess.Bind(wx.EVT_BUTTON, self.OnSpecGuess)
        vsizer.Add(self.bGuess, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5)

        hsizer.Add(vsizer, 0, wx.ALL, 5)

        vsizer = wx.StaticBoxSizer(
            wx.StaticBox(self, -1, 'Channel Assignment '), wx.VERTICAL)

        hsizer2 = wx.BoxSizer(wx.HORIZONTAL)
        hsizer2.Add(wx.StaticText(self, -1, 'p_dye:   '), 0,
                    wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)

        self.tPBelong = wx.TextCtrl(
            self, -1, '%3.3f' % self.pipeline.colourFilter.t_p_dye)
        hsizer2.Add(self.tPBelong, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        self.tPBelong.Bind(wx.EVT_TEXT, self.OnChangePDye)

        vsizer.Add(hsizer2, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 0)

        hsizer2 = wx.BoxSizer(wx.HORIZONTAL)
        hsizer2.Add(wx.StaticText(self, -1, 'p_other:'), 0,
                    wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)

        self.tPOther = wx.TextCtrl(
            self, -1, '%3.3f' % self.pipeline.colourFilter.t_p_other)
        hsizer2.Add(self.tPOther, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        self.tPOther.Bind(wx.EVT_TEXT, self.OnChangePOther)

        vsizer.Add(hsizer2, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 0)

        hsizer.Add(vsizer, 0, wx.ALL, 5)

        bsizer.Add(hsizer, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)

        self.SetSizer(bsizer)
        bsizer.Fit(self)

        self.Bind(wx.EVT_SHOW, self.OnShow)
Ejemplo n.º 9
0
    def draw( self ):
            print('d')
            """Draw data."""
            if self.visFrame.refv and not self.pipeline.ready or len(self.pipeline.filter['x']) == 0:
                return
            
            print('vd')            
            if not hasattr( self, 'subplot1' ):
                self.subplot1 = self.figure.add_axes([.1, .1, .89, .89])
                #self.subplot2 = self.figure.add_subplot( 122 )



            self.subplot1.cla()

            x, y = self.visFrame.pipeline['fitResults_Ag'], self.pipeline.filter['fitResults_Ar']
            n, xedge, yedge = numpy.histogram2d(x, y, bins = [100,100], range=[(x.min(), x.max()), (y.min(), y.max())])

            l_x = len(x)
            x = x[::max(l_x/1e4, 1)]
            y = y[::max(l_x/1e4, 1)]

            #facsPlot.facsPlotContour(x, y, 100)

            c = -5e3*numpy.ones(x.shape)
#            print (c < -1).sum(), c.min()

            for k, v in self.pipeline.fluorSpecies.items():
                p_dye = self.pipeline.mapping['p_%s' % k][::max(l_x/1e4, 1)]

                p_other = numpy.zeros(x.shape)
                #p_tot = numpy.zeros(p_dye.shape)
                p_tot = self.pipeline.t_p_background*self.pipeline.mapping['ColourNorm'][::max(l_x/1e4, 1)]

                for k2 in self.pipeline.fluorSpecies.keys():
                    p_tot  += self.pipeline.mapping['p_%s' % k2][::max(l_x/1e4, 1)]
                    if not k2 ==k:
                        p_other = numpy.maximum(p_other, self.pipeline.mapping['p_%s' % k2][::max(l_x/1e4, 1)])

                p_dye = p_dye/p_tot
                p_other = p_other/p_tot

                c[(p_dye > self.pipeline.t_p_dye)*(p_other < self.pipeline.t_p_other)] = v

            cs = 0.75*cm.jet_r(c.copy())[:,:3]
            
            cs[c < -1, :] = (0.3*numpy.ones(cs.shape))[c < -1, :]

#            print (c < -1).sum(), c.min()
#            print (c < -1).sum(), cs[c < -1, :].shape




            self.subplot1.scatter(x, y, s=2, c=cs, edgecolor='none')
            #self.subplot1.plot(x, y, '.', ms=1, c=cs)

            #n, xedge, yedge = numpy.histogram2d(x, y, bins = [100,100], range=[(x.min(), x.max()), (y.min(), y.max())])

            self.subplot1.contour((xedge[:-1] + xedge[1:])/2, (yedge[:-1] + yedge[1:])/2, numpy.log2(n.T + .5), 7, cmap = cm.copper_r, linewidths=2)
            self.subplot1.axis('image')
            self.subplot1.set_xlabel('Channel 1')
            self.subplot1.set_ylabel('Channel 2')

            x.sort()
            y.sort()

            xl = x[.997*len(x)]
            yl = y[.997*len(x)]

            self.subplot1.set_xlim((0, xl))
            self.subplot1.set_ylim((0, yl))


            for k, v in self.pipeline.fluorSpecies.items():
                self.subplot1.plot([0,xl], [0, ((1-v)/v)*xl], lw=2, c=cm.jet_r(v))

            self.canvas.draw()
Ejemplo n.º 10
0
    def SpecFromMetadata(self, mdh):
        labels = mdh.getEntry('Sample.Labelling')

        structures = []
        for structure, dye in labels:
            if structure in structures: #duplicate structure
                structure += ' A'
            structures.append(structure)
            ratio = dyeRatios.getRatio(dye, mdh)

            if not ratio == None:
                self.pipeline.fluorSpecies[structure] = ratio
                ind = self.lFluorSpecies.InsertStringItem(sys.maxint, structure)
                self.lFluorSpecies.SetStringItem(ind,1, '%3.3f' % ratio)
                self.lFluorSpecies.SetItemTextColour(ind, wx.Colour(*((128*numpy.array(cm.jet_r(ratio)))[:3])))

                #self.visFr.mapping.setMapping('p_%s' % key, 'exp(-(%f*A - fitResults_Ag)**2/(2*fitError_Ag**2))*exp(-(%f*A - fitResults_Ar)**2/(2*fitError_Ar**2))' % (1- val, val))
                #self.visFr.mapping.setMapping('p_%s' % structure, 'exp(-(%f - gFrac)**2/(2*error_gFrac**2))' % (ratio))
                #self.pipeline.mapping.setMapping('p_%s' % structure, '(1.0/(ColourNorm*2*numpy.pi*fitError_Ag*fitError_Ar))*exp(-(fitResults_Ag - %f*A)**2/(2*fitError_Ag**2) - (fitResults_Ar - %f*A)**2/(2*fitError_Ar**2))' % (ratio, 1-ratio))
                self.mapping.setMapping('p_%s' % structure, 'exp(-(%f - gFrac)**2/(2*error_gFrac**2))/(error_gFrac*sqrt(2*numpy.pi))' % ratio)

        self.visFr.UpdatePointColourChoices()
        self.visFr.colourFilterPane.UpdateColourFilterChoices()

        self.refresh()
Ejemplo n.º 11
0
    def OnSpecChange(self, event=None):
        it = self.lFluorSpecies.GetItem(event.m_itemIndex)

        val = float(event.m_item.GetText())

        col = event.GetColumn()

        if col == 1: #frac
            self.pipeline.fluorSpecies[it.GetText()] = val
            self.lFluorSpecies.SetItemTextColour(event.m_itemIndex, wx.Colour(*((128*numpy.array(cm.jet_r(val)))[:3])))

            #self.visFr.mapping.setMapping('p_%s' % it.GetText(), 'exp(-(%f*A - fitResults_Ag)**2/(4*fitError_Ag**2 + 2*fitError_Ar**2))*exp(-(%f*A - fitResults_Ar)**2/(2*fitError_Ag**2 +4*fitError_Ar**2))' % (1- val, val))
            #self.visFr.mapping.setMapping('p_%s' % it.GetText(), 'exp(-(%f - gFrac)**2/(2*error_gFrac**2))' % (val))
            #self.pipeline.mapping.setMapping('p_%s' % it.GetText(), '(1.0/(ColourNorm*2*numpy.pi*fitError_Ag*fitError_Ar))*exp(-(fitResults_Ag - %f*A)**2/(2*fitError_Ag**2) - (fitResults_Ar - %f*A)**2/(2*fitError_Ar**2))' % (val, 1-val))
            self.mapping.setMapping('p_%s' % it.GetText(), 'exp(-(%f - gFrac)**2/(2*error_gFrac**2))/(error_gFrac*sqrt(2*numpy.pi))' % val)

            self.refresh()
        else: #shift
            axis = ['x', 'y', 'z'][col-3]
            specName = it.GetText()
            if not specName in self.pipeline.chromaticShifts.keys():
                self.pipeline.chromaticShifts[specName] = {}

            self.pipeline.chromaticShifts[specName][axis] = val
            self.visFr.RefreshView()
Ejemplo n.º 12
0
    def __init__(self, parent, pipeline,visFrame, id=-1):
        wx.Panel.__init__(self, parent, id)
        bsizer = wx.BoxSizer(wx.VERTICAL)

        self.visFr = visFrame
        self.pipeline = pipeline

        self.colPlotPan = colourPlotPanel(self, pipeline, visFrame)
        bsizer.Add(self.colPlotPan, 4,wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5)

#        hsizer = wx.BoxSizer(wx.HORIZONTAL)
#        hsizer.Add(wx.StaticText(self, -1, "x' = "), 0,wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
#
#        self.tXExpr = wx.TextCtrl(self, -1, self.driftExprX, size=(130, -1))
#        hsizer.Add(self.tXExpr, 2,wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5)
#
#        bsizer.Add(hsizer, 0, wx.ALL, 0)
#
#        hsizer = wx.BoxSizer(wx.HORIZONTAL)
#        hsizer.Add(wx.StaticText(self, -1, "y' = "), 0,wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
#
#        self.tYExpr = wx.TextCtrl(self, -1, self.driftExprY, size=(130,-1))
#        hsizer.Add(self.tYExpr, 2,wx.ALL|wx.ALIGN_CENTER_VERTICAL|wx.EXPAND, 5)
#
#        bsizer.Add(hsizer, 0, wx.ALL, 0)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        vsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, 'Fluorophores'), wx.VERTICAL)

        self.lFluorSpecies = editList.EditListCtrl(self, -1, style=wx.LC_REPORT|wx.LC_SINGLE_SEL|wx.SUNKEN_BORDER, size=(450, 100))
        vsizer.Add(self.lFluorSpecies, 0, wx.ALL, 5)

        self.lFluorSpecies.InsertColumn(0, 'Name')
        self.lFluorSpecies.InsertColumn(1, 'Ag/(Ag + Ar)')
        self.lFluorSpecies.InsertColumn(2, '# Events')
        self.lFluorSpecies.InsertColumn(3, 'dx')
        self.lFluorSpecies.InsertColumn(4, 'dy')
        self.lFluorSpecies.InsertColumn(5, 'dz')
        self.lFluorSpecies.makeColumnEditable(1)
        self.lFluorSpecies.makeColumnEditable(3)
        self.lFluorSpecies.makeColumnEditable(4)
        self.lFluorSpecies.makeColumnEditable(5)

        for key, value in self.pipeline.fluorSpecies.items():
            ind = self.lFluorSpecies.InsertStringItem(sys.maxint, key)
            self.lFluorSpecies.SetStringItem(ind,1, '%3.2f' % value)
            self.lFluorSpecies.SetItemTextColour(ind, wx.Colour(*((128*numpy.array(cm.jet_r(value)))[:3])))
            
            

        self.lFluorSpecies.SetColumnWidth(3, 60)
        self.lFluorSpecies.SetColumnWidth(4, 60)
        self.lFluorSpecies.SetColumnWidth(5, 60)


        ## only do this part the first time so the events are only bound once
        #if not hasattr(self, "ID_FILT_ADD"):
        self.ID_SPEC_ADD = wx.NewId()
        self.ID_SPEC_DELETE = wx.NewId()
        #self.ID_FILT_EDIT = wx.NewId()

        self.Bind(wx.EVT_MENU, self.OnSpecAdd, id=self.ID_SPEC_ADD)
        self.Bind(wx.EVT_MENU, self.OnSpecDelete, id=self.ID_SPEC_DELETE)
        #self.Bind(wx.EVT_MENU, self.OnFilterEdit, id=self.ID_FILT_EDIT)

        # for wxMSW
        self.lFluorSpecies.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnSpecListRightClick)

        # for wxGTK
        self.lFluorSpecies.Bind(wx.EVT_RIGHT_UP, self.OnSpecListRightClick)

#        self.lFluorSpecies.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSpecItemSelected)
#        self.lFluorSpecies.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnSpecItemDeselected)
        #self.lFluorSpecies.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnFilterEdit)

        self.lFluorSpecies.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnSpecChange)

        self.bGuess = wx.Button(self, -1, 'Guess')
        self.bGuess.Bind(wx.EVT_BUTTON, self.OnSpecGuess)
        vsizer.Add(self.bGuess, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5)

        hsizer.Add(vsizer, 0, wx.ALL, 5)

        vsizer = wx.StaticBoxSizer(wx.StaticBox(self, -1, 'Channel Assignment '), wx.VERTICAL)

        hsizer2 = wx.BoxSizer(wx.HORIZONTAL)
        hsizer2.Add(wx.StaticText(self, -1, 'p_dye:   '), 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)

        self.tPBelong = wx.TextCtrl(self, -1, '%3.3f' % self.pipeline.t_p_dye)
        hsizer2.Add(self.tPBelong, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
        self.tPBelong.Bind(wx.EVT_TEXT, self.OnChangePDye)

        vsizer.Add(hsizer2, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 0)

        hsizer2 = wx.BoxSizer(wx.HORIZONTAL)
        hsizer2.Add(wx.StaticText(self, -1, 'p_other:'), 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)

        self.tPOther = wx.TextCtrl(self, -1, '%3.3f' % self.pipeline.t_p_other)
        hsizer2.Add(self.tPOther, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
        self.tPOther.Bind(wx.EVT_TEXT, self.OnChangePOther)

        vsizer.Add(hsizer2, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 0)

        hsizer.Add(vsizer, 0, wx.ALL, 5)

        bsizer.Add(hsizer, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)

        self.SetSizer(bsizer)
        bsizer.Fit(self)

        self.Bind(wx.EVT_SHOW, self.OnShow)