Skip to content
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

Distance function does not calculate path length #572

Open
bantin opened this issue Jan 29, 2025 · 7 comments
Open

Distance function does not calculate path length #572

bantin opened this issue Jan 29, 2025 · 7 comments

Comments

@bantin
Copy link

bantin commented Jan 29, 2025

Hi @michaeldeistler and jaxley team -- I'm working with a few folks to port the biophysical model implemented in this paper from NEURON to Jaxley.

Crucial to this model is that the channel conductances vary by distance to the Soma, where distance is the path length along the tree. Looking at the source code for base.py it seems like the distance returned by Jaxley is just the euclidean distance. Is this true? If so, I'd like to help remedy this!

A second and related question, is that it's not very clear to me what the right way is to iterate over a cell and calculate the distance from each compartment to the soma. Something that I'd expect to work is roughly:

 for branch in cell.branches:
        for c in branch.compartments:
            # get distance to soma

but this doesn't work. Would you mind clarifying what the right way to do this is?

Thanks a bunch! Ben

@michaeldeistler
Copy link
Contributor

michaeldeistler commented Jan 29, 2025

Hi Ben!

Thanks for reaching out, and great that you are starting to look into Jaxley :)

Is this true? If so, I'd like to help remedy this!

Indeed, the distance method computes the euclidean distance. Path distance is not implemented yet. @jnsbck will merging #355 automatically allow to compute the distance along a path?

not very clear to me what the right way is to iterate over a cell and calculate the distance from each compartment to the soma

Your code almost works: it's comps instead of compartments:

import jaxley as jx

comp = jx.Compartment()
branch = jx.Branch(comp, ncomp=4)
cell = jx.Cell(branch, parents=[-1, 0, 0])

for branch in cell.branches:
    for comp in branch.comps:
        comp.set("radius", 2.0)

or

for branch in cell:
    for comp in branch:
        comp.set("length", 200.0)

This requires the most recent version of Jaxley (v0.5.0). Also see this tutorial.

Hope this helps! Let me know if anything is unclear!
Michael

@bantin
Copy link
Author

bantin commented Jan 29, 2025

Awesome, thanks @michaeldeistler !

Hoping #355 is merged soon. In the meantime, I may check out that branch and try getting things working there.

@jnsbck
Copy link
Contributor

jnsbck commented Jan 29, 2025

Hey Ben,
yes indeed merging #355 would make this trivial, which will hopefully happen next week if @michaeldeistler finds time to review the PR (fingers crossed). @manuelgloeckler even implemented a draft for path distances a while back here.

Jonas

@jnsbck
Copy link
Contributor

jnsbck commented Jan 31, 2025

#355 is merged now. Have a look here for how to use it :)

@chaseking
Copy link

Thank you both! What's your PyPI release schedule? Using a local, git pulled jaxley isn't a huge burden but just curious

@michaeldeistler
Copy link
Contributor

We have a dev meeting scheduled Wednesday and I think we can release after that.

Michael

@michaeldeistler
Copy link
Contributor

michaeldeistler commented Feb 7, 2025

New version is on PyPI now. Please let us know if anything does not work as expected!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants