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

Faster _compute_region_cell_counts #72

Merged
merged 3 commits into from
Mar 26, 2024
Merged

Conversation

mgeplf
Copy link
Collaborator

@mgeplf mgeplf commented Mar 1, 2024

Some timings:
old: 391s
new: 7.77 s ± 26.5 ms per loop
So about 55 times faster
maxium difference in cell_count: 9.313225746154785e-10

Note: ValueToIndexVoxels will at some point be included in voxcell

Code used for testing:

from atlas_densities.densities.inhibitory_neuron_densities_optimization import _compute_region_cell_counts
import voxcell
from atlas_densities.densities import utils

annotation = voxcell.VoxelData.load_nrrd('input-data/annotation_ccfv2_l23split_barrelsplit_validated.nrrd')
density = voxcell.VoxelData.load_nrrd('input-data/neuron_density.nrrd')
voxel_volume = annotation.voxel_volume / 1e9
rm =voxcell.RegionMap.load_json('input-data/hierarchy_ccfv2_l23split_barrelsplit.json')
hierarchy_info = utils.get_hierarchy_info(rm, root='root')

res = _compute_region_cell_counts(annotation.raw, density.raw, voxel_volume, hierarchy_info,)

matz-e
matz-e previously approved these changes Mar 1, 2024
Copy link
Member

@matz-e matz-e left a comment

Choose a reason for hiding this comment

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

LGTM

Base automatically changed from cleanup to main March 22, 2024 08:40
@mgeplf mgeplf dismissed matz-e’s stale review March 22, 2024 08:40

The base branch was changed.

mgeplf added 2 commits March 26, 2024 10:14
Some timings:
    old: 391s
    new: 7.77 s ± 26.5 ms per loop
    So about 55 times faster
    maxium difference in cell_count: 9.313225746154785e-10

Note: `ValueToIndexVoxels` will at some point be included in voxcell

Code used for testing:
```
from atlas_densities.densities.inhibitory_neuron_densities_optimization import _compute_region_cell_counts
import voxcell
from atlas_densities.densities import utils

annotation = voxcell.VoxelData.load_nrrd('input-data/annotation_ccfv2_l23split_barrelsplit_validated.nrrd')
density = voxcell.VoxelData.load_nrrd('input-data/neuron_density.nrrd')
voxel_volume = annotation.voxel_volume / 1e9
rm =voxcell.RegionMap.load_json('input-data/hierarchy_ccfv2_l23split_barrelsplit.json')
hierarchy_info = utils.get_hierarchy_info(rm, root='root')

res = _compute_region_cell_counts(annotation.raw, density.raw, voxel_volume, hierarchy_info,)
```
@mgeplf mgeplf force-pushed the faster-_compute_region_cell_counts branch from 7affcf8 to 7bbb615 Compare March 26, 2024 09:36
@mgeplf mgeplf requested a review from eleftherioszisis March 26, 2024 09:36
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (main@31a341d). Click here to learn what that means.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #72   +/-   ##
=======================================
  Coverage        ?   97.72%           
=======================================
  Files           ?       22           
  Lines           ?     1451           
  Branches        ?        0           
=======================================
  Hits            ?     1418           
  Misses          ?       33           
  Partials        ?        0           
Flag Coverage Δ
pytest 97.72% <100.00%> (?)

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

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

Copy link
Contributor

@eleftherioszisis eleftherioszisis left a comment

Choose a reason for hiding this comment

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

Nice

@mgeplf mgeplf merged commit 260a25a into main Mar 26, 2024
5 checks passed
@mgeplf mgeplf deleted the faster-_compute_region_cell_counts branch March 26, 2024 11:16
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.

4 participants