brainglobe / cellfinder-core

Standalone cellfinder cell detection algorithm
https://brainglobe.info/documentation/cellfinder/index.html
BSD 3-Clause "New" or "Revised" License
19 stars 16 forks source link

Convert CellDetector to numba #112

Closed dstansby closed 1 year ago

dstansby commented 1 year ago

This is the final peice in the puzzle for https://github.com/brainglobe/cellfinder-core/issues/89, converting the CellDetector class to numba. Some comments for context:

After this PR, running benchmarks_3d.py gives:

4.304 <module>  filter_3d.py:1
└─ 4.304 VolumeFilter._run_filter  cellfinder_core/detect/filters/volume/volume_filter.py:104
   ├─ 4.091 wrapper  numba/experimental/jitclass/boxing.py:59
   │     [17291 frames hidden]  numba, .., llvmlite, colorama, _colle...
   └─ 0.213 BallFilter.walk  cellfinder_core/detect/filters/volume/ball_filter.py:129
      ├─ 0.164 CPUDispatcher._compile_for_args  numba/core/dispatcher.py:388
      │     [923 frames hidden]  numba, llvmlite, colorama, _collectio...
      └─ 0.049 _walk  cellfinder_core/detect/filters/volume/ball_filter.py:197

Confirming that connect_four runs quicker than 0.049 seconds with the conversion to numba. This is similar or better than the original Cython implementation, where it also didn't show up on the pyinstrument trace: https://github.com/brainglobe/cellfinder-core/issues/89#issue-1604899152

Fixes https://github.com/brainglobe/cellfinder-core/issues/89.

github-advanced-security[bot] commented 1 year ago

You have successfully added a new SonarCloud configuration ``. As part of the setup process, we have scanned this repository and found no existing alerts. In the future, you will see all code scanning alerts on the repository Security tab.