BlueBrain / atlas-densities

Tools to compute densities in the context of brain atlases.
Apache License 2.0
3 stars 8 forks source link

Faster _compute_region_cell_counts #72

Closed mgeplf closed 6 months ago

mgeplf commented 7 months ago

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,)
codecov-commenter commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #72 +/- ## ======================================= Coverage ? 97.72% ======================================= Files ? 22 Lines ? 1451 Branches ? 0 ======================================= Hits ? 1418 Misses ? 33 Partials ? 0 ``` | [Flag](https://app.codecov.io/gh/BlueBrain/atlas-densities/pull/72/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain) | Coverage Δ | | |---|---|---| | [pytest](https://app.codecov.io/gh/BlueBrain/atlas-densities/pull/72/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain) | `97.72% <100.00%> (?)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BlueBrain#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.