def __init__(self, parent=None):
        super(Demo, self).__init__()

        self.setWindowTitle("Pointing Device")
        self.show()

        self.layout = QtGui.QGridLayout()
        self.setLayout(self.layout)

        self.buffer_amount = 20

        self.fc = Flowchart(terminals={
            'dataIn': {
                'io': 'in'
            },
            'dataOut': {
                'io': 'out'
            }
        })
        self.layout.addWidget(self.fc.widget(), 0, 0, 2, 1)

        self.configNodes()
        self.configScatterPlot()

        self.getWiimote()
Esempio n. 2
0
def make_sequential_flowchart(clsList, inputData=None):
    nNodes = len(clsList)

    nodelib = fclib.NodeLibrary()
    for cls in clsList:
        cls.debug = True
        nodelib.addNodeType(cls, [('Basic')])

    fc = Flowchart(terminals={
        'dataIn': {
            'io': 'in'
        },
        'dataOut': {
            'io': 'out'
        }
    })
    fc.library = nodelib

    nodes = []
    for cls in clsList:
        nodes.append(fc.createNode(cls.nodeName))

    fc.connectTerminals(fc['dataIn'], nodes[0]['dataIn'])
    for i in range(nNodes - 1):
        fc.connectTerminals(nodes[i]['dataOut'], nodes[i + 1]['dataIn'])
    fc.connectTerminals(nodes[nNodes - 1]['dataOut'], fc['dataOut'])

    if inputData is not None:
        fc.setInput(dataIn=inputData)

    return nodes, fc
Esempio n. 3
0
 def __init__(self):
     super(ModelWindow, self).__init__()
     self.setupUi(self)
     self.global_id = 0  #每个层对应的唯一ID,用于基于DAG图的校验和代码生成
     self.nodes = dict()  #所有层的信息
     self.id_name = dict()  #ID-名字映射
     self.name_id = dict()  #名字-ID映射
     self.net = nx.DiGraph()  #图,节点为层的ID
     self.library = fclib.LIBRARY.copy()
     self.library.addNodeType(CovNode, [('CovNode', )])
     self.library.addNodeType(PoolNode, [('PoolNode', )])
     self.library.addNodeType(LinearNode, [('LinearNode', )])
     self.library.addNodeType(ConcatNode, [('ConcatNode', )])
     self.library.addNodeType(Concat1dNode, [('Concat1dNode', )])
     self.library.addNodeType(SoftmaxNode, [('SoftmaxNode', )])
     self.library.addNodeType(LogSoftmaxNode, [('LogSoftmaxNode', )])
     self.library.addNodeType(BachNorm1dNode, [('BachNorm1dNode', )])
     self.library.addNodeType(BachNorm2dNode, [('BachNorm2dNode', )])
     self.library.addNodeType(AddNode, [('ResAddNode', )])
     self.library.addNodeType(IdentityNode, [('IdentityNode', )])
     self.type_name = {
         2: 'Cov2d',
         3: 'Pool2d',
         4: 'Linear',
         5: 'Softmax',
         6: 'LogSoftmax',
         7: 'BachNorm1d',
         8: 'BachNorm2d',
         9: 'Res_Add',
         10: 'Concat2d',
         11: 'Concat1d',
         12: 'Identity'
     }
     self.fc = Flowchart()  #模型可视化的流程图,对应FlowChart按钮
     self.fc.setLibrary(self.library)  #引入FCNodes.py中定义的Node
     self.outputs = list()  #模型所有输出
     w = self.fc.widget()
     self.fc_inputs = dict()  #self.fc流程图的输入
     main_widget = QWidget()
     main_layout = QGridLayout()
     main_widget.setLayout(main_layout)
     self.detail = QTreeWidget()
     self.detail.setColumnCount(2)
     self.detail.setHeaderLabels(["属性", "值"])
     self.root = QTreeWidgetItem(self.detail)
     self.root.setText(0, "所有属性")
     main_layout.addWidget(self.fc.widget(), 0, 0, 1, 2)
     main_layout.addWidget(self.detail, 0, 2)
     self.setCentralWidget(main_widget)
    def __init__(self, parent=None):
        super(Demo, self).__init__()

        self.setWindowTitle("Wiimote Activity")
        self.showFullScreen()

        self.layout = QtGui.QGridLayout()
        self.setLayout(self.layout)

        self.fc = Flowchart(terminals={
            'dataIn': {'io': 'in'},
            'dataOut': {'io': 'out'}
        })

        self.layout.addWidget(self.fc.widget(), 0, 0, 4, 1)

        self.createNodes()

        self.getWiimote()
Esempio n. 5
0
    def __init__(self, data_In=None, dataB_In=None, *args, **kwargs):
        super().__init__()

        # data_In will be Adata
        if data_In == None:
            print("Please load data")
            # For testing, create noise data
            data_In = []
            for i in range(50):
                dat = np.random.normal(size=1024)
                dat[200:300] += 1
                dat += np.sin(np.linspace(0, 100, 1024))
                data_In.append(dat)
        data_In = np.array(data_In)

        self.ui = Ui_BackgroundSubtraction()
        self.ui.setupUi(self)

        # Change plot labels, because I was too lazy to create a new widget
        pw1 = self.ui.View_Orig
        pw1.plt.setLabel('bottom', 'Magnetic Field', units='T')  # X-Axis
        pw1.plt.setLabel('left', "Amplitude (Arb. Units)", units='')  # Y-Axis

        pw2 = self.ui.View_Mod
        pw2.plt.setLabel('bottom', 'Magnetic Field', units='T')  # X-Axis
        pw2.plt.setLabel('left', "Amplitude (Arb. Units)", units='')  # Y-Axis

        pw3 = self.ui.View_Colour

        # Create Flowchart with two IO Nodes
        fc = Flowchart(terminals={
            'dataIn': {
                'io': 'in'
            },
            'dataOut': {
                'io': 'out'
            }
        })

        w = fc.widget()
        self.ui.gridLayout.addWidget(w)

        # Create metaarray using data_In and some information
        #data = metaarray.MetaArray(data_In, info=[{'name': 'Amplitude data'}, {}])

        fc.setInput(dataIn=data_In)  #Set data to Input Node

        ## If we want to make our custom node available only to this flowchart,
        ## then instead of registering the node type globally, we can create a new
        ## NodeLibrary:
        library = fclib.LIBRARY.copy()  # start with the default node set
        # Add the node to two locations in the menu to demonstrate
        # that we can create arbitrary menu structures
        library.addNodeType(SavGol_Smooth, [('FMR', 'Filter')])
        library.addNodeType(SavGol_Smooth_2D, [('FMR', 'Filter')])
        library.addNodeType(FMR_Subtract_Average, [('FMR', 'Filter')])
        library.addNodeType(FMR_Subtract_Average_Colour, [('FMR', 'Filter')])
        library.addNodeType(Measurement_Select, [('FMR', 'Data')])
        library.addNodeType(Average_Ang_Dep, [('FMR', 'Data')])
        library.addNodeType(ImageViewNode, [('Display', )])
        fc.setLibrary(library)

        plotList = {'Top Plot': pw1.plt, 'Bottom Plot': pw2.plt}

        pw1Node = fc.createNode('PlotWidget', pos=(0, -150))
        pw1Node.setPlotList(plotList)
        pw1Node.setPlot(pw1.plt)

        pw2Node = fc.createNode('PlotWidget', pos=(150, -150))
        pw2Node.setPlot(pw2.plt)
        pw2Node.setPlotList(plotList)

        pw3Node = fc.createNode('ImageView', pos=(300, -150))
        pw3Node.setView(pw3.img)

        fNode = fc.createNode('Spectrum select', pos=(0, 0))
        fc.connectTerminals(
            fc['dataIn'], fNode['dataIn']
        )  # Use this Slice node to select the measurement that you want to smooth aka axis
        fc.connectTerminals(fNode['dataOut'], pw1Node['In'])
        fc.connectTerminals(fNode['dataOut'], pw2Node['In'])
        fc.connectTerminals(fNode['dataOut'], fc['dataOut'])
Esempio n. 6
0
    def __init__(self):
        """
        Flowchart inside new window for system calibration
        """
        # Graphics window
        self.win = QtGui.QMainWindow()
        self.win.setWindowTitle('System Calibration Flowchart')
        # Dock Area
        dockArea = DockArea()
        # Central widget
        self.win.setCentralWidget(dockArea)

        # Window Docks
        fcWidgetDock = Dock('Flowchart Widget', size=(1, 1), hideTitle=True)
        displayDock = Dock('Measurement and Calibration', size=(1, 1))
        plotDocks = [Dock('Plot {}'.format(i), size=(1, 1)) for i in range(4)]
        dockArea.addDock(fcWidgetDock, 'left')
        dockArea.addDock(displayDock, 'right', fcWidgetDock)
        dockArea.addDock(plotDocks[0], 'top', displayDock)
        dockArea.addDock(plotDocks[1], 'right', plotDocks[0])
        dockArea.addDock(plotDocks[2], 'top', displayDock)
        dockArea.addDock(plotDocks[3], 'right', plotDocks[2])

        # Window size
        self.win.resize(800, 600)

        # Flowchart
        self.fc = Flowchart(terminals={
            'dipImgIn': {
                'io': 'in'
            },
            'CalibConstOut': {
                'io': 'out'
            },
        })
        # row, column, rowspan, colspan
        fcWidgetDock.addWidget(self.fc.widget())

        # Plot widgets
        self.plt_widg = [FlowchartPlotWidget() for _ in range(len(plotDocks))]
        [
            plotDocks[i].addWidget(self.plt_widg[i])
            for i in range(len(plotDocks))
        ]

        # Graphics layout for displays
        displayLayout = pg.GraphicsLayoutWidget(border='w')
        displayDock.addWidget(displayLayout)

        # Display widgets
        self.disp_widg = []
        self.disp_widg.append(
            displayLayout.addLabel('', colspan=2, justify='left'))
        displayLayout.nextRow()
        self.disp_widg.append(
            displayLayout.addLabel('', colspan=2, justify='left'))

        # Flowchart library copy - custom nodes available to user
        self.fc_library = fclib.LIBRARY.copy()
        [
            self.fc_library.addNodeType(nd, [('dipImage', 'Display')])
            for nd in (FlowchartPlotNode, MeasurementDisplayNode,
                       CalibDisplayNode, ORingMeasurementDisplayNode)
        ]
        # Filter nodes
        [
            self.fc_library.addNodeType(nd, [('dipImage', 'Filters')])
            for nd in (GaussianConvolutionNode, GradientNode,
                       GradientMagnitudeNode, GradientDirectionNode,
                       EdgeObjectsRemoveNode, KuwaharaNode,
                       BilateralFilterNode)
        ]
        # Binary Filter nodes
        [
            self.fc_library.addNodeType(nd, [('dipImage', 'Binary')])
            for nd in (BinaryClosingNode, BinaryOpeningNode, BinaryErosionNode,
                       BinaryDilationNode, BinaryAreaClosingNode,
                       BinaryAreaOpeningNode, BinaryPropagationNode,
                       FillHolesNode)
        ]
        # Segmentation nodes
        [
            self.fc_library.addNodeType(nd, [('dipImage', 'Segmentation')])
            for nd in (ThresholdNode, RangeThresholdNode, MinimaNode,
                       MaximaNode, WatershedNode, SeededWatershedNode,
                       CannyNode, SegmentORingNode)
        ]
        # Morphological nodes
        [
            self.fc_library.addNodeType(nd, [('dipImage', 'Morphological')])
            for nd in (DilationNode, ErosionNode, OpeningNode, ClosingNode)
        ]
        # Image nodes
        [
            self.fc_library.addNodeType(nd, [('dipImage', 'Image')])
            for nd in (ConvertNode, FillNode, LabelNode, SetPixelSizeNode)
        ]
        # Arithmetics nodes
        [
            self.fc_library.addNodeType(nd, [('dipImage', 'Arithmetics')])
            for nd in (InvertNode, ApplyMaskNode, CreateMaskNode,
                       OperatorPlusNode)
        ]
        # Measurement nodes
        [
            self.fc_library.addNodeType(nd, [('dipImage', 'Measurement')])
            for nd in (MeasureNode, WorkingDistanceCorrectionNode,
                       CombineMeasurementNode)
        ]
        self.fc.setLibrary(self.fc_library)

        # Plot nodes and Widget connection
        plt_nodes_x = (-20 + x * 120 for x in range(len(self.plt_widg)))
        plt_nodes = [
            self.fc.createNode('FlowchartPlot', pos=(x, -60))
            for x in plt_nodes_x
        ]
        [
            nd.set_fcPlotWidget(widg)
            for nd, widg in zip(plt_nodes, self.plt_widg)
        ]

        # Connecting plot and display widgets with nodes
        self.fc.sigFileLoaded.connect(self.setFlowchartPlotWidgets)
        self.fc.sigFileLoaded.connect(self.setDisplayWidgets)
        self.fc.sigChartChanged.connect(self.setFlowchartPlotWidgets)
        self.fc.sigChartChanged.connect(self.setDisplayWidgets)