Пример #1
0
    def __init__(self, parent):

        sizeX = parent.GetSize()[0] - parent.cpanel.clist.GetSize()[0]
        wx.Panel.__init__(self, parent, -1, size=(sizeX, -1))
        #self.parent = parent

        # start drawing
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        # \n
        box = G.newSpaceV(sizer)
        G.makeTxt(
            self, box,
            'Drag and drop a file to preview the parameters\n or click the button to select a file'
        )

        # \n
        box = G.newSpaceV(sizer)
        self.testButton = G.makeButton(self,
                                       box,
                                       self.onChooseFile,
                                       title='Open')

        dropTarget = ViewFileDropTarget(self)
        self.SetDropTarget(dropTarget)
Пример #2
0
    def __init__(self, parent):

        sizeX = parent.GetSize()[0] - parent.cpanel.clist.GetSize()[0]
        wx.Panel.__init__(self, parent, -1, size=(sizeX,-1))
        #self.parent = parent
        
        # start drawing
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        # \n
        box = G.newSpaceV(sizer)
        G.makeTxt(self, box, 'Drag and drop a file to preview the parameters\n or click the button to select a file')

        # \n
        box = G.newSpaceV(sizer)
        self.testButton = G.makeButton(self, box, self.onChooseFile, title='Open')

        dropTarget = ViewFileDropTarget(self)
        self.SetDropTarget(dropTarget)
Пример #3
0
    def initHists(self):
        ''' Initialize the histogram/aligner panel, and a bunch of empty lists;
        define HistogramCanvas class;s doOnBrace() and doOnMouse() behaviors
        '''
        self.histsPanel = scrolled.ScrolledPanel(self, -1)#wx.Panel(self, -1)

        sizer = wx.BoxSizer(wx.VERTICAL)
        self.histsPanel.SetSizer(sizer)

        cookiecutterSizer = wx.BoxSizer(wx.HORIZONTAL)
        # This sizer contains both the cookie cutter toggle button and the cropbox editor
        sizer.Add(cookiecutterSizer, 0, wx.ALL|wx.EXPAND, 2)

        autoscaleButton = G.makeButton(self.histsPanel, cookiecutterSizer, self.OnAutoScale, title='Auto scale', tip='')


        self.hist = [None] * self.doc.nw
        self.hist_arr = [None] * self.doc.nw
        self.hist_min  = [None]*self.doc.nw
        self.hist_max  = [None]*self.doc.nw
        self.hist_toggleButton  = [None]*self.doc.nw
        self.hist_show = [None]*self.doc.nw
        self.mmms      = [None]*self.doc.nw
        self.intensity_label = [None] * self.doc.nw
        self.hist_label = [None] * self.doc.nw
        
        self.hist_singleChannelMode = None
        self.hist_toggleID2col    = {}

        for i in range(self.doc.nw):
            wave = self.doc.wave[i]#mrcIO.getWaveFromHdr(self.doc.hdr, i)
            self.hist_show[i] = True

            box = G.newSpaceV(sizer)
            
            self.hist_toggleButton[i] = G.makeToggleButton(self.histsPanel, box, self.OnHistToggleButton, title=str(wave), size=(40,-1))
            self.hist_toggleButton[i].Bind(wx.EVT_RIGHT_DOWN, 
                                           lambda ev: self.OnHistToggleButton(ev, i=i, mode="r"))
            self.hist_toggleButton[i].SetValue( self.hist_show[i] )

            self.intensity_label[i] = G.makeTxt(self.histsPanel, box, ' ')

            box = G.newSpaceV(sizer)
            
            self.hist[i] = histogram.HistogramCanvas(self.histsPanel, size=(200,30))#size)

            box.Add(self.hist[i])

            for ii,colName in enumerate(_rgbList_names):
                self.hist[i].menu.Insert(ii, _rgbList_menuIDs[ii], colName)
                self.hist[i].Bind(wx.EVT_MENU, self.OnHistColorChange, id=_rgbList_menuIDs[ii])

            self.hist[i].menu.InsertSeparator(ii+1)


            self.hist_toggleID2col[ self.hist_toggleButton[i].GetId() ] = i
            
            #/n
            box = G.newSpaceV(sizer)
            self.hist_label[i] = G.makeTxt(self.histsPanel, box, ' ')
            
            def fff(s, ii=i):
                l, r = s.leftBrace, s.rightBrace
                for v in self.viewers:
                    ## TODO: different scaling for x-z and y-z viewer??
                    v.changeHistScale(ii, l, r)

            self.hist[i].doOnBrace.append(fff)

            def ggg(xEff, ev, ii=i):
                l,r =  self.hist[ii].leftBrace,  self.hist[ii].rightBrace
                if self.doc.dtype in (N.uint8, N.int16, N.uint16, N.int32):
                    self.hist_label[ii].SetLabel("I: %6.0f  l/r: %6.0f %6.0f"  %(xEff,l,r))
                else:
                    self.hist_label[ii].SetLabel("I: %7.1f  l/r: %7.1f %7.1f"  %(xEff,l,r))

            self.hist[i].doOnMouse.append(ggg)

        if self.doc.nw > 1:
            for i in range(self.doc.nw):
                wave = self.doc.wave[i]
                self.setColor(i, wave, False)

        #/n/n
        box = G.newSpaceV(sizer)
        G.makeTxt(self.histsPanel, box, ' ') # dummy
        box = G.newSpaceV(sizer)
        self.xy_label = G.makeTxt(self.histsPanel, box, ' ')

        self.histsPanel.SetAutoLayout(1)
        self.histsPanel.SetupScrolling()
Пример #4
0
    def addZslider(self):
        self.sliderPanel = wx.Panel(self, -1)

        sizer = wx.BoxSizer(wx.VERTICAL)
        self.sliderPanel.SetSizer(sizer)

        # image info
        # \n
        box = G.newSpaceV(sizer)

        bb, box = G.newStaticBox(self.sliderPanel, box, title='Image info', size=wx.DefaultSize)

        if sys.platform.startswith(('win', 'linux')):
            fsize = 9
        else:
            fsize = 11
        font = wx.Font(fsize, wx.SWISS, wx.NORMAL, wx.NORMAL)
        
        # pixel size
        pxsiz = tuple(self.doc.pxlsiz[::-1])
        dimstr = ('X', 'Y', 'Z')
        line = 'Pixel size (um):\n'
        pxstr = '  '
        for i, d in enumerate(pxsiz):
            if d:
                pxstr += '%s %.3f: ' % (dimstr[i], d)
        if pxstr:
            line += pxstr[:-2]
        else:
            line = ''
        if line:
            label = G.makeTxt(self.sliderPanel, box, line)
            label.SetFont(font)
        # data type
        pxtype = imgio.bioformatsIO.pixeltype_to_bioformats(self.doc.dtype)
        line = 'Data type: %s' % pxtype
        label = G.makeTxt(self.sliderPanel, box, line)
        label.SetFont(font)

        
        # z slider
        if self.doc.nz > 1:
            topSizer = G.newSpaceV(sizer)

            #label, self.zSliderBox = G.makeTxtBox(self.sliderPanel, topSizer, 'Z', defValue=str(self.doc.z), tip='enter z idx', style=wx.TE_PROCESS_ENTER)
            label, self.zSliderBox = G.makeTxtBox(self.sliderPanel, topSizer, 'Z', defValue=self.doc.z, tip='enter z idx', style=wx.TE_PROCESS_ENTER)

            self.zSliderBox.Bind(wx.EVT_TEXT_ENTER, self.OnZSliderBox)

            G.makeTxt(self.sliderPanel, topSizer, r'/'+str(self.doc.nz-1))

            self.zSlider = wx.Slider(self.sliderPanel, wx.ID_ANY, self.doc.z, 0, 
                                     self.doc.nz-1,
                                     size=wx.Size(150,-1),
                                     style = wx.SL_HORIZONTAL | wx.SL_AUTOTICKS)#|wx.SL_LABELS | wx.SL_AUTOTICKS)

            topSizer.Add(self.zSlider, 6, wx.ALL|wx.ALIGN_LEFT, 2)
            #wx.EVT_SLIDER(self, self.zSlider.GetId(), self.OnZSlider)
            self.Bind(wx.EVT_SLIDER, self.OnZSlider, id=self.zSlider.GetId())
            #wx.EVT_KEY_DOWN(self, self.zSlider.GetId(), self.OnKeyZSlider)
            #self.zSlider.Bind(wx.EVT_KEY_DOWN, self.OnKeyZSlider)
            if self.doc.nt == 1:
                self.sliderPanel.Bind(wx.EVT_KEY_DOWN, self.OnKeyZSlider)
            self.zSlider.Bind(wx.EVT_KEY_DOWN, self.OnKeyZSlider)
            #self.Bind(wx.EVT_CHAR, self.OnKeyZSlider)

            #/n
            box = G.newSpaceV(sizer)
            
            autofocusButton = G.makeButton(self.sliderPanel, box, self.OnAutoFocus, title='Auto focus', tip='')
            
            #/n
            box = G.newSpaceV(sizer)

            self.orthogonal_toggle = G.makeToggleButton(self.sliderPanel, box, self.onOrthogonal, title='Orthogonal projections')

            #/n
            box = G.newSpaceV(sizer)
            self.saveScrButton = G.makeButton(self.sliderPanel, box, self.onSaveScr, title='Save screen')

            self.choice_viewers = ['XY', 'XZ', 'ZY']
            label, self.viewerch = G.makeListChoice(self.sliderPanel, box, 'viewer', self.choice_viewers, defValue=[self.choice_viewers[0]])
            self.viewerch.Enable(0)
        
        # t slider
        if self.doc.nt > 1:  ## need a time slider
            box = G.newSpaceV(sizer)

            label, self.tSliderBox = G.makeTxtBox(self.sliderPanel, box, 'T', defValue=str(self.doc.t), tip='enter time idx', style=wx.TE_PROCESS_ENTER)
            
            self.tSliderBox.Bind(wx.EVT_TEXT_ENTER, self.OnTSliderBox)

            G.makeTxt(self.sliderPanel, box, r'/'+str(self.doc.nt-1))

            self.tSlider = wx.Slider(self.sliderPanel, wx.ID_ANY, 0, 0,
                                     self.doc.nt-1,
                                     size=wx.Size(150,-1),
                                     style = wx.SL_HORIZONTAL | wx.SL_AUTOTICKS)#|wx.SL_LABELS | wx.SL_AUTOTICKS)
            box.Add(self.tSlider, 6, wx.ALL|wx.ALIGN_LEFT, 2)
            #wx.EVT_SLIDER(self, self.tSlider.GetId(), self.OnTSlider)
            self.Bind(wx.EVT_SLIDER, self.OnTSlider, id=self.tSlider.GetId())

            if self.doc.nz == 1:
                self.sliderPanel.Bind(wx.EVT_KEY_DOWN, self.OnKeyTSlider)
            self.tSlider.Bind(wx.EVT_KEY_DOWN, self.OnKeyTSlider)
Пример #5
0
    def makePanel(self):
        # config
        confdic = C.readConfig()
        self.lastpath = confdic.get('lastpath', '')
        self.extra_parms = {}

        # draw / arrange
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        # ---- reference ------
        # \n
        box = G.newSpaceV(sizer)
        self.refAddButton = G.makeButton(self, box, lambda ev:self.OnChooseImgFiles(ev,'ref'), title='Reference files', tip='', enable=True)

        self.refClearButton = G.makeButton(self, box, lambda ev:self.clearSelected(ev, 'ref'), title='Clear selected', tip='', enable=False)

        parmSuffixLabel, self.parm_suffix_txt = G.makeTxtBox(self, box, 'Suffix', defValue=confdic.get('parm_suffix_txt', ''), tip='A suffix for the file extention for the chromagnon file name', sizeX=100)

        extraButton = G.makeButton(self, box, self.OnExtraParamButton, title='Extra parameters')
        
        # ---- target ------

        refsize = self.refAddButton.GetSize()[0] + self.refClearButton.GetSize()[0] + parmSuffixLabel.GetSize()[0] + self.parm_suffix_txt.GetSize()[0] + extraButton.GetSize()[0]
        G.newSpaceH(box, LISTSIZE_X+LISTSPACE-refsize)

        self.tgtAddButton = G.makeButton(self, box, lambda ev:self.OnChooseImgFiles(ev,'target'), title='Target files', tip='', enable=True)
        
        self.tgtClearButton = G.makeButton(self, box, lambda ev:self.clearSelected(ev, 'tareget'), title='Clear selected', tip='', enable=False)

        self.cutoutCb = G.makeCheck(self, box, "crop margins", tip='', defChecked=bool(confdic.get('cutout', True)))

        label, self.img_suffix_txt = G.makeTxtBox(self, box, 'Suffix', defValue=confdic.get('img_suffix_txt', aligner.IMG_SUFFIX), tip='A suffix for the file name', sizeX=100)

        self.outext_choices = [os.path.extsep + form for form in aligner.WRITABLE_FORMATS]
        label, self.outextch = G.makeListChoice(self, box, '', self.outext_choices, defValue=confdic.get('format', aligner.WRITABLE_FORMATS[0]), tip='tif: ImageJ format, dv: DeltaVision format, ome.tif: OME-tif format (slow)', targetFunc=self.OnOutFormatChosen)
        if not self.outextch.GetStringSelection():
            self.outextch.SetSelection(0)
        
        ## --- list ----
        # \n
        box = G.newSpaceV(sizer)
        
        self.listRef = listbox.FileListCtrl(self, wx.NewId(),
                                 style=wx.LC_REPORT
                                 | wx.BORDER_NONE,
                                 #| wx.LC_SORT_ASCENDING,
                                 size=(LISTSIZE_X, LIST_Y)
                                 )
        box.Add(self.listRef)
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, lambda ev:self.OnItemSelected(ev, 'reference'), self.listRef)
        self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemSelected, self.listRef)
        self.listRef.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick)
        
        G.newSpaceH(box, LISTSPACE)

        self.listTgt = listbox.FileListCtrl(self, wx.NewId(),
                                 style=wx.LC_REPORT
                                 | wx.BORDER_NONE,
                                # | wx.LC_SORT_ASCENDING,
        size=(LISTSIZE_X, LIST_Y)
                                 )
        box.Add(self.listTgt)
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, lambda ev:self.OnItemSelected(ev, 'target'), self.listTgt)
        self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemSelected, self.listTgt)
        self.listTgt.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick)

        self.listRef.setDefaultFileLoadFunc(self._load_func)
        self.listTgt.setDefaultFileLoadFunc(self._load_func)
        #------- execute ------

        # \n
        box = G.newSpaceV(sizer)
        
        self.goButton = G.makeToggleButton(self, box, self.OnGo, title='Run all', tip='', enable=False)

        if sys.platform.startswith('win'):
            ft = wx.Font(9, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD)
        elif sys.platform.startswith('linux'):
            ft = wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD)
        else:
            ft = wx.Font(14, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD)
        self.goButton.SetFont(ft)
        self.listRef.setOnDrop(self.goButton.Enable, 1)
        self.listTgt.setOnDrop(self.goButton.Enable, 1)
        
        self.averageCb = G.makeCheck(self, box, "average references  ", tip='Multiple reference images are maximum intensity projected to make a single high SNR image for shift calculation.', defChecked=bool(confdic.get('average', False)))

        self.localChoice = LOCAL_CHOICE
        label, self.localListChoice = G.makeListChoice(self, box, 'Local align', self.localChoice, defValue=confdic.get('local', 'None'), targetFunc=self.OnLocalListChose)

        self.min_pxls_label, self.min_pxls_choice = G.makeListChoice(self, box, 'min window size', af.MIN_PXLS_YXS, defValue=confdic.get('min_pxls_yx', af.MIN_PXLS_YXS[1]), tip='Minimum number of pixel to divide as elements of local alignment')

        self.OnLocalListChose()

        self.progress = wx.Gauge(self, -1, 100, size=(100,-1))
        box.Add(self.progress)
        
        self.label = G.makeTxt(self, box, ' ')

        _col_sizes=[(key, val) for key, val in listbox.__dict__.items() if key.startswith('SIZE_COL')]
        _col_sizes.sort()

        LISTSIZE_X2 = sum([val for key, val in _col_sizes[:3]])
        LIST_Y2 = 30
        
        #------ flat fielder --------

        self.flatButton = wx.Button(self, -1, 'Open Flat Fielder')
        self.flatButton.SetToolTip(wx.ToolTip('Open a graphical interphase to flat field images'))

        flatsize = self.goButton.GetSize()[0] + self.averageCb.GetSize()[0] + label.GetSize()[0] + self.localListChoice.GetSize()[0] + self.min_pxls_label.GetSize()[0] + self.min_pxls_choice.GetSize()[0] + self.progress.GetSize()[0] + self.flatButton.GetSize()[0] + 5

        G.newSpaceH(box, FRAMESIZE_X-flatsize)

        box.Add(self.flatButton)
        frame = self.GetTopLevelParent()
        frame.Bind(wx.EVT_BUTTON, self.onFlatFielder, self.flatButton)
        
        # ----- finishing -----
        self.Layout()
        self.parent.Layout()

        self.checkGo()
Пример #6
0
    def makePanel(self, tif=False):
        # config
        confdic = C.readConfig()
        self.lastpath = confdic.get('lastpath', '')

        # draw / arrange
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        # ---- reference ------
        # \n
        box = G.newSpaceV(sizer)
        self.refAddButton = G.makeButton(
            self,
            box,
            lambda ev: self.OnChooseImgFiles(ev, 'ref'),
            title='Reference files',
            tip='',
            enable=True)

        self.refClearButton = G.makeButton(
            self,
            box,
            lambda ev: self.clearSelected(ev, 'ref'),
            title='Clear selected',
            tip='',
            enable=False)

        maxShiftLabel, self.maxShift = G.makeTxtBox(
            self,
            box,
            'max shift allowed (um)',
            defValue=confdic.get('maxShift', af.MAX_SHIFT),
            tip='maximum possible shift of each channel',
            sizeX=50)

        parmSuffixLabel, self.parm_suffix_txt = G.makeTxtBox(
            self,
            box,
            'Suffix',
            defValue=confdic.get('parm_suffix_txt', ''),
            tip='A suffix for the file extention for the chromagnon file name',
            sizeX=100)

        #self.refwave = G.makeButton(self, box, lambda ev:self.clearSelected(ev, 'ref'), title='Ref channel', tip='', enable=True)
        # ---- target ------

        refsize = self.refAddButton.GetSize()[0] + self.refClearButton.GetSize(
        )[0] + parmSuffixLabel.GetSize()[0] + self.parm_suffix_txt.GetSize(
        )[0] + maxShiftLabel.GetSize()[0] + self.maxShift.GetSize()[0]
        G.newSpaceH(box, LISTSIZE_X + LISTSPACE - refsize)

        self.tgtAddButton = G.makeButton(
            self,
            box,
            lambda ev: self.OnChooseImgFiles(ev, 'target'),
            title='Target files',
            tip='',
            enable=True)

        self.tgtClearButton = G.makeButton(
            self,
            box,
            lambda ev: self.clearSelected(ev, 'tareget'),
            title='Clear selected',
            tip='',
            enable=False)

        self.cutoutCb = G.makeCheck(self,
                                    box,
                                    "crop margins",
                                    tip='',
                                    defChecked=bool(confdic.get(
                                        'cutout', True)))

        label, self.img_suffix_txt = G.makeTxtBox(
            self,
            box,
            'Suffix',
            defValue=confdic.get('img_suffix_txt', aligner.IMG_SUFFIX),
            tip='A suffix for the file name',
            sizeX=100)

        self.outext_choices = [
            os.path.extsep + form for form in aligner.WRITABLE_FORMATS
        ]
        label, self.outextch = G.makeListChoice(
            self,
            box,
            '',
            self.outext_choices,
            defValue=confdic.get('format', aligner.WRITABLE_FORMATS[0]),
            tip=
            'tif: ImageJ format, dv: DeltaVision format, ome.tif: OME-tif format (slow)',
            targetFunc=self.OnOutFormatChosen)
        if not self.outextch.GetStringSelection():
            self.outextch.SetSelection(0)

        ## --- list ----
        # \n
        box = G.newSpaceV(sizer)

        self.listRef = listbox.FileListCtrl(
            self,
            wx.NewId(),
            style=wx.LC_REPORT
            | wx.BORDER_NONE,
            #| wx.LC_SORT_ASCENDING,
            size=(LISTSIZE_X, LIST_Y))
        box.Add(self.listRef)
        self.Bind(wx.EVT_LIST_ITEM_SELECTED,
                  lambda ev: self.OnItemSelected(ev, 'reference'),
                  self.listRef)
        self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemSelected,
                  self.listRef)
        self.listRef.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick)

        G.newSpaceH(box, LISTSPACE)

        self.listTgt = listbox.FileListCtrl(
            self,
            wx.NewId(),
            style=wx.LC_REPORT
            | wx.BORDER_NONE,
            # | wx.LC_SORT_ASCENDING,
            size=(LISTSIZE_X, LIST_Y))
        box.Add(self.listTgt)
        self.Bind(wx.EVT_LIST_ITEM_SELECTED,
                  lambda ev: self.OnItemSelected(ev, 'target'), self.listTgt)
        self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemSelected,
                  self.listTgt)
        self.listTgt.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick)

        self.listRef.setDefaultFileLoadFunc(self._load_func)
        self.listTgt.setDefaultFileLoadFunc(self._load_func)
        #------- execute ------

        # \n
        box = G.newSpaceV(sizer)

        self.goButton = G.makeToggleButton(self,
                                           box,
                                           self.OnGo,
                                           title='Run all',
                                           tip='',
                                           enable=False)

        if sys.platform.startswith('win'):
            ft = wx.Font(9, wx.FONTFAMILY_DEFAULT, wx.NORMAL,
                         wx.FONTWEIGHT_BOLD)
        elif sys.platform.startswith('linux'):
            ft = wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.NORMAL,
                         wx.FONTWEIGHT_BOLD)
        else:
            ft = wx.Font(14, wx.FONTFAMILY_DEFAULT, wx.NORMAL,
                         wx.FONTWEIGHT_BOLD)
        self.goButton.SetFont(ft)
        self.listRef.setOnDrop(self.goButton.Enable, 1)
        self.listTgt.setOnDrop(self.goButton.Enable, 1)

        self.zmaglabel, self.zmagch = G.makeListChoice(
            self,
            box,
            '  Z mag',
            aligner.ZMAG_CHOICE,
            defValue=confdic.get('Zmag', aligner.ZMAG_CHOICE[0]),
            tip=
            'if "Auto" is chosen, then z mag calculation is done if the z stack contains more than 30 Z sections with a sufficient contrast'
        )

        self.localChoice = LOCAL_CHOICE
        label, self.localListChoice = G.makeListChoice(
            self,
            box,
            'Local align',
            self.localChoice,
            defValue=confdic.get('local', 'None'),
            targetFunc=self.OnLocalListChose)

        self.min_pxls_label, self.min_pxls_choice = G.makeListChoice(
            self,
            box,
            'min window size',
            af.MIN_PXLS_YXS,
            defValue=confdic.get('min_pxls_yx', af.MIN_PXLS_YXS[1]),
            tip=
            'Minimum number of pixel to divide as elements of local alignment')

        self.OnLocalListChose()

        self.progress = wx.Gauge(self, -1, 100, size=(100, -1))
        box.Add(self.progress)

        self.label = G.makeTxt(self, box, ' ')

        _col_sizes = [(key, val) for key, val in listbox.__dict__.items()
                      if key.startswith('SIZE_COL')]
        _col_sizes.sort()

        LISTSIZE_X2 = sum([val for key, val in _col_sizes[:3]])
        LIST_Y2 = 30

        #------ flat fielder --------

        self.flatButton = wx.Button(self, -1, 'Open Flat Fielder')
        self.flatButton.SetToolTip(
            wx.ToolTip('Open a graphical interphase to flat field images'))

        flatsize = self.goButton.GetSize()[0] + self.zmaglabel.GetSize(
        )[0] + self.zmagch.GetSize()[0] + label.GetSize(
        )[0] + self.localListChoice.GetSize()[0] + self.min_pxls_label.GetSize(
        )[0] + self.min_pxls_choice.GetSize()[0] + self.progress.GetSize(
        )[0] + self.flatButton.GetSize()[0] + 5

        G.newSpaceH(box, FRAMESIZE_X - flatsize)

        box.Add(self.flatButton)
        frame = self.GetTopLevelParent()
        frame.Bind(wx.EVT_BUTTON, self.onFlatFielder, self.flatButton)

        # ----- finishing -----
        self.Layout()
        self.parent.Layout()

        self.checkGo()
Пример #7
0
    def __init__(self, parent=None, fns=[], defPxlSiz=0.1):
        """
        dimension selection dialog for multipage tif

        fns: filenames

        use like
        >>> dlg = FileSelectorDialog()
        >>> if dlg.ShowModal() == wx.ID_OK:
        >>>     fns = dlg.GetPaths()
        """
        wx.Dialog.__init__(self, parent, -1, title='Image Dimensions')

        nfns = len(fns)

        sizer = wx.BoxSizer(wx.VERTICAL)

        hsz = wx.FlexGridSizer(nfns + 1, 14, 0, 0)
        sizer.Add(hsz, 0, wx.EXPAND)

        # header
        G.makeTxt(self, hsz, 'Directory')
        G.makeTxt(self, hsz, 'Filename')
        G.makeTxt(self, hsz, 'Sequence')
        G.makeTxt(self, hsz, 'time')
        G.makeTxt(self, hsz, '    color: ')
        for i, col in enumerate(_COLORS):
            b = G.makeTxt(self, hsz, col)
            b.SetForegroundColour(_COLOR_NAME[i])
        G.makeTxt(self, hsz, '     Z')
        G.makeTxt(self, hsz, 'Pixel size (um)')

        # file
        self.holders = []
        for fn in fns:
            h = DimDataHolder(fn, defPxlSiz)
            self.holders.append(h)

            G.makeTxt(self, hsz, h.direc)
            G.makeTxt(self, hsz, h.basename)

            label, h.seqChoice = G.makeListChoice(
                self,
                hsz,
                '',
                generalIO.IMGSEQ,
                defValue=h.seq,
                targetFunc=self.onSeq
            )  #imgfileIO.generalIO.IMGSEQ[h.seq], targetFunc=self.onSeq)

            comm_divs = [
                str(i) for i in range(1, h.nsec + 1) if not h.nsec % i
            ]
            label, h.ntChoice = G.makeListChoice(self,
                                                 hsz,
                                                 '',
                                                 comm_divs,
                                                 defValue=h.nt,
                                                 targetFunc=self.onNumTimes)

            G.makeTxt(self, hsz, '')
            defcols = [_COLORS[_WAVES.index(w)] for w in h.waves]
            h.nwChecks = [
                G.makeCheck(self,
                            hsz,
                            "",
                            defChecked=(col in defcols),
                            targetFunc=self.onWaves) for col in _COLORS
            ]

            h.nzlabel = G.makeTxt(self,
                                  hsz,
                                  str(int(h.getZ())),
                                  flag=wx.ALIGN_RIGHT)

            h.pxlsiz_txt = wx.TextCtrl(self,
                                       -1,
                                       '%.2f' % h.pxlsiz,
                                       size=(50, -1))
            hsz.Add(h.pxlsiz_txt)
            #label, self.pxlsiz_txt = G.makeTxtBox(self, hsz, '', '0.10', tip='The size of a pixel after magnification', sizeX=50)
            wx.EVT_TEXT(self, h.pxlsiz_txt.GetId(), self.onPxlSiz)

        bsz = wx.StdDialogButtonSizer()
        sizer.Add(bsz, 0, wx.EXPAND)

        button = wx.Button(self, wx.ID_CANCEL)
        bsz.AddButton(button)

        self.okbutton = wx.Button(self, wx.ID_OK)
        bsz.AddButton(self.okbutton)

        bsz.Realize()

        self.SetSizer(sizer)
        sizer.Fit(self)
Пример #8
0
    def __init__(self, parent, fn):
        """
        fn: a chromagnon file
        """
        wx.Panel.__init__(self, parent, -1)

        self.clist = ChromagnonList(self, fn)
        self.fn = fn

        # start drawing
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        # \n
        box = G.newSpaceV(sizer)
        G.makeTxt(self, box, fn)

        # \n
        box = G.newSpaceV(sizer)
        if self.clist.map_str != 'None':
            G.makeTxt(self, box, 'Local: ')
            self.local_label = G.makeTxt(self, box, self.clist.map_str)
            self.viewLocalButton = G.makeButton(
                self,
                box,
                self.onViewLocal,
                title='View',
                tip='View local distortion as a image')
            # \n
            box = G.newSpaceV(sizer)
            G.makeTxt(
                self, box,
                "The file is a .ome.tif file, and the alignment parameters are stored in it's metadata."
            )
        else:
            # \n
            box = G.newSpaceV(sizer)
            G.makeTxt(
                self, box,
                'The file is a text file: rename to ".csv" to open as a spread sheet.'
            )

        # \n\n
        box = G.newSpaceV(sizer)
        G.makeTxt(self, box, ' ')
        box = G.newSpaceV(sizer)
        G.makeTxt(
            self, box, 'Pixel size ZYX (um): %.3f  %.3f  %.3f' %
            tuple(self.clist.creader.pxlsiz))

        if self.clist.nt > 1:
            # \n
            box = G.newSpaceV(sizer)
            label, self.tSliderBox = G.makeTxtBox(self,
                                                  box,
                                                  'T',
                                                  defValue=str(self.clist.t),
                                                  tip='enter time idx',
                                                  style=wx.TE_PROCESS_ENTER)

            self.tSliderBox.Bind(wx.EVT_TEXT_ENTER, self.OnTSliderBox)

            G.makeTxt(self, box, r'/' + str(self.clist.nt - 1))

            self.tSlider = wx.Slider(self,
                                     wx.ID_ANY,
                                     0,
                                     0,
                                     self.clist.nt - 1,
                                     size=wx.Size(150, -1),
                                     style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS)
            box.Add(self.tSlider, 6, wx.ALL | wx.ALIGN_LEFT, 2)
            wx.EVT_SLIDER(self, self.tSlider.GetId(), self.OnTSlider)

        # \n
        box = G.newSpaceV(sizer)
        box.Add(self.clist)

        # \n
        box = G.newSpaceV(sizer)

        self.saveButton = G.makeButton(
            self,
            box,
            self.onSave,
            title='Save as...',
            tip='Save editted parameter into a chromagnon file'
        )  #, enable=False)

        #self.exportButton = G.makeButton(self, box, self.onExport, title='Export as .csv', tip='Save editted parameter into a comma separated file')

        self.clearButton = G.makeButton(self,
                                        box,
                                        self.clearSelected,
                                        title='Remove selected',
                                        tip='Remove one wavelength')

        self.addButton = G.makeButton(self,
                                      box,
                                      self.addRow,
                                      title='add wavelength',
                                      tip='Add one wavelength')

        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self.clist)
        self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemSelected, self.clist)
Пример #9
0
    def makePanel(self, tif=False):
        # config
        confdic = C.readConfig()
        self.lastpath = confdic.get('lastpath', '')

        # draw / arrange
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        # ---- reference ------
        # \n
        box = G.newSpaceV(sizer)
        self.refAddButton = G.makeButton(self, box, self.OnChooseReferenceFile, title='Reference file', tip='', enable=True)

        self.refClearButton = G.makeButton(self, box, lambda ev:self.clearSelected(ev, 'ref'), title='Clear selected', tip='', enable=False)

        flatSuffixLabel, self.flat_suffix_txt = G.makeTxtBox(self, box, 'Suffix', defValue=confdic.get('flat_suffix_txt', ''), tip='A suffix before the file extention for the .flat file name', sizeX=100)
        
        #------- execute ------

        self.goButton = wx.ToggleButton(self, -1, 'Run all')

        if sys.platform.startswith('win'):
            ft = wx.Font(9, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD)
        elif sys.platform.startswith('linux'):
            ft = wx.Font(11, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD)
        else:
            ft = wx.Font(14, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD)
        self.goButton.SetFont(ft)
        #self.goButton.SetToolTipString('Open a graphical interphase to flat field images')
        gosize = self.refAddButton.GetSize()[0] + self.refClearButton.GetSize()[0] + self.goButton.GetSize()[0] + flatSuffixLabel.GetSize()[0] + self.flat_suffix_txt.GetSize()[0]

        G.newSpaceH(box, LISTSIZE_X-gosize)

        box.Add(self.goButton)
        frame = self.GetTopLevelParent()
        frame.Bind(wx.EVT_TOGGLEBUTTON, self.OnGo, self.goButton)

        
        ## --- list reference ----
        # \n
        box = G.newSpaceV(sizer)

        
        self.listRef = listbox.FileListCtrl(self, wx.NewId(),
                                 style=wx.LC_REPORT
                                 | wx.BORDER_NONE
                                 | wx.LC_SORT_ASCENDING,
                                 size=(LISTSIZE_X, LIST_Y2),
                                 multiple=False)
        box.Add(self.listRef)
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, lambda ev:self.OnItemSelected(ev, 'reference'), self.listRef)
        self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemSelected, self.listRef)
        self.listRef.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick)

        flatfn = confdic.get('flatfn', '_FLAT')
        if os.path.isfile(flatfn):
            self.listRef.addFile(flatfn)
        
        self.listRef.setDefaultFileLoadFunc(self._load_func)
        # ---- list target ------

        # \n
        box = G.newSpaceV(sizer)

        self.tgtAddButton = G.makeButton(self, box, self.OnChooseTargetFiles, title='Target files', tip='', enable=True)
        
        self.tgtClearButton = G.makeButton(self, box, lambda ev:self.clearSelected(ev, 'tareget'), title='Clear selected', tip='', enable=False)

        label, self.flatimg_suffix_txt = G.makeTxtBox(self, box, 'Suffix', defValue=confdic.get('flatimg_suffix_txt', '_'+flatConv.EXT.upper()), tip='A suffix for the output file name', sizeX=100)

        choices = [os.path.extsep + form for form in aligner.WRITABLE_FORMATS]
        label, self.outextch = G.makeListChoice(self, box, '', choices, defValue=confdic.get('flat_format', aligner.WRITABLE_FORMATS[0]), tip='Choose image file formats; for reading with ImageJ, dv is recommended.')
        
        # \n
        box = G.newSpaceV(sizer)
        
        self.listTgt = listbox.FileListCtrl(self, wx.NewId(),
                                 style=wx.LC_REPORT
                                 | wx.BORDER_NONE
                                 | wx.LC_SORT_ASCENDING,
                                size=(LISTSIZE_X, LIST_Y)
                                 )
        box.Add(self.listTgt)
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, lambda ev:self.OnItemSelected(ev, 'target'), self.listTgt)
        self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemSelected, self.listTgt)
        self.listTgt.Bind(wx.EVT_LEFT_DCLICK, self.OnDoubleClick)

        self.listTgt.setDefaultFileLoadFunc(self._load_func)
        # ---- Drop befavior ----
        self.listRef.setOnDrop(self.checkGo, 1)#goButton.Enable, 1)
        self.listTgt.setOnDrop(self.checkGo, 1)#goButton.Enable, 1)

        
        # ---- Output ------

        # \n
        box = G.newSpaceV(sizer)
        self.label = G.makeTxt(self, box, ' ')


        # ----- finishing -----
        self.Layout()
        #self.parent.Layout()

        self.checkGo()
Пример #10
0
    def initHists(self):
        ''' Initialize the histogram/aligner panel, and a bunch of empty lists;
        define HistogramCanvas class;s doOnBrace() and doOnMouse() behaviors
        '''
        self.histsPanel = scrolled.ScrolledPanel(self, -1)  #wx.Panel(self, -1)

        sizer = wx.BoxSizer(wx.VERTICAL)
        self.histsPanel.SetSizer(sizer)

        cookiecutterSizer = wx.BoxSizer(wx.HORIZONTAL)
        # This sizer contains both the cookie cutter toggle button and the cropbox editor
        sizer.Add(cookiecutterSizer, 0, wx.ALL | wx.EXPAND, 2)

        autoscaleButton = G.makeButton(self.histsPanel,
                                       cookiecutterSizer,
                                       self.OnAutoScale,
                                       title='Auto scale',
                                       tip='')

        self.hist = [None] * self.doc.nw
        self.hist_arr = [None] * self.doc.nw
        self.hist_min = [None] * self.doc.nw
        self.hist_max = [None] * self.doc.nw
        self.hist_toggleButton = [None] * self.doc.nw
        self.hist_show = [None] * self.doc.nw
        self.mmms = [None] * self.doc.nw
        self.intensity_label = [None] * self.doc.nw
        self.hist_label = [None] * self.doc.nw

        self.hist_singleChannelMode = None
        self.hist_toggleID2col = {}

        for i in range(self.doc.nw):
            wave = self.doc.wave[i]  #mrcIO.getWaveFromHdr(self.doc.hdr, i)
            self.hist_show[i] = True

            box = G.newSpaceV(sizer)

            self.hist_toggleButton[i] = G.makeToggleButton(
                self.histsPanel,
                box,
                self.OnHistToggleButton,
                title=str(wave),
                size=(40, -1))
            self.hist_toggleButton[i].Bind(
                wx.EVT_RIGHT_DOWN,
                lambda ev: self.OnHistToggleButton(ev, i=i, mode="r"))
            self.hist_toggleButton[i].SetValue(self.hist_show[i])

            self.intensity_label[i] = G.makeTxt(self.histsPanel, box, ' ')

            box = G.newSpaceV(sizer)

            self.hist[i] = histogram.HistogramCanvas(self.histsPanel,
                                                     size=(200, 30))  #size)

            box.Add(self.hist[i])

            for ii, colName in enumerate(_rgbList_names):
                self.hist[i].menu.Insert(ii, _rgbList_menuIDs[ii], colName)
                self.hist[i].Bind(wx.EVT_MENU,
                                  self.OnHistColorChange,
                                  id=_rgbList_menuIDs[ii])

            self.hist[i].menu.InsertSeparator(ii + 1)

            self.hist_toggleID2col[self.hist_toggleButton[i].GetId()] = i

            #/n
            box = G.newSpaceV(sizer)
            self.hist_label[i] = G.makeTxt(self.histsPanel, box, ' ')

            def fff(s, ii=i):
                l, r = s.leftBrace, s.rightBrace
                for v in self.viewers:
                    ## TODO: different scaling for x-z and y-z viewer??
                    v.changeHistScale(ii, l, r)

            self.hist[i].doOnBrace.append(fff)

            def ggg(xEff, ev, ii=i):
                l, r = self.hist[ii].leftBrace, self.hist[ii].rightBrace
                if self.doc.dtype in (N.uint8, N.int16, N.uint16, N.int32):
                    self.hist_label[ii].SetLabel("I: %6.0f  l/r: %6.0f %6.0f" %
                                                 (xEff, l, r))
                else:
                    self.hist_label[ii].SetLabel("I: %7.1f  l/r: %7.1f %7.1f" %
                                                 (xEff, l, r))

            self.hist[i].doOnMouse.append(ggg)

        if self.doc.nw > 1:
            for i in range(self.doc.nw):
                wave = self.doc.wave[i]
                self.setColor(i, wave, False)

        #/n/n
        box = G.newSpaceV(sizer)
        G.makeTxt(self.histsPanel, box, ' ')  # dummy
        box = G.newSpaceV(sizer)
        self.xy_label = G.makeTxt(self.histsPanel, box, ' ')

        self.histsPanel.SetAutoLayout(1)
        self.histsPanel.SetupScrolling()
Пример #11
0
    def addZslider(self):
        self.sliderPanel = wx.Panel(self, -1)

        sizer = wx.BoxSizer(wx.VERTICAL)
        self.sliderPanel.SetSizer(sizer)

        # image info
        # \n
        box = G.newSpaceV(sizer)

        bb, box = G.newStaticBox(self.sliderPanel,
                                 box,
                                 title='Image info',
                                 size=wx.DefaultSize)

        if sys.platform.startswith(('win', 'linux')):
            fsize = 9
        else:
            fsize = 11
        font = wx.Font(fsize, wx.SWISS, wx.NORMAL, wx.NORMAL)

        # pixel size
        pxsiz = tuple(self.doc.pxlsiz[::-1])
        dimstr = ('X', 'Y', 'Z')
        line = 'Pixel size (um):\n'
        pxstr = '  '
        for i, d in enumerate(pxsiz):
            if d:
                pxstr += '%s %.3f: ' % (dimstr[i], d)
        if pxstr:
            line += pxstr[:-2]
        else:
            line = ''
        if line:
            label = G.makeTxt(self.sliderPanel, box, line)
            label.SetFont(font)
        # data type
        pxtype = imgio.bioformatsIO.pixeltype_to_bioformats(self.doc.dtype)
        line = 'Data type: %s' % pxtype
        label = G.makeTxt(self.sliderPanel, box, line)
        label.SetFont(font)

        # z slider
        if self.doc.nz > 1:
            topSizer = G.newSpaceV(sizer)

            #label, self.zSliderBox = G.makeTxtBox(self.sliderPanel, topSizer, 'Z', defValue=str(self.doc.z), tip='enter z idx', style=wx.TE_PROCESS_ENTER)
            label, self.zSliderBox = G.makeTxtBox(self.sliderPanel,
                                                  topSizer,
                                                  'Z',
                                                  defValue=self.doc.z,
                                                  tip='enter z idx',
                                                  style=wx.TE_PROCESS_ENTER)

            self.zSliderBox.Bind(wx.EVT_TEXT_ENTER, self.OnZSliderBox)

            G.makeTxt(self.sliderPanel, topSizer, r'/' + str(self.doc.nz - 1))

            self.zSlider = wx.Slider(
                self.sliderPanel,
                wx.ID_ANY,
                self.doc.z,
                0,
                self.doc.nz - 1,
                size=wx.Size(150, -1),
                style=wx.SL_HORIZONTAL
                | wx.SL_AUTOTICKS)  #|wx.SL_LABELS | wx.SL_AUTOTICKS)

            topSizer.Add(self.zSlider, 6, wx.ALL | wx.ALIGN_LEFT, 2)
            #wx.EVT_SLIDER(self, self.zSlider.GetId(), self.OnZSlider)
            self.Bind(wx.EVT_SLIDER, self.OnZSlider, id=self.zSlider.GetId())
            #wx.EVT_KEY_DOWN(self, self.zSlider.GetId(), self.OnKeyZSlider)
            #self.zSlider.Bind(wx.EVT_KEY_DOWN, self.OnKeyZSlider)
            if self.doc.nt == 1:
                self.sliderPanel.Bind(wx.EVT_KEY_DOWN, self.OnKeyZSlider)
            self.zSlider.Bind(wx.EVT_KEY_DOWN, self.OnKeyZSlider)
            #self.Bind(wx.EVT_CHAR, self.OnKeyZSlider)

            #/n
            box = G.newSpaceV(sizer)

            autofocusButton = G.makeButton(self.sliderPanel,
                                           box,
                                           self.OnAutoFocus,
                                           title='Auto focus',
                                           tip='')

            #/n
            box = G.newSpaceV(sizer)

            self.orthogonal_toggle = G.makeToggleButton(
                self.sliderPanel,
                box,
                self.onOrthogonal,
                title='Orthogonal projections')

            #/n
            box = G.newSpaceV(sizer)
            self.saveScrButton = G.makeButton(self.sliderPanel,
                                              box,
                                              self.onSaveScr,
                                              title='Save screen')

            self.choice_viewers = ['XY', 'XZ', 'ZY']
            label, self.viewerch = G.makeListChoice(
                self.sliderPanel,
                box,
                'viewer',
                self.choice_viewers,
                defValue=[self.choice_viewers[0]])
            self.viewerch.Enable(0)

        # t slider
        if self.doc.nt > 1:  ## need a time slider
            box = G.newSpaceV(sizer)

            label, self.tSliderBox = G.makeTxtBox(self.sliderPanel,
                                                  box,
                                                  'T',
                                                  defValue=str(self.doc.t),
                                                  tip='enter time idx',
                                                  style=wx.TE_PROCESS_ENTER)

            self.tSliderBox.Bind(wx.EVT_TEXT_ENTER, self.OnTSliderBox)

            G.makeTxt(self.sliderPanel, box, r'/' + str(self.doc.nt - 1))

            self.tSlider = wx.Slider(
                self.sliderPanel,
                wx.ID_ANY,
                0,
                0,
                self.doc.nt - 1,
                size=wx.Size(150, -1),
                style=wx.SL_HORIZONTAL
                | wx.SL_AUTOTICKS)  #|wx.SL_LABELS | wx.SL_AUTOTICKS)
            box.Add(self.tSlider, 6, wx.ALL | wx.ALIGN_LEFT, 2)
            #wx.EVT_SLIDER(self, self.tSlider.GetId(), self.OnTSlider)
            self.Bind(wx.EVT_SLIDER, self.OnTSlider, id=self.tSlider.GetId())

            if self.doc.nz == 1:
                self.sliderPanel.Bind(wx.EVT_KEY_DOWN, self.OnKeyTSlider)
            self.tSlider.Bind(wx.EVT_KEY_DOWN, self.OnKeyTSlider)
Пример #12
0
    def __init__(self, parent, fn):
        """
        fn: a chromagnon file
        """
        wx.Panel.__init__(self, parent, -1)

        self.clist = ChromagnonList(self, fn)
        self.fn = fn

        # start drawing
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        # \n
        box = G.newSpaceV(sizer)
        G.makeTxt(self, box, fn)

        # \n
        box = G.newSpaceV(sizer)
        if self.clist.map_str != 'None':
            G.makeTxt(self, box, 'Local: ')
            self.local_label = G.makeTxt(self, box, self.clist.map_str)

            # \n
            box = G.newSpaceV(sizer)

            self.viewLocalButton = G.makeButton(
                self,
                box,
                self.onViewLocal,
                title='View',
                tip='View local distortion as a image')

            choice = [
                str(wave) for wave in self.clist.wave
                if wave != self.clist.wave[self.clist.refwave]
            ]
            label, self.wavechoice = G.makeListChoice(self,
                                                      box,
                                                      'wavelength',
                                                      choice,
                                                      defValue=choice[0])

            self.originalFileButton = G.makeButton(self,
                                                   box,
                                                   self.onChooseOriginalFile,
                                                   title='original image file',
                                                   tip='')

            default = os.path.splitext(fn)[0]
            if default.endswith('chromagnon'):
                default = os.path.splitext(default)[0]
            if not os.path.isfile(default):
                default = ''
            label, self.originalFileTxt = G.makeTxtBox(self,
                                                       box,
                                                       '',
                                                       defValue=default,
                                                       tip='',
                                                       sizeX=200)

            choice = [str(factor) for factor in (1, 5, 10, 15, 20)]
            label, self.factorchoice = G.makeListChoice(self,
                                                        box,
                                                        'magnification',
                                                        choice,
                                                        defValue=choice[2])

            self.color_name = ['black'] + [
                colstr for colstr in microscope.COLOR_NAME
            ]
            label, self.colorchoice = G.makeListChoice(
                self,
                box,
                'arrow color',
                self.color_name,
                defValue=self.color_name[-1])

            # \n
            box = G.newSpaceV(sizer)
            G.makeTxt(
                self, box,
                "The file is a .ome.tif file, and the alignment parameters are stored in it's metadata."
            )
        else:
            # \n
            box = G.newSpaceV(sizer)
            G.makeTxt(
                self, box,
                'The file is a text file: rename to ".csv" to open as a spread sheet.'
            )

        # \n\n
        box = G.newSpaceV(sizer)
        G.makeTxt(self, box, ' ')
        box = G.newSpaceV(sizer)
        G.makeTxt(
            self, box, 'Pixel size ZYX (um): %.3f  %.3f  %.3f' %
            tuple(self.clist.creader.pxlsiz))

        if self.clist.nt > 1:
            # \n
            box = G.newSpaceV(sizer)
            label, self.tSliderBox = G.makeTxtBox(self,
                                                  box,
                                                  'T',
                                                  defValue=str(self.clist.t),
                                                  tip='enter time idx',
                                                  style=wx.TE_PROCESS_ENTER)

            self.tSliderBox.Bind(wx.EVT_TEXT_ENTER, self.OnTSliderBox)

            G.makeTxt(self, box, r'/' + str(self.clist.nt - 1))

            self.tSlider = wx.Slider(self,
                                     wx.ID_ANY,
                                     0,
                                     0,
                                     self.clist.nt - 1,
                                     size=wx.Size(150, -1),
                                     style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS)
            box.Add(self.tSlider, 6, wx.ALL | wx.ALIGN_LEFT, 2)
            wx.EVT_SLIDER(self, self.tSlider.GetId(), self.OnTSlider)

        # \n
        box = G.newSpaceV(sizer)
        box.Add(self.clist)

        # \n
        box = G.newSpaceV(sizer)

        self.saveButton = G.makeButton(
            self,
            box,
            self.onExport,
            title='Save as...',
            tip='Save editted parameter into a chromagnon file'
        )  #, enable=False)

        #self.exportButton = G.makeButton(self, box, self.onExport, title='Export as .csv', tip='Save editted parameter into a comma separated file')

        self.clearButton = G.makeButton(self,
                                        box,
                                        self.clearSelected,
                                        title='Remove selected',
                                        tip='Remove one wavelength')

        self.addButton = G.makeButton(self,
                                      box,
                                      self.addRow,
                                      title='add wavelength',
                                      tip='Add one wavelength')

        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self.clist)
        self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemSelected, self.clist)
Пример #13
0
    def __init__(self, parent, listRef, confdic={}, outdir=None, refwave=None):


        self.outdir = None

        wx.Dialog.__init__(self, parent, id=-1, title='Extra parameters')

        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        # -------- output dir -----------
        # \n
        box = G.newSpaceV(sizer)
        bb, box = G.newStaticBox(self, box, title='Output direcotry', size=wx.DefaultSize)

        self.outdir_cb = G.makeCheck(self, box, "same as input direcotry", tip='', defChecked=not(bool(outdir)), targetFunc=self.OnOutDirCb)
        self.chooseOurDirButton = G.makeButton(self, box, self.OnChooseOutDir, title='Choose', tip='', enable=not(self.outdir_cb.GetValue()))

        self.outdir = confdic.get('outdir', '')
        self.outdir_label = G.makeTxt(self, box, self.outdir)
        self.outdir_label.Enable(not(self.outdir_cb.GetValue()))

        # -------- reference wave -----------
        if listRef and listRef.columnkeys:

            waves1 = [list(listRef.getFile(index)[2].split(',')) for index in listRef.columnkeys]
            waves = set()
            for wave in waves1:
                [waves.add(w) for w in wave]
            waves = list(waves)
            waves.sort()

            if len(waves) > 1:
                # \n
                box = G.newSpaceV(sizer)
                bb, box = G.newStaticBox(self, box, title='Reference wavelength', size=wx.DefaultSize)
                if refwave is not None and refwave not in waves:
                    refwave = None
                self.refwave_cb = G.makeCheck(self, box, "auto", tip='', defChecked=not(bool(refwave)), targetFunc=self.OnRefWaveCb)
                label, self.refwave_choice = G.makeListChoice(self, box, '', waves, defValue=refwave or waves[0], tip='Reference wavelength that does not move', targetFunc=self.OnRefWaveChoice)
                self.refwave_choice.Enable(not(self.refwave_cb.GetValue()))

                self.refwave_label = G.makeTxt(self, box, refwave or 'auto')
                self.refwave_label.Enable(not(self.refwave_cb.GetValue()))

        # -------- z accur -----------
        # \n
        box = G.newSpaceV(sizer)
        bb, box = G.newStaticBox(self, box, title='Z-accuracy', size=wx.DefaultSize)
        accurChoice = [str(i) for i in aligner.ACCUR_CHOICE]
        label, self.accurListChoice = G.makeListChoice(self, box, 'Iteration of 3D phase correlation', accurChoice, defValue=confdic.get('accur', accurChoice[0]))

        # -------- max shift -----------
        # \n
        box = G.newSpaceV(sizer)
        bb, box = G.newStaticBox(self, box, title='Maximum shift the channels are possibly misaligned', size=wx.DefaultSize)
        label, self.maxshift_text = G.makeTxtBox(self, box, 'Shift (um)', defValue=confdic.get('max_shift', str(af.MAX_SHIFT)), tip='Maximum shift the channels are possibly misaligned', sizeX=40)
        
        # -------- what to do for time series --------
        if listRef and listRef.columnkeys:

            nt = max([int(listRef.getFile(index)[3]) for index in listRef.columnkeys])
            nw = max([len(listRef.getFile(index)[2].split(',')) for index in listRef.columnkeys])
            if nt > 1 and nw > 1:
                # \n
                box = G.newSpaceV(sizer)
                bb, box = G.newStaticBox(self, box, title='Time series with mulitple channels', size=wx.DefaultSize)
                choice = ['time', 'channel']
                label, self.tseriesListChoice = G.makeListChoice(self, box, 'align', choice, defValue=choice[0], tip='Reference wavelength that does not move', targetFunc=self.OnRefWaveChoice)
        
        # -------- OK and Cancel -----------
        btnsizer = wx.StdDialogButtonSizer()

        btn = wx.Button(self, wx.ID_OK)
        btn.SetDefault()
        btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_CANCEL)
        btnsizer.AddButton(btn)
        btnsizer.Realize()

        sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        sizer.Fit(self)
Пример #14
0
    def __init__(self, parent, fn):
        """
        fn: a chromagnon file
        """
        wx.Panel.__init__(self, parent, -1)
        
        self.clist = ChromagnonList(self, fn)
        self.fn = fn

        # start drawing
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        # \n
        box = G.newSpaceV(sizer)
        G.makeTxt(self, box, fn)

        # \n
        box = G.newSpaceV(sizer)
        if self.clist.map_str != 'None':
            G.makeTxt(self, box, 'Local: ')
            self.local_label = G.makeTxt(self, box, self.clist.map_str)
            
            # \n
            box = G.newSpaceV(sizer)
            
            self.viewLocalButton = G.makeButton(self, box, self.onViewLocal, title='View', tip='View local distortion as a image')

            choice = [str(wave) for wave in self.clist.wave if wave != self.clist.wave[self.clist.refwave]]
            label, self.wavechoice = G.makeListChoice(self, box, 'wavelength', choice, defValue=choice[0])

            self.originalFileButton = G.makeButton(self, box, self.onChooseOriginalFile, title='original image file', tip='')

            default = os.path.splitext(fn)[0]
            if default.endswith('chromagnon'):
                default = os.path.splitext(default)[0]
            if not os.path.isfile(default):
                default = ''
            label, self.originalFileTxt = G.makeTxtBox(self, box, '', defValue=default, tip='', sizeX=200)

            choice = [str(factor) for factor in (1,5,10,15,20)]
            label, self.factorchoice = G.makeListChoice(self, box, 'magnification', choice, defValue=choice[2])

            self.color_name = ['black'] + [colstr for colstr in microscope.COLOR_NAME]
            label, self.colorchoice = G.makeListChoice(self, box, 'arrow color', self.color_name, defValue=self.color_name[-1])
            
            # \n
            box = G.newSpaceV(sizer)
            G.makeTxt(self, box, "The file is a tif file, and the alignment parameters are stored in it's metadata.")
        else:
            # \n
            box = G.newSpaceV(sizer)
            G.makeTxt(self, box, 'The file is a text file')

        # \n\n
        box = G.newSpaceV(sizer)
        G.makeTxt(self, box, ' ')
        box = G.newSpaceV(sizer)
        G.makeTxt(self, box, 'Pixel size ZYX (um): %.3f  %.3f  %.3f' % tuple(self.clist.creader.pxlsiz))

        if self.clist.nt > 1:
            # \n
            box = G.newSpaceV(sizer)
            label, self.tSliderBox = G.makeTxtBox(self, box, 'T', defValue=str(self.clist.t), tip='enter time idx', style=wx.TE_PROCESS_ENTER)
            
            self.tSliderBox.Bind(wx.EVT_TEXT_ENTER, self.OnTSliderBox)

            G.makeTxt(self, box, r'/'+str(self.clist.nt-1))

            self.tSlider = wx.Slider(self, wx.ID_ANY, 0, 0,
                                     self.clist.nt-1,
                                     size=wx.Size(150,-1),
                                     style = wx.SL_HORIZONTAL | wx.SL_AUTOTICKS)
            box.Add(self.tSlider, 6, wx.ALL|wx.ALIGN_LEFT, 2)
            wx.EVT_SLIDER(self, self.tSlider.GetId(), self.OnTSlider)

        
        # \n
        box = G.newSpaceV(sizer)
        box.Add(self.clist)

        # \n
        box = G.newSpaceV(sizer)

        self.saveButton = G.makeButton(self, box, self.onExport, title='Save as...', tip='Save editted parameter into a chromagnon file')#, enable=False)

        #self.exportButton = G.makeButton(self, box, self.onExport, title='Export as .csv', tip='Save editted parameter into a comma separated file')

        self.clearButton = G.makeButton(self, box, self.clearSelected, title='Remove selected', tip='Remove one wavelength')

        self.addButton = G.makeButton(self, box, self.addRow, title='add wavelength', tip='Add one wavelength')

        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, self.clist)
        self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnItemSelected, self.clist)