[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73G01Y41P9PH0JNN2ZTYQ7E":3,"skill-same:01M73G01Y41P9PH0JNN2ZTYQ7E":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M73G01Y41P9PH0JNN2ZTYQ7E","cellpose-cell-segmentation",null,"DL cell\u002Fnucleus segmentation for fluorescence and brightfield microscopy. Pre-trained models (cyto3, nuclei, tissuenet) and a generalist flow-based algorithm segment cells without retraining. Outputs label masks for morphology and tracking. Use scikit-image watershed for rule-based; Cellpose when DL generalization across staining is needed.","bg-szy\u002FTOP-SKILLS","bg-szy","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F106576190?v=4","01M73A4E8KPV67SFXRY8XZGNBX","ShuZhiyong","01M73A4E96MQ294MHM74TZBVQD",6,"BSD-3-Clause","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fawesome-skills\u002Fcellpose-cell-segmentation\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: \"cellpose-cell-segmentation\"\ndescription: \"DL cell\u002Fnucleus segmentation for fluorescence and brightfield microscopy. Pre-trained models (cyto3, nuclei, tissuenet) and a generalist flow-based algorithm segment cells without retraining. Outputs label masks for morphology and tracking. Use scikit-image watershed for rule-based; Cellpose when DL generalization across staining is needed.\"\nlicense: \"BSD-3-Clause\"\n---\n\n# Cellpose — Deep Learning Cell Segmentation\n\n## Overview\n\nCellpose uses a flow-based neural network to segment individual cells or nuclei in fluorescence microscopy images without manual parameter tuning. Pre-trained models (`cyto3`, `nuclei`, `tissuenet`) generalize across cell types, magnifications, and staining conditions — eliminating the need for manual threshold selection or watershed parameter optimization. Cellpose outputs integer label masks (each cell = unique integer) compatible with scikit-image `regionprops` for morphology measurement and with TrackPy for tracking. A built-in diameter estimator removes the need to specify cell size, though providing an approximate diameter improves accuracy.\n\n## When to Use\n\n- Segmenting cells or nuclei in fluorescence microscopy images where rule-based thresholding fails due to varying intensity or cell touching\n- Processing large microscopy datasets in batch without per-image parameter tuning\n- Segmenting diverse cell types (adherent cells, blood cells, bacteria, organoids) with a single model\n- Producing label masks for downstream region property measurement (area, intensity, shape) with scikit-image\n- 3D volumetric segmentation of z-stack microscopy data with `do_3D=True`\n- Use **scikit-image watershed** when cells are well-separated and rule-based thresholding is sufficient\n- Use **StarDist** as an alternative deep learning segmenter optimized for star-convex cells (neurons, nuclei)\n\n## Prerequisites\n\n- **Python packages**: `cellpose`, `numpy`, `matplotlib`\n- **Optional**: GPU with CUDA for 10-50× speedup (`pip install cellpose[gui]` for GUI)\n- **Input**: grayscale or multichannel TIFF\u002FPNG images (2D or 3D arrays)\n\n```bash\n# Install Cellpose\npip install cellpose\n\n# Install with GUI support\npip install cellpose[gui]\n\n# Install with GPU (PyTorch CUDA)\npip install cellpose torch torchvision torchaudio --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118\n\n# Verify\npython -c \"from cellpose import models; print('Cellpose ready')\"\n```\n\n## Quick Start\n\n```python\nfrom cellpose import models\nimport numpy as np\nfrom skimage import io\n\n# Load image (grayscale or 2D array)\nimg = io.imread(\"cells.tif\")  # shape: (H, W) or (H, W, C)\n\n# Initialize model and segment\nmodel = models.Cellpose(model_type=\"cyto3\", gpu=False)\nmasks, flows, styles, diams = model.eval(img, diameter=0, channels=[0, 0])\n\nprint(f\"Cells segmented: {masks.max()}\")  # number of cells\nprint(f\"Estimated diameter: {diams:.1f} px\")\nprint(f\"Mask shape: {masks.shape}\")\n```\n\n## Workflow\n\n### Step 1: Load and Inspect Images\n\nLoad microscopy images and inspect channel layout before segmentation.\n\n```python\nimport numpy as np\nfrom skimage import io\nimport matplotlib.pyplot as plt\n\n# Load single-channel fluorescence image\nimg_gray = io.imread(\"nucleus_dapi.tif\")           # shape: (H, W)\nimg_rgb = io.imread(\"cells_multichannel.tif\")      # shape: (H, W, C)\n\nprint(f\"Grayscale shape: {img_gray.shape}, dtype: {img_gray.dtype}\")\nprint(f\"Multichannel shape: {img_rgb.shape}\")\n\n# Preview\nfig, axes = plt.subplots(1, 2, figsize=(12, 5))\naxes[0].imshow(img_gray, cmap=\"gray\")\naxes[0].set_title(\"DAPI (nuclei)\")\naxes[1].imshow(img_rgb[..., 0], cmap=\"green\")\naxes[1].set_title(\"GFP channel\")\nplt.tight_layout()\nplt.savefig(\"image_preview.png\", dpi=100)\nprint(\"Saved: image_preview.png\")\n```\n\n### Step 2: Segment Cells with a Pre-trained Model\n\nRun Cellpose with the appropriate pre-trained model.\n\n```python\nfrom cellpose import models\nimport numpy as np\nfrom skimage import io\n\n# Available models: 'cyto3' (cells), 'nuclei', 'tissuenet', 'cyto2', 'CP'\nmodel = models.Cellpose(model_type=\"cyto3\", gpu=False)\n\nimg = io.imread(\"cells.tif\")\n\n# channels=[cytoplasm_channel, nucleus_channel]\n# Use [0, 0] for grayscale; [1, 3] for green cytoplasm + blue nucleus (1-indexed)\nmasks, flows, styles, diams = model.eval(\n    img,\n    diameter=0,          # 0 = auto-estimate; or provide px estimate\n    channels=[0, 0],     # grayscale\n    flow_threshold=0.4,  # lower = fewer false positives; range 0.1-1.0\n    cellprob_threshold=0.0,  # lower = more cells detected; range -6 to 6\n)\n\nprint(f\"Cells found: {masks.max()}\")\nprint(f\"Estimated cell diameter: {diams:.1f} pixels\")\nnp.save(\"masks.npy\", masks)\n```\n\n### Step 3: Segment Nuclei from DAPI Channel\n\nUse the `nuclei` model for DAPI-stained nuclei.\n\n```python\nfrom cellpose import models\nfrom skimage import io\nimport numpy as np\n\nmodel = models.Cellpose(model_type=\"nuclei\", gpu=False)\ndapi = io.imread(\"dapi.tif\")\n\n# Nucleus-only segmentation: channels=[0, 0] (single channel)\nmasks, flows, styles, diams = model.eval(\n    dapi,\n    diameter=30,         # approximate nucleus diameter in pixels\n    channels=[0, 0],\n    flow_threshold=0.4,\n    cellprob_threshold=0.0,\n)\n\nprint(f\"Nuclei segmented: {masks.max()}\")\n# Save label mask as TIFF for ImageJ\u002FFIJI compatibility\nfrom skimage import io as skio\nskio.imsave(\"nuclei_masks.tif\", masks.astype(np.uint16))\nprint(\"Saved: nuclei_masks.tif\")\n```\n\n### Step 4: Visualize Segmentation Results\n\nOverlay masks on original images for quality control.\n\n```python\nfrom cellpose import plot as cpplot\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom skimage import io\n\nimg = io.imread(\"cells.tif\")\nmasks = np.load(\"masks.npy\")\nflows_data = None  # load if you saved them: flows = np.load(\"flows.npy\", allow_pickle=True)\n\n# Cellpose built-in visualization\nfig, axes = plt.subplots(1, 3, figsize=(15, 5))\n\n# Original image\naxes[0].imshow(img, cmap=\"gray\")\naxes[0].set_title(f\"Original image\")\n\n# Label mask (each cell = unique color)\naxes[1].imshow(masks, cmap=\"tab20\")\naxes[1].set_title(f\"Segmentation masks ({masks.max()} cells)\")\n\n# Overlay: outline on original\nfrom skimage.segmentation import find_boundaries\nboundaries = find_boundaries(masks, mode=\"inner\")\noverlay = np.stack([img \u002F img.max()] * 3, axis=-1)\noverlay[boundaries] = [1, 0, 0]  # red outlines\naxes[2].imshow(overlay)\naxes[2].set_title(\"Outlines overlay\")\n\nplt.tight_layout()\nplt.savefig(\"segmentation_result.png\", dpi=150)\nprint(\"Saved: segmentation_result.png\")\n```\n\n### Step 5: Measure Cell Properties from Masks\n\nExtract morphology and intensity measurements using scikit-image regionprops.\n\n```python\nimport numpy as np\nimport pandas as pd\nfrom skimage.measure import regionprops_table\nfrom skimage import io\n\nmasks = np.load(\"masks.npy\")\nimg = io.imread(\"cells.tif\")\n\n# Measure morphology and intensity per cell\nprops = regionprops_table(\n    masks, intensity_image=img,\n    properties=[\"label\", \"area\", \"centroid\", \"eccentricity\",\n                 \"mean_intensity\", \"max_intensity\", \"perimeter\",\n                 \"equivalent_diameter_area\"]\n)\ndf = pd.DataFrame(props)\ndf.columns = [\"cell_id\", \"area_px\", \"centroid_y\", \"centroid_x\",\n              \"eccentricity\", \"mean_intensity\", \"max_intensity\",\n              \"perimeter\", \"diameter_px\"]\n\nprint(f\"Cells measured: {len(df)}\")\nprint(f\"Median area: {df['area_px'].median():.0f} px²\")\nprint(f\"Median diameter: {df['diameter_px'].median():.1f} px\")\nprint(df.head())\n\ndf.to_csv(\"cell_measurements.csv\", index=False)\n```\n\n### Step 6: Batch Segment Multiple Images\n\nProcess a directory of images and aggregate results.\n\n```python\nfrom cellpose import models\nfrom skimage import io\nfrom skimage.measure import regionprops_table\nimport pandas as pd\nimport numpy as np\nfrom pathlib import Path\n\nmodel = models.Cellpose(model_type=\"cyto3\", gpu=False)\nimage_dir = Path(\"images\u002F\")\noutput_dir = Path(\"results\u002F\")\noutput_dir.mkdir(exist_ok=True)\n\nall_stats = []\nfor img_path in sorted(image_dir.glob(\"*.tif\")):\n    img = io.imread(img_path)\n    masks, _, _, diams = model.eval(img, diameter=0, channels=[0, 0])\n    \n    # Save mask\n    np.save(output_dir \u002F f\"{img_path.stem}_masks.npy\", masks)\n    \n    # Measure\n    if masks.max() > 0:\n        props = regionprops_table(masks, intensity_image=img,\n                                  properties=[\"label\", \"area\", \"mean_intensity\"])\n        df = pd.DataFrame(props)\n        df[\"image\"] = img_path.name\n        df[\"est_diameter\"] = diams\n        all_stats.append(df)\n    \n    print(f\"{img_path.name}: {masks.max()} cells, diameter={diams:.0f}px\")\n\nsummary = pd.concat(all_stats, ignore_index=True)\nsummary.to_csv(output_dir \u002F \"all_cells.csv\", index=False)\nprint(f\"\\nTotal cells: {len(summary)} across {summary['image'].nunique()} images\")\n```\n\n## Key Parameters\n\n| Parameter | Default | Range\u002FOptions | Effect |\n|-----------|---------|---------------|--------|\n| `model_type` | `\"cyto3\"` | `\"cyto3\"`, `\"cyto2\"`, `\"nuclei\"`, `\"tissuenet\"`, `\"CP\"`, custom path | Pre-trained model; `cyto3` is most general; `nuclei` for DAPI-only |\n| `diameter` | `30` | 0–500 px | Approximate cell diameter in pixels; `0` = auto-estimate from image |\n| `channels` | `[0, 0]` | `[cyto, nucleus]` (0=gray, 1=R, 2=G, 3=B) | Channel indices for cytoplasm and nuclear stain |\n| `flow_threshold` | `0.4` | 0.1–1.0 | Cell probability threshold from flow field; lower = stricter |\n| `cellprob_threshold` | `0.0` | −6 to 6 | Cell probability cutoff; increase to find more cells |\n| `gpu` | `False` | `True`, `False` | Enable GPU inference (requires CUDA PyTorch) |\n| `do_3D` | `False` | `True`, `False` | Enable 3D volumetric segmentation of z-stacks |\n| `min_size` | `15` | integer px² | Minimum object size in pixels²; smaller objects discarded |\n| `batch_size` | `8` | integer | Number of image tiles processed per GPU batch |\n| `normalize` | `True` | `True`, `False` | Normalize image intensity before segmentation |\n\n## Common Recipes\n\n### Recipe 1: Segment Multichannel Image (GFP + DAPI)\n\n```python\nfrom cellpose import models\nfrom skimage import io\nimport numpy as np\n\nmodel = models.Cellpose(model_type=\"cyto3\", gpu=False)\n\n# Multichannel image: channel 1 = GFP (cytoplasm), channel 3 = DAPI (nucleus)\nimg_multi = io.imread(\"cells_gfp_dapi.tif\")  # shape: (H, W, 3)\n\n# channels=[cytoplasm_channel, nucleus_channel] (1-indexed for multichannel)\nmasks, flows, styles, diams = model.eval(\n    img_multi,\n    diameter=0,\n    channels=[2, 3],  # GFP=channel2, DAPI=channel3 (1-indexed)\n    flow_threshold=0.4,\n)\nprint(f\"Cells segmented: {masks.max()}, diameter: {diams:.0f}px\")\nnp.save(\"masks_multichannel.npy\", masks)\n```\n\n### Recipe 2: Use Cellpose CLI for Directory Batch Processing\n\n```bash\n# CLI batch segmentation of all TIFFs in a directory\ncellpose \\\n    --image_path images\u002F \\\n    --pretrained_model cyto3 \\\n    --diameter 0 \\\n    --chan 0 \\\n    --save_tif \\\n    --no_npy\n\n# With GPU\ncellpose \\\n    --image_path images\u002F \\\n    --pretrained_model nuclei \\\n    --diameter 30 \\\n    --chan 0 \\\n    --use_gpu \\\n    --save_tif\n\n# Results saved as: images\u002F*_cp_masks.tif\necho \"Done. Masks saved in images\u002F directory.\"\n```\n\n### Recipe 3: Fine-tune Cellpose on Custom Cell Type\n\n```python\nfrom cellpose import models, train\nimport numpy as np\nfrom skimage import io\n\n# Prepare training data: list of images and corresponding masks\ntrain_images = [io.imread(f\"train\u002Fimg_{i}.tif\") for i in range(10)]\ntrain_masks = [np.load(f\"train\u002Fmask_{i}.npy\") for i in range(10)]\n\n# Fine-tune starting from cyto3\nmodel = models.CellposeModel(model_type=\"cyto3\")\n\n# Train: saves model to models\u002F directory\nmodel_path = train.train_seg(\n    model.net,\n    train_data=train_images,\n    train_labels=train_masks,\n    channels=[0, 0],\n    save_path=\"models\u002F\",\n    n_epochs=100,\n    learning_rate=0.2,\n    weight_decay=1e-5,\n)\nprint(f\"Fine-tuned model saved: {model_path}\")\n```\n\n## Expected Outputs\n\n| Output | Format | Description |\n|--------|--------|-------------|\n| `masks` array | numpy int32 | Label mask: 0=background, 1..N=unique cell IDs |\n| `flows` list | numpy arrays | Flow field components: [XY flows, cell prob, gradient] |\n| `styles` array | numpy float | Style vector embedding (used for model similarity) |\n| `diams` float | scalar | Estimated average cell diameter in pixels |\n| `*_masks.npy` | NumPy | Saved mask array (from `np.save`) |\n| `*_cp_masks.tif` | TIFF uint16 | Mask TIFF (from CLI `--save_tif`); compatible with FIJI\u002FImageJ |\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| All cells merged into one mask | Diameter too large or cells too close | Reduce `diameter`; increase `flow_threshold` to 0.6–0.8 |\n| Very few cells detected | Diameter too small or `cellprob_threshold` too high | Increase `cellprob_threshold` to −2; use `diameter=0` for auto |\n| Many false positives (background labeled) | Low `flow_threshold` | Increase `flow_threshold` to 0.6–0.9; increase `min_size` |\n| GPU out of memory | Image too large for GPU batch | Process in tiles; reduce `batch_size`; crop image |\n| Poor generalization on new cell type | Model not trained on similar cells | Try all pre-trained models; fine-tune with 10-20 annotated images |\n| 3D segmentation very slow | Large z-stack on CPU | Enable GPU; reduce z-stack depth; use `anisotropy` parameter |\n| Mask values overflow uint8 | More than 255 cells in image | Save with `dtype=np.uint16` or `np.int32` |\n| Import error: `No module named 'cellpose'` | Package not installed | `pip install cellpose` or `conda install -c conda-forge cellpose` |\n\n## References\n\n- [Cellpose GitHub: MouseLand\u002Fcellpose](https:\u002F\u002Fgithub.com\u002FMouseLand\u002Fcellpose) — source code, documentation, and model zoo\n- Stringer C et al. (2021) \"Cellpose: a generalist algorithm for cellular segmentation\" — *Nature Methods* 18:100-106. [DOI:10.1038\u002Fs41592-020-01018-x](https:\u002F\u002Fdoi.org\u002F10.1038\u002Fs41592-020-01018-x)\n- Pachitariu M & Stringer C (2022) \"Cellpose 2.0: how to train your own model\" — *Nature Methods* 19:1500-1508. [DOI:10.1038\u002Fs41592-022-01663-4](https:\u002F\u002Fdoi.org\u002F10.1038\u002Fs41592-022-01663-4)\n- [Cellpose documentation](https:\u002F\u002Fcellpose.readthedocs.io\u002F) — official API reference and training guide\n","# Cellpose — Deep Learning Cell Segmentation\n\n## Overview\n\nCellpose uses a flow-based neural network to segment individual cells or nuclei in fluorescence microscopy images without manual parameter tuning. Pre-trained models (`cyto3`, `nuclei`, `tissuenet`) generalize across cell types, magnifications, and staining conditions — eliminating the need for manual threshold selection or watershed parameter optimization. Cellpose outputs integer label masks (each cell = unique integer) compatible with scikit-image `regionprops` for morphology measurement and with TrackPy for tracking. A built-in diameter estimator removes the need to specify cell size, though providing an approximate diameter improves accuracy.\n\n## When to Use\n\n- Segmenting cells or nuclei in fluorescence microscopy images where rule-based thresholding fails due to varying intensity or cell touching\n- Processing large microscopy datasets in batch without per-image parameter tuning\n- Segmenting diverse cell types (adherent cells, blood cells, bacteria, organoids) with a single model\n- Producing label masks for downstream region property measurement (area, intensity, shape) with scikit-image\n- 3D volumetric segmentation of z-stack microscopy data with `do_3D=True`\n- Use **scikit-image watershed** when cells are well-separated and rule-based thresholding is sufficient\n- Use **StarDist** as an alternative deep learning segmenter optimized for star-convex cells (neurons, nuclei)\n\n## Prerequisites\n\n- **Python packages**: `cellpose`, `numpy`, `matplotlib`\n- **Optional**: GPU with CUDA for 10-50× speedup (`pip install cellpose[gui]` for GUI)\n- **Input**: grayscale or multichannel TIFF\u002FPNG images (2D or 3D arrays)\n\n```bash\n# Install Cellpose\npip install cellpose\n\n# Install with GUI support\npip install cellpose[gui]\n\n# Install with GPU (PyTorch CUDA)\npip install cellpose torch torchvision torchaudio --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu118\n\n# Verify\npython -c \"from cellpose import models; print('Cellpose ready')\"\n```\n\n## Quick Start\n\n```python\nfrom cellpose import models\nimport numpy as np\nfrom skimage import io\n\n# Load image (grayscale or 2D array)\nimg = io.imread(\"cells.tif\")  # shape: (H, W) or (H, W, C)\n\n# Initialize model and segment\nmodel = models.Cellpose(model_type=\"cyto3\", gpu=False)\nmasks, flows, styles, diams = model.eval(img, diameter=0, channels=[0, 0])\n\nprint(f\"Cells segmented: {masks.max()}\")  # number of cells\nprint(f\"Estimated diameter: {diams:.1f} px\")\nprint(f\"Mask shape: {masks.shape}\")\n```\n\n## Workflow\n\n### Step 1: Load and Inspect Images\n\nLoad microscopy images and inspect channel layout before segmentation.\n\n```python\nimport numpy as np\nfrom skimage import io\nimport matplotlib.pyplot as plt\n\n# Load single-channel fluorescence image\nimg_gray = io.imread(\"nucleus_dapi.tif\")           # shape: (H, W)\nimg_rgb = io.imread(\"cells_multichannel.tif\")      # shape: (H, W, C)\n\nprint(f\"Grayscale shape: {img_gray.shape}, dtype: {img_gray.dtype}\")\nprint(f\"Multichannel shape: {img_rgb.shape}\")\n\n# Preview\nfig, axes = plt.subplots(1, 2, figsize=(12, 5))\naxes[0].imshow(img_gray, cmap=\"gray\")\naxes[0].set_title(\"DAPI (nuclei)\")\naxes[1].imshow(img_rgb[..., 0], cmap=\"green\")\naxes[1].set_title(\"GFP channel\")\nplt.tight_layout()\nplt.savefig(\"image_preview.png\", dpi=100)\nprint(\"Saved: image_preview.png\")\n```\n\n### Step 2: Segment Cells with a Pre-trained Model\n\nRun Cellpose with the appropriate pre-trained model.\n\n```python\nfrom cellpose import models\nimport numpy as np\nfrom skimage import io\n\n# Available models: 'cyto3' (cells), 'nuclei', 'tissuenet', 'cyto2', 'CP'\nmodel = models.Cellpose(model_type=\"cyto3\", gpu=False)\n\nimg = io.imread(\"cells.tif\")\n\n# channels=[cytoplasm_channel, nucleus_channel]\n# Use [0, 0] for grayscale; [1, 3] for green cytoplasm + blue nucleus (1-indexed)\nmasks, flows, styles, diams = model.eval(\n    img,\n    diameter=0,          # 0 = auto-estimate; or provide px estimate\n    channels=[0, 0],     # grayscale\n    flow_threshold=0.4,  # lower = fewer false positives; range 0.1-1.0\n    cellprob_threshold=0.0,  # lower = more cells detected; range -6 to 6\n)\n\nprint(f\"Cells found: {masks.max()}\")\nprint(f\"Estimated cell diameter: {diams:.1f} pixels\")\nnp.save(\"masks.npy\", masks)\n```\n\n### Step 3: Segment Nuclei from DAPI Channel\n\nUse the `nuclei` model for DAPI-stained nuclei.\n\n```python\nfrom cellpose import models\nfrom skimage import io\nimport numpy as np\n\nmodel = models.Cellpose(model_type=\"nuclei\", gpu=False)\ndapi = io.imread(\"dapi.tif\")\n\n# Nucleus-only segmentation: channels=[0, 0] (single channel)\nmasks, flows, styles, diams = model.eval(\n    dapi,\n    diameter=30,         # approximate nucleus diameter in pixels\n    channels=[0, 0],\n    flow_threshold=0.4,\n    cellprob_threshold=0.0,\n)\n\nprint(f\"Nuclei segmented: {masks.max()}\")\n# Save label mask as TIFF for ImageJ\u002FFIJI compatibility\nfrom skimage import io as skio\nskio.imsave(\"nuclei_masks.tif\", masks.astype(np.uint16))\nprint(\"Saved: nuclei_masks.tif\")\n```\n\n### Step 4: Visualize Segmentation Results\n\nOverlay masks on original images for quality control.\n\n```python\nfrom cellpose import plot as cpplot\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom skimage import io\n\nimg = io.imread(\"cells.tif\")\nmasks = np.load(\"masks.npy\")\nflows_data = None  # load if you saved them: flows = np.load(\"flows.npy\", allow_pickle=True)\n\n# Cellpose built-in visualization\nfig, axes = plt.subplots(1, 3, figsize=(15, 5))\n\n# Original image\naxes[0].imshow(img, cmap=\"gray\")\naxes[0].set_title(f\"Original image\")\n\n# Label mask (each cell = unique color)\naxes[1].imshow(masks, cmap=\"tab20\")\naxes[1].set_title(f\"Segmentation masks ({masks.max()} cells)\")\n\n# Overlay: outline on original\nfrom skimage.segmentation import find_boundaries\nboundaries = find_boundaries(masks, mode=\"inner\")\noverlay = np.stack([img \u002F img.max()] * 3, axis=-1)\noverlay[boundaries] = [1, 0, 0]  # red outlines\naxes[2].imshow(overlay)\naxes[2].set_title(\"Outlines overlay\")\n\nplt.tight_layout()\nplt.savefig(\"segmentation_result.png\", dpi=150)\nprint(\"Saved: segmentation_result.png\")\n```\n\n### Step 5: Measure Cell Properties from Masks\n\nExtract morphology and intensity measurements using scikit-image regionprops.\n\n```python\nimport numpy as np\nimport pandas as pd\nfrom skimage.measure import regionprops_table\nfrom skimage import io\n\nmasks = np.load(\"masks.npy\")\nimg = io.imread(\"cells.tif\")\n\n# Measure morphology and intensity per cell\nprops = regionprops_table(\n    masks, intensity_image=img,\n    properties=[\"label\", \"area\", \"centroid\", \"eccentricity\",\n                 \"mean_intensity\", \"max_intensity\", \"perimeter\",\n                 \"equivalent_diameter_area\"]\n)\ndf = pd.DataFrame(props)\ndf.columns = [\"cell_id\", \"area_px\", \"centroid_y\", \"centroid_x\",\n              \"eccentricity\", \"mean_intensity\", \"max_intensity\",\n              \"perimeter\", \"diameter_px\"]\n\nprint(f\"Cells measured: {len(df)}\")\nprint(f\"Median area: {df['area_px'].median():.0f} px²\")\nprint(f\"Median diameter: {df['diameter_px'].median():.1f} px\")\nprint(df.head())\n\ndf.to_csv(\"cell_measurements.csv\", index=False)\n```\n\n### Step 6: Batch Segment Multiple Images\n\nProcess a directory of images and aggregate results.\n\n```python\nfrom cellpose import models\nfrom skimage import io\nfrom skimage.measure import regionprops_table\nimport pandas as pd\nimport numpy as np\nfrom pathlib import Path\n\nmodel = models.Cellpose(model_type=\"cyto3\", gpu=False)\nimage_dir = Path(\"images\u002F\")\noutput_dir = Path(\"results\u002F\")\noutput_dir.mkdir(exist_ok=True)\n\nall_stats = []\nfor img_path in sorted(image_dir.glob(\"*.tif\")):\n    img = io.imread(img_path)\n    masks, _, _, diams = model.eval(img, diameter=0, channels=[0, 0])\n    \n    # Save mask\n    np.save(output_dir \u002F f\"{img_path.stem}_masks.npy\", masks)\n    \n    # Measure\n    if masks.max() > 0:\n        props = regionprops_table(masks, intensity_image=img,\n                                  properties=[\"label\", \"area\", \"mean_intensity\"])\n        df = pd.DataFrame(props)\n        df[\"image\"] = img_path.name\n        df[\"est_diameter\"] = diams\n        all_stats.append(df)\n    \n    print(f\"{img_path.name}: {masks.max()} cells, diameter={diams:.0f}px\")\n\nsummary = pd.concat(all_stats, ignore_index=True)\nsummary.to_csv(output_dir \u002F \"all_cells.csv\", index=False)\nprint(f\"\\nTotal cells: {len(summary)} across {summary['image'].nunique()} images\")\n```\n\n## Key Parameters\n\n| Parameter | Default | Range\u002FOptions | Effect |\n|-----------|---------|---------------|--------|\n| `model_type` | `\"cyto3\"` | `\"cyto3\"`, `\"cyto2\"`, `\"nuclei\"`, `\"tissuenet\"`, `\"CP\"`, custom path | Pre-trained model; `cyto3` is most general; `nuclei` for DAPI-only |\n| `diameter` | `30` | 0–500 px | Approximate cell diameter in pixels; `0` = auto-estimate from image |\n| `channels` | `[0, 0]` | `[cyto, nucleus]` (0=gray, 1=R, 2=G, 3=B) | Channel indices for cytoplasm and nuclear stain |\n| `flow_threshold` | `0.4` | 0.1–1.0 | Cell probability threshold from flow field; lower = stricter |\n| `cellprob_threshold` | `0.0` | −6 to 6 | Cell probability cutoff; increase to find more cells |\n| `gpu` | `False` | `True`, `False` | Enable GPU inference (requires CUDA PyTorch) |\n| `do_3D` | `False` | `True`, `False` | Enable 3D volumetric segmentation of z-stacks |\n| `min_size` | `15` | integer px² | Minimum object size in pixels²; smaller objects discarded |\n| `batch_size` | `8` | integer | Number of image tiles processed per GPU batch |\n| `normalize` | `True` | `True`, `False` | Normalize image intensity before segmentation |\n\n## Common Recipes\n\n### Recipe 1: Segment Multichannel Image (GFP + DAPI)\n\n```python\nfrom cellpose import models\nfrom skimage import io\nimport numpy as np\n\nmodel = models.Cellpose(model_type=\"cyto3\", gpu=False)\n\n# Multichannel image: channel 1 = GFP (cytoplasm), channel 3 = DAPI (nucleus)\nimg_multi = io.imread(\"cells_gfp_dapi.tif\")  # shape: (H, W, 3)\n\n# channels=[cytoplasm_channel, nucleus_channel] (1-indexed for multichannel)\nmasks, flows, styles, diams = model.eval(\n    img_multi,\n    diameter=0,\n    channels=[2, 3],  # GFP=channel2, DAPI=channel3 (1-indexed)\n    flow_threshold=0.4,\n)\nprint(f\"Cells segmented: {masks.max()}, diameter: {diams:.0f}px\")\nnp.save(\"masks_multichannel.npy\", masks)\n```\n\n### Recipe 2: Use Cellpose CLI for Directory Batch Processing\n\n```bash\n# CLI batch segmentation of all TIFFs in a directory\ncellpose \\\n    --image_path images\u002F \\\n    --pretrained_model cyto3 \\\n    --diameter 0 \\\n    --chan 0 \\\n    --save_tif \\\n    --no_npy\n\n# With GPU\ncellpose \\\n    --image_path images\u002F \\\n    --pretrained_model nuclei \\\n    --diameter 30 \\\n    --chan 0 \\\n    --use_gpu \\\n    --save_tif\n\n# Results saved as: images\u002F*_cp_masks.tif\necho \"Done. Masks saved in images\u002F directory.\"\n```\n\n### Recipe 3: Fine-tune Cellpose on Custom Cell Type\n\n```python\nfrom cellpose import models, train\nimport numpy as np\nfrom skimage import io\n\n# Prepare training data: list of images and corresponding masks\ntrain_images = [io.imread(f\"train\u002Fimg_{i}.tif\") for i in range(10)]\ntrain_masks = [np.load(f\"train\u002Fmask_{i}.npy\") for i in range(10)]\n\n# Fine-tune starting from cyto3\nmodel = models.CellposeModel(model_type=\"cyto3\")\n\n# Train: saves model to models\u002F directory\nmodel_path = train.train_seg(\n    model.net,\n    train_data=train_images,\n    train_labels=train_masks,\n    channels=[0, 0],\n    save_path=\"models\u002F\",\n    n_epochs=100,\n    learning_rate=0.2,\n    weight_decay=1e-5,\n)\nprint(f\"Fine-tuned model saved: {model_path}\")\n```\n\n## Expected Outputs\n\n| Output | Format | Description |\n|--------|--------|-------------|\n| `masks` array | numpy int32 | Label mask: 0=background, 1..N=unique cell IDs |\n| `flows` list | numpy arrays | Flow field components: [XY flows, cell prob, gradient] |\n| `styles` array | numpy float | Style vector embedding (used for model similarity) |\n| `diams` float | scalar | Estimated average cell diameter in pixels |\n| `*_masks.npy` | NumPy | Saved mask array (from `np.save`) |\n| `*_cp_masks.tif` | TIFF uint16 | Mask TIFF (from CLI `--save_tif`); compatible with FIJI\u002FImageJ |\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| All cells merged into one mask | Diameter too large or cells too close | Reduce `diameter`; increase `flow_threshold` to 0.6–0.8 |\n| Very few cells detected | Diameter too small or `cellprob_threshold` too high | Increase `cellprob_threshold` to −2; use `diameter=0` for auto |\n| Many false positives (background labeled) | Low `flow_threshold` | Increase `flow_threshold` to 0.6–0.9; increase `min_size` |\n| GPU out of memory | Image too large for GPU batch | Process in tiles; reduce `batch_size`; crop image |\n| Poor generalization on new cell type | Model not trained on similar cells | Try all pre-trained models; fine-tune with 10-20 annotated images |\n| 3D segmentation very slow | Large z-stack on CPU | Enable GPU; reduce z-stack depth; use `anisotropy` parameter |\n| Mask values overflow uint8 | More than 255 cells in image | Save with `dtype=np.uint16` or `np.int32` |\n| Import error: `No module named 'cellpose'` | Package not installed | `pip install cellpose` or `conda install -c conda-forge cellpose` |\n\n## References\n\n- [Cellpose GitHub: MouseLand\u002Fcellpose](https:\u002F\u002Fgithub.com\u002FMouseLand\u002Fcellpose) — source code, documentation, and model zoo\n- Stringer C et al. (2021) \"Cellpose: a generalist algorithm for cellular segmentation\" — *Nature Methods* 18:100-106. [DOI:10.1038\u002Fs41592-020-01018-x](https:\u002F\u002Fdoi.org\u002F10.1038\u002Fs41592-020-01018-x)\n- Pachitariu M & Stringer C (2022) \"Cellpose 2.0: how to train your own model\" — *Nature Methods* 19:1500-1508. [DOI:10.1038\u002Fs41592-022-01663-4](https:\u002F\u002Fdoi.org\u002F10.1038\u002Fs41592-022-01663-4)\n- [Cellpose documentation](https:\u002F\u002Fcellpose.readthedocs.io\u002F) — official API reference and training guide\n",{"name":5,"license":15,"description":7},"master","63f17866001c5ca854bf2fa0b678ce277133de5b","skills\u002Fawesome-skills\u002Fcellpose-cell-segmentation",0,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS","https:\u002F\u002Fbg-szy.github.io\u002FTOP-SKILLS\u002F","https:\u002F\u002Fgithub.com\u002Fbg-szy","https:\u002F\u002Fwww.ecust.edu.cn\u002F","a student of East China University of Science and Technology","2026-11-15 03:38:02",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add bg-szy\u002FTOP-SKILLS --skill cellpose-cell-segmentation",{"tool":40,"command":41},"bunx","bunx skills add bg-szy\u002FTOP-SKILLS --skill cellpose-cell-segmentation",{"tool":43,"command":44},"pnpm","pnpm dlx skills add bg-szy\u002FTOP-SKILLS --skill cellpose-cell-segmentation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fawesome-skills\u002Fcellpose-cell-segmentation\u002FSKILL.md",true,[],[49,58,65,72,79,86],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":57},"01M7DXW9N826PKXK174PVW3038","serpmaven","Scrape Google search results (SERP) to JSON with SERP Maven (serpmaven) - a real Chrome browser on a residential proxy with sticky sessions. Run it as a CLI, a Python library, a local HTTP search API (`serve`), an MCP server or a Docker image; set the proxy login, workers, pages and cost tracking. Use when the user wants Google results, rank tracking, a self-hosted SERP API, or live Google search for an AI agent.","MIT","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fserpmaven\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":57},"01M7DXVHSTWDV65475QEQ915M7","revnu-landing-page-audit","Find out why a landing page isn't turning visitors into signups, demos or sales. Audits one page against what the ad, post or search that sends people there promised, then checks the first screen, proof, call to action, friction and mobile. Returns at most 7 prioritized fixes, plus what is fine and what could not be checked; rewrites specific lines and fixes the page in the repo when asked. Never promises a conversion lift. Works without a Revnu account. Use when the user says or asks: \"audit my landing page\", \"why isn't this page converting\", \"review my homepage\", \"my ads get clicks but no signups\", \"people bounce from the pricing page\", \"CRO review\", \"improve conversion rate\", \"is my hero section clear\", \"roast my landing page\", \"rewrite my headline\", \"what's wrong with this page\", \"landing page feedback\", \"make the signup page convert better\". Not for SEO or AI-search audits, page speed engineering on its own, or building a new page from scratch.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-landing-page-audit\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":57},"01M7DXV8X2D7B3VTD4HHYYHTGR","revnu-growth-context","Write down once who buys, what they're stuck on, what it costs, what proof you have and what you've already tried, so every growth task starts from facts instead of a questionnaire. Creates or updates .agents\u002Frevnu-growth.md from the repo, the live site and the user, and imports an existing product-marketing.md. Use when the user says \"set up our marketing context\", \"who is our ideal customer\", \"write our ICP\", \"describe the product for marketing\", \"positioning doc\", \"what's our brand voice\", \"remember this about our customers\", \"log what we tried\", \"what have we learned from marketing\", \"we changed pricing, update the context\", \"update our growth notes\", \"summarize the business for the agent\", \"import my product-marketing.md\", \"start a growth doc\", or before a first marketing, SEO, outreach or launch task when no context file exists. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-growth-context\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":57},"01M7DXV0DGJ1G0A60PAHC6J3C5","revnu-get-listed","Get onto the third-party pages AI answers and search cite when buyers ask for the best tool in your category: \"best X\" roundups, directories, review sites, GitHub awesome lists, community threads and comparison pages. Finds which ones are cited, ranks them by fit and effort, and drafts each submission, PR or pitch by the target's own rules. Use when the user says \"get us listed\", \"which directories should we submit to\", \"how do we get into best-of lists\", \"why does ChatGPT recommend competitors and not us\", \"get mentioned in AI answers\", \"submit to awesome lists\", \"get on G2\", \"where are our competitors listed\", \"pitch listicle authors\", \"find backlink opportunities\", \"launch directories\", \"get into roundups\", \"Product Hunt alternatives\", \"where should we be listed\", \"get cited by Perplexity\". Never submits, pays or posts without a yes. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-get-listed\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":57},"01M7DXTSPMGT9D6DSS0HP9BSTA","revnu-ai-readiness-audit","Audit whether your website gives ChatGPT, Perplexity, Claude, Gemini and Google's AI Overviews something worth quoting, and fix the pages that don't. Use when the user says or asks \"is my site ready for AI search\", \"audit my site for AI answers\", \"AEO audit\", \"GEO audit\", \"why doesn't ChatGPT quote our pricing\", \"make our pages citable by AI\", \"do I need llms.txt\", \"does schema help with ChatGPT\", \"check our structured data\", \"is our content visible without JavaScript\", \"AI SEO audit\", \"optimize our homepage for AI answers\", \"LLM SEO check\", \"why does AI get our product wrong\", \"fix our site for AI Overviews\". Checks fetchability and indexability, answers in the raw HTML, entity facts, schema (including JS-injected markup), headings, dates and llms.txt, then gives at most 10 prioritised fixes and edits the repo when asked. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-ai-readiness-audit\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":57},"01M7DXSZHCVTRS620GC3S97JZV","proxy-troubleshooting","Diagnose residential proxy failures, with NodeMaven's gateway as the reference - 407 with correct credentials, 406, 410, 500, a connection that hangs, ERR_TUNNEL_CONNECTION_FAILED in a browser, Playwright or Puppeteer ignoring proxy credentials, a sticky session that changes IP, geo-targeting that is silently ignored, passwords with special characters, and unexpected traffic from headless Chrome. Use when a proxy connection fails, returns the wrong location, or costs more traffic than expected.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fproxy-troubleshooting\u002FSKILL.md",[],[]]