Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4f9aeec

Browse files
committedApr 9, 2020
RF: Better under/overlay handling
1 parent 863a655 commit 4f9aeec

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎nibabel/viewers.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ def set_overlay(self, data, affine=None, threshold=None, cmap='viridis',
381381
(target_shape, self._affine)).dataobj
382382
affine = self._affine
383383

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

396-
# create an axis if we have a 4D overlay (vs a 3D underlay)
397397
axes = self._axes
398398
o_n_volumes = int(np.prod(data.shape[3:]))
399-
if o_n_volumes > self.n_volumes:
399+
# 3D underlay, 4D overlay
400+
if o_n_volumes > self.n_volumes and self.n_volumes == 1:
400401
axes += [axes[0].figure.add_subplot(224)]
401-
elif o_n_volumes < self.n_volumes:
402+
# 4D underlay, 3D overlay
403+
elif o_n_volumes < self.n_volumes and o_n_volumes == 1:
402404
axes = axes[:-1]
403405

404406
# mask array for provided threshold

0 commit comments

Comments
 (0)
Please sign in to comment.