Skip to content

Commit a8c7924

Browse files
committed
RF: Better under/overlay handling
1 parent fad82cd commit a8c7924

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
@@ -380,6 +380,7 @@ def set_overlay(self, data, affine=None, threshold=None, cmap='viridis',
380380
(target_shape, self._affine)).dataobj
381381
affine = self._affine
382382

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

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

403405
# mask array for provided threshold

0 commit comments

Comments
 (0)