Skip to content

Commit

Permalink
trying to update google format
Browse files Browse the repository at this point in the history
  • Loading branch information
carsen-stringer committed Feb 22, 2024
1 parent 3173eec commit 8a19e25
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
5 changes: 3 additions & 2 deletions cellpose/dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ def get_centers(masks, slices):
slices (ndarray): The slices of the masks.
Returns:
ndarray: The centers of the masks.
ndarray: The extents of the masks.
tuple containing
- centers (ndarray): The centers of the masks.
- ext (ndarray): The extents of the masks.
"""
centers = np.zeros((len(slices), 2), "int32")
ext = np.zeros((len(slices),), "int32")
Expand Down
2 changes: 1 addition & 1 deletion cellpose/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def eval(self, x, batch_size=8, channels=[0,0], channel_axis=None, invert=False,
do_3D (bool, optional): Set to True to run 3D segmentation on 4D image input. Defaults to False.
Returns:
tuple: Tuple containing masks, flows, styles, and diams.
tuple containing
- masks (list of 2D arrays or single 3D array): Labelled image, where 0=no masks; 1,2,...=mask labels.
- flows (list of lists 2D arrays or list of 3D arrays):
- flows[k][0] = XY flow in HSV 0-255
Expand Down
27 changes: 15 additions & 12 deletions cellpose/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ def make_tiles(imgi, bsize=224, augment=False, tile_overlap=0.1):
tile_overlap (float, optional): Fraction of overlap of tiles. Defaults to 0.1.
Returns:
np.ndarray: Array of shape (ntiles, nchan, bsize, bsize) representing the tiles.
list: List of arrays with start and end of tiles in Y of length ntiles.
list: List of arrays with start and end of tiles in X of length ntiles.
int: Height of the input image.
int: Width of the input image.
tuple containing
- IMG (np.ndarray): Array of shape (ntiles, nchan, bsize, bsize) representing the tiles.
- ysub (list): List of arrays with start and end of tiles in Y of length ntiles.
- xsub (list): List of arrays with start and end of tiles in X of length ntiles.
- Ly (int): Height of the input image.
- Lx (int): Width of the input image.
"""
nchan, Ly, Lx = imgi.shape
if augment:
Expand Down Expand Up @@ -736,10 +737,11 @@ def pad_image_ND(img0, div=16, extra=1, min_size=None):
extra (int, optional): Extra padding. Defaults to 1.
min_size (tuple, optional): Minimum size of the image. Defaults to None.
Returns:
ndarray: Padded image.
ndarray: Y range of pixels in the padded image corresponding to img0.
ndarray: X range of pixels in the padded image corresponding to img0.
Returns:
tuple containing
- I (ndarray): Padded image.
- ysub (ndarray): Y range of pixels in the padded image corresponding to img0.
- xsub (ndarray): X range of pixels in the padded image corresponding to img0.
"""
if min_size is None or img0.shape[-2] >= min_size[-2]:
Lpad = int(div * np.ceil(img0.shape[-2] / div) - img0.shape[-2])
Expand Down Expand Up @@ -789,9 +791,10 @@ def random_rotate_and_resize(X, Y=None, scale_range=1., xy=(224, 224), do_3D=Fal
random_per_image (bool, optional): Different random rotate and resize per image. Defaults to True.
Returns:
imgi (ND-array, float): Transformed images in array [nimg x nchan x xy[0] x xy[1]].
lbl (ND-array, float): Transformed labels in array [nimg x nchan x xy[0] x xy[1]].
scale (array, float): Amount each image was resized by.
tuple containing
- imgi (ND-array, float): Transformed images in array [nimg x nchan x xy[0] x xy[1]].
- lbl (ND-array, float): Transformed labels in array [nimg x nchan x xy[0] x xy[1]].
- scale (array, float): Amount each image was resized by.
"""
scale_range = max(0, min(2, float(scale_range)))
nimg = len(X)
Expand Down

0 comments on commit 8a19e25

Please sign in to comment.