def get_merged_basin():
    # todo: replace "system" with "circuit"
    cho_basin_g = get_data(Circuit.CHO_BASIN)
    nx.set_edge_attributes(cho_basin_g, 1, "drive")
    nx.set_edge_attributes(cho_basin_g, "chordotonal-Basin", "system")

    ln_basin_g = get_data(Circuit.LN_BASIN)
    nx.set_edge_attributes(ln_basin_g, -1, "drive")
    nx.set_edge_attributes(ln_basin_g, "LN-Basin", "system")

    return merge_multi(cho_basin_g, ln_basin_g)
def syn_area_distribution():
    n = len(list(Circuit))
    for circuit in Circuit:
        g = get_data(circuit)
        data = [data["area"] for _, _, data in g.edges(data=True)]
        # bonferroni-corrected p-value
        print(f"{circuit}: {NormalVsLognormal.from_data(data, 0.05/n)}")
def all_plots_for_system(circuit: Circuit, directory=None, ext=DEFAULT_EXT, show=False, **kwargs):
    logger.info("creating plots for " + str(circuit))
    multi_g = get_data(circuit)
    for plot_class in circuit_plot_classes:
        with plot_class(multi_g, circuit).plot(**kwargs) as plot:
            if directory:
                plot.save(directory, ext)
            if show:
                plt.show()
 def plot(self, tgt_path=None, increment=False, **kwargs):
     tgt_path = tgt_path or self.layout_path
     for circuit in Circuit:
         multi_g = get_data(circuit)
         for plot_cls in [ContactNumberHeatMap, DendriticFractionHeatMap]:
             fig_ax_arr = self._fig_ax_arr(f"{circuit} {plot_cls.__name__}")
             with plot_cls(multi_g, circuit).plot(fig_ax_arr, **kwargs) as plot:
                 ax = plot.ax_arr[0, 0]
                 ax.set_title('')
     # self.layout.insert_figures(self.layer_name)
     if increment:
         tgt_path = increment_filename(tgt_path)
     self.layout.write_svg(tgt_path)
Exemple #5
0
        done_edges.add((pre, post))
        done_edges.add((post, pre))

    erroneous_edges = set()

    for pre_post in g_auto.edges:
        if pre_post not in done_edges:
            erroneous_edges.add(pre_post)

    print(f"{len(erroneous_edges)} erroneous edges found: ")
    for pre, post in sorted(erroneous_edges):
        print(f"\t{pre} -> {post}")

    fig, ax_arr = plt.subplots(1, 2)
    count_ax, area_ax = ax_arr.flatten()

    manual_auto_scatter(manual_counts, auto_counts, "Contact number", count_ax)
    manual_auto_scatter(manual_areas, auto_areas, "Contact area", area_ax)


if __name__ == "__main__":
    catmaid = get_catmaid()
    multi_g = get_data("ORN-PN")
    g_manual = multidigraph_to_digraph(multi_g)
    skids = list(g_manual.nodes)
    detected_df = catmaid.get_detected_synapses_between(*skids)
    g_auto = df_to_graph(detected_df)

    compare_edges(g_manual, g_auto)
    plt.show()
data_dir = TABLES_DIR / "out" / "count_frac_area"
data_dir.mkdir(parents=True, exist_ok=True)

HEADERS = ("circuit", "pre_id", "pre_name", "pre_side", "pre_segment",
           "post_id", "post_name", "post_side", "post_segment",
           "contact_number", "contact_fraction", "synaptic_area")

all_data = []

tgt_total_counts_df = pd.read_csv(CATMAID_CSV_DIR /
                                  "dendritic_synapse_counts.csv",
                                  index_col=0)

for circuit in Circuit:
    g = multidigraph_to_digraph(get_data(circuit))
    rows = []
    total_count = 0

    for pre, post, edata in iter_data(g):
        row = [str(circuit)]
        for node in (pre, post):
            row.extend([node.id, node.name, str(node.side), str(node.segment)])
        row.append(edata["count"])

        frac = edata["count"] / tgt_total_counts_df["post_count"].loc[post.id]
        row.append(frac)

        row.append(edata["area"])
        rows.append(row)
Exemple #7
0
from clefts.manual_label.common import get_data
from clefts.manual_label.constants import Circuit, TABLES_DIR
from clefts.manual_label.make_tables.common import iter_data, write_rows

data_dir = TABLES_DIR / "out" / "areas"
data_dir.mkdir(parents=True, exist_ok=True)

HEADERS = ("circuit", "pre_id", "pre_name", "pre_side", "pre_segment",
           "post_id", "post_name", "post_side", "post_segment", "connector_id",
           "synaptic_area")

all_data = []

for circuit in Circuit:
    g = get_data(circuit)
    rows = []
    total_count = 0

    for pre, post, edata in iter_data(g):
        row = [str(circuit)]
        for node in (pre, post):
            row.extend([node.id, node.name, str(node.side), str(node.segment)])
        row.append(edata["conn_id"])
        row.append(edata["area"])
        rows.append(row)

        total_count += 1

    print(f"Total synapse count for {circuit}: {total_count}")
    rows = sorted(rows)
    write_rows(data_dir / f"{circuit}.csv", rows, HEADERS)