Skip to content

Commit b9d25e7

Browse files
adding z_axis in cellposedenoisemodel (#1099)
1 parent 8526c84 commit b9d25e7

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

cellpose/denoise.py

+1
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ def eval(self, x, batch_size=8, channels=None, channel_axis=None, z_axis=None,
584584
diameter = self.dn.diam_mean if self.dn.ratio > 1 else diameter
585585
masks, flows, styles = self.cp.eval(
586586
img_restore, batch_size=batch_size, channels=channels_new, channel_axis=-1,
587+
z_axis=0 if img_restore.ndim > 3 and img_restore.shape[0] > 0 else None,
587588
normalize=normalize_params, rescale=rescale, diameter=diameter,
588589
tile_overlap=tile_overlap, augment=augment, resample=resample,
589590
invert=invert, flow_threshold=flow_threshold,

cellpose/transforms.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ def convert_image(x, channels, channel_axis=None, z_axis=None, do_3D=False, ncha
470470
"""
471471
# check if image is a torch array instead of numpy array
472472
# converts torch to numpy
473+
ndim = x.ndim
473474
if torch.is_tensor(x):
474475
transforms_logger.warning("torch array used as input, converting to numpy")
475476
x = x.cpu().numpy()
@@ -516,7 +517,7 @@ def convert_image(x, channels, channel_axis=None, z_axis=None, do_3D=False, ncha
516517
x = x[:, :, np.newaxis]
517518

518519
if do_3D:
519-
if x.ndim < 3:
520+
if ndim < 3:
520521
transforms_logger.critical("ERROR: cannot process 2D images in 3D mode")
521522
raise ValueError("ERROR: cannot process 2D images in 3D mode")
522523
elif x.ndim < 4:

0 commit comments

Comments
 (0)