示例#1
0
def get_current_contacts(G, data):
    cs = data['cellStates']
    it = iter(cs)
    n = len(cs)
    cell_type = {}
    pos_dict = {}
    for it in cs:
        cell_type[cs[it].idx] = cs[it].cellType
        pos_dict[cs[it].idx] = cs[it].pos[0:2]
    modname = data['moduleName']
    moduleStr = data['moduleStr']
    sim = Simulator(modname, 0.0, moduleStr=moduleStr, saveOutput=False)
    sim.loadFromPickle(data)
    sim.phys.update_grid()  # we assume local cell_centers is current
    sim.phys.bin_cells()
    sim.phys.cell_sqs = sim.phys.cell_sqs_dev.get()  # get updated cell sqs
    sim.phys.sort_cells()
    sim.phys.sorted_ids_dev.set(
        sim.phys.sorted_ids)  # push changes to the device
    sim.phys.sq_inds_dev.set(sim.phys.sq_inds)
    sim.phys.find_contacts(predict=False)
    sim.phys.get_cts()
    ct_pts = sim.phys.ct_pts  #these are the points on the cell surface - they can be transformed into the global coordinate system
    ct_tos = sim.phys.ct_tos  #this is the list of *some* contacts from each cell (only for lower cell_ids)
    ct_dists = sim.phys.ct_dists
    cell_cts = sim.phys.cell_n_cts  #not really all the contacts of the cell, because the tos are only defined between a cell and ones with lower ids
    generate_network(G, n, ct_tos, cell_cts, pos_dict, cell_type)
示例#2
0
    def loadPickle(self):
        options = QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        qs, _ = QFileDialog.getOpenFileName(self,
                                            'Load pickle file',
                                            '',
                                            '*.pickle',
                                            options=options)
        if qs and self.getOpenCLPlatDev():
            filename = str(qs)
            print(filename)
            data = pickle.load(open(filename, 'rb'))
            if isinstance(data, dict):
                self.modName = data['moduleName']
                self.moduleStr = data['moduleStr']
                self.frameNo = data['stepNum']
                sim = Simulator(self.modName, \
                                    self.dt, \
                                    moduleStr=self.moduleStr, \
                                    clPlatformNum=self.clPlatformNum, \
                                    clDeviceNum=self.clDeviceNum, \
                                    is_gui=True)

                self.loadingFromPickle = True
                sim.loadFromPickle(data)
                self.setSimulator(sim)
                # Note: the pickle loaded contains the stepNum, hence we now
                # need to set the GUI frameNo to match
                self.frameNo = self.sim.stepNum
                if self.run:
                    self.frameNo += 1
                self.updateGL()
            else:
                print("Pickle is in an unsupported format, sorry")
示例#3
0
def get_current_contacts(G, data):
    cs = data["cellStates"]
    it = iter(cs)
    n = len(cs)
    cell_type = {}
    pos_dict = {}
    for it in cs:
        cell_type[cs[it].idx] = cs[it].cellType
        pos_dict[cs[it].idx] = cs[it].pos[0:2]
    modname = data["moduleName"]
    moduleStr = data["moduleStr"]
    sim = Simulator(modname, 0.0, moduleStr=moduleStr, saveOutput=False)
    sim.loadFromPickle(data)
    sim.phys.update_grid()  # we assume local cell_centers is current
    sim.phys.bin_cells()
    sim.phys.cell_sqs = sim.phys.cell_sqs_dev.get()  # get updated cell sqs
    sim.phys.sort_cells()
    sim.phys.sorted_ids_dev.set(sim.phys.sorted_ids)  # push changes to the device
    sim.phys.sq_inds_dev.set(sim.phys.sq_inds)
    sim.phys.find_contacts(predict=False)
    sim.phys.get_cts()
    ct_pts = (
        sim.phys.ct_pts
    )  # these are the points on the cell surface - they can be transformed into the global coordinate system
    ct_tos = sim.phys.ct_tos  # this is the list of *some* contacts from each cell (only for lower cell_ids)
    ct_dists = sim.phys.ct_dists
    cell_cts = (
        sim.phys.cell_n_cts
    )  # not really all the contacts of the cell, because the tos are only defined between a cell and ones with lower ids
    generate_network(G, n, ct_tos, cell_cts, pos_dict, cell_type)