Skip to content

Add deterministic explicit morphology locations - #818

Open
ilkilic wants to merge 12 commits into
mainfrom
deterministic-morph-loc
Open

Add deterministic explicit morphology locations#818
ilkilic wants to merge 12 commits into
mainfrom
deterministic-morph-loc

Conversation

@ilkilic

@ilkilic ilkilic commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Implement #769

Add deterministic morphology targeting through a new ExplicitMorphologyLocations block.

Locations are represented as a non-empty collection of:

MorphologyLocationPoint(section_id=1, offset=0.5)

The block supports both single and multiple explicit locations.

Implementation

  • Add MorphologyLocationPoint as a nested model.
  • Add ExplicitMorphologyLocations as the only new user-facing block.
  • Validate:
    • section_id is a non-negative integer.
    • offset is between 0.0 and 1.0.
    • At least one location is provided.
    • Referenced neurite sections exist when points_on() is called.
  • Update the morphology locations example notebook.

Section ID convention

Locations use SONATA global section IDs:

  • 0: soma
  • 1..N: neurite sections in MorphIO nrn_order

Therefore, SONATA neurite section ID N maps to MorphIO section N - 1.

The generated dataframe is compatible with existing random morphology locations and contains section_id and normalized_section_offset for compartment-set materialization.

Additional fix

Fix normalized section-offset/path-distance calculations for random morphology locations

Tests

Added coverage for:

  • Single neurite location
  • Soma location
  • Multiple locations
  • Invalid section IDs and offsets
  • Empty location lists
  • Missing morphology sections

Compartment-set materialization is provided by the dependent infrastructure in PR #498.

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.28571% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...scientific/blocks/morphology_locations/explicit.py 88.00% 4 Missing and 2 partials ⚠️
Flag Coverage Δ
pytest 75.59% <89.28%> (+0.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
obi_one/__init__.py 100.00% <100.00%> (ø)
obi_one/scientific/library/morphology_locations.py 60.17% <100.00%> (+32.49%) ⬆️
...ific/unions_and_references/morphology_locations.py 100.00% <100.00%> (ø)
...scientific/blocks/morphology_locations/explicit.py 88.00% <88.00%> (ø)

... and 2 files with indirect coverage changes

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

@james-isbister james-isbister left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good. Just one suggestion

)
segment_start = 0.0 if segment_id == 0 else float(cumulative_lengths[segment_id - 1])

path_distance = distance_on_section

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Probably we can reuse path_distance_all_segments_from in the library for calculating the path distance

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point, I reused path_distances directly since we only need the distance for one segment here.

@ilkilic
ilkilic requested a review from james-isbister July 16, 2026 13:02
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