Beispiel #1
0
def judge_box(
    offset_nm,
    shape_nm,
    all_cache,
    basin_cache,
    padding_nm=None,
    catmaid=None,
    verbose=False,
):
    if catmaid is None:
        catmaid = get_catmaid()

    missing_slice_loc = {
        int(z_idx) * RESOLUTION.z + TRANSLATION.z
        for z_idx in catmaid.get_missing_sections(STACK_ID)
    }

    max_bound = offset_nm + shape_nm
    contained_missing = {
        z
        for z in missing_slice_loc if offset_nm.z <= z <= max_bound.z
    }

    all_conns = list(all_cache.in_box(offset_nm, shape_nm))
    basin_conns = list(basin_cache.in_box(offset_nm, shape_nm))

    d = {
        "offset": offset_nm,
        "shape": shape_nm,
        "missing_slices": len(contained_missing),
        "connectors": len(all_conns),
        "basin_connectors": len(basin_conns),
    }

    if padding_nm:
        padded_offset = offset_nm - padding_nm
        padded_shape = shape_nm + padding_nm * 2
        padded_judgement = judge_box(padded_offset,
                                     padded_shape,
                                     all_cache,
                                     basin_cache,
                                     catmaid=catmaid)
        d["padded"] = padded_judgement

    if verbose:
        print(judgement_to_str(d))

    return d
Beispiel #2
0
def get_caches(conn_path=CONN_CACHE_PATH,
               basin_path=BASIN_CACHE_PATH,
               force=False):
    should_populate_conns = force or not os.path.exists(conn_path)
    all_cache = ConnectorCache(conn_path, force)
    if should_populate_conns:
        all_cache.populate_from(conn)

    should_populate_basin = force or not os.path.exists(basin_path)
    basin_cache = ConnectorCache(basin_path, force)
    if should_populate_basin:
        catmaid = get_catmaid()
        basin_skids = [
            row["skeleton_id"]
            for row in catmaid.get_skeletons_by_annotation(BASIN_ANNOTATION)
        ]
        basin_cids = catmaid.get_synapses_among(basin_skids)["connector_id"]
        basin_cache.populate_from(conn, basin_cids)

    return all_cache, basin_cache
        contrib["n_nodes"],
        contrib["n_pre"],
        contrib["n_post"],
        fmt_mins(contrib["construction_minutes"]),
    )
    assert len(ret) == len(HEADERS) - 1
    return ret


def join_row(label, *values):
    fmt = "${}$"
    val_strs = [fmt.format(v) if isinstance(v, Number) else v for v in values]
    return " & ".join([label] + val_strs)


catmaid = get_catmaid()

pre_rows = (
    "\\begin{tabular}{l|" + "l" * len(HEADERS) + "}",
    " & ".join(HEADERS) + " \\\\ \\hline",
)

post_rows = ("\\end{tabular}", )

rows = list(pre_rows)

all_skids = set()

for circuit in tqdm(Circuit):
    annotation = circuit.annotation()
Beispiel #4
0
from catpy.image import ImageFetcher

from clefts.constants import (
    DIMS,
    STACK_ID,
    CREDENTIALS_PATH,
    ANTENNAL_LOBE_OUTPUT,
    OUTPUT_ROOT,
)
from clefts.common import offset_shape_to_dicts, center_radius_to_offset_shape
from clefts.catmaid_interface import get_catmaid, TooManyNodesError, get_all_connectors

logger = logging.getLogger(__name__)


catmaid = get_catmaid(CREDENTIALS_PATH)
im_fetcher = ImageFetcher.from_catmaid(catmaid, STACK_ID)


class BrokenSliceError(Exception):
    pass


def get_connectors_in_df(df, offset_p, shape_p):
    bool_idxs = np.ones(len(df), dtype=int)
    bounds_dicts = offset_shape_to_dicts(offset_p, shape_p)
    for dim, min_val in bounds_dicts["min"].items():
        logger.debug("applying constraint %smin", dim)
        bool_idxs *= df[dim + "p"] >= min_val
    for dim, max_val in bounds_dicts["max"].items():
        logger.debug("applying constraint %smax", dim)