broadinstitute / ml4h

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fix display of MRI images in plot_mri_tensor_as_animation

deflaux opened this issue · comments

What
When using matplotlib 3.4 instead of 3.3 or older, the images displayed by ml4h.visualization_tools.hd5_mri_plots.plot_mri_tensor_as_animation display one after another instead of replacing the prior image. (The animation is no longer an animation.)

This appears to be due to https://matplotlib.org/stable/users/whats_new.html#changes-to-behavior-of-axes-creation-methods-gca-add-axes-add-subplot

How
Update the usage of matplot lib to correctly replace the images.

Acceptance Criteria
It appears as an animation again.

Note that %matplotlib notebook instead of %matplotlib inline sorta fixes it on Jupyter, but not on JupyterLab.

Testing on newer Docker images for both Terra (e.g., #469) and GCP Notebooks fixes the issue.

So this was not due to a behavior change in matplotlib 3.4, but due to some bug fixed in a more recent Python package version.