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

Allow changing nseg after initialization #436

Merged
merged 1 commit into from
Oct 4, 2024
Merged

Conversation

michaeldeistler
Copy link
Contributor

@michaeldeistler michaeldeistler commented Sep 29, 2024

This PR is a follow-up to #418 and #426. It allows to set nseg after initialization of the module. This is achieved with a new set_ncomp method. This PR is the final requirement for a new release with these features.

API

Works for branches:

comp = jx.Compartment()
branch = jx.Branch(comp, nseg=2)
branch.set_ncomp(4)

...for branches within a cell:

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

...and for branches read from SWC files, in which case it reuses the xyzr to compute optional radiuses:

cell = jx.read_swc(fname, nseg=2)
cell.branch(1).set_ncomp(4)

Assumption and Raises

The set_ncomp function will raise an error if:

  • There are stimuli in any compartment in the module
  • There are recordings in any compartment in the module
  • The channels of the compartments are not the same within the branch that is modified
  • The lengths of the compartments are not the same within the branch that is modified

In addition, unlike the data was read from an SWC file, .set_ncomp() raises an error if:

  • The radiuses of the compartments are not the same within the branch that is modified

Finally, we currently raise NotImplementedError if the Module is a Network, e.g. for

net.cell(0).branch(1).set_ncomp(4)

This is because I do not want to deal with synapse indexing for now.

We also raise a NotImplementedError if the Module is an entire Cell, e.g. for

cell.set_ncomp(4)

Copy link
Contributor

@jnsbck jnsbck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Awesome that this is working now on both the API and solver levels now! Amazing effort! I have not specifically thought about how I would implement this, but I assume you have spent quite some time thinking about how to best do it, so I assume its a good solution. I left a few comments. Good to go once comments are addressed.

jaxley/modules/base.py Show resolved Hide resolved
jaxley/modules/base.py Show resolved Hide resolved
jaxley/modules/base.py Outdated Show resolved Hide resolved
jaxley/modules/base.py Outdated Show resolved Hide resolved
jaxley/modules/branch.py Outdated Show resolved Hide resolved
jaxley/modules/cell.py Show resolved Hide resolved
jaxley/modules/cell.py Outdated Show resolved Hide resolved
tests/test_set_ncomp.py Outdated Show resolved Hide resolved
jaxley/modules/cell.py Show resolved Hide resolved
jaxley/modules/branch.py Show resolved Hide resolved
@michaeldeistler michaeldeistler merged commit dfd5087 into main Oct 4, 2024
1 check passed
@michaeldeistler michaeldeistler deleted the set-custom-nseg2 branch October 4, 2024 13:26
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

Successfully merging this pull request may close these issues.

2 participants