Skip to content

Commit b94514d

Browse files
updating docstrings for google format
1 parent 402288e commit b94514d

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

cellpose/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ def eval(self, x, batch_size=8, resample=True, channels=None, channel_axis=None,
432432
progress (QProgressBar, optional): pyqt progress bar. Defaults to None.
433433
434434
Returns:
435+
A tuple containing (masks, flows, styles, diams):
435436
masks (list of 2D arrays or single 3D array): Labelled image, where 0=no masks; 1,2,...=mask labels;
436437
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;
437438
flows[k][2] = cell probability (if > cellprob_threshold, pixel used for dynamics);

cellpose/transforms.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ def make_tiles(imgi, bsize=224, augment=False, tile_overlap=0.1):
9797
tile_overlap (float, optional): Fraction of overlap of tiles. Defaults to 0.1.
9898
9999
Returns:
100-
tuple containing
101-
- IMG (np.ndarray): Array of shape (ntiles, nchan, bsize, bsize) representing the tiles.
102-
- ysub (list): List of arrays with start and end of tiles in Y of length ntiles.
103-
- xsub (list): List of arrays with start and end of tiles in X of length ntiles.
104-
- Ly (int): Height of the input image.
105-
- Lx (int): Width of the input image.
100+
A tuple containing (IMG, ysub, xsub, Ly, Lx):
101+
IMG (np.ndarray): Array of shape (ntiles, nchan, bsize, bsize) representing the tiles.
102+
ysub (list): List of arrays with start and end of tiles in Y of length ntiles.
103+
xsub (list): List of arrays with start and end of tiles in X of length ntiles.
104+
Ly (int): Height of the input image.
105+
Lx (int): Width of the input image.
106106
"""
107107
nchan, Ly, Lx = imgi.shape
108108
if augment:
@@ -859,10 +859,8 @@ def pad_image_ND(img0, div=16, extra=1, min_size=None, zpad=False):
859859
min_size (tuple, optional): Minimum size of the image. Defaults to None.
860860
861861
Returns:
862-
tuple containing
863-
- I (ndarray): Padded image.
864-
- ysub (ndarray): Y range of pixels in the padded image corresponding to img0.
865-
- xsub (ndarray): X range of pixels in the padded image corresponding to img0.
862+
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.
863+
866864
"""
867865
Ly, Lx = img0.shape[-2:]
868866
ypad1, ypad2, xpad1, xpad2 = get_pad_yx(Ly, Lx, div=div, extra=extra, min_size=min_size)
@@ -910,10 +908,9 @@ def random_rotate_and_resize(X, Y=None, scale_range=1., xy=(224, 224), do_3D=Fal
910908
random_per_image (bool, optional): Different random rotate and resize per image. Defaults to True.
911909
912910
Returns:
913-
tuple containing
914-
- imgi (ND-array, float): Transformed images in array [nimg x nchan x xy[0] x xy[1]].
915-
- lbl (ND-array, float): Transformed labels in array [nimg x nchan x xy[0] x xy[1]].
916-
- scale (array, float): Amount each image was resized by.
911+
A tuple containing (imgi, lbl, scale): imgi (ND-array, float): Transformed images in array [nimg x nchan x xy[0] x xy[1]];
912+
lbl (ND-array, float): Transformed labels in array [nimg x nchan x xy[0] x xy[1]];
913+
scale (array, float): Amount each image was resized by.
917914
"""
918915
scale_range = max(0, min(2, float(scale_range)))
919916
nimg = len(X)

cellpose/utils.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ def diameters(masks):
561561
masks (ndarray): masks (0=no cells, 1=first cell, 2=second cell,...)
562562
563563
Returns:
564-
tuple: A tuple containing the median diameter and an array of diameters for each object.
564+
tuple: A tuple containing the median diameter and an array of diameters for each object.
565565
566566
Examples:
567567
>>> masks = np.array([[0, 1, 1], [1, 0, 0], [1, 1, 0]])
@@ -586,10 +586,7 @@ def radius_distribution(masks, bins):
586586
bins (int): Number of bins for the histogram.
587587
588588
Returns:
589-
tuple: A tuple containing:
590-
- nb (ndarray): Normalized histogram of radii.
591-
- md (float): Median radius.
592-
- radii (ndarray): Array of radii.
589+
A tuple containing a normalized histogram of radii, median radius, array of radii.
593590
594591
"""
595592
unique, counts = np.unique(masks, return_counts=True)
@@ -634,9 +631,9 @@ def fill_holes_and_remove_small_masks(masks, min_size=15):
634631
Set to -1 to turn off this functionality. Default is 15.
635632
636633
Returns:
637-
ndarray: Int, 2D or 3D array of masks with holes filled and small masks removed.
638-
0 represents no mask, while positive integers represent mask labels.
639-
The size is [Ly x Lx] or [Lz x Ly x Lx].
634+
ndarray: Int, 2D or 3D array of masks with holes filled and small masks removed.
635+
0 represents no mask, while positive integers represent mask labels.
636+
The size is [Ly x Lx] or [Lz x Ly x Lx].
640637
"""
641638

642639
if masks.ndim > 3 or masks.ndim < 2:

0 commit comments

Comments
 (0)