-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New feature: split connectivity #92
Comments
How about something like: def split_connectivity(
pre: list[TreeNeuron],
post: list[TreeNeuron] | None,
split_fn: Callable[[TreeNeuron], dict[Any, TreeNeuron]]
) -> pd.DataFrame:
pre_compartments = dict()
for n in pre:
compartment_to_nrn = split_fn(n)
for compartment, nrn in split_fn(n).items():
pre_compartments[(n.id, compartment)] = nrn
if post is None:
post_compartments = pre_compartments
else:
...
# same as above
data = pd.DataFrame(
np.array([[None] * len(post_compartments)] * pre_compartments),
index=pre_compartments.keys(),
columns=post_compartments.keys()
)
for (pre_key, pre_nrn), (post_key, post_nrn) in itertools.product(pre_compartments.items(), post_compartments.items()):
adj = make_connectivity_matrix(post_name, post_nrn) # whatever the current function is called...
data[pre_key, post_key] = adj
return adj I think the |
Yes something along those lines is what I had in mind. It boils down to a three-step process:
I would have probably gone for a |
Usually in favour of using classes, so sure! It might need to be a little more complex than the above to handle "compartments" which aren't necessarily contiguous. You could build a TreeNeuron on top of a graph which is a forest but that would probably break some validation steps elsewhere. Probably better, as you say, to just label nodes and then treat labels as a compartment (if people want to handle e.g. multiple dendrites then they can just do "dendrite-1", "dendrite-2" etc. in their split function). |
Occasionally I find myself splitting neurons into axon & dendrites and then do the same with connectivity.
While this is perfectly possible using Navis, it requires a fair bit of boiler plate. Would be nice to have a dedicated function. Perhaps something more general like a function that takes pre->post synapses and neuron splits (axon/dendrite, by compartment, etc) and returns a compartmentalized connectivity table?
The text was updated successfully, but these errors were encountered: