[MAINT, MRG] Refactor BEM code#9625
Conversation
There was a problem hiding this comment.
Awesome, glad to see that it was so simple!
Since the BEM and GUI code also share a lot of common viz stuff (labeling, surface contours, slice numbers, etc.) hopefully we can continue to refactor that stuff as we go in subsequent PRs. To me the tasks of:
- look at where this BEM boundary is on the MRI
- look at where this dipole is in the MRI, and
- display MRI slices so I can click on them
are all shared EDIT: orthorview-like tasks to it would be good to continue to refactor them. IIRC we unified the dipole plotting code with the BEM plotting code years ago and both benefitted from it, so I'm hoping similar advantages can come from the electrode GUI work!
Coming back to this PR, can you touch some examples that use plot_dipole_locations, Report, and plot_bem? That way we can visually verify that the output hasn't changed. IIRC there should be unit tests that yell at you if something is wrong with the plotting, but who knows. I'll see if I can dig up some old issues that led to refactoring before to see if we can visually verify they still work okay...
|
... also I might be wrong about BEM and dipoles being shared. Looking a bit, that code uses |
Hmmm yeah I was going to say, |
|
Okay just a commit that touches |
Reporting back, they are unchanged but I touched them anyway. |
|
Ideally we would have some non-standard-orientation MRI to test with, but given that even standard FreeSurfer axes are not ordered RAS and this code generalizes everything, I think we'll be okay. I'll merge once CIs come back happy! |
|
Ok good to go! |
|
Thanks @alexrockhill ! |
This wasn't nearly as much of a pain as I thought. This simplifies things quite a bit and has the code from developing the GUI that can now be shared in
_freesurfer.py.Addresses comments in #9586.
Basically, instead of this very confusing which axis to flip and order of everything, the MRI is just reoriented to RAS and everything is follows from there.
Should be easy to use this code in the GUI, good idea @larsoner.