Skip to content

Refactor apical dend#467

Merged
bgmeulem merged 67 commits intodevelopfrom
refactor-apical-dend
Mar 23, 2026
Merged

Refactor apical dend#467
bgmeulem merged 67 commits intodevelopfrom
refactor-apical-dend

Conversation

@bgmeulem
Copy link
Copy Markdown
Collaborator

This pr should be merged after #465 and #466

This PR removes all mentions of "ApicalDendrite" in those situations where it is overly specific.

This means that it is still ok to use it for examples, some default values, L5PT specific functions, and those functions that specifically target "ApicalDendrite"

Todo: refactor scim (again) to also make it more generic in the network embedding procedure

bgmeulem added 30 commits March 12, 2026 15:08
Remove unused data and scripts
Roberts param files exist in ibs_projects, and is also not really used in ISF beyond the one ongoing
getattr and setattr work fine
tested reproducibility with a single synapse activation simulation for identical results
- not dependant on barrel cortex
- not dependent on old cluster paths
- still can do the C2-relative redirect

Todo: improve implementation, adapt tutorial
Todo: finalize refactoring source data files etc
Added explicit default values for ongoing activity rates. useful for future
Network params can now be used in a builder pattern
This makes it easy to add synapse dynamics, ongoing activity, evoked activity, and network embeddings to network parameter files in a modular, model system-agnostic way

Todo: test if this gives the results we want and deprecate the runfiles
Todo: ensure backwards compatible
Gives same results as old method :)
Must however be invoked differently
Todo: compatibility fix
Instead of having this specific reader for reading in whisker-evoked activity data, I simply pre-process the data here. The reader then only needs to worry about fetching the correct file, which I believe is the most configurable and general way it should work.

I kept a notebook outlining how exactly I "augmented" the data. This was not very well documented.

Added readme to explain the data as well.
bgmeulem added 15 commits March 19, 2026 16:54
scim.scim has been renamed to scim.udvary2022 to highlight the possibility of adding other methods

Hardcoded data paths also moved to user config

Top-level maper is a strategy pattern invoking the correct pipeline depending on configuration. Useful for future extensions
Todo: to which extent should we pre-process and explore the barrel cortex data? to which extent do we want this specific pipeline to be generally applicable? Should we suggest other researchers to start from syn and con files?
We now just use either `simrun` or a `Simulator` object
@bgmeulem bgmeulem mentioned this pull request Mar 23, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 83.01887% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.28%. Comparing base (e9b0a2b) to head (643dcd5).
⚠️ Report is 72 commits behind head on develop.

Files with missing lines Patch % Lines
config/isf_logging.py 25.00% 6 Missing ⚠️
biophysics_fitting/hay/setup_stim.py 89.47% 2 Missing ⚠️
...ta_base/db_initializers/somatic_summation_model.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #467      +/-   ##
===========================================
+ Coverage    47.18%   47.28%   +0.10%     
===========================================
  Files          243      246       +3     
  Lines        22476    22124     -352     
===========================================
- Hits         10605    10462     -143     
+ Misses       11871    11662     -209     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bgmeulem bgmeulem merged commit 3658ecd into develop Mar 23, 2026
4 checks passed
@bgmeulem bgmeulem mentioned this pull request Mar 23, 2026
bgmeulem added a commit that referenced this pull request Mar 23, 2026
Should be merged after #467 

This PR properly separates L5PT specific code from the rest of ISF

`hay` was already implemented as a separate package. Now, it is clearer
this is an example implementation of `biophysics_fitting` etc.
Additionally moved all code that is L5PT specific to this package. Only
generic code is allowed to live in the top-level `biophysics_fitting`
package.

Removed `BAC_injection` as a `cell_modify_function`. We only ever use
this for our own use cases in the form of a stimulus protocol configured
with a `Simulator`. Not as a `cell_modify_function` for `simrun`.

Removed `scale_apical_morph_86` as a `cell_modify_function` as it is
_highly_ specific to one of our morphologies. However, I kept it in the
test suite for reproducibility tests
@bgmeulem bgmeulem deleted the refactor-apical-dend branch April 2, 2026 10:34
bgmeulem added a commit that referenced this pull request Apr 2, 2026
…#479)

The last parts of ISF that are (highly) specific to barrel cortex after
the connectivity refactors (#465 #466) and removing hardcoded structure
labels (#467 #469 #478 ) are some older writers for writing out
simulation data.
These writers hardcode values that are highly specific to barrel cortex
or L5PTs for e.g. exportation to Amira, or to define a
`cell_modify_function`.
We don't use these writers anymore. Data output is handled by `simrun`
and `data_base` and generally does not involve AMIRA anymore. In
addition Visualization is now handled by the `visualize` module, or
exporters to non-proprietary `VTK` or `Blender`.

I figured it made the most sense to simply remove these writers. They
are for properietary and expensive formats, highly specific to our use
case, and even then remain unused.
bgmeulem added a commit that referenced this pull request Apr 15, 2026
…c` support, and cell type agnosticism (#487)

This PR adds all code implementations to address our revision.

# swc support
We now support `swc`. ISF pipelines are agnostic to whether a morphology
file is `hoc` or `swc`. Reading in and building the morphology is simply
handled by `single_cell_parser.io.morphology.read_morphology`. Big
thanks to @su-saka and @fkkastrinakis for writing the initial
converters, that save me a bunch of time for further integration.

We have converters from `swc` to `hoc` and `hoc` to `swc`. Converting
`hoc` to `swc` can slightly change connectivity of some sections to the
soma, but this is of no impact in ISF as we connect them by default at
`x=0.5`.

Simulations on both yield almost identical results. I implemented a test
for this. variable time step simulations are not fully identical, fixed
timesteps simulations are. I am not sure yet why this is the case.
Variable time step simulations for `hoc` vs `swc` are virtually
indistinguishable, but the time steps are ever so slightly different.

See #482 and #476 

# Network mapping generalizibility
I changed the network mapping procedure so it does not depend anymore on
any particular label (e.g. "apical"). Instead, labels are inferred from
the morphology file. Additional empirical data should then match these
labels (e.g. connections spreadsheet) case-insensitively #478 #467

I extended the network parameters with a `NetworkParamBuilder` class
that makes it way more convenient to build network parameters, and makes
it explicit which data you add, when, and where. This is explored
extensively in the tutorials. #465

Network mapping does not rely anymore on a `NrOfConnections.csv`. This
used to be default output of our network mapper. However, the same
information is contained in a `.con` file. We now parse it from a `.con`
file. This way, ISF is fully independent of any particular network
mapping procedure, and simply relies on a `syn` and `con` file.

I augmented our dataset for activity data. The correct activity data
file + key used to be inferred at runtime, i.e. depending on your
recording site and stimulus, it would redirect you to the correct
activity data file on the fly. This was very barrel cortex specific. I
augmented the activity data by simply generating datasets for all
stimuli. The augmentation method is saved as a notebook in
`getting_started/functional_constraints/evoked_activity/empirical_recordings`.
Now, the key you pass under "whisker" is instead interpreted as a
globstring that fetches the correct data file in a preconfigured data
directory. The `NetworkParamBuilder` of course also allows you to
directly add activity data, independent of any directory configuration.
#465

A tutorial now explores all the data requirements for Udvary 2022 #480

The network mapper used in ISF is Udvary 2022, but it should be clear
that ISF does not rely on this particular network mapping. I refactored
the top-level pipeline so it infers a specific network mapping
procedure, and refactored Udvary 2022 as a separate subpackage in
`singlecell_input_mapper`. #466

# L5PT mentions

I removed all mentions of "L5PT" in the code, except for those methods
that are actually specific to L5PTs. In the latter case, it should be
clear that this methods provides an example, and should not live in
top-level pipelines or modules #469

# Tutorials

Updated the intro tutorial so be more targeted at exactly what ISF does.
Removed configuration setup. Added more headings, intro and explanation
on what we do, how, and why. #484

Updated network mapping tutorial to add API for the SynapseMapper and
visualizations. Added auxiliary tutorials. They are hidden from direct
view in the webpage, but reflinks work. This is e.g. used in tutorial
2.1 #485

# Config

Added config for morphology labels. You can extend a map so labels
identified in morphology files are renamed to something else. This is
useful for having a consistent internal representation. I had to do this
to rename "BasalDendrite" (in network mapping methods) to "Dendrite"

Added mechanisms to user config, since the mechanisms are user-specific,
technically.

# Docs

Added documentation on `swc` and `mod` files. Wrote a custom lexer for
NMODL :)
bgmeulem added a commit that referenced this pull request Apr 22, 2026
This is a relatively large refactor to address many reviewer comments,
and to make ISF more generally applicable.

# swc support
We now support `swc`. ISF pipelines are agnostic to whether a morphology
file is `hoc` or `swc`. Reading in and building the morphology is simply
handled by `single_cell_parser.io.morphology.read_morphology`. Big
thanks to @su-saka and @fkkastrinakis for writing the initial
converters, that save me a bunch of time for further integration.

We have converters from `swc` to `hoc` and `hoc` to `swc`. Converting
`hoc` to `swc` can slightly change connectivity of some sections to the
soma, but this is of no impact in ISF as we connect them by default at
`x=0.5`.

Simulations on both yield almost identical results. I implemented a test
for this. variable time step simulations are not fully identical, fixed
timesteps simulations are. I am not sure yet why this is the case.
Variable time step simulations for `hoc` vs `swc` are virtually
indistinguishable, but the time steps are ever so slightly different.

#482 and #476 

# Network mapping generalizibility
I changed the network mapping procedure so it does not depend anymore on
any particular label (e.g. "apical"). Instead, labels are inferred from
the morphology file. Additional empirical data should then match these
labels (e.g. connections spreadsheet) case-insensitively #478 #467

`singlecell_input_mapper` has been refactored extensively. It now uses a
builder pattern to add network parameters. this makes it way easier to
modularize and understand which data is being added, and how (see #465).
In addition, the default network embedding strategy can now be
configured on a user-level (see #466 )

I extended the network parameters with a `NetworkParamBuilder` class
that makes it way more convenient to build network parameters, and makes
it explicit which data you add, when, and where. This is explored
extensively in the tutorials. #465

Network mapping does not rely anymore on a `NrOfConnections.csv`. This
used to be default output of our network mapper. However, the same
information is contained in a `.con` file. We now parse it from a `.con`
file. This way, ISF is fully independent of any particular network
mapping procedure, and simply relies on a `syn` and `con` file.

I augmented our dataset for activity data. The correct activity data
file + key used to be inferred at runtime, i.e. depending on your
recording site and stimulus, it would redirect you to the correct
activity data file on the fly. This was very barrel cortex specific. I
augmented the activity data by simply generating datasets for all
stimuli. The augmentation method is saved as a notebook in
`getting_started/functional_constraints/evoked_activity/empirical_recordings`.
Now, the key you pass under "whisker" is instead interpreted as a
globstring that fetches the correct data file in a preconfigured data
directory. The `NetworkParamBuilder` of course also allows you to
directly add activity data, independent of any directory configuration.
#465

A tutorial now explores all the data requirements for Udvary 2022 #480

The network mapper used in ISF is Udvary 2022, but it should be clear
that ISF does not rely on this particular network mapping. I refactored
the top-level pipeline so it infers a specific network mapping
procedure, and refactored Udvary 2022 as a separate subpackage in
`singlecell_input_mapper`. #466

# L5PT mentions

I removed all mentions of "L5PT" in the code, except for those methods
that are actually specific to L5PTs. In the latter case, it should be
clear that this methods provides an example, and should not live in
top-level pipelines or modules #469

# Tutorials

Updated the intro tutorial so be more targeted at exactly what ISF does.
Removed configuration setup. Added more headings, intro and explanation
on what we do, how, and why. #484

Updated network mapping tutorial to add API for the SynapseMapper and
visualizations. Added auxiliary tutorials. They are hidden from direct
view in the webpage, but reflinks work. This is e.g. used in tutorial
2.1 #485

# Config

Added config for morphology labels. You can extend a map so labels
identified in morphology files are renamed to something else. This is
useful for having a consistent internal representation. I had to do this
to rename "BasalDendrite" (in network mapping methods) to "Dendrite"

Added mechanisms to user config, since the mechanisms are user-specific,
technically.

# Docs

Added documentation on `swc` and `mod` files. Wrote a custom lexer for
NMODL :)
Extended installation instructions for more info on how ISF handles
environments and env variables.
Extended documentation on file formats, added data sources to paramfile
overview
Extended tutorials
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.

1 participant