def get_cell_groups(self, pairs):
     """Given a list of cell pairs, return a dict indicating which cells
     are members of each user selected cell class.
     This internally calls cell_class.classify_cells
     """
     if self.cell_groups is None:
         self.cell_classes = []
         for group in self.params.children():
             if group.value() is True:
                 self.cell_classes.extend(cell_class_groups[group.name()]) 
         self.cell_classes = [CellClass(**c) for c in self.cell_classes]
         self.cell_groups = classify_cells(self.cell_classes, pairs=pairs)
     return self.cell_groups, self.cell_classes
Exemplo n.º 2
0
 def get_cell_groups(self, pairs):
     """Given a list of cell pairs, return a dict indicating which cells
     are members of each user selected cell class.
     This internally calls cell_class.classify_cells
     """
     if self.cell_groups is None:
         self.cell_classes = []
         for group in self.params.children():
             if group.value() is True:
                 self.cell_classes.extend(self.cell_class_groups[group.name()]) 
         self.cell_classes = [CellClass(**c) for c in self.cell_classes]
         self.cell_groups = classify_cells(self.cell_classes, pairs=pairs)
     return self.cell_groups, self.cell_classes
Exemplo n.º 3
0
    def update_matrix(self):
        project_names = self.win.filter_control_panel.selected_project_names()

        # Select pairs (todo: age, acsf, internal, temp, etc.)
        self.pairs = query_pairs(project_name=project_names, session=self.session).all()

        # Group all cells by selected classes
        cell_groups = classify_cells(self.cell_classes, pairs=self.pairs)

        # Group pairs into (pre_class, post_class) groups
        pair_groups = classify_pairs(self.pairs, cell_groups)

        # analyze matrix elements
        results = self.analysis_func(pair_groups)

        shape = (len(cell_groups),) * 2
        text = np.empty(shape, dtype=object)
        fgcolor = np.empty(shape, dtype=object)
        bgcolor = np.empty(shape, dtype=object)
        bordercolor = np.empty(shape, dtype=object)

        # call display function on every matrix element
        for i,row in enumerate(cell_groups):
            for j,col in enumerate(cell_groups):
                output = self.display_func(row, col, results[(row, col)])
                text[i, j] = output['text']
                fgcolor[i, j] = output['fgcolor']
                bgcolor[i, j] = output['bgcolor']
                bordercolor[i, j] = output['bordercolor']
                
        # Force cell class descriptions down to tuples of 2 items
        # Kludgy, but works for now.
        rows = []
        for cell_class in self.cell_classes:
            tup = cell_class.as_tuple
            row = tup[:1]
            if len(tup) > 1:
                row = row + (' '.join(tup[1:]),)
            rows.append(row)

        self.win.matrix_widget.set_matrix_data(text=text, fgcolor=fgcolor, bgcolor=bgcolor, border_color=bordercolor,
                    rows=rows, cols=rows, size=50, header_color='k')
    (CellClass(target_layer='2', pyramidal=True), 'L2', (247, 118, 118)),
    (CellClass(target_layer='3', pyramidal=True), 'L3', (246, 197, 97)),
    (CellClass(target_layer='4', pyramidal=True), 'L4', (100, 202, 103)),
    (CellClass(target_layer='5', pyramidal=True), 'L5', (107, 155, 250)),
    (CellClass(target_layer='6', pyramidal=True), 'L6', (153, 51, 255)),
]


session = db.Session()


max_distance = None#100e-6

# analyze connectivity <100 um for mouse
mouse_pairs = query_pairs(acsf="2mM Ca & Mg", age=(40, None), species='mouse', distance=(None, max_distance), session=session).all()
mouse_groups = classify_cells([c[0] for c in mouse_classes], pairs=mouse_pairs)
mouse_results = measure_connectivity(mouse_pairs, mouse_groups)

# analyze connectivity < 100 um for human
human_pairs = query_pairs(species='human', distance=(None, max_distance), session=session).all()
human_groups = classify_cells([c[0] for c in human_classes], pairs=human_pairs)
human_results = measure_connectivity(human_pairs, human_groups)

csv_file = open("manuscript_fig_4.csv", 'wb')

# plot connectivity < 100 um
for conn_plot, results, cell_classes, fig_letter in [
        (mouse_conn_plot, mouse_results, mouse_classes, 'A'),
        (human_conn_plot, human_results, human_classes, 'C')]:

    # set axis labels