jaxleyverse / jaxley

Differentiable neuron simulations with biophysical detail on CPU, GPU, or TPU.
https://jaxley.readthedocs.io
Apache License 2.0
52 stars 7 forks source link

Can different branches have a different nseg? #415

Closed Tunenip closed 1 month ago

Tunenip commented 1 month ago

1.Can different branch has different nseg? Like NEURON, I wanna set different branch with differen nseg, but when I give a list to that, the cell.show() can not work.

2.When setting dt !=0.025, traces change a lot. I tried to set dt = 0.01 or other values which are not 0.025, but the voltage traces changed a lot, I dont konw why.

3.Can init_state() in channel class receive public channel_states as input? Sometimes the init_states() needs the cai as input.

michaeldeistler commented 1 month ago

Hi! Thanks for reaching out!

  1. Right now this is not possible, but we are working on it. I will get back to you once there is news. For now I recommend using nseg=4 for all branches and splitting very long branches into two subbranches (for swc files you can do this with jx.read_swc(..., max_branch_len=x), where x is the maximal branch length in micrometer, above which the branch will be splitted into two subbranches).
  2. You have to change delta_t in the jx.step_current(..., delta_t=xxx) and in jx.integrate(..., delta_t=xxx). See also here.
  3. That's a good point, I had not yet thought about this. I will try to make it possible asap.

Hope this helps! Michael

Tunenip commented 1 month ago

Thanks for your help! I realized the mistake was that I only changed the dt in jx.step_current(). I appreciate your assistance and hope you make great progress too!

michaeldeistler commented 1 month ago

Quick update: Point 3 (public states in init_state) is solved now:

pip install jaxley --upgrade

I also started working on Point 1 (different nseg), but this will still take a few days.

Cheers Michael

michaeldeistler commented 1 month ago

Hi there, quick update regarding having a different number of nseg per branch. The new version of Jaxley (v0.3.0) supports the following:

comp = jx.Compartment()
branch1 = jx.Branch(comp, nseg=1)
branch2 = jx.Branch(comp, nseg=2)
branch3 = jx.Branch(comp, nseg=4)
cell = jx.Cell([branch1, branch2, branch3], parents=[-1, 0, 0])

Currently, you cannot modify the nseg after initialization, but we are also working on this, see here.

Hope this helps! Michael

Tunenip commented 1 month ago

Thanks! It really helps a lot!

michaeldeistler commented 1 month ago

This is now finished and release: pip install jaxley --upgrade.

You can set the number of compartment per branch with the set_ncomp() method:

cell.branch.set_ncomp(6)

I will close this issue for now, but please let us know if anything is not working as expected! Michael