Exemple #1
0
    def update_fdr_buttons(self):
        """
        When the heatmap volume has been changed, check for the presence of q->t threshold mapping dict and set buttons if present

        """
        slice_layers = self.controller.current_view.layers
        heatmap_vol = slice_layers[Layers.heatmap].vol
        if not heatmap_vol:
            return

        row = 0
        col = 0

        self.clear_layout(self.ui.gridLayoutFdrButtons)

        if heatmap_vol.fdr_thresholds:
            self.ui.labelFdrThresholds.show()
            group = QtGui.QButtonGroup(self)
            for q, t in heatmap_vol.fdr_thresholds.items():
                try:
                    float(t)
                except (ValueError, TypeError):
                    continue
                button = QtGui.QPushButton(str(q))
                group.addButton(button)
                button.clicked.connect(partial(self.on_fdr_button_clicked, t))
                self.ui.gridLayoutFdrButtons.addWidget(button, row, col)
                col += 1
                if col > 5:
                    row += 1
                    col = 0
        else:
            self.ui.labelFdrThresholds.hide()
    def __init__(self, choices, orientation='horizontal', parent=None):
        """
        The choices are specified as a list of dictionaries containing:

        * 'label': Shown in the UI
        * 'value': The value returned is selected

        :param choices: List of choices. See description.
        :param orientation: 'horizontal' (default) of 'vertical'.
        :param parent: Qt parent widget.
        :type choices: list
        """
        super(RadioSet, self).__init__(parent)
        self.choices = copy(choices)

        if orientation == 'horizontal':
            layout = QtGui.QHBoxLayout()
        else:
            layout = QtGui.QVBoxLayout()

        group = QtGui.QButtonGroup(self)

        for choice in self.choices:
            choice['radio'] = QtGui.QRadioButton(choice['label'])
            group.addButton(choice['radio'])
            layout.addWidget(choice['radio'], stretch=0)
            choice['radio'].toggled.connect(self.on_toggle)

        layout.addStretch()
        self.setLayout(layout)

        self.group_toggle_fn = lambda: None
Exemple #3
0
    def createButtons(self):
        iconSize = QtCore.QSize(30, 30)
        openButton = QtGui.QToolButton()
        openButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_DialogOpenButton))
        openButton.setIconSize(iconSize)
        openButton.setToolTip("Open ops file")
        openButton.clicked.connect(self.open)

        self.playButton = QtGui.QToolButton()
        self.playButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_MediaPlay))
        self.playButton.setIconSize(iconSize)
        self.playButton.setToolTip("Play")
        self.playButton.setCheckable(True)
        self.playButton.clicked.connect(self.start)

        self.pauseButton = QtGui.QToolButton()
        self.pauseButton.setCheckable(True)
        self.pauseButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_MediaPause))
        self.pauseButton.setIconSize(iconSize)
        self.pauseButton.setToolTip("Pause")
        self.pauseButton.clicked.connect(self.pause)

        btns = QtGui.QButtonGroup(self)
        btns.addButton(self.playButton,0)
        btns.addButton(self.pauseButton,1)
        btns.setExclusive(True)

        self.l0.addWidget(openButton,0,0,1,1)
        self.l0.addWidget(self.playButton,14,12,1,1)
        self.l0.addWidget(self.pauseButton,14,13,1,1)
        #self.l0.addWidget(quitButton,0,1,1,1)
        self.playButton.setEnabled(False)
        self.pauseButton.setEnabled(False)
        self.pauseButton.setChecked(True)
 def flipOptions(self):
     groupBox = QtGui.QGroupBox("Tablet Orientation")
     groupBox.setAlignment(QtCore.Qt.AlignHCenter)
     groupBox.setFixedHeight(120)
     self.tabletFlipGroup = QtGui.QButtonGroup(groupBox)
     self.tabletRight = QtGui.QRadioButton("Right-Handed")
     self.tabletLeft = QtGui.QRadioButton("Left-Handed")
     self.tabletFlipGroup.addButton(self.tabletRight)
     self.tabletFlipGroup.addButton(self.tabletLeft)
     flipLayout = QtGui.QVBoxLayout()
     flipLayout.addWidget(self.tabletRight)
     flipLayout.addWidget(self.tabletLeft)
     flipLayout.addStretch(1)
     getCommand = os.popen("xsetwacom --get \"%s stylus\" Rotate" %
                           self.tabletStylus).readlines()
     # check correct button for orientation
     if getCommand[0] == "none\n":
         self.orient = "xsetwacom --set \"%s stylus\" Rotate none" % self.tabletStylus
         self.orient += "\nxsetwacom --set \"%s eraser\" Rotate none" % self.tabletEraser
         self.tabletRight.setChecked(1)
     elif getCommand[0] == "half\n":
         self.orient = "xsetwacom --set \"%s stylus\" Rotate half" % self.tabletStylus
         self.orient += "\nxsetwacom --set \"%s eraser\" Rotate half" % self.tabletEraser
         self.tabletLeft.setChecked(1)
     self.tabletFlipGroup.buttonClicked.connect(self.tabletFlipChange)
     groupBox.setLayout(flipLayout)
     return groupBox
Exemple #5
0
def make_selection(parent):
    """ buttons to draw a square on view """
    parent.topbtns = QtGui.QButtonGroup()
    ql = QtGui.QLabel("select cells")
    ql.setStyleSheet("color: white;")
    ql.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
    parent.l0.addWidget(ql, 0, 2, 1, 2)
    pos = [2, 3, 4]
    for b in range(3):
        btn = TopButton(b, parent)
        btn.setFont(QtGui.QFont("Arial", 8))
        parent.topbtns.addButton(btn, b)
        parent.l0.addWidget(btn, 0, (pos[b]) * 2, 1, 2)
        btn.setEnabled(False)
    parent.topbtns.setExclusive(True)
    parent.isROI = False
    parent.ROIplot = 0
    ql = QtGui.QLabel("n=")
    ql.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
    ql.setStyleSheet("color: white;")
    ql.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
    parent.l0.addWidget(ql, 0, 10, 1, 1)
    parent.topedit = QtGui.QLineEdit(parent)
    parent.topedit.setValidator(QtGui.QIntValidator(0, 500))
    parent.topedit.setText("40")
    parent.ntop = 40
    parent.topedit.setFixedWidth(35)
    parent.topedit.setAlignment(QtCore.Qt.AlignRight)
    parent.topedit.returnPressed.connect(parent.top_number_chosen)
    parent.l0.addWidget(parent.topedit, 0, 11, 1, 1)
Exemple #6
0
    def createButtons(self):
        iconSize = QtCore.QSize(30, 30)
        openButton = QtGui.QPushButton('load ops.npy')
        #openButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_DialogOpenButton))
        #openButton.setIconSize(iconSize)
        openButton.setToolTip("Open single-plane ops.npy")
        openButton.clicked.connect(self.open)

        openButton2 = QtGui.QPushButton('load ops1.npy')
        #openButton2.setIcon(self.style().standardIcon(QtGui.QStyle.SP_DirOpenIcon))
        #openButton2.setIconSize(iconSize)
        #openButton2.setToolTip("Open multi-plane ops1.npy")
        openButton2.clicked.connect(self.open_combined)

        loadZ = QtGui.QPushButton('load z-stack tiff')
        loadZ.clicked.connect(self.load_zstack)

        self.computeZ = QtGui.QPushButton('compute z position')
        self.computeZ.setEnabled(False)
        self.computeZ.clicked.connect(self.compute_z)

        self.playButton = QtGui.QToolButton()
        self.playButton.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_MediaPlay))
        self.playButton.setIconSize(iconSize)
        self.playButton.setToolTip("Play")
        self.playButton.setCheckable(True)
        self.playButton.clicked.connect(self.start)

        self.pauseButton = QtGui.QToolButton()
        self.pauseButton.setCheckable(True)
        self.pauseButton.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_MediaPause))
        self.pauseButton.setIconSize(iconSize)
        self.pauseButton.setToolTip("Pause")
        self.pauseButton.clicked.connect(self.pause)

        btns = QtGui.QButtonGroup(self)
        btns.addButton(self.playButton, 0)
        btns.addButton(self.pauseButton, 1)
        btns.setExclusive(True)

        quitButton = QtGui.QToolButton()
        quitButton.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_DialogCloseButton))
        quitButton.setIconSize(iconSize)
        quitButton.setToolTip("Quit")
        quitButton.clicked.connect(self.close)

        self.l0.addWidget(openButton, 1, 0, 1, 2)
        self.l0.addWidget(openButton2, 2, 0, 1, 2)
        self.l0.addWidget(loadZ, 3, 0, 1, 2)
        self.l0.addWidget(self.computeZ, 4, 0, 1, 2)
        self.l0.addWidget(self.playButton, 15, 0, 1, 1)
        self.l0.addWidget(self.pauseButton, 15, 1, 1, 1)
        #self.l0.addWidget(quitButton,0,1,1,1)
        self.playButton.setEnabled(False)
        self.pauseButton.setEnabled(False)
        self.pauseButton.setChecked(True)
Exemple #7
0
def make_quadrants(parent):
    parent.quadbtns = QtGui.QButtonGroup(parent)
    for b in range(9):
        btn = QuadButton(b, ' ' + str(b + 1), parent)
        parent.quadbtns.addButton(btn, b)
        parent.l0.addWidget(btn, 0 + parent.quadbtns.button(b).ypos,
                            29 + parent.quadbtns.button(b).xpos, 1, 1)
        btn.setEnabled(False)
        b += 1
    parent.quadbtns.setExclusive(True)
    def penSettings(self):
        groupBox = QtGui.QGroupBox("Mode")
        groupBox.setAlignment(QtCore.Qt.AlignCenter)
        self.penGroup = QtGui.QButtonGroup(groupBox)
        self.penAbs = QtGui.QRadioButton("Absolute")
        self.penAbs.setToolTip("%s maps 1:1 to mapped input area." %
                               self.sensor.title())
        self.penRel = QtGui.QRadioButton("Relative")
        self.penRel.setToolTip("%s moves relative to when it is detected." %
                               self.sensor.title())

        self.penGroup.addButton(self.penAbs)
        self.penGroup.addButton(self.penRel)

        penLayout = QtGui.QHBoxLayout()
        penLayout.addWidget(self.penAbs)
        penLayout.addWidget(self.penRel)
        penLayout.addStretch(1)

        #if self.sensor == 'stylus' or self.sensor == 'eraser':
        getCommand = os.popen(
            "xsetwacom --get \"%s %s\" Mode" %
            (self.tabletName, self.sensor.lower())).readlines()
        #check stylus mode
        if getCommand[0] == "Absolute\n":
            self.penMode = "xsetwacom --set \"%s %s\" mode Absolute" % (
                self.tabletName, self.sensor.lower())
            self.penAbs.setChecked(1)
        elif getCommand[0] == "Relative\n":
            self.penMode = "xsetwacom --set \"%s %s\" mode Relative" % (
                self.tabletName, self.sensor.lower())
            self.penRel.setChecked(1)
        if self.sensor == 'stylus':
            #for buttons
            but1 = os.popen(
                ("xsetwacom --get \"%s %s\" Button 2") %
                (self.tabletName, self.sensor.lower())).readlines()
            but2 = os.popen(
                ("xsetwacom --get \"%s %s\" Button 3") %
                (self.tabletName, self.sensor.lower())).readlines()
            if but1[0].find('3') != -1 and but2[0].find('2') != -1:
                self.buttons.setChecked(True)
            #for tip touch check
            tip = os.popen("xsetwacom --get \"%s %s\" TabletPCButton" %
                           (self.tabletName, self.sensor.lower())).readlines()
            if tip[0].find('on') != -1:
                self.tiptouch.setChecked(True)
        else:
            self.tiptouch.hide()

        self.penGroup.buttonClicked.connect(self.penChange)

        groupBox.setLayout(penLayout)

        return groupBox
Exemple #9
0
    def createButtons(self):
        iconSize = QtCore.QSize(30, 30)
        openButton = QtGui.QToolButton()
        openButton.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_DialogOpenButton))
        openButton.setIconSize(iconSize)
        openButton.setToolTip("Open single-plane ops.npy")
        openButton.clicked.connect(self.open)

        openButton2 = QtGui.QToolButton()
        openButton2.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_DirOpenIcon))
        openButton2.setIconSize(iconSize)
        openButton2.setToolTip("Open multi-plane ops1.npy")
        openButton2.clicked.connect(self.open_combined)

        self.playButton = QtGui.QToolButton()
        self.playButton.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_MediaPlay))
        self.playButton.setIconSize(iconSize)
        self.playButton.setToolTip("Play")
        self.playButton.setCheckable(True)
        self.playButton.clicked.connect(self.start)

        self.pauseButton = QtGui.QToolButton()
        self.pauseButton.setCheckable(True)
        self.pauseButton.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_MediaPause))
        self.pauseButton.setIconSize(iconSize)
        self.pauseButton.setToolTip("Pause")
        self.pauseButton.clicked.connect(self.pause)

        btns = QtGui.QButtonGroup(self)
        btns.addButton(self.playButton, 0)
        btns.addButton(self.pauseButton, 1)
        btns.setExclusive(True)

        quitButton = QtGui.QToolButton()
        quitButton.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_DialogCloseButton))
        quitButton.setIconSize(iconSize)
        quitButton.setToolTip("Quit")
        quitButton.clicked.connect(self.close)

        self.l0.addWidget(openButton, 1, 0, 1, 1)
        self.l0.addWidget(openButton2, 1, 1, 1, 1)
        self.l0.addWidget(self.playButton, 15, 0, 1, 1)
        self.l0.addWidget(self.pauseButton, 15, 1, 1, 1)
        #self.l0.addWidget(quitButton,0,1,1,1)
        self.playButton.setEnabled(False)
        self.pauseButton.setEnabled(False)
        self.pauseButton.setChecked(True)
Exemple #10
0
def func(self):
    layout = QtGui.QHBoxLayout()  # layout for the central widget
    widget = QtGui.QWidget(self)  # central widget
    widget.setLayout(layout)

    number_group = QtGui.QButtonGroup(widget)  # Number group
    r0 = QtGui.QRadioButton("0")
    number_group.addButton(r0)
    r1 = QtGui.QRadioButton("1")
    number_group.addButton(r1)
    layout.addWidget(r0)
    layout.addWidget(r1)

    letter_group = QtGui.QButtonGroup(widget)  # Letter group
    ra = QtGui.QRadioButton("a")
    letter_group.addButton(ra)
    rb = QtGui.QRadioButton("b")
    letter_group.addButton(rb)
    layout.addWidget(ra)
    layout.addWidget(rb)

    # assign the widget to the main window
    self.setCentralWidget(widget)
    self.show()
Exemple #11
0
def make_buttons(parent):
    """ view buttons"""
    # view buttons
    parent.view_names = [
        "Q: ROIs",
        "W: mean img",
        "E: mean img (enhanced)",
        "R: correlation map",
        "T: max projection",
        "Y: mean img chan2, corr",
        "U: mean img chan2",
    ]
    b = 0
    parent.viewbtns = QtGui.QButtonGroup(parent)
    vlabel = QtGui.QLabel(parent)
    vlabel.setText("<font color='white'>Background</font>")
    vlabel.setFont(parent.boldfont)
    vlabel.resize(vlabel.minimumSizeHint())
    parent.l0.addWidget(vlabel, 1, 0, 1, 1)
    for names in parent.view_names:
        btn = ViewButton(b, "&" + names, parent)
        parent.viewbtns.addButton(btn, b)
        if b > 0:
            parent.l0.addWidget(btn, b + 2, 0, 1, 1)
        else:
            parent.l0.addWidget(btn, b + 2, 0, 1, 1)
            label = QtGui.QLabel("sat: ")
            label.setStyleSheet("color: white;")
            parent.l0.addWidget(label, b + 2, 1, 1, 1)
        btn.setEnabled(False)
        b += 1
    parent.viewbtns.setExclusive(True)
    slider = RangeSlider(parent)
    slider.setMinimum(0)
    slider.setMaximum(255)
    slider.setLow(0)
    slider.setHigh(255)
    slider.setTickPosition(QtGui.QSlider.TicksBelow)
    parent.l0.addWidget(slider, 3, 1, len(parent.view_names) - 2, 1)

    b += 2
    return b
Exemple #12
0
    def init_buttons(self):

        self.radio_group = QtGui.QButtonGroup(self.widget)  # Number group
        self.button1 = QtWidgets.QRadioButton('SAP FLUX', self)
        self.button2 = QtWidgets.QRadioButton('PDCSAP FLUX"', self)

        self.radio_group.addButton(self.button1)
        self.radio_group.addButton(self.button2)

        self.radio_group.setId(self.button1, 1)
        self.radio_group.setId(self.button2, 2)

        self.layout.addWidget(self.button1)
        self.layout.addWidget(self.button2)

        self.cancel_button = QtGui.QPushButton('Accept', self)
        self.layout.addWidget(self.cancel_button)

        self.button1.setChecked(True)
        self.cancel_button.clicked.connect(self.close)
Exemple #13
0
def make_cellnotcell(parent):
    # number of ROIs in each image
    parent.lcell0 = QtGui.QLabel("")
    parent.lcell0.setStyleSheet("color: white;")
    parent.lcell0.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
    parent.l0.addWidget(parent.lcell0, 0, 12, 1, 2)
    parent.lcell1 = QtGui.QLabel("")
    parent.lcell1.setStyleSheet("color: white;")
    parent.l0.addWidget(parent.lcell1, 0, 20, 1, 2)

    parent.sizebtns = QtGui.QButtonGroup(parent)
    b = 0
    labels = [" cells", " both", " not cells"]
    for l in labels:
        btn = SizeButton(b, l, parent)
        parent.sizebtns.addButton(btn, b)
        parent.l0.addWidget(btn, 0, 14 + 2 * b, 1, 2)
        btn.setEnabled(False)
        if b == 1:
            btn.setEnabled(True)
        b += 1
    parent.sizebtns.setExclusive(True)
Exemple #14
0
 def screenOptions(self):
     if QtGui.QDesktopWidget().numScreens() == 1:
         self.screenFull = None
         return None
     groupBox = QtGui.QGroupBox("Screen Area")
     groupBox.setAlignment(QtCore.Qt.AlignHCenter)
     groupBox.setFixedHeight(120)
     self.screenGroup = QtGui.QButtonGroup(groupBox)
     self.displays = []
     for x in range(0, QtGui.QDesktopWidget().numScreens()):
         self.displays.append(QtGui.QRadioButton("Monitor %d" % x))
     self.screenFull = QtGui.QRadioButton("All Monitors")
     for screen in self.displays:
         self.screenGroup.addButton(screen)
     self.screenGroup.addButton(self.screenFull)
     screenLayout = QtGui.QVBoxLayout()
     for screen in self.displays:
         screenLayout.addWidget(screen)
     screenLayout.addWidget(self.screenFull)
     screenLayout.addStretch(1)
     self.screenGroup.buttonClicked.connect(self.screenChange)
     groupBox.setLayout(screenLayout)
     return groupBox
Exemple #15
0
def make_buttons(parent, b0):
    """ color buttons at row b0 """
    # color buttons
    parent.color_names = [
        "A: random", "S: skew", "D: compact", "F: footprint",
        "G: aspect_ratio", "H: chan2_prob", "J: classifier, cell prob=",
        "K: correlations, bin=", "L: corr with 1D var, bin=^^^",
        "M: rastermap / custom"
    ]
    parent.colorbtns = QtGui.QButtonGroup(parent)
    clabel = QtGui.QLabel(parent)
    clabel.setText("<font color='white'>Colors</font>")
    clabel.setFont(parent.boldfont)
    parent.l0.addWidget(clabel, b0, 0, 1, 1)

    iwid = 65

    # add colormaps
    parent.CmapChooser = QtGui.QComboBox()
    cmaps = [
        'hsv', 'viridis', 'plasma', 'inferno', 'magma', 'cividis', 'viridis_r',
        'plasma_r', 'inferno_r', 'magma_r', 'cividis_r'
    ]
    parent.CmapChooser.addItems(cmaps)
    parent.CmapChooser.setCurrentIndex(0)
    parent.CmapChooser.activated.connect(lambda: cmap_change(parent))
    parent.CmapChooser.setFont(QtGui.QFont("Arial", 8))
    parent.CmapChooser.setFixedWidth(iwid)
    parent.l0.addWidget(parent.CmapChooser, b0, 1, 1, 1)

    nv = b0
    b = 0
    # colorbars for different statistics
    colorsAll = parent.color_names.copy()
    for names in colorsAll:
        btn = ColorButton(b, "&" + names, parent)
        parent.colorbtns.addButton(btn, b)
        if b > 4 and b < 8:
            parent.l0.addWidget(btn, nv + b + 1, 0, 1, 1)
        else:
            parent.l0.addWidget(btn, nv + b + 1, 0, 1, 2)
        btn.setEnabled(False)
        parent.color_names[b] = parent.color_names[b][3:]
        b += 1
    parent.chan2edit = QtGui.QLineEdit(parent)
    parent.chan2edit.setText("0.6")
    parent.chan2edit.setFixedWidth(iwid)
    parent.chan2edit.setAlignment(QtCore.Qt.AlignRight)
    parent.chan2edit.returnPressed.connect(lambda: chan2_prob(parent))
    parent.l0.addWidget(parent.chan2edit, nv + b - 4, 1, 1, 1)

    parent.probedit = QtGui.QLineEdit(parent)
    parent.probedit.setText("0.5")
    parent.probedit.setFixedWidth(iwid)
    parent.probedit.setAlignment(QtCore.Qt.AlignRight)
    parent.probedit.returnPressed.connect(
        lambda: suite2p.gui.merge.apply(parent))
    parent.l0.addWidget(parent.probedit, nv + b - 3, 1, 1, 1)

    parent.binedit = QtGui.QLineEdit(parent)
    parent.binedit.setValidator(QtGui.QIntValidator(0, 500))
    parent.binedit.setText("1")
    parent.binedit.setFixedWidth(iwid)
    parent.binedit.setAlignment(QtCore.Qt.AlignRight)
    parent.binedit.returnPressed.connect(
        lambda: parent.mode_change(parent.activityMode))
    parent.l0.addWidget(parent.binedit, nv + b - 2, 1, 1, 1)
    b0 = nv + b + 2
    return b0
Exemple #16
0
    def __init__(self, parent=None):
        super(RunWindow, self).__init__(parent)
        self.setGeometry(50,50,1200,900)
        self.setWindowTitle('Choose run options')
        self.win = QtGui.QWidget(self)
        self.layout = QtGui.QGridLayout()
        self.layout.setHorizontalSpacing(25)
        self.win.setLayout(self.layout)
        # initial ops values
        self.opsfile = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                          'ops/ops_user.npy')
        try:
            self.ops = np.load(self.opsfile)
            self.ops = self.ops.item()
            print('loaded default ops')
        except Exception as e:
            print('could not load default ops, using built-in ops settings')
            self.ops = run_s2p.default_ops()
        self.data_path = []
        self.save_path = []
        self.fast_disk = []
        self.opslist = []
        self.batch = False
        tifkeys = ['nplanes','nchannels','functional_chan','diameter','tau','fs','delete_bin']
        outkeys = [['save_mat','combined'],['num_workers','num_workers_roi']]
        regkeys = ['do_registration','align_by_chan','nimg_init', 'batch_size', 'maxregshift','smooth_sigma','keep_movie_raw', 'reg_tif','reg_tif_chan2']
        nrkeys = ['nonrigid','block_size','snr_thresh','maxregshiftNR']
        cellkeys = ['connected','max_overlap','threshold_scaling','smooth_masks','max_iterations','navg_frames_svd','nsvd_for_roi','ratio_neuropil','high_pass']
        neudeconvkeys = [['allow_overlap','inner_neuropil_radius','min_neuropil_pixels'], ['win_baseline','sig_baseline','prctile_baseline','neucoeff']]
        keys = [tifkeys, outkeys, regkeys, nrkeys, cellkeys, neudeconvkeys]
        labels = ['Main settings',['Output settings','Parallel'],'Registration','Nonrigid','ROI detection',['Extraction/Neuropil','Deconvolution']]
        tooltips = ['each tiff has this many planes in sequence',
                    'each tiff has this many channels per plane',
                    'this channel is used to extract functional ROIs (1-based)',
                    'approximate diameter of ROIs in pixels (can input two numbers separated by a comma for elongated ROIs)',
                    'timescale of sensor in deconvolution (in seconds)',
                    'sampling rate (per plane)',
                    'if 1, binary file is deleted after processing is complete',
                    'save output also as mat file "Fall.mat"',
                    'combine results across planes in separate folder "combined" at end of processing',
                    '0 to select num_cores, -1 to disable parallelism, N to enforce value',
                    'ROI detection parallelism: 0 to select number of planes, -1 to disable parallelism, N to enforce value',
                    'if 1, registration is performed',
                    'when multi-channel, you can align by non-functional channel (1-based)',
                    '# of subsampled frames for finding reference image',
                    'number of frames per batch',
                    'max allowed registration shift, as a fraction of frame max(width and height)',
                    '1.15 good for 2P recordings, recommend >5 for 1P recordings',
                    'if 1, unregistered binary is kept in a separate file data_raw.bin',
                    'if 1, registered tiffs are saved',
                    'if 1, registered tiffs of channel 2 (non-functional channel) are saved',
                    'whether to use nonrigid registration (splits FOV into blocks of size block_size)',
                    'block size in number of pixels in Y and X (two numbers separated by a comma)',
                    'if any nonrigid block is below this threshold, it gets smoothed until above this threshold. 1.0 results in no smoothing',
                    'maximum *pixel* shift allowed for nonrigid, relative to rigid',
                    'whether or not to require ROIs to be fully connected (set to 0 for dendrites/boutons)',
                    'ROIs with greater than this overlap as a fraction of total pixels will be discarded',
                    'adjust the automatically determined threshold by this scalar multiplier',
                    'whether to smooth masks in final pass of cell detection',
                    'maximum number of iterations for ROI detection',
                    'max number of binned frames for the SVD',
                    'max number of SVD components to keep for ROI detection',
                    'ratio between neuropil basis size and cell radius',
                    'running mean subtraction with window of size "high_pass" (use low values for 1P)',
                    'allow shared pixels to be used for fluorescence extraction from overlapping ROIs (otherwise excluded from both ROIs)',
                    'number of pixels between ROI and neuropil donut',
                    'minimum number of pixels in the neuropil',
                    'window for maximin',
                    'smoothing constant for gaussian filter',
                    'smoothing constant for gaussian filter',
                    'neuropil coefficient']

        bigfont = QtGui.QFont("Arial", 10, QtGui.QFont.Bold)
        qlabel = QtGui.QLabel('File paths')
        qlabel.setFont(bigfont)
        self.layout.addWidget(qlabel,0,0,1,1)
        #self.loadDb = QtGui.QPushButton('Load db.npy')
        #self.loadDb.clicked.connect(self.load_db)
        #self.layout.addWidget(self.loadDb,0,1,1,1)

        loadOps = QtGui.QPushButton('Load ops file')
        loadOps.clicked.connect(self.load_ops)
        saveDef = QtGui.QPushButton('Save ops as default')
        saveDef.clicked.connect(self.save_default_ops)
        saveOps = QtGui.QPushButton('Save ops to file')
        saveOps.clicked.connect(self.save_ops)
        self.layout.addWidget(loadOps,0,2,1,2)
        self.layout.addWidget(saveDef,1,2,1,2)
        self.layout.addWidget(saveOps,2,2,1,2)
        self.layout.addWidget(QtGui.QLabel(''),3,2,1,2)
        self.layout.addWidget(QtGui.QLabel('Load example ops'),4,2,1,2)
        for k in range(3):
            qw = QtGui.QPushButton('Save ops to file')
        saveOps.clicked.connect(self.save_ops)
        self.opsbtns = QtGui.QButtonGroup(self)
        opsstr = ['cell soma', 'dendrites/axons']
        self.opsname = ['soma', 'dendrite']
        for b in range(len(opsstr)):
            btn = OpsButton(b, opsstr[b], self)
            self.opsbtns.addButton(btn, b)
            self.layout.addWidget(btn, 5+b,2,1,2)
        l=0
        self.keylist = []
        self.editlist = []
        kk=0
        wk=0
        for lkey in keys:
            k = 0
            kl=0
            if type(labels[l]) is list:
                labs = labels[l]
                keyl = lkey
            else:
                labs = [labels[l]]
                keyl = [lkey]
            for label in labs:
                qlabel = QtGui.QLabel(label)
                qlabel.setFont(bigfont)
                self.layout.addWidget(qlabel,k*2,2*(l+2),1,2)
                k+=1
                for key in keyl[kl]:
                    lops = 1
                    if self.ops[key] or (self.ops[key] == 0):
                        qedit = LineEdit(wk,key,self)
                        qlabel = QtGui.QLabel(key)
                        qlabel.setToolTip(tooltips[kk])
                        qedit.set_text(self.ops)
                        qedit.setFixedWidth(90)
                        self.layout.addWidget(qlabel,k*2-1,2*(l+2),1,2)
                        self.layout.addWidget(qedit,k*2,2*(l+2),1,2)
                        self.keylist.append(key)
                        self.editlist.append(qedit)
                        wk+=1
                    k+=1
                    kk+=1
                kl+=1
            l+=1

        # data_path
        key = 'look_one_level_down'
        qlabel = QtGui.QLabel(key)
        qlabel.setToolTip('whether to look in all subfolders when searching for tiffs')
        self.layout.addWidget(qlabel,1,0,1,1)
        qedit = LineEdit(wk,key,self)
        qedit.set_text(self.ops)
        qedit.setFixedWidth(95)
        self.layout.addWidget(qedit,2,0,1,1)
        self.keylist.append(key)
        self.editlist.append(qedit)
        self.btiff = QtGui.QPushButton('Add directory to data_path')
        self.btiff.clicked.connect(self.get_folders)
        self.layout.addWidget(self.btiff,3,0,1,2)
        qlabel = QtGui.QLabel('data_path')
        qlabel.setFont(bigfont)
        self.layout.addWidget(qlabel,4,0,1,1)
        self.qdata = []
        for n in range(7):
            self.qdata.append(QtGui.QLabel(''))
            self.layout.addWidget(self.qdata[n],
                                  n+5,0,1,2)
        # save_path0
        self.bh5py = QtGui.QPushButton('OR add h5 file path')
        self.bh5py.clicked.connect(self.get_h5py)
        self.layout.addWidget(self.bh5py,11,0,1,2)
        self.h5text = QtGui.QLabel('')
        self.layout.addWidget(self.h5text,12,0,1,2)
        self.bsave = QtGui.QPushButton('Add save_path (default is 1st data_path)')
        self.bsave.clicked.connect(self.save_folder)
        self.layout.addWidget(self.bsave,13,0,1,2)
        self.savelabel = QtGui.QLabel('')
        self.layout.addWidget(self.savelabel,14,0,1,2)
        # fast_disk
        self.bbin = QtGui.QPushButton('Add fast_disk (default is save_path)')
        self.bbin.clicked.connect(self.bin_folder)
        self.layout.addWidget(self.bbin,15,0,1,2)
        self.binlabel = QtGui.QLabel('')
        self.layout.addWidget(self.binlabel,16,0,1,2)
        self.runButton = QtGui.QPushButton('RUN SUITE2P')
        self.runButton.clicked.connect(lambda: self.run_S2P(parent))
        self.layout.addWidget(self.runButton,19,0,1,1)
        self.runButton.setEnabled(False)
        self.textEdit = QtGui.QTextEdit()
        self.layout.addWidget(self.textEdit, 20,0,30,2*l)
        self.process = QtCore.QProcess(self)
        self.process.readyReadStandardOutput.connect(self.stdout_write)
        self.process.readyReadStandardError.connect(self.stderr_write)
        # disable the button when running the s2p process
        self.process.started.connect(self.started)
        self.process.finished.connect(lambda: self.finished(parent))
        # stop process
        self.stopButton = QtGui.QPushButton('STOP')
        self.stopButton.setEnabled(False)
        self.layout.addWidget(self.stopButton, 19,1,1,1)
        self.stopButton.clicked.connect(self.stop)
        # cleanup button
        self.cleanButton = QtGui.QPushButton('Add a clean-up *.py')
        self.cleanButton.setToolTip('will run at end of processing')
        self.cleanButton.setEnabled(True)
        self.layout.addWidget(self.cleanButton, 19,2,1,2)
        self.cleanup = False
        self.cleanButton.clicked.connect(self.clean_script)
        self.cleanLabel = QtGui.QLabel('')
        self.layout.addWidget(self.cleanLabel,19,4,1,12)
        self.listOps = QtGui.QPushButton('save settings and\n add more (batch)')
        self.listOps.clicked.connect(self.list_ops)
        self.layout.addWidget(self.listOps,19,14,1,2)
        self.listOps.setEnabled(False)
        self.removeOps = QtGui.QPushButton('remove last added')
        self.removeOps.clicked.connect(self.remove_ops)
        self.layout.addWidget(self.removeOps,19,16,1,2)
        self.removeOps.setEnabled(False)
        self.odata = []
        for n in range(10):
            self.odata.append(QtGui.QLabel(''))
            self.layout.addWidget(self.odata[n],
                                  20+n,14,1,4)
        self.f = 0
Exemple #17
0
    def make_buttons(self):
        # create frame slider
        binLabel = QtGui.QLabel("SVD spatial bin:")
        binLabel.setStyleSheet("color: gray;")
        self.binSpinBox = QtGui.QSpinBox()
        self.binSpinBox.setRange(1, 20)
        self.binSpinBox.setValue(self.ops['sbin'])
        self.binSpinBox.setFixedWidth(50)
        self.l0.addWidget(binLabel, 7, 0, 1, 3)
        self.l0.addWidget(self.binSpinBox, 8, 0, 1, 3)
        binLabel = QtGui.QLabel("pupil sigma:")
        binLabel.setStyleSheet("color: gray;")
        self.sigmaBox = QtGui.QLineEdit()
        self.sigmaBox.setText(str(self.ops['pupil_sigma']))
        self.sigmaBox.setFixedWidth(45)
        self.l0.addWidget(binLabel, 9, 0, 1, 3)
        self.l0.addWidget(self.sigmaBox, 10, 0, 1, 3)
        self.pupil_sigma = float(self.sigmaBox.text())
        self.sigmaBox.returnPressed.connect(self.pupil_sigma_change)
        self.frameLabel = QtGui.QLabel("Current frame:")
        self.frameLabel.setStyleSheet("color: white;")
        self.frameNumber = QtGui.QLabel("0")
        self.frameNumber.setStyleSheet("color: white;")
        self.frameSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
        #self.frameSlider.setTickPosition(QtGui.QSlider.TicksBelow)
        self.frameSlider.setTickInterval(5)
        self.frameSlider.setTracking(False)
        self.frameSlider.valueChanged.connect(self.go_to_frame)
        self.frameDelta = 10
        istretch = 23
        iplay = istretch + 15
        iconSize = QtCore.QSize(20, 20)

        self.process = QtGui.QPushButton('process ROIs')
        self.process.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.process.clicked.connect(self.process_ROIs)
        self.process.setEnabled(False)

        self.savefolder = QtGui.QPushButton("save folder \u2b07")
        self.savefolder.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.savefolder.clicked.connect(self.save_folder)
        self.savefolder.setEnabled(False)
        if len(self.save_path) > 0:
            self.savelabel = QtGui.QLabel(self.save_path)
        else:
            self.savelabel = QtGui.QLabel('same as video')
        self.savelabel.setStyleSheet("color: white;")

        self.saverois = QtGui.QPushButton('save ROIs')
        self.saverois.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.saverois.clicked.connect(self.save_ROIs)
        self.saverois.setEnabled(False)

        self.batchlist = []
        self.batchname = []
        for k in range(6):
            self.batchname.append(QtGui.QLabel(''))
            self.batchname[-1].setStyleSheet("color: white;")
            self.l0.addWidget(self.batchname[-1], 18 + k, 0, 1, 4)

        self.processbatch = QtGui.QPushButton(u"process batch \u2b07")
        self.processbatch.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.processbatch.clicked.connect(self.process_batch)
        self.processbatch.setEnabled(False)

        iconSize = QtCore.QSize(30, 30)
        self.playButton = QtGui.QToolButton()
        self.playButton.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_MediaPlay))
        self.playButton.setIconSize(iconSize)
        self.playButton.setToolTip("Play")
        self.playButton.setCheckable(True)
        self.playButton.clicked.connect(self.start)

        self.pauseButton = QtGui.QToolButton()
        self.pauseButton.setCheckable(True)
        self.pauseButton.setIcon(self.style().standardIcon(
            QtGui.QStyle.SP_MediaPause))
        self.pauseButton.setIconSize(iconSize)
        self.pauseButton.setToolTip("Pause")
        self.pauseButton.clicked.connect(self.pause)

        btns = QtGui.QButtonGroup(self)
        btns.addButton(self.playButton, 0)
        btns.addButton(self.pauseButton, 1)
        btns.setExclusive(True)

        self.comboBox = QtGui.QComboBox(self)
        self.comboBox.setFixedWidth(100)
        self.comboBox.addItem("ROI type")
        self.comboBox.addItem("pupil")
        self.comboBox.addItem("motion SVD")
        self.comboBox.addItem("blink")
        self.comboBox.addItem("running")
        self.newROI = 0
        self.comboBox.setCurrentIndex(0)
        #self.comboBox.currentIndexChanged.connect(self.mode_change)

        self.addROI = QtGui.QPushButton("add ROI")
        self.addROI.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.addROI.clicked.connect(self.add_ROI)
        self.addROI.setEnabled(False)

        self.checkBox = QtGui.QCheckBox("Compute multivideo SVD")
        self.checkBox.setStyleSheet("color: gray;")
        if self.ops['fullSVD']:
            self.checkBox.toggle()

        self.save_mat = QtGui.QCheckBox("Save *.mat file")
        self.save_mat.setStyleSheet("color: gray;")
        if self.ops['save_mat']:
            self.save_mat.toggle()

        self.l0.addWidget(self.comboBox, 1, 0, 1, 3)
        self.l0.addWidget(self.addROI, 2, 0, 1, 3)
        self.l0.addWidget(self.checkBox, 11, 0, 1, 4)
        self.l0.addWidget(self.save_mat, 12, 0, 1, 3)
        self.l0.addWidget(self.savefolder, 13, 0, 1, 3)
        self.l0.addWidget(self.savelabel, 14, 0, 1, 4)
        self.l0.addWidget(self.saverois, 15, 0, 1, 3)
        self.l0.addWidget(self.process, 16, 0, 1, 3)
        self.l0.addWidget(self.processbatch, 17, 0, 1, 3)
        self.l0.addWidget(self.playButton, iplay, 0, 1, 1)
        self.l0.addWidget(self.pauseButton, iplay, 1, 1, 1)
        #self.l0.addWidget(quitButton,0,1,1,1)
        self.playButton.setEnabled(False)
        self.pauseButton.setEnabled(False)
        self.pauseButton.setChecked(True)

        self.l0.addWidget(QtGui.QLabel(''), istretch, 0, 1, 3)
        self.l0.setRowStretch(istretch, 1)
        self.l0.addWidget(self.frameLabel, istretch + 13, 0, 1, 3)
        self.l0.addWidget(self.frameNumber, istretch + 14, 0, 1, 3)
        self.l0.addWidget(self.frameSlider, istretch + 15, 3, 1, 15)

        # plotting boxes
        pl = QtGui.QLabel("after processing")
        pl.setStyleSheet("color: gray;")
        self.l0.addWidget(pl, istretch + 1, 0, 1, 3)
        pl = QtGui.QLabel("p1")
        pl.setStyleSheet("color: gray;")
        self.l0.addWidget(pl, istretch + 2, 0, 1, 1)
        pl = QtGui.QLabel("p2")
        pl.setStyleSheet("color: gray;")
        self.l0.addWidget(pl, istretch + 2, 1, 1, 1)
        pl = QtGui.QLabel("roi")
        pl.setStyleSheet("color: gray;")
        self.l0.addWidget(pl, istretch + 2, 2, 1, 1)
        self.cbs1 = []
        self.cbs2 = []
        self.lbls = []
        for k in range(8):
            self.cbs1.append(QtGui.QCheckBox(''))
            self.l0.addWidget(self.cbs1[-1], istretch + 3 + k, 0, 1, 1)
            self.cbs2.append(QtGui.QCheckBox(''))
            self.l0.addWidget(self.cbs2[-1], istretch + 3 + k, 1, 1, 1)
            self.cbs1[-1].toggled.connect(self.plot_processed)
            self.cbs2[-1].toggled.connect(self.plot_processed)
            self.cbs1[-1].setEnabled(False)
            self.cbs2[-1].setEnabled(False)
            self.lbls.append(QtGui.QLabel(''))
            self.lbls[-1].setStyleSheet("color: white;")
            self.l0.addWidget(self.lbls[-1], istretch + 3 + k, 2, 1, 1)

        #self.l0.addWidget(QtGui.QLabel(''),17,2,1,1)
        #self.l0.setRowStretch(16,2)
        ll = QtGui.QLabel('play/pause [SPACE]')
        ll.setStyleSheet("color: gray;")
        self.l0.addWidget(ll, istretch + 3 + k + 1, 0, 1, 4)
        self.updateFrameSlider()
Exemple #18
0
    def __init__(self, parent=None):
        super(ROIDraw, self).__init__(parent)
        pg.setConfigOptions(imageAxisOrder='row-major')
        self.setGeometry(70,70,1400,800)
        self.setWindowTitle('extract ROI activity')
        self.cwidget = QtGui.QWidget(self)
        self.setCentralWidget(self.cwidget)
        self.l0 = QtGui.QGridLayout()
        #layout = QtGui.QFormLayout()
        self.cwidget.setLayout(self.l0)
        self.stylePressed = ("QPushButton {Text-align: left; "
                             "background-color: rgb(100,50,100); "
                             "color:white;}")
        self.styleUnpressed = ("QPushButton {Text-align: left; "
                               "background-color: rgb(50,50,50); "
                               "color:white;}")

        #self.p0 = pg.ViewBox(lockAspect=False,name='plot1',border=[100,100,100],invertY=True)
        self.win = pg.GraphicsLayoutWidget()
        # --- cells image
        self.win = pg.GraphicsLayoutWidget()
        self.l0.addWidget(self.win,3,0,13,14)
        layout = self.win.ci.layout
        # A plot area (ViewBox + axes) for displaying the image
        self.p1 = self.win.addPlot(row=0,col=1)
        self.p1.setMouseEnabled(x=True,y=False)
        self.p1.setMenuEnabled(False)
        self.p1.scene().sigMouseMoved.connect(self.mouse_moved)

        self.p0 = self.win.addViewBox(name='plot1',lockAspect=True,row=0,col=0,invertY=True)
        self.img0=pg.ImageItem()
        self.p0.addItem(self.img0)
        self.img0.setImage(parent.ops['meanImg'])
        self.win.scene().sigMouseClicked.connect(self.plot_clicked)

        self.instructions = QtGui.QLabel("Add ROI: button / SHIFT+CLICK")
        self.instructions.setStyleSheet("color: white;")
        self.l0.addWidget(self.instructions,0,0,1,4)
        self.instructions = QtGui.QLabel("Remove last clicked ROI: DELETE")
        self.instructions.setStyleSheet("color: white;")
        self.l0.addWidget(self.instructions,1,0,1,4)

        self.addROI = QtGui.QPushButton("add ROI")
        self.addROI.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.addROI.clicked.connect(lambda: self.add_ROI(pos=None))
        self.addROI.setEnabled(True)
        self.addROI.setFixedWidth(60)
        self.addROI.setStyleSheet(self.styleUnpressed)
        self.l0.addWidget(self.addROI,2,0,1,1)
        lbl = QtGui.QLabel('diameter:')
        lbl.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        lbl.setStyleSheet("color: white;")
        lbl.setFixedWidth(60)
        self.l0.addWidget(lbl,2,1,1,1)
        self.diam = QtGui.QLineEdit(self)
        self.diam.setValidator(QtGui.QIntValidator(0, 10000))
        self.diam.setText("12")
        self.diam.setFixedWidth(35)
        self.diam.setAlignment(QtCore.Qt.AlignRight)
        self.l0.addWidget(self.diam, 2,2,1,1)
        self.procROI = QtGui.QPushButton("extract ROIs")
        self.procROI.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.procROI.clicked.connect(lambda: self.proc_ROI(parent))
        self.procROI.setStyleSheet(self.styleUnpressed)
        self.procROI.setEnabled(True)
        self.l0.addWidget(self.procROI,3,0,1,3)
        self.l0.addWidget(QtGui.QLabel(""), 4, 0, 1, 3)
        self.l0.setRowStretch(4, 1)

        # view buttons
        self.views = ["W: mean img",
                      "E: mean img (enhanced)",
                      "R: correlation map",
                      "T: max projection"]
        b = 0
        self.viewbtns = QtGui.QButtonGroup(self)
        for names in self.views:
            btn = ViewButton(b, "&" + names, self)
            self.viewbtns.addButton(btn, b)
            self.l0.addWidget(btn, b, 3, 1, 2)
            btn.setEnabled(True)
            b += 1
        b=0
        self.viewbtns.button(b).setChecked(True)
        self.viewbtns.button(b).setStyleSheet(self.stylePressed)

        self.l0.addWidget(QtGui.QLabel("neuropil"), 13,13,1,1)

        self.ops = parent.ops
        self.Ly = self.ops['Ly']
        self.Lx = self.ops['Lx']
        self.ROIs = []
        self.cell_pos = []
        self.extracted = False
Exemple #19
0
    def init_buttons(self):

        self.radio_group = QtGui.QButtonGroup(self.widget)  # Number group
        self.button1 = QtWidgets.QRadioButton('symbol "o"', self)
        self.button2 = QtWidgets.QRadioButton('symbol "t"', self)
        self.button3 = QtWidgets.QRadioButton('symbol "t1"', self)
        self.button4 = QtWidgets.QRadioButton('symbol "t2"', self)
        self.button5 = QtWidgets.QRadioButton('symbol "t3"', self)
        self.button6 = QtWidgets.QRadioButton('symbol "s"', self)
        self.button7 = QtWidgets.QRadioButton('symbol "p"', self)
        self.button8 = QtWidgets.QRadioButton('symbol "h"', self)
        self.button9 = QtWidgets.QRadioButton('symbol "star"', self)
        self.button10 = QtWidgets.QRadioButton('symbol "+"', self)
        self.button11 = QtWidgets.QRadioButton('symbol "d"', self)

        self.radio_group.addButton(self.button1)
        self.radio_group.addButton(self.button2)
        self.radio_group.addButton(self.button3)
        self.radio_group.addButton(self.button4)
        self.radio_group.addButton(self.button5)
        self.radio_group.addButton(self.button6)
        self.radio_group.addButton(self.button7)
        self.radio_group.addButton(self.button8)
        self.radio_group.addButton(self.button9)
        self.radio_group.addButton(self.button10)
        self.radio_group.addButton(self.button11)

        self.radio_group.setId(self.button1, 1)
        self.radio_group.setId(self.button2, 2)
        self.radio_group.setId(self.button3, 3)
        self.radio_group.setId(self.button4, 4)
        self.radio_group.setId(self.button5, 5)
        self.radio_group.setId(self.button6, 6)
        self.radio_group.setId(self.button7, 7)
        self.radio_group.setId(self.button8, 8)
        self.radio_group.setId(self.button9, 9)
        self.radio_group.setId(self.button10, 10)
        self.radio_group.setId(self.button11, 11)

        #self.radio_group.buttonClicked.connect(self.do_test)

        self.layout.addWidget(self.button1)
        self.layout.addWidget(self.button2)
        self.layout.addWidget(self.button3)
        self.layout.addWidget(self.button4)
        self.layout.addWidget(self.button5)
        self.layout.addWidget(self.button6)
        self.layout.addWidget(self.button7)
        self.layout.addWidget(self.button8)
        self.layout.addWidget(self.button9)
        self.layout.addWidget(self.button10)
        self.layout.addWidget(self.button11)

        #self.setCentralWidget(self.widget)

        #self.Ok_button = QtGui.QPushButton('OK', self)
        #self.layout.addWidget(self.Ok_button)

        self.cancel_button = QtGui.QPushButton('Accept', self)
        self.layout.addWidget(self.cancel_button)

        self.cancel_button.clicked.connect(self.close)
Exemple #20
0
    def __init__(self, parent, filename):
        QtGui.QDialog.__init__(self, parent)
        self.parent = parent
        self.filename = filename
        self.setMinimumWidth(1200)
        self.setMinimumHeight(600)
        self.setWindowTitle('LWA Preview & Parser')
        self.entry_id_to_export = []

        self.mainLayout = QtGui.QVBoxLayout()
        self.mainLayout.setAlignment(QtCore.Qt.AlignTop)
        self.mainLayout.addWidget(
            QtGui.QLabel('Source file: {:s}'.format(filename)))

        # read lwa batch scan entry from file
        self.entry_settings, self.hd_line_num = lwaparser.scan_header(filename)

        if self.entry_settings:
            # set top buttons
            topButtons = QtGui.QWidget()
            self.exportButton = QtGui.QPushButton('Export selected scans')
            self.exportButton.clicked.connect(self.export_lwa)
            self.openFileButton = QtGui.QPushButton('Open New File')
            self.openFileButton.clicked.connect(self.open_new_file)
            topButtonLayout = QtGui.QHBoxLayout()
            topButtonLayout.addWidget(self.exportButton)
            topButtonLayout.addWidget(self.openFileButton)
            topButtons.setLayout(topButtonLayout)
            self.mainLayout.addWidget(topButtons)

            # set up a QButtonGroup to manage checkboxes
            self.entryGroup = QtGui.QButtonGroup()
            self.entryGroup.setExclusive(False)
            # set up the batch list area
            self.batchListWidget = QtGui.QWidget()
            batchArea = QtGui.QScrollArea()
            batchArea.setWidgetResizable(True)
            batchArea.setWidget(self.batchListWidget)

            self.batchLayout = QtGui.QGridLayout()
            self.batchLayout.setAlignment(QtCore.Qt.AlignTop)
            # row of names
            self.batchLayout.addWidget(QtGui.QLabel('Scan #'), 0, 0)
            self.batchLayout.addWidget(QtGui.QLabel('Comment'), 0, 1)
            self.batchLayout.addWidget(QtGui.QLabel('Date'), 0, 2)
            self.batchLayout.addWidget(QtGui.QLabel('Time'), 0, 3)
            self.batchLayout.addWidget(QtGui.QLabel('Start Freq (MHz)'), 0, 4)
            self.batchLayout.addWidget(QtGui.QLabel('Stop Freq (MHz)'), 0, 5)
            self.batchLayout.addWidget(QtGui.QLabel('Step Freq'), 0, 6)
            self.batchLayout.addWidget(QtGui.QLabel('Points'), 0, 7)
            self.batchLayout.addWidget(QtGui.QLabel('Average'), 0, 8)
            self.batchLayout.addWidget(QtGui.QLabel('Sensitivity'), 0, 9)
            self.batchLayout.addWidget(QtGui.QLabel('Time Const'), 0, 10)
            self.batchLayout.addWidget(QtGui.QLabel('Wait Time'), 0, 11)
            self.batchLayout.addWidget(QtGui.QLabel('Modulation'), 0, 12)
            self.batchLayout.addWidget(QtGui.QLabel('Harmonics'), 0, 13)
            self.batchLayout.addWidget(QtGui.QLabel('Mod Freq'), 0, 14)
            self.batchLayout.addWidget(QtGui.QLabel('Mod Amp'), 0, 15)
            self.batchLayout.addWidget(QtGui.QLabel('Phase'), 0, 16)

            for row in range(len(self.entry_settings)):
                current_setting = self.entry_settings[row]
                entry = Shared.LWAScanHdEntry(self,
                                              entry_setting=current_setting)
                # add entry number checkbox to the button group
                self.entryGroup.addButton(entry.scanNumLabel, row)
                # add widgets to the dispaly panel layout
                self.batchLayout.addWidget(entry.scanNumLabel, row + 1, 0)
                self.batchLayout.addWidget(entry.commentLabel, row + 1, 1)
                self.batchLayout.addWidget(entry.dateLabel, row + 1, 2)
                self.batchLayout.addWidget(entry.timeLabel, row + 1, 3)
                self.batchLayout.addWidget(entry.startFreqLabel, row + 1, 4)
                self.batchLayout.addWidget(entry.stopFreqLabel, row + 1, 5)
                self.batchLayout.addWidget(entry.stepLabel, row + 1, 6)
                self.batchLayout.addWidget(entry.ptsLabel, row + 1, 7)
                self.batchLayout.addWidget(entry.avgLabel, row + 1, 8)
                self.batchLayout.addWidget(entry.sensLabel, row + 1, 9)
                self.batchLayout.addWidget(entry.tcLabel, row + 1, 10)
                self.batchLayout.addWidget(entry.itLabel, row + 1, 11)
                self.batchLayout.addWidget(entry.modModeLabel, row + 1, 12)
                self.batchLayout.addWidget(entry.harmLabel, row + 1, 13)
                self.batchLayout.addWidget(entry.modFreqLabel, row + 1, 14)
                self.batchLayout.addWidget(entry.modAmpLabel, row + 1, 15)
                self.batchLayout.addWidget(entry.phaseLabel, row + 1, 16)

            self.batchListWidget.setLayout(self.batchLayout)
            self.mainLayout.addWidget(batchArea)
            self.entryGroup.buttonClicked[int].connect(self.add_to_list)
        else:
            self.mainLayout.addWidget(
                QtGui.QLabel('Invalid file! No scans found.'))

        self.setLayout(self.mainLayout)
Exemple #21
0
    def __init__(self, app,
                 args=None,
                 parent=None,
                 gaussian_smoothing=0,
                 cm_scale_px=570,
                 subsampling=1000):
        """
        sampling in Hz
        """
        self.app = app
        
        super(MainWindow, self).__init__()

        self.setGeometry(500,150,400,400)

        self.process_script = os.path.join(str(pathlib.Path(__file__).resolve().parents[0]),'process.py')
        self.script = os.path.join(str(pathlib.Path(__file__).resolve().parents[1]), 'script.sh') # for batch processing

        # adding a "quit" keyboard shortcut
        self.quitSc = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+Q'), self)
        self.quitSc.activated.connect(self.quit)
        self.maxSc = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+M'), self)
        self.maxSc.activated.connect(self.showwindow)
        self.fitSc = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+F'), self)
        self.fitSc.activated.connect(self.fit_pupil_size)
        self.loadSc = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+O'), self)
        self.loadSc.activated.connect(self.load_data)
        self.refSc = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+R'), self)
        self.refSc.activated.connect(self.jump_to_frame)
        # self.refEx = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+E'), self)
        # self.refEx.activated.connect(self.exclude_outlier)
        self.refPr = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+P'), self)
        self.refPr.activated.connect(self.process_ROIs)
        self.refS = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+S'), self)
        self.refS.activated.connect(self.save_pupil_data)
        self.refc1 = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+1'), self)
        self.refc1.activated.connect(self.set_cursor_1)
        self.refc2 = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+2'), self)
        self.refc2.activated.connect(self.set_cursor_2)
        self.refc3 = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+3'), self)
        self.refc3.activated.connect(self.process_outliers)

        self.add2Bash = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+B'), self)
        self.add2Bash.activated.connect(self.add_to_bash_script)
        
        self.minView = False
        self.showwindow()
        
        pg.setConfigOptions(imageAxisOrder='row-major')
        
        self.gaussian_smoothing = gaussian_smoothing
        self.subsampling = subsampling
        self.cm_scale_px = cm_scale_px
        
        self.cwidget = QtGui.QWidget(self)
        self.setCentralWidget(self.cwidget)
        self.l0 = QtGui.QGridLayout()
        self.cwidget.setLayout(self.l0)
        self.win = pg.GraphicsLayoutWidget()
        self.win.move(600,0)
        self.win.resize(600,400)
        self.l0.addWidget(self.win,1,3,37,15)
        layout = self.win.ci.layout

        # A plot area (ViewBox + axes) for displaying the image
        self.p0 = self.win.addViewBox(lockAspect=False,
                                      row=0,col=0,#border=[100,100,100],
                                      invertY=True)

        self.p0.setMouseEnabled(x=False,y=False)
        self.p0.setMenuEnabled(False)
        self.pimg = pg.ImageItem()
        self.p0.setAspectLocked()
        self.p0.addItem(self.pimg)

        # image ROI
        self.pPupil = self.win.addViewBox(lockAspect=True,#row=0,col=1,
                                          # border=[100,100,100],
                                          invertY=True)
        #self.p0.setMouseEnabled(x=False,y=False)
        self.pPupil.setMenuEnabled(False)
        self.pPupilimg = pg.ImageItem(None)
        self.pPupil.addItem(self.pPupilimg)
        self.pupilContour = pg.ScatterPlotItem()
        self.pPupil.addItem(self.pupilContour)
        self.pupilCenter = pg.ScatterPlotItem()
        self.pPupil.addItem(self.pupilCenter)

        # roi initializations
        self.iROI = 0
        self.nROIs = 0
        self.saturation = 255
        self.ROI = None
        self.pupil = None
        self.iframes, self.times, self.Pr1, self.Pr2 = [], [], [], []

        # saturation sliders
        self.sl = guiparts.Slider(0, self)
        self.l0.addWidget(self.sl,1,6,1,7)
        qlabel= QtGui.QLabel('saturation')
        qlabel.setStyleSheet('color: white;')
        self.l0.addWidget(qlabel, 0,8,1,3)

        # adding blanks ("corneal reflections, ...")
        self.reflector = QtGui.QPushButton('add blank')
        self.l0.addWidget(self.reflector, 1, 8+6, 1, 1)
        # self.reflector.setEnabled(True)
        self.reflector.clicked.connect(self.add_reflectROI)
        # fit pupil
        self.fit_pupil = QtGui.QPushButton('fit Pupil [Ctrl+F]')
        self.l0.addWidget(self.fit_pupil, 1, 9+6, 1, 1)
        # self.fit_pupil.setEnabled(True)
        self.fit_pupil.clicked.connect(self.fit_pupil_size)
        # choose pupil shape
        self.pupil_shape = QtGui.QComboBox(self)
        self.pupil_shape.addItem("Ellipse fit")
        self.pupil_shape.addItem("Circle fit")
        self.l0.addWidget(self.pupil_shape, 1, 10+6, 1, 1)
        # reset
        self.reset_btn = QtGui.QPushButton('reset')
        self.l0.addWidget(self.reset_btn, 1, 11+6, 1, 1)
        self.reset_btn.clicked.connect(self.reset)
        # self.reset_btn.setEnabled(True)
        # draw pupil
        self.refresh_pupil = QtGui.QPushButton('Refresh [Ctrl+R]')
        self.l0.addWidget(self.refresh_pupil, 2, 11+6, 1, 1)
        self.refresh_pupil.setEnabled(True)
        self.refresh_pupil.clicked.connect(self.jump_to_frame)

        self.data = None
        self.rROI= []
        self.reflectors=[]
        self.scatter, self.fit= None, None # the pupil size contour

        self.p1 = self.win.addPlot(name='plot1',row=1,col=0, colspan=2, rowspan=4,
                                   title='Pupil diameter')
        self.p1.setMouseEnabled(x=True,y=False)
        self.p1.setMenuEnabled(False)
        self.p1.hideAxis('left')
        self.scatter = pg.ScatterPlotItem()
        self.p1.addItem(self.scatter)
        self.p1.setLabel('bottom', 'time (frame #)')
        self.xaxis = self.p1.getAxis('bottom')
        self.p1.autoRange(padding=0.01)
        
        self.win.ci.layout.setRowStretchFactor(0,5)
        self.movieLabel = QtGui.QLabel("No datafile chosen")
        self.movieLabel.setStyleSheet("color: white;")
        self.l0.addWidget(self.movieLabel,0,1,1,5)


        # create frame slider
        self.timeLabel = QtGui.QLabel("Current time (seconds):")
        self.timeLabel.setStyleSheet("color: white;")
        self.currentTime = QtGui.QLineEdit()
        self.currentTime.setText('0')
        self.currentTime.setValidator(QtGui.QDoubleValidator(0, 100000, 2))
        self.currentTime.setFixedWidth(50)
        self.currentTime.returnPressed.connect(self.set_precise_time)
        
        self.frameSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.frameSlider.setMinimum(0)
        self.frameSlider.setMaximum(200)
        self.frameSlider.setTickInterval(1)
        self.frameSlider.setTracking(False)
        self.frameSlider.valueChanged.connect(self.go_to_frame)

        istretch = 23
        iplay = istretch+15
        iconSize = QtCore.QSize(20, 20)

        self.folderB = QtWidgets.QComboBox(self)
        self.folderB.setMinimumWidth(150)
        self.folderB.addItems(FOLDERS.keys())

        self.process = QtGui.QPushButton('process data [Ctrl+P]')
        self.process.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.process.clicked.connect(self.process_ROIs)

        self.cursor1 = QtGui.QPushButton('Set Cursor 1 [Ctrl+1]')
        self.cursor1.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.cursor1.clicked.connect(self.set_cursor_1)

        self.cursor2 = QtGui.QPushButton('Set Cursor 2 [Ctrl+2]')
        self.cursor2.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.cursor2.clicked.connect(self.set_cursor_2)
        
        self.runAsSubprocess = QtGui.QPushButton('run as subprocess')
        self.runAsSubprocess.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.runAsSubprocess.clicked.connect(self.run_as_subprocess)

        self.load = QtGui.QPushButton('  load data [Ctrl+O]  \u2b07')
        self.load.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.load.clicked.connect(self.load_data)

        sampLabel = QtGui.QLabel("Subsampling (frame)")
        sampLabel.setStyleSheet("color: gray;")
        self.samplingBox = QtGui.QLineEdit()
        self.samplingBox.setText(str(self.subsampling))
        self.samplingBox.setFixedWidth(50)

        smoothLabel = QtGui.QLabel("Smoothing (px)")
        smoothLabel.setStyleSheet("color: gray;")
        self.smoothBox = QtGui.QLineEdit()
        self.smoothBox.setText(str(self.gaussian_smoothing))
        self.smoothBox.setFixedWidth(30)

        scaleLabel = QtGui.QLabel("1cm = (px)")
        scaleLabel.setStyleSheet("color: gray;")
        self.scaleBox = QtGui.QLineEdit()
        self.scaleBox.setText(str(self.cm_scale_px))
        self.scaleBox.setFixedWidth(30)

        self.addROI = QtGui.QPushButton("add Pupil-ROI")
        self.addROI.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.addROI.clicked.connect(self.add_ROI)

        self.saverois = QtGui.QPushButton('save data [Ctrl+S]')
        self.saverois.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.saverois.clicked.connect(self.save_ROIs)

        # self.addOutlier = QtGui.QPushButton('exclude outlier [Ctrl+E]')
        # self.addOutlier.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        # self.addOutlier.clicked.connect(self.exclude_outlier)

        self.processOutliers = QtGui.QPushButton('Set blinking interval')
        self.processOutliers.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.processOutliers.clicked.connect(self.process_outliers)

        self.printSize = QtGui.QPushButton('print ROI size')
        self.printSize.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.printSize.clicked.connect(self.print_size)
        
        iconSize = QtCore.QSize(30, 30)
        self.playButton = QtGui.QToolButton()
        self.playButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_MediaPlay))
        self.playButton.setIconSize(iconSize)
        self.playButton.setToolTip("Play")
        self.playButton.setCheckable(True)
        self.pauseButton = QtGui.QToolButton()
        self.pauseButton.setCheckable(True)
        self.pauseButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_MediaPause))
        self.pauseButton.setIconSize(iconSize)
        self.pauseButton.setToolTip("Pause")

        btns = QtGui.QButtonGroup(self)
        btns.addButton(self.playButton,0)
        btns.addButton(self.pauseButton,1)

        self.l0.addWidget(self.folderB,1,0,1,3)
        self.l0.addWidget(self.load,2,0,1,3)
        self.l0.addWidget(sampLabel, 8, 0, 1, 3)
        self.l0.addWidget(self.samplingBox, 8, 2, 1, 3)
        self.l0.addWidget(smoothLabel, 9, 0, 1, 3)
        self.l0.addWidget(self.smoothBox, 9, 2, 1, 3)
        self.l0.addWidget(scaleLabel, 10, 0, 1, 3)
        self.l0.addWidget(self.scaleBox, 10, 2, 1, 3)
        self.l0.addWidget(self.addROI,14,0,1,3)
        self.l0.addWidget(self.process, 16, 0, 1, 3)
        self.l0.addWidget(self.runAsSubprocess, 17, 0, 1, 3)
        self.l0.addWidget(self.saverois, 19, 0, 1, 3)
        self.l0.addWidget(self.cursor1, 23, 0, 1, 3)
        self.l0.addWidget(self.cursor2, 24, 0, 1, 3)
        self.l0.addWidget(self.processOutliers, 25, 0, 1, 3)
        self.l0.addWidget(self.printSize, 26, 0, 1, 3)

        self.l0.addWidget(QtGui.QLabel(''),istretch,0,1,3)
        self.l0.setRowStretch(istretch,1)
        self.l0.addWidget(self.timeLabel, istretch+13,0,1,3)
        self.l0.addWidget(self.currentTime, istretch+14,0,1,3)
        self.l0.addWidget(self.frameSlider, istretch+15,3,1,15)

        self.l0.addWidget(QtGui.QLabel(''),17,2,1,1)
        self.l0.setRowStretch(16,2)
        # self.l0.addWidget(ll, istretch+3+k+1,0,1,4)
        self.updateFrameSlider()
        
        self.nframes = 0
        self.cframe, self.cframe1, self.cframe2, = 0, 0, 0

        self.updateTimer = QtCore.QTimer()
        
        self.win.show()
        self.show()
        self.processed = False

        # self.datafile = args.datafile
        self.show()
Exemple #22
0
    def __init__(self, parent=None):
        super(RunWindow, self).__init__(parent)
        self.setGeometry(0, 0, 1500, 900)
        self.setWindowTitle(
            'Choose run options (hold mouse over parameters to see descriptions)'
        )
        self.win = QtGui.QWidget(self)
        self.layout = QtGui.QGridLayout()
        self.layout.setVerticalSpacing(2)
        self.layout.setHorizontalSpacing(25)
        self.win.setLayout(self.layout)
        # initial ops values
        self.opsfile = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                                    'ops/ops_user.npy')
        try:
            self.ops = np.load(self.opsfile, allow_pickle=True).item()
            ops0 = run_s2p.default_ops()
            self.ops = {**ops0, **self.ops}
            print('loaded default ops')
        except Exception as e:
            print('could not load default ops, using built-in ops settings')
            self.ops = run_s2p.default_ops()
        self.data_path = []
        self.save_path = []
        self.fast_disk = []
        self.opslist = []
        self.batch = False
        self.intkeys = [
            'nplanes', 'nchannels', 'functional_chan', 'align_by_chan',
            'nimg_init', 'batch_size', 'max_iterations', 'nbinned',
            'inner_neuropil_radius', 'min_neuropil_pixels', 'spatial_scale',
            'do_registration'
        ]
        self.boolkeys = [
            'delete_bin', 'do_bidiphase', 'reg_tif', 'reg_tif_chan2',
            'save_mat', 'combined', '1Preg', 'nonrigid', 'bruker', 'connected',
            'roidetect', 'keep_movie_raw', 'allow_overlap', 'sparse_mode'
        ]
        tifkeys = [
            'nplanes', 'nchannels', 'functional_chan', 'tau', 'fs',
            'delete_bin', 'do_bidiphase', 'bidiphase'
        ]
        outkeys = [
            'preclassify', 'save_mat', 'combined', 'reg_tif', 'reg_tif_chan2',
            'aspect', 'bruker'
        ]
        regkeys = [
            'do_registration', 'align_by_chan', 'nimg_init', 'batch_size',
            'smooth_sigma', 'maxregshift', 'th_badframes', 'keep_movie_raw'
        ]
        nrkeys = [['nonrigid', 'block_size', 'snr_thresh', 'maxregshiftNR'],
                  ['1Preg', 'spatial_hp', 'pre_smooth', 'spatial_taper']]
        cellkeys = [
            'roidetect', 'sparse_mode', 'diameter', 'spatial_scale',
            'connected', 'threshold_scaling', 'max_overlap', 'max_iterations',
            'high_pass'
        ]
        neudeconvkeys = [[
            'allow_overlap', 'inner_neuropil_radius', 'min_neuropil_pixels'
        ], ['win_baseline', 'sig_baseline', 'neucoeff']]
        keys = [tifkeys, outkeys, regkeys, nrkeys, cellkeys, neudeconvkeys]
        labels = [
            'Main settings', 'Output settings', 'Registration',
            ['Nonrigid', '1P'], 'ROI detection',
            ['Extraction/Neuropil', 'Deconvolution']
        ]
        tooltips = [
            'each tiff has this many planes in sequence',
            'each tiff has this many channels per plane',
            'this channel is used to extract functional ROIs (1-based)',
            'timescale of sensor in deconvolution (in seconds)',
            'sampling rate (per plane)',
            'if 1, binary file is deleted after processing is complete',
            'whether or not to compute bidirectional phase offset of recording (from line scanning)',
            'set a fixed number (in pixels) for the bidirectional phase offset',
            'apply ROI classifier before signal extraction with probability threshold (set to 0 to turn off)',
            'save output also as mat file "Fall.mat"',
            'combine results across planes in separate folder "combined" at end of processing',
            'if 1, registered tiffs are saved',
            'if 1, registered tiffs of channel 2 (non-functional channel) are saved',
            'um/pixels in X / um/pixels in Y (for correct aspect ratio in GUI)',
            'if you have bruker single-page tiffs with Ch1 and Ch2, say 1',
            "if 1, registration is performed if it wasn't performed already",
            'when multi-channel, you can align by non-functional channel (1-based)',
            '# of subsampled frames for finding reference image',
            'number of frames per batch',
            'gaussian smoothing after phase corr: 1.15 good for 2P recordings, recommend 2-5 for 1P recordings',
            'max allowed registration shift, as a fraction of frame max(width and height)',
            'this parameter determines which frames to exclude when determining cropped frame size - set it smaller to exclude more frames',
            'if 1, unregistered binary is kept in a separate file data_raw.bin',
            'whether to use nonrigid registration (splits FOV into blocks of size block_size)',
            'block size in number of pixels in Y and X (two numbers separated by a comma)',
            'if any nonrigid block is below this threshold, it gets smoothed until above this threshold. 1.0 results in no smoothing',
            'maximum *pixel* shift allowed for nonrigid, relative to rigid',
            'whether to perform high-pass filtering and tapering for registration (necessary for 1P recordings)',
            'window for spatial high-pass filtering before registration',
            'whether to smooth before high-pass filtering before registration',
            "how much to ignore on edges (important for vignetted windows, for FFT padding do not set BELOW 3*smooth_sigma)",
            'whether or not to run cell (ROI) detection',
            'whether to run sparse_mode cell extraction (scale-free) or original algorithm (default is original)',
            'if sparse_mode=0, input average diameter of ROIs in recording (can give a list e.g. 6,9)',
            'if sparse_mode=1, choose size of ROIs: 0 = multi-scale; 1 = 6 pixels, 2 = 12, 3 = 24, 4 = 48',
            'whether or not to require ROIs to be fully connected (set to 0 for dendrites/boutons)',
            'adjust the automatically determined threshold by this scalar multiplier',
            'ROIs with greater than this overlap as a fraction of total pixels will be discarded',
            'maximum number of iterations for ROI detection',
            'running mean subtraction with window of size "high_pass" (use low values for 1P)',
            'allow shared pixels to be used for fluorescence extraction from overlapping ROIs (otherwise excluded from both ROIs)',
            'number of pixels between ROI and neuropil donut',
            'minimum number of pixels in the neuropil', 'window for maximin',
            'smoothing constant for gaussian filter', 'neuropil coefficient'
        ]

        bigfont = QtGui.QFont("Arial", 10, QtGui.QFont.Bold)
        qlabel = QtGui.QLabel('File paths')
        qlabel.setFont(bigfont)
        self.layout.addWidget(qlabel, 0, 0, 1, 1)
        #self.loadDb = QtGui.QPushButton('Load db.npy')
        #self.loadDb.clicked.connect(self.load_db)
        #self.layout.addWidget(self.loadDb,0,1,1,1)

        loadOps = QtGui.QPushButton('Load ops file')
        loadOps.clicked.connect(self.load_ops)
        saveDef = QtGui.QPushButton('Save ops as default')
        saveDef.clicked.connect(self.save_default_ops)
        saveOps = QtGui.QPushButton('Save ops to file')
        saveOps.clicked.connect(self.save_ops)
        self.layout.addWidget(loadOps, 0, 2, 1, 2)
        self.layout.addWidget(saveDef, 1, 2, 1, 2)
        self.layout.addWidget(saveOps, 2, 2, 1, 2)
        self.layout.addWidget(QtGui.QLabel(''), 3, 2, 1, 2)
        self.layout.addWidget(QtGui.QLabel('Load example ops'), 4, 2, 1, 2)
        for k in range(3):
            qw = QtGui.QPushButton('Save ops to file')
        saveOps.clicked.connect(self.save_ops)
        self.opsbtns = QtGui.QButtonGroup(self)
        opsstr = ['1P imaging', 'dendrites/axons']
        self.opsname = ['1P', 'dendrite']
        for b in range(len(opsstr)):
            btn = OpsButton(b, opsstr[b], self)
            self.opsbtns.addButton(btn, b)
            self.layout.addWidget(btn, 5 + b, 2, 1, 2)
        l = 0
        self.keylist = []
        self.editlist = []
        kk = 0
        wk = 0
        for lkey in keys:
            k = 0
            kl = 0
            if type(labels[l]) is list:
                labs = labels[l]
                keyl = lkey
            else:
                labs = [labels[l]]
                keyl = [lkey]
            for label in labs:
                qlabel = QtGui.QLabel(label)
                qlabel.setFont(bigfont)
                self.layout.addWidget(qlabel, k * 2, 2 * (l + 2), 1, 2)
                k += 1
                for key in keyl[kl]:
                    lops = 1
                    if self.ops[key] or (self.ops[key] == 0):
                        qedit = LineEdit(wk, key, self)
                        qlabel = QtGui.QLabel(key)
                        qlabel.setToolTip(tooltips[kk])
                        qedit.set_text(self.ops)
                        qedit.setToolTip(tooltips[kk])
                        qedit.setFixedWidth(90)
                        self.layout.addWidget(qlabel, k * 2 - 1, 2 * (l + 2),
                                              1, 2)
                        self.layout.addWidget(qedit, k * 2, 2 * (l + 2), 1, 2)
                        self.keylist.append(key)
                        self.editlist.append(qedit)
                        wk += 1
                    k += 1
                    kk += 1
                kl += 1
            l += 1

        # data_path
        key = 'look_one_level_down'
        qlabel = QtGui.QLabel(key)
        qlabel.setToolTip(
            'whether to look in all subfolders when searching for tiffs')
        self.layout.addWidget(qlabel, 1, 0, 1, 1)
        qedit = LineEdit(wk, key, self)
        qedit.set_text(self.ops)
        qedit.setFixedWidth(95)
        self.layout.addWidget(qedit, 2, 0, 1, 1)
        self.keylist.append(key)
        self.editlist.append(qedit)
        self.btiff = QtGui.QPushButton('Add directory to data_path')
        self.btiff.clicked.connect(self.get_folders)
        self.layout.addWidget(self.btiff, 3, 0, 1, 2)
        qlabel = QtGui.QLabel('data_path')
        qlabel.setFont(bigfont)
        self.layout.addWidget(qlabel, 4, 0, 1, 1)
        self.qdata = []
        for n in range(7):
            self.qdata.append(QtGui.QLabel(''))
            self.layout.addWidget(self.qdata[n], n + 5, 0, 1, 2)
        # save_path0
        self.bh5py = QtGui.QPushButton('OR add h5 file path')
        self.bh5py.clicked.connect(self.get_h5py)
        self.layout.addWidget(self.bh5py, 11, 0, 1, 2)
        self.h5text = QtGui.QLabel('')
        self.layout.addWidget(self.h5text, 12, 0, 1, 2)
        self.bsave = QtGui.QPushButton(
            'Add save_path (default is 1st data_path)')
        self.bsave.clicked.connect(self.save_folder)
        self.layout.addWidget(self.bsave, 13, 0, 1, 2)
        self.savelabel = QtGui.QLabel('')
        self.layout.addWidget(self.savelabel, 14, 0, 1, 2)
        # fast_disk
        self.bbin = QtGui.QPushButton('Add fast_disk (default is save_path)')
        self.bbin.clicked.connect(self.bin_folder)
        self.layout.addWidget(self.bbin, 15, 0, 1, 2)
        self.binlabel = QtGui.QLabel('')
        self.layout.addWidget(self.binlabel, 16, 0, 1, 2)
        self.runButton = QtGui.QPushButton('RUN SUITE2P')
        self.runButton.clicked.connect(lambda: self.run_S2P(parent))
        n0 = 21
        self.layout.addWidget(self.runButton, n0, 0, 1, 1)
        self.runButton.setEnabled(False)
        self.textEdit = QtGui.QTextEdit()
        self.layout.addWidget(self.textEdit, n0 + 1, 0, 30, 2 * l)
        self.textEdit.setFixedHeight(300)
        self.process = QtCore.QProcess(self)
        self.process.readyReadStandardOutput.connect(self.stdout_write)
        self.process.readyReadStandardError.connect(self.stderr_write)
        # disable the button when running the s2p process
        self.process.started.connect(self.started)
        self.process.finished.connect(lambda: self.finished(parent))
        # stop process
        self.stopButton = QtGui.QPushButton('STOP')
        self.stopButton.setEnabled(False)
        self.layout.addWidget(self.stopButton, n0, 1, 1, 1)
        self.stopButton.clicked.connect(self.stop)
        # cleanup button
        self.cleanButton = QtGui.QPushButton('Add a clean-up *.py')
        self.cleanButton.setToolTip('will run at end of processing')
        self.cleanButton.setEnabled(True)
        self.layout.addWidget(self.cleanButton, n0, 2, 1, 2)
        self.cleanup = False
        self.cleanButton.clicked.connect(self.clean_script)
        self.cleanLabel = QtGui.QLabel('')
        self.layout.addWidget(self.cleanLabel, n0, 4, 1, 12)
        self.listOps = QtGui.QPushButton(
            'save settings and\n add more (batch)')
        self.listOps.clicked.connect(self.list_ops)
        self.layout.addWidget(self.listOps, n0, 12, 1, 2)
        self.listOps.setEnabled(False)
        self.removeOps = QtGui.QPushButton('remove last added')
        self.removeOps.clicked.connect(self.remove_ops)
        self.layout.addWidget(self.removeOps, n0, 14, 1, 2)
        self.removeOps.setEnabled(False)
        self.odata = []
        for n in range(10):
            self.odata.append(QtGui.QLabel(''))
            self.layout.addWidget(self.odata[n], n0 + 1 + n, 12, 1, 4)
        self.f = 0
Exemple #23
0
    def initUI(self):
        signal.signal(signal.SIGINT, signal.SIG_DFL)  # allow Control-C

        # Always start by initializing Qt (only once per application)
        app = QtGui.QApplication([])

        # Define a top-level widget to hold everything
        w = QtGui.QWidget()

        # 2D plot for the cspad and mask
        self.plot = pg.ImageView()

        # save mask button
        save_button = QtGui.QPushButton('save mask')
        save_button.clicked.connect(self.save_mask)

        # rectangular ROI selection
        self.roi = pg.RectROI([-200, -200], [100, 100])
        self.plot.addItem(self.roi)
        self.roi.setZValue(10)  # make sure ROI is drawn above image
        ROI_button = QtGui.QPushButton('mask rectangular ROI')
        ROI_button.clicked.connect(lambda: self.mask_ROI(self.roi))

        # circular ROI selection
        self.roi_circle = pg.CircleROI([-200, 200], [101, 101])
        self.plot.addItem(self.roi_circle)
        self.roi.setZValue(10)  # make sure ROI is drawn above image
        ROI_circle_button = QtGui.QPushButton('mask circular ROI')
        ROI_circle_button.clicked.connect(
            lambda: self.mask_ROI_circle(self.roi_circle))

        # histogram mask button
        hist_button = QtGui.QPushButton('mask outside histogram')
        hist_button.clicked.connect(self.mask_hist)

        # dilate button
        dilate_button = QtGui.QPushButton('dilate mask')
        dilate_button.clicked.connect(self.dilate_mask)

        # errode button
        errode_button = QtGui.QPushButton('errode mask')
        errode_button.clicked.connect(self.errode_mask)

        # toggle / mask / unmask checkboxes
        self.toggle_checkbox = QtGui.QCheckBox('toggle')
        self.mask_checkbox = QtGui.QCheckBox('mask')
        self.unmask_checkbox = QtGui.QCheckBox('unmask')
        self.mask_checkbox.setChecked(True)

        toggle_group = QtGui.QButtonGroup()  #"masking behaviour")
        toggle_group.addButton(self.toggle_checkbox)
        toggle_group.addButton(self.mask_checkbox)
        toggle_group.addButton(self.unmask_checkbox)
        toggle_group.setExclusive(True)

        # unbonded pixels button
        unbonded_button = QtGui.QPushButton('unbonded pixels')
        unbonded_button.clicked.connect(self.mask_unbonded_pixels)
        if self.cspad_shape_flag in ['psana', 'psana2', 'slab']:
            unbonded_button.setEnabled(False)

        # asic edges button
        edges_button = QtGui.QPushButton('panel edges')
        edges_button.clicked.connect(self.mask_edge_pixels)

        # mouse hover ij value label
        ij_label = QtGui.QLabel()
        disp = 'ss fs {0:5} {1:5}   value {2:2}'.format('-', '-', '-')
        ij_label.setText(disp)
        self.plot.scene.sigMouseMoved.connect(
            lambda pos: self.mouseMoved(ij_label, pos))

        # unbonded pixels checkbox
        unbonded_checkbox = QtGui.QCheckBox('unbonded pixels')
        unbonded_checkbox.stateChanged.connect(self.update_mask_unbonded)
        if self.cspad_shape_flag == 'other':
            unbonded_checkbox.setEnabled(False)

        # asic edges checkbox
        edges_checkbox = QtGui.QCheckBox('asic edges')
        edges_checkbox.stateChanged.connect(self.update_mask_edges)
        if self.cspad_shape_flag == 'other':
            edges_checkbox.setEnabled(False)

        # mouse click mask
        self.plot.scene.sigMouseClicked.connect(
            lambda click: self.mouseClicked(self.plot, click))

        ## Add widgets to the layout in their proper positions
        # stack up sidepanel widgets
        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(save_button)
        vbox.addWidget(ROI_button)
        vbox.addWidget(ROI_circle_button)
        vbox.addWidget(hist_button)
        vbox.addWidget(dilate_button)
        vbox.addWidget(errode_button)
        vbox.addWidget(unbonded_button)
        vbox.addWidget(edges_button)

        # asic sub-panel edges button
        if self.cspad_shape_flag == 'pilatus':
            olek_edges_button = QtGui.QPushButton('more edges')
            olek_edges_button.clicked.connect(self.mask_olek_edge_pixels)
            vbox.addWidget(olek_edges_button)

        # cheetah mask button
        if self.geom_fnam is not None:
            cheetah_mask_button = QtGui.QPushButton('cheetah threshold')
            cheetah_mask_button.clicked.connect(self.make_cheetah_mask)
            vbox.addWidget(cheetah_mask_button)

        vbox.addWidget(self.toggle_checkbox)
        vbox.addWidget(self.mask_checkbox)
        vbox.addWidget(self.unmask_checkbox)

        vbox.addStretch(1)
        #vbox.addWidget(unbonded_checkbox)
        #vbox.addWidget(edges_checkbox)

        # Create a grid layout to manage the widgets size and position
        layout = QtGui.QGridLayout()
        w.setLayout(layout)

        layout.addLayout(vbox, 0, 0)
        layout.addWidget(self.plot, 0, 1)
        layout.addWidget(ij_label, 1, 0, 1, 2)
        layout.setColumnStretch(1, 1)
        #layout.setColumnMinimumWidth(0, 250)

        # display the image
        self.generate_mask()
        self.updateDisplayRGB(auto=True)

        # centre the circle initially
        if self.geom_fnam is not None:
            self.roi_circle.setPos([
                self.cspad_shape[0] // 2 - 1 - 50,
                self.cspad_shape[1] // 2 - 1 - 50
            ])

        ## Display the widget as a new window
        w.resize(800, 480)
        w.show()

        ## Start the Qt event loop
        app.exec_()
Exemple #24
0
    def __init__(self):
        super(MainW, self).__init__()
        pg.setConfigOptions(imageAxisOrder='row-major')
        self.setGeometry(25, 25, 1600, 1000)
        self.setWindowTitle('suite2p (run pipeline or load stat.npy)')
        icon_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                 'logo/logo.png')
        app_icon = QtGui.QIcon()
        app_icon.addFile(icon_path, QtCore.QSize(16, 16))
        app_icon.addFile(icon_path, QtCore.QSize(24, 24))
        app_icon.addFile(icon_path, QtCore.QSize(32, 32))
        app_icon.addFile(icon_path, QtCore.QSize(48, 48))
        app_icon.addFile(icon_path, QtCore.QSize(96, 96))
        app_icon.addFile(icon_path, QtCore.QSize(256, 256))
        self.setWindowIcon(app_icon)
        self.setStyleSheet("QMainWindow {background: 'black';}")
        self.stylePressed = "QPushButton {Text-align: left; background-color: rgb(100,50,100); color:white;}"
        self.styleUnpressed = "QPushButton {Text-align: left; background-color: rgb(50,50,50); color:white;}"
        self.styleInactive = "QPushButton {Text-align: left; background-color: rgb(50,50,50); color:gray;}"
        self.loaded = False
        self.ops_plot = []
        # default plot options
        self.ops_plot.append(True)
        self.ops_plot.append(0)
        self.ops_plot.append(0)
        self.ops_plot.append(0)
        self.ops_plot.append(0)
        #### ------ MENU BAR ----------------- ####
        # run suite2p from scratch
        runS2P = QtGui.QAction('&Run suite2p ', self)
        runS2P.setShortcut('Ctrl+R')
        runS2P.triggered.connect(self.run_suite2p)
        self.addAction(runS2P)
        # load processed data
        loadProc = QtGui.QAction('&Load processed data', self)
        loadProc.setShortcut('Ctrl+L')
        loadProc.triggered.connect(self.load_dialog)
        self.addAction(loadProc)
        # load a behavioral trace
        self.loadBeh = QtGui.QAction('Load behavior or stim trace (1D only)',
                                     self)
        self.loadBeh.triggered.connect(self.load_behavior)
        self.loadBeh.setEnabled(False)
        self.addAction(self.loadBeh)
        # load masks
        #loadMask = QtGui.QAction('&Load masks (stat.npy) and extract traces', self)
        #loadMask.setShortcut('Ctrl+M')
        #self.addAction(loadMask)
        # make mainmenu!
        main_menu = self.menuBar()
        file_menu = main_menu.addMenu('&File')
        file_menu.addAction(runS2P)
        file_menu.addAction(loadProc)
        file_menu.addAction(self.loadBeh)
        # classifier menu
        self.trainfiles = []
        self.statlabels = None
        self.loadMenu = QtGui.QMenu('Load', self)
        self.loadClass = QtGui.QAction('from file', self)
        self.loadClass.triggered.connect(self.load_classifier)
        self.loadClass.setEnabled(False)
        self.loadMenu.addAction(self.loadClass)
        self.loadUClass = QtGui.QAction('default classifier', self)
        self.loadUClass.triggered.connect(self.load_default_classifier)
        self.loadUClass.setEnabled(False)
        self.loadMenu.addAction(self.loadUClass)
        self.loadSClass = QtGui.QAction('built-in classifier', self)
        self.loadSClass.triggered.connect(self.load_s2p_classifier)
        self.loadSClass.setEnabled(False)
        self.loadMenu.addAction(self.loadSClass)
        self.loadTrain = QtGui.QAction('Build', self)
        self.loadTrain.triggered.connect(lambda: classifier.load_list(self))
        self.loadTrain.setEnabled(False)
        self.saveDefault = QtGui.QAction('Save loaded as default', self)
        self.saveDefault.triggered.connect(self.class_default)
        self.saveDefault.setEnabled(False)
        self.resetDefault = QtGui.QAction('Reset default to built-in', self)
        self.resetDefault.triggered.connect(self.reset_default)
        self.resetDefault.setEnabled(False)
        class_menu = main_menu.addMenu('&Classifier')
        class_menu.addMenu(self.loadMenu)
        class_menu.addAction(self.loadTrain)
        class_menu.addAction(self.resetDefault)
        class_menu.addAction(self.saveDefault)
        # visualizations menuBar
        self.visualizations = QtGui.QAction('&Visualize selected cells', self)
        self.visualizations.triggered.connect(self.vis_window)
        self.visualizations.setEnabled(False)
        vis_menu = main_menu.addMenu('&Visualizations')
        vis_menu.addAction(self.visualizations)
        self.visualizations.setShortcut('Ctrl+V')
        #### --------- MAIN WIDGET LAYOUT --------- ####
        #pg.setConfigOption('background', 'w')
        #cwidget = EventWidget(self)
        cwidget = QtGui.QWidget()
        self.l0 = QtGui.QGridLayout()
        cwidget.setLayout(self.l0)
        self.setCentralWidget(cwidget)
        # ROI CHECKBOX
        self.checkBox = QtGui.QCheckBox('&O: ROIs On')
        self.checkBox.setStyleSheet("color: white;")
        self.checkBox.stateChanged.connect(self.ROIs_on)
        self.checkBox.toggle()
        self.l0.addWidget(self.checkBox, 0, 0, 1, 2)
        # number of ROIs in each image
        self.lcell0 = QtGui.QLabel('')
        self.lcell0.setStyleSheet("color: white;")
        self.lcell0.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        self.l0.addWidget(self.lcell0, 0, 12, 1, 2)
        self.lcell1 = QtGui.QLabel('')
        self.lcell1.setStyleSheet("color: white;")
        self.l0.addWidget(self.lcell1, 0, 20, 1, 2)
        # buttons to draw a square on view
        self.topbtns = QtGui.QButtonGroup()
        ql = QtGui.QLabel('select cells')
        ql.setStyleSheet('color: white;')
        ql.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.l0.addWidget(ql, 0, 2, 1, 2)
        pos = [2, 3, 4]
        for b in range(3):
            btn = gui.TopButton(b, self)
            btn.setFont(QtGui.QFont("Arial", 8))
            self.topbtns.addButton(btn, b)
            self.l0.addWidget(btn, 0, (pos[b]) * 2, 1, 2)
            btn.setEnabled(False)
        self.topbtns.setExclusive(True)
        self.isROI = False
        self.ROIplot = 0
        ql = QtGui.QLabel('n=')
        ql.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
        ql.setStyleSheet('color: white;')
        ql.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.l0.addWidget(ql, 0, 10, 1, 1)
        #self.l0.setColumnStretch(5,0.1)
        self.topedit = QtGui.QLineEdit(self)
        self.topedit.setValidator(QtGui.QIntValidator(0, 500))
        self.topedit.setText('40')
        self.ntop = 40
        self.topedit.setFixedWidth(35)
        self.topedit.setAlignment(QtCore.Qt.AlignRight)
        self.topedit.returnPressed.connect(self.top_number_chosen)
        self.l0.addWidget(self.topedit, 0, 11, 1, 1)
        # minimize view
        self.sizebtns = QtGui.QButtonGroup(self)
        b = 0
        labels = [' cells', ' both', ' not cells']
        for l in labels:
            btn = gui.SizeButton(b, l, self)
            self.sizebtns.addButton(btn, b)
            self.l0.addWidget(btn, 0, 14 + 2 * b, 1, 2)
            btn.setEnabled(False)
            if b == 1:
                btn.setEnabled(True)
            b += 1
        self.sizebtns.setExclusive(True)
        #### -------- MAIN PLOTTING AREA ---------- ####
        self.win = pg.GraphicsLayoutWidget()
        self.win.move(600, 0)
        self.win.resize(1000, 500)
        self.l0.addWidget(self.win, 1, 2, 38, 30)
        layout = self.win.ci.layout
        # --- cells image
        self.p1 = self.win.addViewBox(lockAspect=True,
                                      name='plot1',
                                      border=[100, 100, 100],
                                      row=0,
                                      col=0,
                                      invertY=True)
        self.img1 = pg.ImageItem()
        self.p1.setMenuEnabled(False)
        data = np.zeros((700, 512, 3))
        self.img1.setImage(data)
        self.p1.addItem(self.img1)
        # --- noncells image
        self.p2 = self.win.addViewBox(lockAspect=True,
                                      name='plot2',
                                      border=[100, 100, 100],
                                      row=0,
                                      col=1,
                                      invertY=True)
        self.p2.setMenuEnabled(False)
        self.img2 = pg.ImageItem()
        self.img2.setImage(data)
        self.p2.addItem(self.img2)
        self.p2.setXLink('plot1')
        self.p2.setYLink('plot1')
        # --- fluorescence trace plot
        self.p3 = self.win.addPlot(row=1, col=0, colspan=2)
        self.win.ci.layout.setRowStretchFactor(0, 2)
        layout.setColumnMinimumWidth(0, 1)
        layout.setColumnMinimumWidth(1, 1)
        layout.setHorizontalSpacing(20)
        self.p3.setMouseEnabled(x=True, y=False)
        self.p3.enableAutoRange(x=True, y=True)
        self.win.scene().sigMouseClicked.connect(self.plot_clicked)
        #self.key_on(self.win.scene().keyPressEvent)
        self.show()
        self.win.show()
        #### --------- VIEW AND COLOR BUTTONS ---------- ####
        self.views = [
            'Q: ROIs', 'W: mean img', 'E: mean img (enhanced)',
            'R: correlation map', 'T: mean img (non-functional)'
        ]
        self.colors = [
            'A: random', 'S: skew', 'D: compact', 'F: footprint',
            'G: aspect_ratio', 'H: classifier', 'J: correlations, bin='
        ]
        b = 0
        boldfont = QtGui.QFont("Arial", 10, QtGui.QFont.Bold)
        self.viewbtns = QtGui.QButtonGroup(self)
        vlabel = QtGui.QLabel(self)
        vlabel.setText("<font color='white'>Background</font>")
        vlabel.setFont(boldfont)
        vlabel.resize(vlabel.minimumSizeHint())
        self.l0.addWidget(vlabel, 1, 0, 1, 1)
        for names in self.views:
            btn = gui.ViewButton(b, '&' + names, self)
            self.viewbtns.addButton(btn, b)
            self.l0.addWidget(btn, b + 2, 0, 1, 2)
            btn.setEnabled(False)
            b += 1
        self.viewbtns.setExclusive(True)
        # color buttons
        self.colorbtns = QtGui.QButtonGroup(self)
        clabel = QtGui.QLabel(self)
        clabel.setText("<font color='white'>Colors</font>")
        clabel.setFont(boldfont)
        self.l0.addWidget(clabel, b + 3, 0, 1, 2)
        nv = b + 3
        b = 0
        # colorbars for different statistics
        colorsAll = self.colors.copy()
        colorsAll.append('K: corr with 1D var, bin= ^^^')
        for names in colorsAll:
            btn = gui.ColorButton(b, '&' + names, self)
            self.colorbtns.addButton(btn, b)
            if b == len(self.colors) - 1:
                self.l0.addWidget(btn, nv + b + 1, 0, 1, 1)
            else:
                self.l0.addWidget(btn, nv + b + 1, 0, 1, 2)
            btn.setEnabled(False)
            if b < len(self.colors):
                self.colors[b] = self.colors[b][3:]
            b += 1
        self.binedit = QtGui.QLineEdit(self)
        self.binedit.setValidator(QtGui.QIntValidator(0, 500))
        self.binedit.setText('0')
        self.binedit.setFixedWidth(40)
        self.binedit.setAlignment(QtCore.Qt.AlignRight)
        self.binedit.returnPressed.connect(
            lambda: self.mode_change(self.activityMode))
        self.l0.addWidget(self.binedit, nv + b - 1, 1, 1, 1)
        self.bend = nv + b + 4
        colorbarW = pg.GraphicsLayoutWidget()
        colorbarW.setMaximumHeight(60)
        colorbarW.setMaximumWidth(150)
        colorbarW.ci.layout.setRowStretchFactor(0, 2)
        colorbarW.ci.layout.setContentsMargins(0, 0, 0, 0)
        self.l0.addWidget(colorbarW, nv + b + 2, 0, 1, 2)
        self.colorbar = pg.ImageItem()
        cbar = colorbarW.addViewBox(row=0, col=0, colspan=3)
        cbar.setMenuEnabled(False)
        cbar.addItem(self.colorbar)
        self.clabel = [
            colorbarW.addLabel('0.0', color=[255, 255, 255], row=1, col=0),
            colorbarW.addLabel('0.5', color=[255, 255, 255], row=1, col=1),
            colorbarW.addLabel('1.0', color=[255, 255, 255], row=1, col=2)
        ]
        plabel = QtGui.QLabel('\t    cell probability')
        plabel.setStyleSheet("color: white;")
        self.l0.addWidget(plabel, self.bend, 0, 1, 2)
        self.probedit = QtGui.QDoubleSpinBox(self)
        self.probedit.setDecimals(3)
        self.probedit.setMaximum(1.0)
        self.probedit.setMinimum(0.0)
        self.probedit.setSingleStep(0.01)
        self.probedit.setValue(0.5)
        self.probedit.setFixedWidth(55)
        self.l0.addWidget(self.probedit, self.bend, 0, 1, 1)
        self.applyclass = QtGui.QPushButton(' apply')
        self.applyclass.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.applyclass.clicked.connect(lambda: classifier.apply(self))
        self.applyclass.setEnabled(False)
        self.applyclass.setStyleSheet(self.styleInactive)
        self.l0.addWidget(self.applyclass, self.bend + 1, 0, 1, 1)

        #### ----- CLASSIFIER BUTTONS ------- ####
        cllabel = QtGui.QLabel("")
        cllabel.setFont(boldfont)
        cllabel.setText("<font color='white'>Classifier</font>")
        self.classLabel = QtGui.QLabel("<font color='white'>not loaded</font>")
        self.classLabel.setFont(QtGui.QFont('Arial', 8))
        self.l0.addWidget(cllabel, self.bend + 2, 0, 1, 2)
        self.l0.addWidget(self.classLabel, self.bend + 3, 0, 1, 2)
        self.addtoclass = QtGui.QPushButton(' add current data to classifier')
        self.addtoclass.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.addtoclass.clicked.connect(lambda: classifier.add_to(self))
        self.addtoclass.setStyleSheet(self.styleInactive)
        self.l0.addWidget(self.addtoclass, self.bend + 4, 0, 1, 2)
        #### ------ CELL STATS -------- ####
        # which stats
        self.bend = self.bend + 5
        self.stats_to_show = [
            'med', 'npix', 'skew', 'compact', 'footprint', 'aspect_ratio'
        ]
        lilfont = QtGui.QFont("Arial", 8)
        qlabel = QtGui.QLabel(self)
        qlabel.setFont(boldfont)
        qlabel.setText("<font color='white'>Selected ROI:</font>")
        self.l0.addWidget(qlabel, self.bend, 0, 1, 2)
        self.ROIedit = QtGui.QLineEdit(self)
        self.ROIedit.setValidator(QtGui.QIntValidator(0, 10000))
        self.ROIedit.setText('0')
        self.ROIedit.setFixedWidth(45)
        self.ROIedit.setAlignment(QtCore.Qt.AlignRight)
        self.ROIedit.returnPressed.connect(self.number_chosen)
        self.l0.addWidget(self.ROIedit, self.bend + 1, 0, 1, 1)
        self.ROIstats = []
        self.ROIstats.append(qlabel)
        for k in range(1, len(self.stats_to_show) + 1):
            llabel = QtGui.QLabel(self.stats_to_show[k - 1])
            self.ROIstats.append(llabel)
            self.ROIstats[k].setFont(lilfont)
            self.ROIstats[k].setStyleSheet("color: white;")
            self.ROIstats[k].resize(self.ROIstats[k].minimumSizeHint())
            self.l0.addWidget(self.ROIstats[k], self.bend + 2 + k, 0, 1, 2)
        self.l0.addWidget(QtGui.QLabel(''), self.bend + 3 + k, 0, 1, 2)
        self.l0.setRowStretch(self.bend + 3 + k, 1)
        # combo box to decide what kind of activity to view
        qlabel = QtGui.QLabel(self)
        qlabel.setText("<font color='white'>Activity mode:</font>")
        self.l0.addWidget(qlabel, self.bend + k + 4, 0, 1, 1)
        self.comboBox = QtGui.QComboBox(self)
        self.comboBox.setFixedWidth(100)
        self.l0.addWidget(self.comboBox, self.bend + k + 5, 0, 1, 1)
        self.comboBox.addItem('F')
        self.comboBox.addItem('Fneu')
        self.comboBox.addItem('F - 0.7*Fneu')
        self.comboBox.addItem('deconvolved')
        self.activityMode = 2
        self.comboBox.setCurrentIndex(self.activityMode)
        self.comboBox.currentIndexChanged.connect(self.mode_change)
        # up/down arrows to resize view
        self.level = 1
        self.arrowButtons = [
            QtGui.QPushButton(u" \u25b2"),
            QtGui.QPushButton(u" \u25bc")
        ]
        self.arrowButtons[0].clicked.connect(self.expand_trace)
        self.arrowButtons[1].clicked.connect(self.collapse_trace)
        b = 0
        for btn in self.arrowButtons:
            btn.setMaximumWidth(22)
            btn.setFont(QtGui.QFont('Arial', 11, QtGui.QFont.Bold))
            btn.setStyleSheet(self.styleUnpressed)
            self.l0.addWidget(btn, self.bend + 4 + k + b, 1, 1, 1,
                              QtCore.Qt.AlignRight)
            b += 1
        self.pmButtons = [QtGui.QPushButton(' +'), QtGui.QPushButton(' -')]
        self.pmButtons[0].clicked.connect(self.expand_scale)
        self.pmButtons[1].clicked.connect(self.collapse_scale)
        b = 0
        self.sc = 2
        for btn in self.pmButtons:
            btn.setMaximumWidth(22)
            btn.setFont(QtGui.QFont('Arial', 11, QtGui.QFont.Bold))
            btn.setStyleSheet(self.styleUnpressed)
            self.l0.addWidget(btn, self.bend + 4 + k + b, 1, 1, 1)
            b += 1
        # choose max # of cells plotted
        self.l0.addWidget(
            QtGui.QLabel("<font color='white'>max # plotted:</font>"),
            self.bend + 6 + k, 0, 1, 1)
        self.ncedit = QtGui.QLineEdit(self)
        self.ncedit.setValidator(QtGui.QIntValidator(0, 400))
        self.ncedit.setText('40')
        self.ncedit.setFixedWidth(35)
        self.ncedit.setAlignment(QtCore.Qt.AlignRight)
        self.ncedit.returnPressed.connect(self.nc_chosen)
        self.l0.addWidget(self.ncedit, self.bend + 7 + k, 0, 1, 1)
        # labels for traces
        self.traceLabel = [
            QtGui.QLabel(self),
            QtGui.QLabel(self),
            QtGui.QLabel(self)
        ]
        self.traceText = [
            "<font color='blue'>fluorescence</font>",
            "<font color='red'>neuropil</font>",
            "<font color='gray'>deconvolved</font>"
        ]
        for n in range(3):
            self.traceLabel[n].setText(self.traceText[n])
            self.traceLabel[n].setFont(boldfont)
            self.l0.addWidget(self.traceLabel[n], self.bend + 8 + k, 4 + n * 2,
                              1, 2)
        # classifier file to load
        self.classfile = os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            'classifiers/classifier_user.npy')
        self.classorig = os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            'classifiers/classifier.npy')
        model = np.load(self.classorig)
        model = model.item()
        self.default_keys = model['keys']
Exemple #25
0
    def create_buttons(self):
        self.intkeys = [
            'nplanes', 'nchannels', 'functional_chan', 'align_by_chan',
            'nimg_init', 'batch_size', 'max_iterations', 'nbinned',
            'inner_neuropil_radius', 'min_neuropil_pixels', 'spatial_scale',
            'do_registration'
        ]
        self.boolkeys = [
            'delete_bin', 'move_bin', 'do_bidiphase', 'reg_tif',
            'reg_tif_chan2', 'save_mat', 'save_NWB'
            'combined', '1Preg', 'nonrigid', 'connected', 'roidetect',
            'neuropil_extract', 'spikedetect', 'keep_movie_raw',
            'allow_overlap', 'sparse_mode'
        ]
        tifkeys = [
            'nplanes', 'nchannels', 'functional_chan', 'tau', 'fs',
            'do_bidiphase', 'bidiphase', 'multiplane_parallel',
            'ignore_flyback'
        ]
        outkeys = [
            'preclassify', 'save_mat', 'save_NWB', 'combined', 'reg_tif',
            'reg_tif_chan2', 'aspect', 'delete_bin', 'move_bin'
        ]
        regkeys = [
            'do_registration', 'align_by_chan', 'nimg_init', 'batch_size',
            'smooth_sigma', 'smooth_sigma_time', 'maxregshift', 'th_badframes',
            'keep_movie_raw', 'two_step_registration'
        ]
        nrkeys = [['nonrigid', 'block_size', 'snr_thresh', 'maxregshiftNR'],
                  ['1Preg', 'spatial_hp_reg', 'pre_smooth', 'spatial_taper']]
        cellkeys = [
            'roidetect', 'denoise', 'anatomical_only', 'diameter',
            'spatial_scale', 'threshold_scaling', 'max_overlap',
            'max_iterations', 'high_pass'
        ]
        neudeconvkeys = [[
            'neuropil_extract', 'allow_overlap', 'inner_neuropil_radius',
            'min_neuropil_pixels'
        ],
                         [
                             'soma_crop', 'spikedetect', 'win_baseline',
                             'sig_baseline', 'neucoeff'
                         ]]
        keys = [tifkeys, outkeys, regkeys, nrkeys, cellkeys, neudeconvkeys]
        labels = [
            'Main settings', 'Output settings', 'Registration',
            ['Nonrigid', '1P'], 'ROI detection',
            ['Extraction/Neuropil', 'Classification/Deconvolution']
        ]
        tooltips = [
            'each tiff has this many planes in sequence',
            'each tiff has this many channels per plane',
            'this channel is used to extract functional ROIs (1-based)',
            'timescale of sensor in deconvolution (in seconds)',
            'sampling rate (per plane)',
            'whether or not to compute bidirectional phase offset of recording (from line scanning)',
            'set a fixed number (in pixels) for the bidirectional phase offset',
            'process each plane with a separate job on a computing cluster',
            'ignore flyback planes 0-indexed separated by a comma e.g. "0,10"; "-1" means no planes ignored so all planes processed',
            'apply ROI classifier before signal extraction with probability threshold (set to 0 to turn off)',
            'save output also as mat file "Fall.mat"',
            'save output also as NWB file "ophys.nwb"',
            'combine results across planes in separate folder "combined" at end of processing',
            'if 1, registered tiffs are saved',
            'if 1, registered tiffs of channel 2 (non-functional channel) are saved',
            'um/pixels in X / um/pixels in Y (for correct aspect ratio in GUI)',
            'if 1, binary file is deleted after processing is complete',
            'if 1, and fast_disk is different than save_disk, binary file is moved to save_disk',
            "if 1, registration is performed if it wasn't performed already",
            'when multi-channel, you can align by non-functional channel (1-based)',
            '# of subsampled frames for finding reference image',
            'number of frames per batch',
            'gaussian smoothing after phase corr: 1.15 good for 2P recordings, recommend 2-5 for 1P recordings',
            'gaussian smoothing in time, useful for low SNR data',
            'max allowed registration shift, as a fraction of frame max(width and height)',
            'this parameter determines which frames to exclude when determining cropped frame size - set it smaller to exclude more frames',
            'if 1, unregistered binary is kept in a separate file data_raw.bin',
            'run registration twice (useful if data is really noisy), *keep_movie_raw must be 1*',
            'whether to use nonrigid registration (splits FOV into blocks of size block_size)',
            'block size in number of pixels in Y and X (two numbers separated by a comma)',
            'if any nonrigid block is below this threshold, it gets smoothed until above this threshold. 1.0 results in no smoothing',
            'maximum *pixel* shift allowed for nonrigid, relative to rigid',
            'whether to perform high-pass filtering and tapering for registration (necessary for 1P recordings)',
            'window for spatial high-pass filtering before registration',
            'whether to smooth before high-pass filtering before registration',
            "how much to ignore on edges (important for vignetted windows, for FFT padding do not set BELOW 3*smooth_sigma)",
            'if 1, run cell (ROI) detection',
            'if 1, run PCA denoising on binned movie to improve cell detection',
            'run cellpose to get masks on 1: max_proj / mean_img; 2: mean_img; or 3: mean_img enhanced',
            'if anatomical_only>0, input average diameter of ROIs in recording (can give a list e.g. 6,9)',
            'if anatomical_only=0, choose size of ROIs: 0 = multi-scale; 1 = 6 pixels, 2 = 12, 3 = 24, 4 = 48',
            'adjust the automatically determined threshold for finding ROIs by this scalar multiplier',
            'ROIs with greater than this overlap as a fraction of total pixels will be discarded',
            'maximum number of iterations for ROI detection',
            'running mean subtraction with window of size "high_pass" (use low values for 1P)',
            'whether or not to extract neuropil; if 0, Fneu is set to 0',
            'allow shared pixels to be used for fluorescence extraction from overlapping ROIs (otherwise excluded from both ROIs)',
            'number of pixels between ROI and neuropil donut',
            'minimum number of pixels in the neuropil',
            'if 1, crop dendrites for cell classification stats like compactness',
            'if 1, run spike detection (deconvolution)', 'window for maximin',
            'smoothing constant for gaussian filter', 'neuropil coefficient'
        ]

        bigfont = QtGui.QFont("Arial", 10, QtGui.QFont.Bold)
        qlabel = QtGui.QLabel('File paths')
        qlabel.setFont(bigfont)
        self.layout.addWidget(qlabel, 0, 0, 1, 1)
        loadOps = QtGui.QPushButton('Load ops file')
        loadOps.clicked.connect(self.load_ops)
        saveDef = QtGui.QPushButton('Save ops as default')
        saveDef.clicked.connect(self.save_default_ops)
        revertDef = QtGui.QPushButton('Revert default ops to built-in')
        revertDef.clicked.connect(self.revert_default_ops)
        saveOps = QtGui.QPushButton('Save ops to file')
        saveOps.clicked.connect(self.save_ops)
        self.layout.addWidget(loadOps, 0, 2, 1, 2)
        self.layout.addWidget(saveDef, 1, 2, 1, 2)
        self.layout.addWidget(revertDef, 2, 2, 1, 2)
        self.layout.addWidget(saveOps, 3, 2, 1, 2)
        self.layout.addWidget(QtGui.QLabel(''), 4, 2, 1, 2)
        self.layout.addWidget(QtGui.QLabel('Load example ops'), 5, 2, 1, 2)
        for k in range(3):
            qw = QtGui.QPushButton('Save ops to file')
        #saveOps.clicked.connect(self.save_ops)
        self.opsbtns = QtGui.QButtonGroup(self)
        opsstr = ['1P imaging', 'dendrites/axons']
        self.opsname = ['1P', 'dendrite']
        for b in range(len(opsstr)):
            btn = OpsButton(b, opsstr[b], self)
            self.opsbtns.addButton(btn, b)
            self.layout.addWidget(btn, 6 + b, 2, 1, 2)
        l = 0
        self.keylist = []
        self.editlist = []
        kk = 0
        wk = 0
        for lkey in keys:
            k = 0
            kl = 0
            if type(labels[l]) is list:
                labs = labels[l]
                keyl = lkey
            else:
                labs = [labels[l]]
                keyl = [lkey]
            for label in labs:
                qlabel = QtGui.QLabel(label)
                qlabel.setFont(bigfont)
                self.layout.addWidget(qlabel, k * 2, 2 * (l + 2), 1, 2)
                k += 1
                for key in keyl[kl]:
                    lops = 1
                    if self.ops[key] or (self.ops[key] == 0) or len(
                            self.ops[key]) == 0:
                        qedit = LineEdit(wk, key, self)
                        qlabel = QtGui.QLabel(key)
                        qlabel.setToolTip(tooltips[kk])
                        qedit.set_text(self.ops)
                        qedit.setToolTip(tooltips[kk])
                        qedit.setFixedWidth(90)
                        self.layout.addWidget(qlabel, k * 2 - 1, 2 * (l + 2),
                                              1, 2)
                        self.layout.addWidget(qedit, k * 2, 2 * (l + 2), 1, 2)
                        self.keylist.append(key)
                        self.editlist.append(qedit)
                        wk += 1
                    k += 1
                    kk += 1
                kl += 1
            l += 1

        # data_path
        key = 'input_format'
        qlabel = QtGui.QLabel(key)
        qlabel.setFont(bigfont)
        qlabel.setToolTip('File format (selects which parser to use)')
        self.layout.addWidget(qlabel, 1, 0, 1, 1)
        self.inputformat = QtGui.QComboBox()
        [
            self.inputformat.addItem(f)
            for f in ['tif', 'bruker', 'sbx', 'h5', 'mesoscan', 'haus', 'raw']
        ]
        self.inputformat.currentTextChanged.connect(self.parse_inputformat)
        self.layout.addWidget(self.inputformat, 2, 0, 1, 1)

        key = 'look_one_level_down'
        qlabel = QtGui.QLabel(key)
        qlabel.setToolTip(
            'whether to look in all subfolders when searching for files')
        self.layout.addWidget(qlabel, 3, 0, 1, 1)
        qedit = LineEdit(wk, key, self)
        qedit.set_text(self.ops)
        qedit.setFixedWidth(95)
        self.layout.addWidget(qedit, 4, 0, 1, 1)
        self.keylist.append(key)
        self.editlist.append(qedit)
        self.btiff = QtGui.QPushButton('Add directory to data_path')
        self.btiff.clicked.connect(self.get_folders)
        self.layout.addWidget(self.btiff, 5, 0, 1, 2)
        qlabel = QtGui.QLabel('data_path')
        qlabel.setFont(bigfont)
        self.layout.addWidget(qlabel, 6, 0, 1, 1)
        self.qdata = []
        for n in range(9):
            self.qdata.append(QtGui.QLabel(''))
            self.layout.addWidget(self.qdata[n], n + 7, 0, 1, 2)

        self.bsave = QtGui.QPushButton(
            'Add save_path (default is 1st data_path)')
        self.bsave.clicked.connect(self.save_folder)
        self.layout.addWidget(self.bsave, 16, 0, 1, 2)
        self.savelabel = QtGui.QLabel('')
        self.layout.addWidget(self.savelabel, 17, 0, 1, 2)
        # fast_disk
        self.bbin = QtGui.QPushButton('Add fast_disk (default is save_path)')
        self.bbin.clicked.connect(self.bin_folder)
        self.layout.addWidget(self.bbin, 18, 0, 1, 2)
        self.binlabel = QtGui.QLabel('')
        self.layout.addWidget(self.binlabel, 19, 0, 1, 2)
        self.runButton = QtGui.QPushButton('RUN SUITE2P')
        self.runButton.clicked.connect(self.run_S2P)
        n0 = 21
        self.layout.addWidget(self.runButton, n0, 0, 1, 1)
        self.runButton.setEnabled(False)
        self.textEdit = QtGui.QTextEdit()
        self.layout.addWidget(self.textEdit, n0 + 1, 0, 30, 2 * l)
        self.textEdit.setFixedHeight(300)
        self.process = QtCore.QProcess(self)
        self.process.readyReadStandardOutput.connect(self.stdout_write)
        self.process.readyReadStandardError.connect(self.stderr_write)
        # disable the button when running the s2p process
        self.process.started.connect(self.started)
        self.process.finished.connect(self.finished)
        # stop process
        self.stopButton = QtGui.QPushButton('STOP')
        self.stopButton.setEnabled(False)
        self.layout.addWidget(self.stopButton, n0, 1, 1, 1)
        self.stopButton.clicked.connect(self.stop)
        # cleanup button
        self.cleanButton = QtGui.QPushButton('Add a clean-up *.py')
        self.cleanButton.setToolTip('will run at end of processing')
        self.cleanButton.setEnabled(True)
        self.layout.addWidget(self.cleanButton, n0, 2, 1, 2)
        self.cleanup = False
        self.cleanButton.clicked.connect(self.clean_script)
        self.cleanLabel = QtGui.QLabel('')
        self.layout.addWidget(self.cleanLabel, n0, 4, 1, 12)
        n0 += 1
        self.listOps = QtGui.QPushButton(
            'save settings and\n add more (batch)')
        self.listOps.clicked.connect(self.add_batch)
        self.layout.addWidget(self.listOps, n0, 12, 1, 2)
        self.listOps.setEnabled(False)
        self.removeOps = QtGui.QPushButton('remove last added')
        self.removeOps.clicked.connect(self.remove_ops)
        self.layout.addWidget(self.removeOps, n0, 14, 1, 2)
        self.removeOps.setEnabled(False)
        self.odata = []
        for n in range(10):
            self.odata.append(QtGui.QLabel(''))
            self.layout.addWidget(self.odata[n], n0 + 1 + n, 12, 1, 4)
Exemple #26
0
def add_buttons(self, Layout):

    self.styleUnpressed = ("QPushButton {Text-align: left; "
                           "background-color: rgb(200, 200, 200); "
                           "color:white;}")
    self.stylePressed = ("QPushButton {Text-align: left; "
                         "background-color: rgb(100,50,100); "
                         "color:white;}")
    self.styleInactive = ("QPushButton {Text-align: left; "
                          "background-color: rgb(200, 200, 200); "
                          "color:gray;}")

    iconSize = QtCore.QSize(20, 20)

    self.playButton = QtGui.QToolButton()
    self.playButton.setIcon(self.style().standardIcon(
        QtGui.QStyle.SP_MediaPlay))
    self.playButton.setIconSize(iconSize)
    self.playButton.setToolTip("Play   -> [Space]")
    self.playButton.setCheckable(True)
    self.playButton.setEnabled(True)
    self.playButton.clicked.connect(self.play)

    self.pauseButton = QtGui.QToolButton()
    self.pauseButton.setCheckable(True)
    self.pauseButton.setIcon(self.style().standardIcon(
        QtGui.QStyle.SP_MediaPause))
    self.pauseButton.setIconSize(iconSize)
    self.pauseButton.setToolTip("Pause   -> [Space]")
    self.pauseButton.clicked.connect(self.pause)

    btns = QtGui.QButtonGroup(self)
    btns.addButton(self.playButton, 0)
    btns.addButton(self.pauseButton, 1)
    btns.setExclusive(True)

    self.playButton.setEnabled(False)
    self.pauseButton.setEnabled(True)
    self.pauseButton.setChecked(True)

    self.refreshButton = QtGui.QToolButton()
    self.refreshButton.setCheckable(True)
    self.refreshButton.setIcon(self.style().standardIcon(
        QtGui.QStyle.SP_BrowserReload))
    self.refreshButton.setIconSize(iconSize)
    self.refreshButton.setToolTip("Refresh   -> [r]")
    self.refreshButton.clicked.connect(self.refresh)

    self.quitButton = QtGui.QToolButton()
    # self.quitButton.setCheckable(True)
    self.quitButton.setIcon(self.style().standardIcon(
        QtGui.QStyle.SP_DialogCloseButton))
    self.quitButton.setIconSize(iconSize)
    self.quitButton.setToolTip("Quit")
    self.quitButton.clicked.connect(self.quit)

    self.backButton = QtGui.QToolButton()
    # self.backButton.setCheckable(True)
    self.backButton.setIcon(self.style().standardIcon(
        QtGui.QStyle.SP_FileDialogBack))
    self.backButton.setIconSize(iconSize)
    self.backButton.setToolTip("Back to initial view   -> [i]")
    self.backButton.clicked.connect(self.back_to_initial_view)

    self.settingsButton = QtGui.QToolButton()
    # self.settingsButton.setCheckable(True)
    self.settingsButton.setIcon(self.style().standardIcon(
        QtGui.QStyle.SP_FileDialogDetailedView))
    self.settingsButton.setIconSize(iconSize)
    # self.settingsButton.setToolTip("Settings")
    # self.settingsButton.clicked.connect(self.change_settings)
    self.settingsButton.setToolTip("Metadata")
    self.settingsButton.clicked.connect(self.see_metadata)

    Layout.addWidget(self.quitButton)
    Layout.addWidget(self.playButton)
    Layout.addWidget(self.pauseButton)
    Layout.addWidget(self.refreshButton)
    Layout.addWidget(self.backButton)
    Layout.addWidget(self.settingsButton)
Exemple #27
0
    def __init__(self, app,
                 args=None,
                 parent=None,
                 spatial_subsampling=1,
                 time_subsampling=1):
        """
        sampling in Hz
        """
        self.app = app
        
        super(MainWindow, self).__init__(i=1,
                                         title='Face-motion/Whisking tracking')
        
        # self.refEx = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+E'), self)
        # self.refEx.activated.connect(self.exclude_outlier)
        # self.refPr = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+P'), self)
        # self.refPr.activated.connect(self.process_outliers)
        # self.refc1 = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+1'), self)
        # self.refc1.activated.connect(self.set_cursor_1)
        # self.refc2 = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+2'), self)
        # self.refc2.activated.connect(self.set_cursor_2)
        # self.refc3 = QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+3'), self)
        # self.refc3.activated.connect(self.process_outliers)

        self.process_script = os.path.join(str(pathlib.Path(__file__).resolve().parents[0]),
                                           'process.py')
        
        
        self.minView = False
        self.showwindow()
        
        pg.setConfigOptions(imageAxisOrder='row-major')
        
        self.spatial_subsampling = spatial_subsampling
        self.time_subsampling = time_subsampling
        
        self.cwidget = QtGui.QWidget(self)
        self.setCentralWidget(self.cwidget)
        self.l0 = QtGui.QGridLayout()
        self.cwidget.setLayout(self.l0)
        self.win = pg.GraphicsLayoutWidget()
        self.win.move(600,0)
        self.win.resize(600,400)
        self.l0.addWidget(self.win,1,3,37,15)
        layout = self.win.ci.layout

        # A plot area (ViewBox + axes) for displaying the image
        self.p0 = self.win.addViewBox(lockAspect=False,row=0,col=0,invertY=True,
                                      border=[100,100,100])
        self.p0.setMouseEnabled(x=False,y=False)
        self.p0.setMenuEnabled(False)
        self.pimg = pg.ImageItem()
        self.p0.setAspectLocked()
        self.p0.addItem(self.pimg)

        # image ROI
        self.pFace = self.win.addViewBox(lockAspect=False,row=0,col=1,invertY=True,
                                         border=[100,100,100])
        self.pFace.setAspectLocked()
        #self.p0.setMouseEnabled(x=False,y=False)
        self.pFace.setMenuEnabled(False)
        self.pFaceimg = pg.ImageItem(None)
        self.pFace.addItem(self.pFaceimg)

        # roi initializations
        self.iROI = 0
        self.nROIs = 0
        self.saturation = 255
        self.ROI = None
        self.pupil = None
        self.iframes, self.times, self.Pr1, self.Pr2 = [], [], [], []
        self.times, self.imgfolder, self.nframes, self.FILES = None, None, None, None

        # saturation sliders
        self.sl = guiparts.Slider(0, self)
        self.l0.addWidget(self.sl,1,6,1,7)
        qlabel= QtGui.QLabel('saturation')
        qlabel.setStyleSheet('color: white;')
        self.l0.addWidget(qlabel, 0,8,1,3)

        # # # adding blanks ("corneal reflections, ...")
        # self.roiBtn = QtGui.QPushButton('set ROI')
        # self.l0.addWidget(self.roiBtn, 1, 8+6, 1, 1)
        # self.roiBtn.setEnabled(True)
        # self.roiBtn.clicked.connect(self.add_ROI)
        
        # # fit pupil
        # self.fit_pupil = QtGui.QPushButton('fit Pupil [Ctrl+F]')
        # self.l0.addWidget(self.fit_pupil, 1, 9+6, 1, 1)
        # # self.fit_pupil.setEnabled(True)
        # self.fit_pupil.clicked.connect(self.fit_pupil_size)
        # # choose pupil shape
        # self.pupil_shape = QtGui.QComboBox(self)
        # self.pupil_shape.addItem("Ellipse fit")
        # self.pupil_shape.addItem("Circle fit")
        # self.l0.addWidget(self.pupil_shape, 1, 10+6, 1, 1)
        # reset
        self.reset_btn = QtGui.QPushButton('reset')
        self.l0.addWidget(self.reset_btn, 1, 11+6, 1, 1)
        self.reset_btn.clicked.connect(self.reset)
        self.reset_btn.setEnabled(True)

        
        self.debugBtn = QtGui.QPushButton('- Debug -')
        self.l0.addWidget(self.debugBtn, 2, 11+6, 1, 1)
        self.debugBtn.setEnabled(True)
        self.debugBtn.clicked.connect(self.debug)

        self.data = None
        self.scatter, self.fit= None, None # the pupil size contour

        self.p1 = self.win.addPlot(name='plot1',row=1,col=0, colspan=2, rowspan=4,
                                   title='*face motion*')
        self.p1.setMouseEnabled(x=True,y=False)
        self.p1.setMenuEnabled(False)
        self.p1.hideAxis('left')
        self.scatter = pg.ScatterPlotItem()
        self.p1.addItem(self.scatter)
        self.p1.setLabel('bottom', 'time (frame #)')
        self.xaxis = self.p1.getAxis('bottom')
        self.p1.autoRange(padding=0.01)
        
        self.win.ci.layout.setRowStretchFactor(0,5)
        self.movieLabel = QtGui.QLabel("No datafile chosen")
        self.movieLabel.setStyleSheet("color: white;")
        self.l0.addWidget(self.movieLabel,0,1,1,5)


        # create frame slider
        self.timeLabel = QtGui.QLabel("time : ")
        self.timeLabel.setStyleSheet("color: white;")
        # self.timeLabel.setFixedWidth(300)
        self.currentTime = QtGui.QLineEdit()
        self.currentTime.setText('0 s')
        self.currentTime.setFixedWidth(70)
        # self.currentTime.returnPressed.connect(self.set_precise_time)
        
        self.frameSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.frameSlider.setMinimum(0)
        self.frameSlider.setMaximum(200)
        self.frameSlider.setTickInterval(1)
        self.frameSlider.setTracking(False)
        self.frameSlider.valueChanged.connect(self.go_to_frame)

        istretch = 23
        iplay = istretch+15
        iconSize = QtCore.QSize(20, 20)

        self.folderB = QtWidgets.QComboBox(self)
        self.folderB.setMinimumWidth(150)
        self.folderB.addItems(FOLDERS.keys())
        
        self.processBtn = QtGui.QPushButton('process data')
        self.processBtn.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.processBtn.clicked.connect(self.process)

        # self.interpolate = QtGui.QPushButton('interpolate')
        # self.interpolate.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        # self.interpolate.clicked.connect(self.interpolate_data)

        self.motionCheckBox = QtGui.QCheckBox("display motion frames")
        self.motionCheckBox.setStyleSheet("color: gray;")
        
        self.runAsSubprocess = QtGui.QPushButton('run as subprocess')
        self.runAsSubprocess.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.runAsSubprocess.clicked.connect(self.run_as_subprocess)
        # self.runAsSubprocess.setEnabled(True)

        self.load = QtGui.QPushButton('  load data [Ctrl+O]  \u2b07')
        self.load.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.load.clicked.connect(self.open_file)

        sampLabel1 = QtGui.QLabel("spatial subsampling")
        sampLabel1.setStyleSheet("color: gray;")
        sampLabel1.setFixedWidth(220)
        self.SsamplingBox = QtGui.QLineEdit()
        self.SsamplingBox.setText(str(self.spatial_subsampling))
        self.SsamplingBox.setFixedWidth(30)

        sampLabel2 = QtGui.QLabel("temporal subsampling")
        sampLabel2.setStyleSheet("color: gray;")
        sampLabel2.setFixedWidth(220)
        self.TsamplingBox = QtGui.QLineEdit()
        self.TsamplingBox.setText(str(self.time_subsampling))
        self.TsamplingBox.setFixedWidth(30)
        
        self.addROI = QtGui.QPushButton("set ROI")
        self.addROI.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.addROI.clicked.connect(self.add_ROI)

        self.saveData = QtGui.QPushButton('save data')
        self.saveData.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.saveData.clicked.connect(self.save_data)

        iconSize = QtCore.QSize(30, 30)
        self.playButton = QtGui.QToolButton()
        self.playButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_MediaPlay))
        self.playButton.setIconSize(iconSize)
        self.playButton.setToolTip("Play")
        self.playButton.setCheckable(True)
        self.pauseButton = QtGui.QToolButton()
        self.pauseButton.setCheckable(True)
        self.pauseButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_MediaPause))
        self.pauseButton.setIconSize(iconSize)
        self.pauseButton.setToolTip("Pause")

        btns = QtGui.QButtonGroup(self)
        btns.addButton(self.playButton,0)
        btns.addButton(self.pauseButton,1)

        self.l0.addWidget(self.folderB,1,0,1,3)
        self.l0.addWidget(self.load,2,0,1,3)
        self.l0.addWidget(self.addROI,14,0,1,3)
        self.l0.addWidget(self.saveData, 16, 0, 1, 3)
        self.l0.addWidget(self.processBtn, 20, 0, 1, 3)
        self.l0.addWidget(self.runAsSubprocess, 21, 0, 1, 3)
        self.l0.addWidget(self.motionCheckBox, 18, 0, 1, 3)
        
        self.l0.addWidget(sampLabel1, 8, 0, 1, 3)
        self.l0.addWidget(self.SsamplingBox, 8, 2, 1, 3)
        self.l0.addWidget(sampLabel2, 9, 0, 1, 3)
        self.l0.addWidget(self.TsamplingBox, 9, 2, 1, 3)

        self.l0.addWidget(QtGui.QLabel(''),istretch,0,1,3)
        self.l0.setRowStretch(istretch,1)
        self.l0.addWidget(self.timeLabel, istretch+10,0,1,3)
        self.l0.addWidget(self.currentTime, istretch+10,1,1,3)
        self.l0.addWidget(self.frameSlider, istretch+15,3,1,15)

        self.l0.addWidget(QtGui.QLabel(''),17,2,1,1)
        self.l0.setRowStretch(16,2)
        # self.l0.addWidget(ll, istretch+3+k+1,0,1,4)
        self.timeLabel.setEnabled(True)
        self.frameSlider.setEnabled(True)
        
        self.nframes = 0
        self.cframe = 0

        self.show()
Exemple #28
0
    def createButtons(self):
        iconSize = QtCore.QSize(30, 30)
        openButton = QtGui.QToolButton()
        openButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_DialogOpenButton))
        openButton.setIconSize(iconSize)
        openButton.setToolTip("Open movie file/folder")
        openButton.clicked.connect(self.open)

        self.process = QtGui.QToolButton()
        self.process.setIcon(self.style().standardIcon(QtGui.QStyle.SP_ComputerIcon))
        self.process.setIconSize(iconSize)
        self.process.setToolTip("Process ROIs")
        self.process.clicked.connect(self.process_ROIs)
        self.process.setEnabled(False)

        self.playButton = QtGui.QToolButton()
        self.playButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_MediaPlay))
        self.playButton.setIconSize(iconSize)
        self.playButton.setToolTip("Play")
        self.playButton.setCheckable(True)
        self.playButton.clicked.connect(self.start)

        self.pauseButton = QtGui.QToolButton()
        self.pauseButton.setCheckable(True)
        self.pauseButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_MediaPause))
        self.pauseButton.setIconSize(iconSize)
        self.pauseButton.setToolTip("Pause")
        self.pauseButton.clicked.connect(self.pause)

        btns = QtGui.QButtonGroup(self)
        btns.addButton(self.playButton,0)
        btns.addButton(self.pauseButton,1)
        btns.setExclusive(True)

        quitButton = QtGui.QToolButton()
        quitButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_DialogCloseButton))
        quitButton.setIconSize(iconSize)
        quitButton.setToolTip("Quit")
        quitButton.clicked.connect(self.close)

        self.comboBox = QtGui.QComboBox(self)
        self.comboBox.setFixedWidth(80)
        self.comboBox.addItem("ROI type")
        self.comboBox.addItem("pupil")
        self.comboBox.addItem("motion SVD")
        self.comboBox.addItem("blink")
        self.newROI = 0
        self.comboBox.setCurrentIndex(0)
        #self.comboBox.currentIndexChanged.connect(self.mode_change)

        self.addROI = QtGui.QPushButton("add ROI")
        self.addROI.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.addROI.clicked.connect(self.add_ROI)
        self.addROI.setEnabled(False)

        self.l0.addWidget(openButton,1,0,1,1)
        self.l0.addWidget(self.process,2,0,1,1)
        self.l0.addWidget(self.comboBox, 3, 0, 1, 2)
        self.l0.addWidget(self.addROI,4,0,1,2)
        self.l0.addWidget(self.playButton,15,0,1,1)
        self.l0.addWidget(self.pauseButton,15,1,1,1)
        #self.l0.addWidget(quitButton,0,1,1,1)
        self.playButton.setEnabled(False)
        self.pauseButton.setEnabled(False)
        self.pauseButton.setChecked(True)
    def setupUi(self, PlanNavigatorWidget):
        PlanNavigatorWidget.setObjectName(_fromUtf8("PlanNavigatorWidget"))
        PlanNavigatorWidget.resize(415, 712)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            PlanNavigatorWidget.sizePolicy().hasHeightForWidth())
        PlanNavigatorWidget.setSizePolicy(sizePolicy)
        PlanNavigatorWidget.setMinimumSize(QtCore.QSize(415, 620))
        PlanNavigatorWidget.setMaximumSize(QtCore.QSize(415, 524287))
        PlanNavigatorWidget.setBaseSize(QtCore.QSize(440, 665))
        self.dockWidgetContents = QtGui.QWidget()
        self.dockWidgetContents.setObjectName(_fromUtf8("dockWidgetContents"))
        self.scrollArea = QtGui.QScrollArea(self.dockWidgetContents)
        self.scrollArea.setGeometry(QtCore.QRect(0, 0, 418, 650))
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.scrollArea.sizePolicy().hasHeightForWidth())
        self.scrollArea.setSizePolicy(sizePolicy)
        self.scrollArea.setMinimumSize(QtCore.QSize(0, 600))
        self.scrollArea.setMaximumSize(QtCore.QSize(435, 650))
        self.scrollArea.setWidgetResizable(False)
        self.scrollArea.setObjectName(_fromUtf8("scrollArea"))
        self.scrollAreaWidgetContents = QtGui.QWidget()
        self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 419, 664))
        self.scrollAreaWidgetContents.setObjectName(
            _fromUtf8("scrollAreaWidgetContents"))
        self.tabWidget = QtGui.QTabWidget(self.scrollAreaWidgetContents)
        self.tabWidget.setGeometry(QtCore.QRect(6, 0, 386, 625))
        self.tabWidget.setMaximumSize(QtCore.QSize(16777215, 625))
        self.tabWidget.setUsesScrollButtons(True)
        self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
        self.plan_tab = QtGui.QWidget()
        self.plan_tab.setObjectName(_fromUtf8("plan_tab"))
        self.groupBox_11 = QtGui.QGroupBox(self.plan_tab)
        self.groupBox_11.setGeometry(QtCore.QRect(5, 30, 371, 231))
        self.groupBox_11.setObjectName(_fromUtf8("groupBox_11"))
        self.plan_num_edit = QtGui.QLineEdit(self.groupBox_11)
        self.plan_num_edit.setGeometry(QtCore.QRect(190, 25, 170, 20))
        self.plan_num_edit.setObjectName(_fromUtf8("plan_num_edit"))
        self.label_31 = QtGui.QLabel(self.groupBox_11)
        self.label_31.setGeometry(QtCore.QRect(10, 82, 171, 17))
        self.label_31.setObjectName(_fromUtf8("label_31"))
        self.label_32 = QtGui.QLabel(self.groupBox_11)
        self.label_32.setGeometry(QtCore.QRect(10, 160, 171, 17))
        self.label_32.setObjectName(_fromUtf8("label_32"))
        self.label_34 = QtGui.QLabel(self.groupBox_11)
        self.label_34.setGeometry(QtCore.QRect(190, 8, 171, 17))
        self.label_34.setObjectName(_fromUtf8("label_34"))
        self.office_in_charge_cbox = QtGui.QComboBox(self.groupBox_11)
        self.office_in_charge_cbox.setGeometry(QtCore.QRect(10, 180, 170, 21))
        self.office_in_charge_cbox.setObjectName(
            _fromUtf8("office_in_charge_cbox"))
        self.status_cbox = QtGui.QComboBox(self.groupBox_11)
        self.status_cbox.setGeometry(QtCore.QRect(10, 99, 351, 21))
        self.status_cbox.setObjectName(_fromUtf8("status_cbox"))
        self.plan_results_label = QtGui.QLabel(self.groupBox_11)
        self.plan_results_label.setGeometry(QtCore.QRect(10, 206, 121, 20))
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("Lucida Grande"))
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.plan_results_label.setFont(font)
        self.plan_results_label.setAlignment(QtCore.Qt.AlignLeading
                                             | QtCore.Qt.AlignLeft
                                             | QtCore.Qt.AlignVCenter)
        self.plan_results_label.setObjectName(_fromUtf8("plan_results_label"))
        self.next_officer_in_charge_cbox = QtGui.QComboBox(self.groupBox_11)
        self.next_officer_in_charge_cbox.setGeometry(
            QtCore.QRect(190, 180, 170, 21))
        self.next_officer_in_charge_cbox.setObjectName(
            _fromUtf8("next_officer_in_charge_cbox"))
        self.label_37 = QtGui.QLabel(self.groupBox_11)
        self.label_37.setGeometry(QtCore.QRect(190, 160, 171, 17))
        self.label_37.setObjectName(_fromUtf8("label_37"))
        self.label_55 = QtGui.QLabel(self.groupBox_11)
        self.label_55.setGeometry(QtCore.QRect(10, 42, 171, 20))
        self.label_55.setObjectName(_fromUtf8("label_55"))
        self.plan_type_cbox = QtGui.QComboBox(self.groupBox_11)
        self.plan_type_cbox.setGeometry(QtCore.QRect(10, 60, 351, 23))
        self.plan_type_cbox.setObjectName(_fromUtf8("plan_type_cbox"))
        self.plan_date_checkbox = QtGui.QCheckBox(self.groupBox_11)
        self.plan_date_checkbox.setGeometry(QtCore.QRect(10, 24, 81, 20))
        self.plan_date_checkbox.setObjectName(_fromUtf8("plan_date_checkbox"))
        self.plan_datetime_edit = QtGui.QDateEdit(self.groupBox_11)
        self.plan_datetime_edit.setEnabled(False)
        self.plan_datetime_edit.setGeometry(QtCore.QRect(100, 25, 81, 20))
        self.plan_datetime_edit.setObjectName(_fromUtf8("plan_datetime_edit"))
        self.label_33 = QtGui.QLabel(self.groupBox_11)
        self.label_33.setGeometry(QtCore.QRect(10, 121, 171, 17))
        self.label_33.setObjectName(_fromUtf8("label_33"))
        self.decision_level_cbox = QtGui.QComboBox(self.groupBox_11)
        self.decision_level_cbox.setGeometry(QtCore.QRect(10, 138, 351, 21))
        self.decision_level_cbox.setObjectName(
            _fromUtf8("decision_level_cbox"))
        self.plan_find_button = QtGui.QPushButton(self.plan_tab)
        self.plan_find_button.setGeometry(QtCore.QRect(291, 234, 75, 23))
        self.plan_find_button.setAutoDefault(True)
        self.plan_find_button.setDefault(True)
        self.plan_find_button.setObjectName(_fromUtf8("plan_find_button"))
        self.plan_clear_button = QtGui.QPushButton(self.plan_tab)
        self.plan_clear_button.setGeometry(QtCore.QRect(205, 234, 75, 23))
        self.plan_clear_button.setObjectName(_fromUtf8("plan_clear_button"))
        self.groupBox_12 = QtGui.QGroupBox(self.plan_tab)
        self.groupBox_12.setGeometry(QtCore.QRect(5, 260, 371, 301))
        self.groupBox_12.setObjectName(_fromUtf8("groupBox_12"))
        self.plan_results_twidget = QtGui.QTableWidget(self.groupBox_12)
        self.plan_results_twidget.setGeometry(QtCore.QRect(5, 18, 361, 241))
        self.plan_results_twidget.setSelectionMode(
            QtGui.QAbstractItemView.ExtendedSelection)
        self.plan_results_twidget.setObjectName(
            _fromUtf8("plan_results_twidget"))
        self.plan_results_twidget.setColumnCount(0)
        self.plan_results_twidget.setRowCount(0)
        self.current_view_button = QtGui.QPushButton(self.groupBox_12)
        self.current_view_button.setGeometry(QtCore.QRect(260, 270, 100, 23))
        self.current_view_button.setObjectName(
            _fromUtf8("current_view_button"))
        self.plan_edit_button = QtGui.QPushButton(self.groupBox_12)
        self.plan_edit_button.setGeometry(QtCore.QRect(140, 270, 100, 23))
        self.plan_edit_button.setObjectName(_fromUtf8("plan_edit_button"))
        self.case_button = QtGui.QPushButton(self.groupBox_12)
        self.case_button.setGeometry(QtCore.QRect(15, 270, 100, 23))
        self.case_button.setObjectName(_fromUtf8("case_button"))
        self.working_l2_cbox = QtGui.QComboBox(self.plan_tab)
        self.working_l2_cbox.setGeometry(QtCore.QRect(236, 5, 140, 22))
        self.working_l2_cbox.setObjectName(_fromUtf8("working_l2_cbox"))
        self.working_l1_cbox = QtGui.QComboBox(self.plan_tab)
        self.working_l1_cbox.setGeometry(QtCore.QRect(88, 5, 140, 22))
        self.working_l1_cbox.setObjectName(_fromUtf8("working_l1_cbox"))
        self.error_label = QtGui.QLabel(self.plan_tab)
        self.error_label.setGeometry(QtCore.QRect(7, 568, 374, 21))
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("Helvetica"))
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.error_label.setFont(font)
        self.error_label.setStyleSheet(
            _fromUtf8("QLabel {color : red;}\n"
                      "font: 75 14pt \"Helvetica\";"))
        self.error_label.setText(_fromUtf8(""))
        self.error_label.setWordWrap(True)
        self.error_label.setObjectName(_fromUtf8("error_label"))
        self.is_filter_chbox = QtGui.QCheckBox(self.plan_tab)
        self.is_filter_chbox.setGeometry(QtCore.QRect(8, 8, 78, 17))
        self.is_filter_chbox.setObjectName(_fromUtf8("is_filter_chbox"))
        self.tabWidget.addTab(self.plan_tab, _fromUtf8(""))
        self.st_tm_filter_tab = QtGui.QWidget()
        self.st_tm_filter_tab.setObjectName(_fromUtf8("st_tm_filter_tab"))
        self.spatial_groupbox = QtGui.QGroupBox(self.st_tm_filter_tab)
        self.spatial_groupbox.setGeometry(QtCore.QRect(5, 0, 371, 151))
        self.spatial_groupbox.setObjectName(_fromUtf8("spatial_groupbox"))
        self.get_extent_button = QtGui.QPushButton(self.spatial_groupbox)
        self.get_extent_button.setGeometry(QtCore.QRect(129, 53, 111, 28))
        self.get_extent_button.setObjectName(_fromUtf8("get_extent_button"))
        self.apply_button = QtGui.QPushButton(self.spatial_groupbox)
        self.apply_button.setGeometry(QtCore.QRect(10, 120, 110, 23))
        self.apply_button.setObjectName(_fromUtf8("apply_button"))
        self.clear_b_box_button = QtGui.QPushButton(self.spatial_groupbox)
        self.clear_b_box_button.setGeometry(QtCore.QRect(250, 120, 110, 23))
        self.clear_b_box_button.setObjectName(_fromUtf8("clear_b_box_button"))
        self.remove_button = QtGui.QPushButton(self.spatial_groupbox)
        self.remove_button.setGeometry(QtCore.QRect(130, 120, 110, 23))
        self.remove_button.setObjectName(_fromUtf8("remove_button"))
        self.extent_rbutton = QtGui.QRadioButton(self.spatial_groupbox)
        self.extent_rbutton.setGeometry(QtCore.QRect(13, 14, 321, 16))
        self.extent_rbutton.setChecked(True)
        self.extent_rbutton.setObjectName(_fromUtf8("extent_rbutton"))
        self.buttonGroup = QtGui.QButtonGroup(PlanNavigatorWidget)
        self.buttonGroup.setObjectName(_fromUtf8("buttonGroup"))
        self.buttonGroup.addButton(self.extent_rbutton)
        self.extent_east_spinbox = QtGui.QDoubleSpinBox(self.spatial_groupbox)
        self.extent_east_spinbox.setGeometry(QtCore.QRect(250, 57, 110, 20))
        self.extent_east_spinbox.setInputMethodHints(
            QtCore.Qt.ImhFormattedNumbersOnly)
        self.extent_east_spinbox.setReadOnly(True)
        self.extent_east_spinbox.setButtonSymbols(
            QtGui.QAbstractSpinBox.NoButtons)
        self.extent_east_spinbox.setMinimum(-200000010.0)
        self.extent_east_spinbox.setMaximum(200000010.0)
        self.extent_east_spinbox.setObjectName(
            _fromUtf8("extent_east_spinbox"))
        self.extent_west_spinbox = QtGui.QDoubleSpinBox(self.spatial_groupbox)
        self.extent_west_spinbox.setGeometry(QtCore.QRect(10, 58, 110, 20))
        self.extent_west_spinbox.setInputMethodHints(
            QtCore.Qt.ImhFormattedNumbersOnly)
        self.extent_west_spinbox.setReadOnly(True)
        self.extent_west_spinbox.setButtonSymbols(
            QtGui.QAbstractSpinBox.NoButtons)
        self.extent_west_spinbox.setMinimum(-200000010.0)
        self.extent_west_spinbox.setMaximum(200000010.0)
        self.extent_west_spinbox.setObjectName(
            _fromUtf8("extent_west_spinbox"))
        self.extent_south_spinbox = QtGui.QDoubleSpinBox(self.spatial_groupbox)
        self.extent_south_spinbox.setGeometry(QtCore.QRect(132, 85, 110, 20))
        self.extent_south_spinbox.setInputMethodHints(
            QtCore.Qt.ImhFormattedNumbersOnly)
        self.extent_south_spinbox.setReadOnly(True)
        self.extent_south_spinbox.setButtonSymbols(
            QtGui.QAbstractSpinBox.NoButtons)
        self.extent_south_spinbox.setMinimum(-200000010.0)
        self.extent_south_spinbox.setMaximum(200000010.0)
        self.extent_south_spinbox.setObjectName(
            _fromUtf8("extent_south_spinbox"))
        self.extent_north_spinbox = QtGui.QDoubleSpinBox(self.spatial_groupbox)
        self.extent_north_spinbox.setGeometry(QtCore.QRect(130, 28, 110, 20))
        self.extent_north_spinbox.setInputMethodHints(
            QtCore.Qt.ImhFormattedNumbersOnly)
        self.extent_north_spinbox.setReadOnly(True)
        self.extent_north_spinbox.setButtonSymbols(
            QtGui.QAbstractSpinBox.NoButtons)
        self.extent_north_spinbox.setMinimum(-200000010.0)
        self.extent_north_spinbox.setMaximum(200000010.0)
        self.extent_north_spinbox.setObjectName(
            _fromUtf8("extent_north_spinbox"))
        self.groupBox_6 = QtGui.QGroupBox(self.st_tm_filter_tab)
        self.groupBox_6.setGeometry(QtCore.QRect(5, 150, 371, 82))
        self.groupBox_6.setObjectName(_fromUtf8("groupBox_6"))
        self.from_date_edit = QtGui.QDateEdit(self.groupBox_6)
        self.from_date_edit.setGeometry(QtCore.QRect(120, 14, 91, 22))
        self.from_date_edit.setCalendarPopup(True)
        self.from_date_edit.setObjectName(_fromUtf8("from_date_edit"))
        self.till_date_edit = QtGui.QDateEdit(self.groupBox_6)
        self.till_date_edit.setGeometry(QtCore.QRect(120, 40, 91, 22))
        self.till_date_edit.setCalendarPopup(True)
        self.till_date_edit.setObjectName(_fromUtf8("till_date_edit"))
        self.infinity_check_box = QtGui.QCheckBox(self.groupBox_6)
        self.infinity_check_box.setGeometry(QtCore.QRect(20, 40, 91, 20))
        self.infinity_check_box.setObjectName(_fromUtf8("infinity_check_box"))
        self.temp_filter_apply_button = QtGui.QPushButton(self.groupBox_6)
        self.temp_filter_apply_button.setGeometry(QtCore.QRect(
            240, 40, 91, 23))
        self.temp_filter_apply_button.setObjectName(
            _fromUtf8("temp_filter_apply_button"))
        self.label_12 = QtGui.QLabel(self.groupBox_6)
        self.label_12.setGeometry(QtCore.QRect(20, 18, 101, 17))
        self.label_12.setObjectName(_fromUtf8("label_12"))
        self.tabWidget_2 = QtGui.QTabWidget(self.st_tm_filter_tab)
        self.tabWidget_2.setGeometry(QtCore.QRect(0, 240, 381, 351))
        self.tabWidget_2.setObjectName(_fromUtf8("tabWidget_2"))
        self.tab_6 = QtGui.QWidget()
        self.tab_6.setObjectName(_fromUtf8("tab_6"))
        self.dateEdit_2 = QtGui.QDateEdit(self.tab_6)
        self.dateEdit_2.setGeometry(QtCore.QRect(110, 10, 70, 22))
        self.dateEdit_2.setObjectName(_fromUtf8("dateEdit_2"))
        self.dateEdit = QtGui.QDateEdit(self.tab_6)
        self.dateEdit.setGeometry(QtCore.QRect(10, 10, 70, 22))
        self.dateEdit.setObjectName(_fromUtf8("dateEdit"))
        self.layers_twidget = QtGui.QTableWidget(self.tab_6)
        self.layers_twidget.setGeometry(QtCore.QRect(10, 40, 361, 241))
        self.layers_twidget.setObjectName(_fromUtf8("layers_twidget"))
        self.layers_twidget.setColumnCount(0)
        self.layers_twidget.setRowCount(0)
        self.filter_view_button = QtGui.QPushButton(self.tab_6)
        self.filter_view_button.setGeometry(QtCore.QRect(287, 290, 75, 23))
        self.filter_view_button.setObjectName(_fromUtf8("filter_view_button"))
        self.filter_chbox = QtGui.QCheckBox(self.tab_6)
        self.filter_chbox.setGeometry(QtCore.QRect(190, 293, 91, 17))
        self.filter_chbox.setObjectName(_fromUtf8("filter_chbox"))
        self.tabWidget_2.addTab(self.tab_6, _fromUtf8(""))
        self.tab_5 = QtGui.QWidget()
        self.tab_5.setObjectName(_fromUtf8("tab_5"))
        self.au_level2_button_2 = QtGui.QPushButton(self.tab_5)
        self.au_level2_button_2.setGeometry(QtCore.QRect(16, 55, 161, 23))
        self.au_level2_button_2.setObjectName(_fromUtf8("au_level2_button_2"))
        self.au_level1_button_2 = QtGui.QPushButton(self.tab_5)
        self.au_level1_button_2.setGeometry(QtCore.QRect(16, 30, 161, 23))
        self.au_level1_button_2.setObjectName(_fromUtf8("au_level1_button_2"))
        self.layer_view_button_2 = QtGui.QPushButton(self.tab_5)
        self.layer_view_button_2.setGeometry(QtCore.QRect(190, 185, 161, 23))
        self.layer_view_button_2.setStyleSheet(_fromUtf8(""))
        self.layer_view_button_2.setObjectName(
            _fromUtf8("layer_view_button_2"))
        self.fee_tax_zone_button_2 = QtGui.QPushButton(self.tab_5)
        self.fee_tax_zone_button_2.setGeometry(QtCore.QRect(16, 105, 161, 23))
        self.fee_tax_zone_button_2.setObjectName(
            _fromUtf8("fee_tax_zone_button_2"))
        self.type_cbox_2 = QtGui.QComboBox(self.tab_5)
        self.type_cbox_2.setGeometry(QtCore.QRect(17, 150, 333, 22))
        self.type_cbox_2.setObjectName(_fromUtf8("type_cbox_2"))
        self.valuation_zone_button_2 = QtGui.QPushButton(self.tab_5)
        self.valuation_zone_button_2.setGeometry(
            QtCore.QRect(190, 105, 161, 23))
        self.valuation_zone_button_2.setObjectName(
            _fromUtf8("valuation_zone_button_2"))
        self.sec_zone_button_2 = QtGui.QPushButton(self.tab_5)
        self.sec_zone_button_2.setGeometry(QtCore.QRect(190, 80, 161, 23))
        self.sec_zone_button_2.setObjectName(_fromUtf8("sec_zone_button_2"))
        self.au_level3_button_2 = QtGui.QPushButton(self.tab_5)
        self.au_level3_button_2.setGeometry(QtCore.QRect(16, 80, 161, 23))
        self.au_level3_button_2.setObjectName(_fromUtf8("au_level3_button_2"))
        self.label_2 = QtGui.QLabel(self.tab_5)
        self.label_2.setGeometry(QtCore.QRect(19, 135, 331, 16))
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.mpa_zone_button_2 = QtGui.QPushButton(self.tab_5)
        self.mpa_zone_button_2.setGeometry(QtCore.QRect(190, 55, 161, 23))
        self.mpa_zone_button_2.setObjectName(_fromUtf8("mpa_zone_button_2"))
        self.free_zone_button_2 = QtGui.QPushButton(self.tab_5)
        self.free_zone_button_2.setGeometry(QtCore.QRect(190, 30, 161, 23))
        self.free_zone_button_2.setObjectName(_fromUtf8("free_zone_button_2"))
        self.tabWidget_2.addTab(self.tab_5, _fromUtf8(""))
        self.tabWidget.addTab(self.st_tm_filter_tab, _fromUtf8(""))
        self.tab_3 = QtGui.QWidget()
        self.tab_3.setObjectName(_fromUtf8("tab_3"))
        self.qa_lwidget = QtGui.QListWidget(self.tab_3)
        self.qa_lwidget.setGeometry(QtCore.QRect(4, 5, 371, 181))
        self.qa_lwidget.setObjectName(_fromUtf8("qa_lwidget"))
        item = QtGui.QListWidgetItem()
        self.qa_lwidget.addItem(item)
        item = QtGui.QListWidgetItem()
        self.qa_lwidget.addItem(item)
        item = QtGui.QListWidgetItem()
        self.qa_lwidget.addItem(item)
        item = QtGui.QListWidgetItem()
        self.qa_lwidget.addItem(item)
        item = QtGui.QListWidgetItem()
        self.qa_lwidget.addItem(item)
        item = QtGui.QListWidgetItem()
        self.qa_lwidget.addItem(item)
        item = QtGui.QListWidgetItem()
        self.qa_lwidget.addItem(item)
        item = QtGui.QListWidgetItem()
        self.qa_lwidget.addItem(item)
        item = QtGui.QListWidgetItem()
        self.qa_lwidget.addItem(item)
        self.qa_layer_button = QtGui.QPushButton(self.tab_3)
        self.qa_layer_button.setGeometry(QtCore.QRect(9, 220, 360, 23))
        self.qa_layer_button.setObjectName(_fromUtf8("qa_layer_button"))
        self.p_button = QtGui.QPushButton(self.tab_3)
        self.p_button.setGeometry(QtCore.QRect(90, 250, 201, 23))
        self.p_button.setObjectName(_fromUtf8("p_button"))
        self.tabWidget.addTab(self.tab_3, _fromUtf8(""))
        self.maintenance_tab = QtGui.QWidget()
        self.maintenance_tab.setObjectName(_fromUtf8("maintenance_tab"))
        self.groupBox_20 = QtGui.QGroupBox(self.maintenance_tab)
        self.groupBox_20.setGeometry(QtCore.QRect(5, 255, 371, 239))
        self.groupBox_20.setObjectName(_fromUtf8("groupBox_20"))
        self.case_results_twidget = QtGui.QTableWidget(self.groupBox_20)
        self.case_results_twidget.setGeometry(QtCore.QRect(5, 25, 361, 181))
        self.case_results_twidget.setSelectionMode(
            QtGui.QAbstractItemView.ExtendedSelection)
        self.case_results_twidget.setObjectName(
            _fromUtf8("case_results_twidget"))
        self.case_results_twidget.setColumnCount(0)
        self.case_results_twidget.setRowCount(0)
        self.case_finalize_button = QtGui.QPushButton(self.groupBox_20)
        self.case_finalize_button.setGeometry(QtCore.QRect(239, 213, 131, 23))
        self.case_finalize_button.setObjectName(
            _fromUtf8("case_finalize_button"))
        self.case_revert_button = QtGui.QPushButton(self.groupBox_20)
        self.case_revert_button.setGeometry(QtCore.QRect(115, 213, 111, 23))
        self.case_revert_button.setObjectName(_fromUtf8("case_revert_button"))
        self.case_create_button = QtGui.QPushButton(self.groupBox_20)
        self.case_create_button.setGeometry(QtCore.QRect(0, 213, 101, 23))
        self.case_create_button.setObjectName(_fromUtf8("case_create_button"))
        self.groupBox_21 = QtGui.QGroupBox(self.maintenance_tab)
        self.groupBox_21.setGeometry(QtCore.QRect(5, 0, 371, 256))
        self.groupBox_21.setObjectName(_fromUtf8("groupBox_21"))
        self.case_no_edit = QtGui.QLineEdit(self.groupBox_21)
        self.case_no_edit.setGeometry(QtCore.QRect(10, 28, 170, 20))
        self.case_no_edit.setObjectName(_fromUtf8("case_no_edit"))
        self.case_parcel_no_edit = QtGui.QLineEdit(self.groupBox_21)
        self.case_parcel_no_edit.setGeometry(QtCore.QRect(190, 67, 170, 20))
        self.case_parcel_no_edit.setObjectName(
            _fromUtf8("case_parcel_no_edit"))
        self.label_50 = QtGui.QLabel(self.groupBox_21)
        self.label_50.setGeometry(QtCore.QRect(10, 13, 170, 17))
        self.label_50.setObjectName(_fromUtf8("label_50"))
        self.label_51 = QtGui.QLabel(self.groupBox_21)
        self.label_51.setGeometry(QtCore.QRect(10, 52, 170, 17))
        self.label_51.setObjectName(_fromUtf8("label_51"))
        self.label_52 = QtGui.QLabel(self.groupBox_21)
        self.label_52.setGeometry(QtCore.QRect(10, 92, 170, 17))
        self.label_52.setObjectName(_fromUtf8("label_52"))
        self.label_53 = QtGui.QLabel(self.groupBox_21)
        self.label_53.setGeometry(QtCore.QRect(190, 13, 170, 17))
        self.label_53.setObjectName(_fromUtf8("label_53"))
        self.label_54 = QtGui.QLabel(self.groupBox_21)
        self.label_54.setGeometry(QtCore.QRect(190, 52, 170, 16))
        self.label_54.setObjectName(_fromUtf8("label_54"))
        self.case_completion_date_edit = QtGui.QDateEdit(self.groupBox_21)
        self.case_completion_date_edit.setGeometry(
            QtCore.QRect(39, 67, 141, 21))
        self.case_completion_date_edit.setCalendarPopup(True)
        self.case_completion_date_edit.setObjectName(
            _fromUtf8("case_completion_date_edit"))
        self.case_clear_button = QtGui.QPushButton(self.groupBox_21)
        self.case_clear_button.setGeometry(QtCore.QRect(204, 215, 75, 23))
        self.case_clear_button.setObjectName(_fromUtf8("case_clear_button"))
        self.case_find_button = QtGui.QPushButton(self.groupBox_21)
        self.case_find_button.setGeometry(QtCore.QRect(290, 215, 75, 23))
        self.case_find_button.setDefault(True)
        self.case_find_button.setObjectName(_fromUtf8("case_find_button"))
        self.case_completion_date_checkbox = QtGui.QCheckBox(self.groupBox_21)
        self.case_completion_date_checkbox.setGeometry(
            QtCore.QRect(10, 67, 21, 20))
        self.case_completion_date_checkbox.setText(_fromUtf8(""))
        self.case_completion_date_checkbox.setObjectName(
            _fromUtf8("case_completion_date_checkbox"))
        self.case_results_label = QtGui.QLabel(self.groupBox_21)
        self.case_results_label.setGeometry(QtCore.QRect(10, 220, 111, 20))
        font = QtGui.QFont()
        font.setFamily(_fromUtf8("Lucida Grande"))
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.case_results_label.setFont(font)
        self.case_results_label.setAlignment(QtCore.Qt.AlignLeading
                                             | QtCore.Qt.AlignLeft
                                             | QtCore.Qt.AlignVCenter)
        self.case_results_label.setObjectName(_fromUtf8("case_results_label"))
        self.surveyed_by_company_cbox = QtGui.QComboBox(self.groupBox_21)
        self.surveyed_by_company_cbox.setGeometry(QtCore.QRect(
            9, 107, 171, 21))
        self.surveyed_by_company_cbox.setObjectName(
            _fromUtf8("surveyed_by_company_cbox"))
        self.surveyed_by_land_officer_cbox = QtGui.QComboBox(self.groupBox_21)
        self.surveyed_by_land_officer_cbox.setGeometry(
            QtCore.QRect(10, 146, 170, 21))
        self.surveyed_by_land_officer_cbox.setObjectName(
            _fromUtf8("surveyed_by_land_officer_cbox"))
        self.label_56 = QtGui.QLabel(self.groupBox_21)
        self.label_56.setGeometry(QtCore.QRect(10, 131, 170, 17))
        self.label_56.setObjectName(_fromUtf8("label_56"))
        self.finalized_by_cbox = QtGui.QComboBox(self.groupBox_21)
        self.finalized_by_cbox.setGeometry(QtCore.QRect(190, 28, 171, 21))
        self.finalized_by_cbox.setObjectName(_fromUtf8("finalized_by_cbox"))
        self.case_status_cbox = QtGui.QComboBox(self.groupBox_21)
        self.case_status_cbox.setGeometry(QtCore.QRect(190, 146, 170, 21))
        self.case_status_cbox.setObjectName(_fromUtf8("case_status_cbox"))
        self.label_58 = QtGui.QLabel(self.groupBox_21)
        self.label_58.setGeometry(QtCore.QRect(190, 131, 170, 17))
        self.label_58.setObjectName(_fromUtf8("label_58"))
        self.label_57 = QtGui.QLabel(self.groupBox_21)
        self.label_57.setGeometry(QtCore.QRect(190, 94, 170, 16))
        self.label_57.setObjectName(_fromUtf8("label_57"))
        self.case_app_no_edit = QtGui.QLineEdit(self.groupBox_21)
        self.case_app_no_edit.setGeometry(QtCore.QRect(190, 109, 170, 20))
        self.case_app_no_edit.setObjectName(_fromUtf8("case_app_no_edit"))
        self.personal_case_edit = QtGui.QLineEdit(self.groupBox_21)
        self.personal_case_edit.setGeometry(QtCore.QRect(191, 186, 169, 20))
        self.personal_case_edit.setObjectName(_fromUtf8("personal_case_edit"))
        self.label_81 = QtGui.QLabel(self.groupBox_21)
        self.label_81.setGeometry(QtCore.QRect(193, 173, 153, 10))
        self.label_81.setObjectName(_fromUtf8("label_81"))
        self.label_82 = QtGui.QLabel(self.groupBox_21)
        self.label_82.setGeometry(QtCore.QRect(10, 170, 171, 17))
        self.label_82.setObjectName(_fromUtf8("label_82"))
        self.case_right_holder_name_edit = QtGui.QLineEdit(self.groupBox_21)
        self.case_right_holder_name_edit.setGeometry(
            QtCore.QRect(10, 186, 170, 20))
        self.case_right_holder_name_edit.setObjectName(
            _fromUtf8("case_right_holder_name_edit"))
        self.tabWidget.addTab(self.maintenance_tab, _fromUtf8(""))
        self.scrollArea.setWidget(self.scrollAreaWidgetContents)
        PlanNavigatorWidget.setWidget(self.dockWidgetContents)

        self.retranslateUi(PlanNavigatorWidget)
        self.tabWidget.setCurrentIndex(0)
        self.tabWidget_2.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(PlanNavigatorWidget)
        PlanNavigatorWidget.setTabOrder(self.tabWidget, self.extent_rbutton)
        PlanNavigatorWidget.setTabOrder(self.extent_rbutton,
                                        self.get_extent_button)
        PlanNavigatorWidget.setTabOrder(self.get_extent_button,
                                        self.extent_west_spinbox)
        PlanNavigatorWidget.setTabOrder(self.extent_west_spinbox,
                                        self.extent_east_spinbox)
        PlanNavigatorWidget.setTabOrder(self.extent_east_spinbox,
                                        self.extent_north_spinbox)
        PlanNavigatorWidget.setTabOrder(self.extent_north_spinbox,
                                        self.extent_south_spinbox)
        PlanNavigatorWidget.setTabOrder(self.extent_south_spinbox,
                                        self.apply_button)
        PlanNavigatorWidget.setTabOrder(self.apply_button, self.remove_button)
        PlanNavigatorWidget.setTabOrder(self.remove_button,
                                        self.clear_b_box_button)
        PlanNavigatorWidget.setTabOrder(self.clear_b_box_button,
                                        self.from_date_edit)
        PlanNavigatorWidget.setTabOrder(self.from_date_edit,
                                        self.till_date_edit)
        PlanNavigatorWidget.setTabOrder(self.till_date_edit,
                                        self.infinity_check_box)
        PlanNavigatorWidget.setTabOrder(self.infinity_check_box,
                                        self.temp_filter_apply_button)
        PlanNavigatorWidget.setTabOrder(self.temp_filter_apply_button,
                                        self.status_cbox)
        PlanNavigatorWidget.setTabOrder(self.status_cbox,
                                        self.office_in_charge_cbox)
        PlanNavigatorWidget.setTabOrder(self.office_in_charge_cbox,
                                        self.plan_num_edit)
        PlanNavigatorWidget.setTabOrder(self.plan_num_edit,
                                        self.plan_clear_button)
        PlanNavigatorWidget.setTabOrder(self.plan_clear_button,
                                        self.plan_find_button)
        PlanNavigatorWidget.setTabOrder(self.plan_find_button,
                                        self.plan_results_twidget)
        PlanNavigatorWidget.setTabOrder(self.plan_results_twidget,
                                        self.case_button)
        PlanNavigatorWidget.setTabOrder(self.case_button,
                                        self.plan_edit_button)
        PlanNavigatorWidget.setTabOrder(self.plan_edit_button,
                                        self.current_view_button)
        PlanNavigatorWidget.setTabOrder(self.current_view_button,
                                        self.case_no_edit)
        PlanNavigatorWidget.setTabOrder(self.case_no_edit,
                                        self.case_completion_date_checkbox)
        PlanNavigatorWidget.setTabOrder(self.case_completion_date_checkbox,
                                        self.case_completion_date_edit)
        PlanNavigatorWidget.setTabOrder(self.case_completion_date_edit,
                                        self.surveyed_by_company_cbox)
        PlanNavigatorWidget.setTabOrder(self.surveyed_by_company_cbox,
                                        self.surveyed_by_land_officer_cbox)
        PlanNavigatorWidget.setTabOrder(self.surveyed_by_land_officer_cbox,
                                        self.finalized_by_cbox)
        PlanNavigatorWidget.setTabOrder(self.finalized_by_cbox,
                                        self.case_parcel_no_edit)
        PlanNavigatorWidget.setTabOrder(self.case_parcel_no_edit,
                                        self.case_status_cbox)
        PlanNavigatorWidget.setTabOrder(self.case_status_cbox,
                                        self.case_clear_button)
        PlanNavigatorWidget.setTabOrder(self.case_clear_button,
                                        self.case_find_button)
        PlanNavigatorWidget.setTabOrder(self.case_find_button,
                                        self.case_results_twidget)
        PlanNavigatorWidget.setTabOrder(self.case_results_twidget,
                                        self.case_create_button)
        PlanNavigatorWidget.setTabOrder(self.case_create_button,
                                        self.case_revert_button)
        PlanNavigatorWidget.setTabOrder(self.case_revert_button,
                                        self.case_finalize_button)
        PlanNavigatorWidget.setTabOrder(self.case_finalize_button,
                                        self.scrollArea)
Exemple #30
0
    def __init__(self, moviefile=None, savedir=None):
        super(MainW, self).__init__()
        icon_path = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), "mouse.png"
        )
        app_icon = QtGui.QIcon()
        app_icon.addFile(icon_path, QtCore.QSize(16, 16))
        app_icon.addFile(icon_path, QtCore.QSize(24, 24))
        app_icon.addFile(icon_path, QtCore.QSize(32, 32))
        app_icon.addFile(icon_path, QtCore.QSize(48, 48))
        app_icon.addFile(icon_path, QtCore.QSize(96, 96))
        app_icon.addFile(icon_path, QtCore.QSize(256, 256))
        self.setWindowIcon(app_icon)

        pg.setConfigOptions(imageAxisOrder='row-major')
        self.setGeometry(15,15,1470,1000)
        self.setWindowTitle('FaceMap')
        self.setStyleSheet("QMainWindow {background: 'black';}")
        self.styleUnpressed = ("QPushButton {Text-align: left; "
                               "background-color: rgb(50,50,50); "
                               "color:white;}")
        self.stylePressed = ("QPushButton {Text-align: left; "
                             "background-color: rgb(100,50,100); "
                             "color:white;}")
        self.styleInactive = ("QPushButton {Text-align: left; "
                              "background-color: rgb(50,50,50); "
                              "color:gray;}")

        try:
            # try to load user settings
            opsfile = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'ops_user.npy')
            self.ops = np.load(opsfile, allow_pickle=True).item()
        except:
            self.ops = {'sbin': 4, 'pupil_sigma': 2., 'fullSVD': False,
                        'save_path': '', 'save_mat': False}

        self.save_path = self.ops['save_path']

        self.cwidget = QtGui.QWidget(self)
        self.setCentralWidget(self.cwidget)
        self.l0 = QtGui.QGridLayout()
        #layout = QtGui.QFormLayout()
        self.cwidget.setLayout(self.l0)
        #self.p0 = pg.ViewBox(lockAspect=False,name='plot1',border=[100,100,100],invertY=True)
        self.win = pg.GraphicsLayoutWidget()
        # --- cells image
        self.win = pg.GraphicsLayoutWidget()
        self.win.move(600,0)
        self.win.resize(1000,500)
        self.l0.addWidget(self.win,1,3,37,15)
        layout = self.win.ci.layout

        # A plot area (ViewBox + axes) for displaying the image
        self.p0 = self.win.addViewBox(lockAspect=True,row=0,col=0,invertY=True)
        #self.p0.setMouseEnabled(x=False,y=False)
        self.p0.setMenuEnabled(False)
        self.pimg = pg.ImageItem()
        self.p0.addItem(self.pimg)

        # image ROI
        self.pROI = self.win.addViewBox(lockAspect=True,row=0,col=1,invertY=True)
        #self.p0.setMouseEnabled(x=False,y=False)
        self.pROI.setMenuEnabled(False)
        self.pROIimg = pg.ImageItem()
        self.pROI.addItem(self.pROIimg)
        self.scatter = pg.ScatterPlotItem([0], [0], pen='k', symbol='+')
        self.pROI.addItem(self.scatter)

        # roi initializations
        self.iROI = 0
        self.nROIs = 0
        self.saturation = []
        self.ROIs = []

        # saturation sliders
        self.sl = []
        txt = ["saturation", 'saturation']
        self.sat = [255,255]
        for j in range(2):
            self.sl.append(Slider(j, self))
            self.l0.addWidget(self.sl[j],1,6+5*j,1,2)
            qlabel = QtGui.QLabel(txt[j])
            qlabel.setStyleSheet('color: white;')
            self.l0.addWidget(qlabel,0,6+5*j,1,1)

        self.reflector = QtGui.QPushButton('add corneal reflection')
        self.l0.addWidget(self.reflector, 1, 8+5*j, 1, 2)
        self.reflector.setEnabled(False)
        self.reflector.clicked.connect(self.add_reflectROI)
        self.rROI=[]
        self.reflectors=[]

        self.p1 = self.win.addPlot(name='plot1',row=1,col=0,colspan=2, title='p1')
        self.p1.setMouseEnabled(x=True,y=False)
        self.p1.setMenuEnabled(False)
        self.p1.hideAxis('left')
        self.scatter1 = pg.ScatterPlotItem()
        self.p1.addItem(self.scatter1)
        #self.p1.setLabel('bottom', 'plot1')
        #self.p1.autoRange(padding=0.01)
        self.p2 = self.win.addPlot(name='plot2',row=2,col=0,colspan=2, title='p2')
        self.p2.setMouseEnabled(x=True,y=False)
        self.p2.setMenuEnabled(False)
        self.p2.hideAxis('left')
        self.scatter2 = pg.ScatterPlotItem()
        self.p2.addItem(self.scatter1)
        #self.p2.setLabel('bottom', 'plot2')
        self.p2.setXLink("plot1")
        #self.p2.autoRange(padding=0.01)
        self.win.ci.layout.setRowStretchFactor(0,5)
        self.movieLabel = QtGui.QLabel("No movie chosen")
        self.movieLabel.setStyleSheet("color: white;")
        self.movieLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.nframes = 0
        self.cframe = 0
        # create ROI chooser
        #qlabel = QtGui.QLabel(self)
        #qlabel.setText("<font color='white'>Selected ROI:</font>")
        #self.l0.addWidget(qlabel,3,0,1,2)
        # create frame slider
        binLabel = QtGui.QLabel("SVD spatial bin:")
        binLabel.setStyleSheet("color: gray;")
        self.binSpinBox = QtGui.QSpinBox()
        self.binSpinBox.setRange(1, 20)
        self.binSpinBox.setValue(self.ops['sbin'])
        self.binSpinBox.setFixedWidth(50)
        self.l0.addWidget(binLabel, 7, 0, 1, 3)
        self.l0.addWidget(self.binSpinBox, 8, 0, 1, 3)
        binLabel = QtGui.QLabel("pupil sigma:")
        binLabel.setStyleSheet("color: gray;")
        self.sigmaBox = QtGui.QLineEdit()
        self.sigmaBox.setText(str(self.ops['pupil_sigma']))
        self.sigmaBox.setFixedWidth(45)
        self.l0.addWidget(binLabel, 9, 0, 1, 3)
        self.l0.addWidget(self.sigmaBox, 10, 0, 1, 3)
        self.pupil_sigma = float(self.sigmaBox.text())
        self.sigmaBox.returnPressed.connect(self.pupil_sigma_change)
        self.frameLabel = QtGui.QLabel("Current frame:")
        self.frameLabel.setStyleSheet("color: white;")
        self.frameNumber = QtGui.QLabel("0")
        self.frameNumber.setStyleSheet("color: white;")
        self.frameSlider = QtGui.QSlider(QtCore.Qt.Horizontal)
        #self.frameSlider.setTickPosition(QtGui.QSlider.TicksBelow)
        self.frameSlider.setTickInterval(5)
        self.frameSlider.setTracking(False)
        self.frameDelta = 10
        istretch = 23
        iplay = istretch+15
        iconSize = QtCore.QSize(20, 20)
        openButton = QtGui.QToolButton()
        openButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_FileIcon))
        openButton.setIconSize(iconSize)
        openButton.setToolTip("Open single movie file")
        openButton.clicked.connect(self.open_file)

        openButton2 = QtGui.QToolButton()
        openButton2.setIcon(self.style().standardIcon(QtGui.QStyle.SP_DialogOpenButton))
        openButton2.setIconSize(iconSize)
        openButton2.setToolTip("Open movie folder")
        openButton2.clicked.connect(self.open_folder)

        openButton3 = QtGui.QToolButton()
        openButton3.setIcon(self.style().standardIcon(QtGui.QStyle.SP_FileDialogStart))
        openButton3.setIconSize(iconSize)
        openButton3.setToolTip("Open processed file")
        openButton3.clicked.connect(self.open_proc)

        self.process = QtGui.QPushButton('process ROIs')
        self.process.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.process.clicked.connect(self.process_ROIs)
        self.process.setEnabled(False)

        self.savefolder = QtGui.QPushButton("save folder \u2b07")
        self.savefolder.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.savefolder.clicked.connect(self.save_folder)
        self.savefolder.setEnabled(False)
        if len(self.save_path) > 0:
            self.savelabel = QtGui.QLabel(self.save_path)
        else:
            self.savelabel = QtGui.QLabel('same as video')
        self.savelabel.setStyleSheet("color: white;")

        self.saverois = QtGui.QPushButton('save ROIs')
        self.saverois.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.saverois.clicked.connect(self.save_ROIs)
        self.saverois.setEnabled(False)

        self.batchlist=[]
        self.batchname=[]
        for k in range(6):
            self.batchname.append(QtGui.QLabel(''))
            self.batchname[-1].setStyleSheet("color: white;")
            self.l0.addWidget(self.batchname[-1],18+k,0,1,4)

        self.processbatch = QtGui.QPushButton(u"process batch \u2b07")
        self.processbatch.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.processbatch.clicked.connect(self.process_batch)
        self.processbatch.setEnabled(False)

        iconSize = QtCore.QSize(30, 30)
        self.playButton = QtGui.QToolButton()
        self.playButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_MediaPlay))
        self.playButton.setIconSize(iconSize)
        self.playButton.setToolTip("Play")
        self.playButton.setCheckable(True)
        self.playButton.clicked.connect(self.start)

        self.pauseButton = QtGui.QToolButton()
        self.pauseButton.setCheckable(True)
        self.pauseButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_MediaPause))
        self.pauseButton.setIconSize(iconSize)
        self.pauseButton.setToolTip("Pause")
        self.pauseButton.clicked.connect(self.pause)

        btns = QtGui.QButtonGroup(self)
        btns.addButton(self.playButton,0)
        btns.addButton(self.pauseButton,1)
        btns.setExclusive(True)

        quitButton = QtGui.QToolButton()
        quitButton.setIcon(self.style().standardIcon(QtGui.QStyle.SP_DialogCloseButton))
        quitButton.setIconSize(iconSize)
        quitButton.setToolTip("Quit")
        quitButton.clicked.connect(self.close)

        self.comboBox = QtGui.QComboBox(self)
        self.comboBox.setFixedWidth(100)
        self.comboBox.addItem("ROI type")
        self.comboBox.addItem("pupil")
        self.comboBox.addItem("motion SVD")
        self.comboBox.addItem("blink")
        self.comboBox.addItem("running")
        self.newROI = 0
        self.comboBox.setCurrentIndex(0)
        #self.comboBox.currentIndexChanged.connect(self.mode_change)

        self.addROI = QtGui.QPushButton("add ROI")
        self.addROI.setFont(QtGui.QFont("Arial", 8, QtGui.QFont.Bold))
        self.addROI.clicked.connect(self.add_ROI)
        self.addROI.setEnabled(False)

        self.checkBox = QtGui.QCheckBox("Compute multivideo SVD")
        self.checkBox.setStyleSheet("color: gray;")
        if self.ops['fullSVD']:
            self.checkBox.toggle()

        self.save_mat = QtGui.QCheckBox("Save *.mat file")
        self.save_mat.setStyleSheet("color: gray;")
        if self.ops['save_mat']:
            self.save_mat.toggle()

        self.l0.addWidget(openButton,1,0,1,1)
        self.l0.addWidget(openButton2,1,1,1,1)
        self.l0.addWidget(openButton3,1,2,1,1)
        self.l0.addWidget(self.comboBox, 2, 0, 1, 3)
        self.l0.addWidget(self.addROI,3,0,1,3)
        self.l0.addWidget(self.checkBox, 11, 0, 1, 4)
        self.l0.addWidget(self.save_mat, 12, 0, 1, 3)
        self.l0.addWidget(self.savefolder, 13, 0, 1, 3)
        self.l0.addWidget(self.savelabel, 14, 0, 1, 4)
        self.l0.addWidget(self.saverois, 15, 0, 1, 3)
        self.l0.addWidget(self.process,  16, 0, 1, 3)
        self.l0.addWidget(self.processbatch,  17, 0, 1, 3)
        self.l0.addWidget(self.playButton,iplay,0,1,1)
        self.l0.addWidget(self.pauseButton,iplay,1,1,1)
        #self.l0.addWidget(quitButton,0,1,1,1)
        self.playButton.setEnabled(False)
        self.pauseButton.setEnabled(False)
        self.pauseButton.setChecked(True)


        self.l0.addWidget(QtGui.QLabel(''),istretch,0,1,3)
        self.l0.setRowStretch(istretch,1)
        self.l0.addWidget(self.frameLabel, istretch+13,0,1,3)
        self.l0.addWidget(self.frameNumber, istretch+14,0,1,3)
        self.l0.addWidget(self.frameSlider, istretch+15,3,1,15)

        # plotting boxes
        pl = QtGui.QLabel("after processing")
        pl.setStyleSheet("color: gray;")
        self.l0.addWidget(pl, istretch+1, 0, 1, 3)
        pl = QtGui.QLabel("p1")
        pl.setStyleSheet("color: gray;")
        self.l0.addWidget(pl, istretch+2, 0, 1, 1)
        pl = QtGui.QLabel("p2")
        pl.setStyleSheet("color: gray;")
        self.l0.addWidget(pl, istretch+2, 1, 1, 1)
        pl = QtGui.QLabel("roi")
        pl.setStyleSheet("color: gray;")
        self.l0.addWidget(pl, istretch+2, 2, 1, 1)
        self.cbs1 = []
        self.cbs2 = []
        self.lbls = []
        for k in range(8):
            self.cbs1.append(QtGui.QCheckBox(''))
            self.l0.addWidget(self.cbs1[-1], istretch+3+k, 0, 1, 1)
            self.cbs2.append(QtGui.QCheckBox(''))
            self.l0.addWidget(self.cbs2[-1], istretch+3+k, 1, 1, 1)
            self.cbs1[-1].toggled.connect(self.plot_processed)
            self.cbs2[-1].toggled.connect(self.plot_processed)
            self.cbs1[-1].setEnabled(False)
            self.cbs2[-1].setEnabled(False)
            self.lbls.append(QtGui.QLabel(''))
            self.lbls[-1].setStyleSheet("color: white;")
            self.l0.addWidget(self.lbls[-1], istretch+3+k, 2, 1, 1)

        #self.l0.addWidget(QtGui.QLabel(''),17,2,1,1)
        #self.l0.setRowStretch(16,2)
        ll = QtGui.QLabel('play/pause [SPACE]')
        ll.setStyleSheet("color: gray;")
        self.l0.addWidget(ll, istretch+3+k+1,0,1,4)
        #ll = QtGui.QLabel('(when paused, left/right arrow keys can move slider)')
        #ll.setStyleSheet("color: white;")
        #self.l0.addWidget(ll,14,0,1,4)
        self.frameSlider.valueChanged.connect(self.go_to_frame)
        self.l0.addWidget(self.movieLabel,0,0,1,5)
        self.updateFrameSlider()
        #self.updateButtons()
        self.updateTimer = QtCore.QTimer()
        self.updateTimer.timeout.connect(self.next_frame)
        self.cframe = 0
        self.loaded = False
        self.Floaded = False
        self.wraw = False
        self.win.scene().sigMouseClicked.connect(self.plot_clicked)
        self.win.show()
        self.show()
        self.processed = False
        if moviefile is not None:
            self.load_movies([[moviefile]])
        if savedir is not None:
            self.save_path = savedir
            self.savelabel.setText(savedir)