Skip to content

Commit ac2307e

Browse files
needed to add extra channel since changing convert_images
1 parent af9866c commit ac2307e

2 files changed

Lines changed: 11 additions & 18 deletions

File tree

cellpose/gui/gui.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,24 +1885,23 @@ def compute_saturation(self, return_img=False):
18851885
self.saturation.append([])
18861886
for n in range(self.NZ):
18871887
self.saturation[-1].append([0, 255])
1888-
self.sliders[r].setValue([0, 255])
18891888

18901889
if img_norm.shape[-1] == 1:
18911890
if len(self.saturation) > 1:
18921891
self.saturation = [self.saturation[0]]
18931892
self.saturation.append(self.saturation[0])
18941893
self.saturation.append(self.saturation[0])
1895-
self.sliders[1].setValue(self.saturation[1][self.currentZ])
1896-
self.sliders[2].setValue(self.saturation[2][self.currentZ])
18971894
else:
18981895
self.saturation = [copy.deepcopy(self.saturation[r]) for r in range(img_norm.shape[-1])]
18991896
if len(self.saturation) == 2:
19001897
self.saturation.append([])
19011898
for n in range(self.NZ):
19021899
self.saturation[-1].append([0, 255])
1903-
self.sliders[2].setValue(self.saturation[2][self.currentZ])
1904-
print(len(self.saturation))
1905-
print(len(self.saturation[0]))
1900+
1901+
self.sliders[0].setValue(self.saturation[0][self.currentZ])
1902+
self.sliders[1].setValue(self.saturation[1][self.currentZ])
1903+
self.sliders[2].setValue(self.saturation[2][self.currentZ])
1904+
# print(len(self.saturation), len(self.saturation[0]))
19061905

19071906
def get_model_path(self, custom=False):
19081907
if custom:

cellpose/gui/io.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,16 @@ def _initialize_images(parent, image, load_3D=False):
179179

180180
img_min = image.min()
181181
img_max = image.max()
182-
parent.stack = parent.stack.astype(np.float32)
182+
parent.stack = parent.stack.astype("float32")
183183
parent.stack -= img_min
184184
if img_max > img_min + 1e-3:
185185
parent.stack /= (img_max - img_min)
186186
parent.stack *= 255
187187

188+
if parent.stack.shape[-1] == 2:
189+
parent.stack = np.concatenate((parent.stack, np.zeros((*parent.stack.shape[:-1], 1), dtype="float32")), axis=-1)
190+
print(parent.stack.shape)
191+
188192
if load_3D:
189193
parent.logger.info(": converted to float and normalized values to 0.0->255.0")
190194

@@ -196,19 +200,9 @@ def _initialize_images(parent, image, load_3D=False):
196200
parent.Ly0, parent.Lx0 = parent.stack.shape[-3:-1]
197201
parent.nchan = parent.stack.shape[-1]
198202
parent.layerz = 255 * np.ones((parent.Ly, parent.Lx, 4), "uint8")
199-
if hasattr(parent, "stack_filtered"):
200-
parent.Lyr, parent.Lxr = parent.stack_filtered.shape[-3:-1]
201-
elif parent.restore and "upsample" in parent.restore:
202-
parent.Lyr, parent.Lxr = int(parent.Ly * parent.ratio), int(parent.Lx *
203-
parent.ratio)
204-
else:
205-
parent.Lyr, parent.Lxr = parent.Ly, parent.Lx
203+
parent.Lyr, parent.Lxr = parent.stack.shape[-3:-1]
206204
parent.clear_all()
207205

208-
if not hasattr(parent, "stack_filtered") and parent.restore:
209-
parent.logger.info(": no 'img_restore' found, applying current settings")
210-
parent.compute_restore()
211-
212206
parent.compute_saturation()
213207
parent.compute_scale()
214208
parent.track_changes = []

0 commit comments

Comments
 (0)