agencyenterprise / neurotechdevkit

Neurotech Development Kit (NDK)
https://agencyenterprise.github.io/neurotechdevkit/
Apache License 2.0
115 stars 10 forks source link

[#109] ultrasound imaging examples #145

Closed charlesbmi closed 1 year ago

charlesbmi commented 1 year ago

Github Issue: https://github.com/agencyenterprise/neurotechdevkit/issues/109

Introduction

In addition to neurostimulation, ultrasound is frequently used for imaging as well. The most common type of ultrasound imaging is diagnostic/anatomical ultrasound imaging, sometimes called B-mode imaging. We add B-mode imaging functionality and examples here: to provide teaching materials, showcase the flexibility of NDK, and inspire potential future directions.

Changes

Ultrasound imaging consists of 3 steps:

  1. transmit pulse
  2. receive echo
  3. reconstruct image

Parts 1 and 2 are already implemented in NDK; we add demodulate.py and beamform.py to implement the image reconstruction steps.

We also update the ndk.scenario module to enable receiver locations (not just at the wavefield grid points).

Behavior

New functionality. Tests should probably be added for the new libraries. We can compare against MUST as a reference implementation, similar to: https://app.reviewnb.com/agencyenterprise/bci-experiments/blob/master/experiments/neurotechdevkit-109-ultrasound-imaging/109-beamforming.ipynb/. Open to any other ideas!

Note: currently checking this in as a Jupyter notebook, because that seems easier to attach output to and view. Will repoint this to a docs/examples Python script after receiving feedback.

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage is 84.58% of modified lines.

Files Changed Coverage
src/neurotechdevkit/imaging/util.py 0.00%
src/neurotechdevkit/imaging/demodulate.py 81.53%
src/neurotechdevkit/imaging/beamform.py 89.25%
.../neurotechdevkit/scenarios/built_in/_scenario_3.py 98.11%
src/neurotechdevkit/imaging/__init__.py 100.00%
src/neurotechdevkit/scenarios/_base.py 100.00%
src/neurotechdevkit/scenarios/_shots.py 100.00%
src/neurotechdevkit/scenarios/built_in/__init__.py 100.00%

:loudspeaker: Thoughts on this report? Let us know!.

d-lucena commented 1 year ago

Thanks for the great new functionality, @charlesincharge! I thought the notebooks are great as they are. I'd agree with Newton on reducing some of the complexity the main DAS function would be worthwhile.

For validation/integration testing, we could add a notebook that does the comparison as you suggested (and as we discussed doing for the stimulation results as well). This could be a separate story/PR though.

charlesbmi commented 1 year ago

Seems like the stride installation is failing in docker-test. Perhaps this has to do with conflicting dependencies with xarray? Anyone have guidance on this? Perhaps we could move stride into the poetry dependencies?

d-lucena commented 1 year ago

Thanks @charlesincharge! The notebooks look good to me, thank you! I made some minor changes to keep it consistent across the two, but feel free to revert or change something I missed or is not correct. Could you transfer them to a python file so they're rendered in the documentation gallery, please?

Regarding adding stride into poetry -- I believe that causes an issue with the pip deployment of the package; @NewtonSander, can you confirm?

charlesbmi commented 1 year ago

Thanks @d-lucena ! Also, looks like the tests are now passing; I wonder if the stride installation issue was related to https://github.com/agencyenterprise/neurotechdevkit/issues/149 and now fixed.