Пример #1
0
    def get_condition_data(self, research_name, group, condition):
        """This function calculates all the graph attributes of a specific conddition, group and research.
                                                   :param research_name: Research's name
                                                   :type research_name: String
                                                   :param group: Group's name.
                                                   :type group: String
                                                   :param condition: Condition's name.
                                                   :type condition: String
                                                   :return: density, shortest_path_length, min_degree, max_degree, degree, local_efficiency
                                                   :rtype: float
                                                   """
        from undirectedGraph import Graph
        import numpy
        with open(
                r'\\URI\Users\uriel\PycharmProjects\FinalProject\Gui\Patients.json'
        ) as json_file:
            patients_counter = 0
            shortest_path_length = 0
            density = 0
            modularity = 0
            min_degree = 0
            max_degree = 0
            min_efficiency = 0
            max_efficiency = 0
            degree = 0
            local_efficiency = 0
            data = json.load(json_file)
            for res in data['Patients']:
                if (res['research_name'] == research_name) and (res['group']
                                                                == group):
                    patients_counter = patients_counter + 1
                    g = Graph()
                    g.create_nodes(
                        g.create_edges(res['full_name'] + '-' + condition))
                    print(res['full_name'] + '-' + condition + '-->' +
                          res['group'])

                    shortest_path_length = shortest_path_length + g.shortest_paths
                    density = density + g.density
                    # modularity
                    min_degree = min_degree + g.min_degree()
                    max_degree = max_degree + g.max_degree()

                    # degree = numpy.array(degree)
                    print(numpy.array(g.degrees))
                    degree = degree + numpy.array(g.degrees)
                    local_efficiency = local_efficiency + numpy.array(
                        g.locals_efficiency)
            print((density / patients_counter),
                  (shortest_path_length / patients_counter),
                  (min_degree / patients_counter),
                  (max_degree / patients_counter), (degree / patients_counter),
                  (local_efficiency / patients_counter))
            return (density / patients_counter), (
                shortest_path_length /
                patients_counter), (min_degree / patients_counter), (
                    max_degree /
                    patients_counter), (degree /
                                        patients_counter), (local_efficiency /
                                                            patients_counter)
Пример #2
0
    def electrode_changed(self):
        value = self.cBoxCond.currentText()

        if (self.cBoxElectrode1.currentText() == ''):
            self.TxtDegLoc1.clear()
            self.TxtDegLoc1_2.clear()
            self.TxtDegLocDif.clear()

            self.TxtEffLoc1.clear()
            self.TxtEffLoc2.clear()
            self.TxtEffLocDif.clear()
        else:
            if (value == 'Alone'):
                cond = 'B'
            elif (value == 'Spontaneous'):
                cond = 'C'
            else:
                cond = 'D'

            from undirectedGraph import Graph
            g1 = Graph()
            g1.create_nodes(
                g1.create_edges(self.cBoxPatient1.currentText() + '-' + cond))
            self.TxtDegLoc1.setText(
                str(
                    round(
                        g1.degrees[int(self.cBoxElectrode1.currentText()) - 1],
                        3)))
            self.TxtEffLoc1.setText(
                str(
                    round(
                        g1.locals_efficiency[
                            int(self.cBoxElectrode1.currentText()) - 1], 3)))

            g2 = Graph()
            g2.create_nodes(
                g2.create_edges(self.cBoxPatient2.currentText() + '-' + cond))
            self.TxtDegLoc1_2.setText(
                str(
                    round(
                        g2.degrees[int(self.cBoxElectrode1.currentText()) - 1],
                        3)))
            self.TxtEffLoc2.setText(
                str(
                    round(
                        g2.locals_efficiency[
                            int(self.cBoxElectrode1.currentText()) - 1], 3)))

            self.TxtDegLocDif.setText(
                str(
                    round(
                        abs(
                            float(self.TxtDegLoc1.text()) -
                            float(self.TxtDegLoc1_2.text())), 3)))
            self.TxtEffLocDif.setText(
                str(
                    round(
                        abs(
                            float(self.TxtEffLoc1.text()) -
                            float(self.TxtEffLoc2.text())), 3)))
Пример #3
0
 def show_res_electrode(self):
     from undirectedGraph import Graph
     print(self.cBoxPname.currentText())
     g = Graph()
     g.create_nodes(
         g.create_edges(self.cBoxPname.currentText() + '-' + cond))
     # ---- For the COMOBO BOX -------- #
     self.TxtDeg.setText(
         str(round(g.degrees[int(self.cBoxElectrode.currentText()) - 1],
                   3)))
     self.TxtEff.setText(
         str(
             round(
                 g.locals_efficiency[int(self.cBoxElectrode.currentText()) -
                                     1], 3)))
Пример #4
0
    def patient1_changed(self, value):
        print(value)
        condVal = self.cBoxCond.currentText()

        if (value == ''):
            self.TxtDesGlob1.clear()
            self.TxtAvgGlob1.clear()
            self.BrainGraph_2.clear()
        else:

            from undirectedGraph import Graph
            g = Graph()
            g.create_nodes(g.create_edges(value + '-' + cond))
            # Global Parameters
            self.TxtDesGlob1.setText(str(round(g.density, 3)))
            self.TxtAvgGlob1.setText(str(round(g.shortest_paths, 3)))
            self.BrainGraph_2.setPixmap(
                QtGui.QPixmap(value + '-' + cond + ".png"))
            self.BrainGraph_2.setScaledContents(True)

        self.check_patients()
Пример #5
0
    def patient2_changed(self, value):
        print(value)
        conddVal = self.cBoxCond.currentText()

        if (value == ''):
            self.TxtDesGlo2.clear()
            self.TxtAvgGlob2.clear()
            self.BrainGraph.clear()
        else:

            from undirectedGraph import Graph
            g = Graph()
            g.create_nodes(g.create_edges(value + '-' + cond))
            self.TxtDesGlo2.setText(str(round(g.density, 3)))
            self.TxtAvgGlob2.setText(str(round(g.shortest_paths, 3)))
            self.BrainGraph.setPixmap(
                QtGui.QPixmap(value + '-' + cond + ".png"))
            self.BrainGraph.setScaledContents(True)
            # self.TxtDeg.setText(str(g.degrees[int(self.cBoxElectrode.currentText()) - 1]))
            # self.TxtEff.setText(str(g.locals_efficiency[int(self.cBoxElectrode.currentText()) - 1]))

        self.check_patients()
Пример #6
0
    def condition_changed(self, value):
        global cond
        cond = ''
        if not (value == ''):
            if (value == 'Alone'):
                cond = 'B'
            elif (value == 'Spontaneous'):
                cond = 'C'
            else:
                cond = 'D'

            from undirectedGraph import Graph
            g = Graph()
            g.create_nodes(
                g.create_edges(self.cBoxPname.currentText() + '-' + cond))
            self.TxtDes.setText(str(round(g.density, 3)))
            self.TxtAvg.setText(str(round(g.shortest_paths, 3)))
            self.BrainGraph.setPixmap(
                QtGui.QPixmap(self.cBoxPname.currentText() + '-' + cond +
                              ".png"))
            self.BrainGraph.setScaledContents(True)
            self.TxtDeg.setText(
                str(
                    round(g.degrees[int(self.cBoxElectrode.currentText()) - 1],
                          3)))
            self.TxtEff.setText(
                str(
                    round(
                        g.locals_efficiency[
                            int(self.cBoxElectrode.currentText()) - 1], 3)))

        else:
            self.TxtDes.clear()
            self.TxtAvg.clear()
            self.TxtMod.clear()
            self.BrainGraph.clear()
            self.TxtDeg.clear()
            self.TxtEff.clear()