Skip to content

Commit

Permalink
updating docstrings for google format
Browse files Browse the repository at this point in the history
  • Loading branch information
carsen-stringer committed Feb 11, 2025
1 parent 402288e commit b94514d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
1 change: 1 addition & 0 deletions cellpose/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ def eval(self, x, batch_size=8, resample=True, channels=None, channel_axis=None,
progress (QProgressBar, optional): pyqt progress bar. Defaults to None.
Returns:
A tuple containing (masks, flows, styles, diams):
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; flows[k][1] = XY flows at each pixel;
flows[k][2] = cell probability (if > cellprob_threshold, pixel used for dynamics);
Expand Down
25 changes: 11 additions & 14 deletions cellpose/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,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:
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.
A tuple containing (IMG, ysub, xsub, Ly, Lx):
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 @@ -859,10 +859,8 @@ def pad_image_ND(img0, div=16, extra=1, min_size=None, zpad=False):
min_size (tuple, optional): Minimum size of the image. Defaults to None.
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.
A tuple containing (I, ysub, xsub) or (I, ysub, xsub, zsub), I is padded image, -sub are ranges of pixels in the padded image corresponding to img0.
"""
Ly, Lx = img0.shape[-2:]
ypad1, ypad2, xpad1, xpad2 = get_pad_yx(Ly, Lx, div=div, extra=extra, min_size=min_size)
Expand Down Expand Up @@ -910,10 +908,9 @@ 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:
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.
A tuple containing (imgi, lbl, scale): 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
13 changes: 5 additions & 8 deletions cellpose/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def diameters(masks):
masks (ndarray): masks (0=no cells, 1=first cell, 2=second cell,...)
Returns:
tuple: A tuple containing the median diameter and an array of diameters for each object.
tuple: A tuple containing the median diameter and an array of diameters for each object.
Examples:
>>> masks = np.array([[0, 1, 1], [1, 0, 0], [1, 1, 0]])
Expand All @@ -586,10 +586,7 @@ def radius_distribution(masks, bins):
bins (int): Number of bins for the histogram.
Returns:
tuple: A tuple containing:
- nb (ndarray): Normalized histogram of radii.
- md (float): Median radius.
- radii (ndarray): Array of radii.
A tuple containing a normalized histogram of radii, median radius, array of radii.
"""
unique, counts = np.unique(masks, return_counts=True)
Expand Down Expand Up @@ -634,9 +631,9 @@ def fill_holes_and_remove_small_masks(masks, min_size=15):
Set to -1 to turn off this functionality. Default is 15.
Returns:
ndarray: Int, 2D or 3D array of masks with holes filled and small masks removed.
0 represents no mask, while positive integers represent mask labels.
The size is [Ly x Lx] or [Lz x Ly x Lx].
ndarray: Int, 2D or 3D array of masks with holes filled and small masks removed.
0 represents no mask, while positive integers represent mask labels.
The size is [Ly x Lx] or [Lz x Ly x Lx].
"""

if masks.ndim > 3 or masks.ndim < 2:
Expand Down

0 comments on commit b94514d

Please sign in to comment.