MAINT: Cleaner 3D vol viewer code #12570
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I really just wanted to take care of this:
by using the data in X/Y/Z / RAS / physical space instead of voxel space to do the distance query (which I did implement here). However, in working on it I realized there was a bug in my code that was very difficult to track down due to
img
being modified in the function, and me using it too early in the flow of the code.This made me realize that it's not helpful to have a bunch of functions/callbacks defined inside the
plot_volume_source_estimates
code, because there's a mixture of namespaces that happens between those and the enclosing function. So I refactored the code by moving all those functions outside the function definition, then passing parameters that they need through theparams
dict. This should lead to more maintainable code.The code is 98% copy-pasted. The remaining 2% changes are rewriting code to make use of
params["img"]
for example instead ofimg
(which was formerly pulled from the enclosing function's variable namespace).Based on how things were breaking in the tests when I went to fix the original
# XXX
comment, I think we can rely on them to tell us that things are still working okay after this PR. But I also touched a couple of tutorials that made use of the function so we can check to make sure they still look okay as well.