Skip to content

Commit

Permalink
RF: Better under/overlay handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rmarkello committed Apr 9, 2020
1 parent 863a655 commit 4f9aeec
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions nibabel/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ def set_overlay(self, data, affine=None, threshold=None, cmap='viridis',
(target_shape, self._affine)).dataobj
affine = self._affine

# we already have a plotted overlay
if self._overlay is not None:
# remove all images + cross hair lines
for nn, im in enumerate(self._overlay._ims):
Expand All @@ -393,12 +394,13 @@ def set_overlay(self, data, affine=None, threshold=None, cmap='viridis',
a = self._axes.pop(-1)
a.remove()

# create an axis if we have a 4D overlay (vs a 3D underlay)
axes = self._axes
o_n_volumes = int(np.prod(data.shape[3:]))
if o_n_volumes > self.n_volumes:
# 3D underlay, 4D overlay
if o_n_volumes > self.n_volumes and self.n_volumes == 1:
axes += [axes[0].figure.add_subplot(224)]
elif o_n_volumes < self.n_volumes:
# 4D underlay, 3D overlay
elif o_n_volumes < self.n_volumes and o_n_volumes == 1:
axes = axes[:-1]

# mask array for provided threshold
Expand Down

0 comments on commit 4f9aeec

Please sign in to comment.