Main Content

downloadCellposeModels

Download pretrained models from Cellpose Library

Since R2023b

Description

example

downloadCellposeModels downloads all of the pretrained models available in the Cellpose Library to the userpath folder, within the subfolder cellposeModels, on your local machine. Downloading models from the Cellpose Library requires an internet connection.

downloadCellposeModels(Name=Value) specifies options using one or more name-value arguments. For example, Models=["cyto","cyto2","nuclei"] specifies to download only the cyto, cyto2, and nuclei models.

Note

This functionality requires Deep Learning Toolbox™, Computer Vision Toolbox™, and the Medical Imaging Toolbox™ Interface for Cellpose Library. You can install the Medical Imaging Toolbox Interface for Cellpose Library from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

Examples

collapse all

Download the cyto, cyto2, and nuclei models from the Cellpose Library. By default, downloadCellposeModels downloads all versions of each model to use as an ensemble.

downloadCellposeModels(Models=["cyto","cyto2","nuclei"],ModelFolder="C:\cellposeModels")
Downloading "cytotorch_0" from www.cellpose.org to "C:\cellposeModels\cytotorch_0".
Downloading "cytotorch_1" from www.cellpose.org to "C:\cellposeModels\cytotorch_1".
Downloading "cytotorch_2" from www.cellpose.org to "C:\cellposeModels\cytotorch_2".
Downloading "cytotorch_3" from www.cellpose.org to "C:\cellposeModels\cytotorch_3".
Downloading "cyto2torch_0" from www.cellpose.org to "C:\cellposeModels\cyto2torch_0".
Downloading "cyto2torch_1" from www.cellpose.org to "C:\cellposeModels\cyto2torch_1".
Downloading "cyto2torch_2" from www.cellpose.org to "C:\cellposeModels\cyto2torch_2".
Downloading "cyto2torch_3" from www.cellpose.org to "C:\cellposeModels\cyto2torch_3".
Downloading "nucleitorch_0" from www.cellpose.org to "C:\cellposeModels\nucleitorch_0".
Downloading "nucleitorch_1" from www.cellpose.org to "C:\cellposeModels\nucleitorch_1".
Downloading "nucleitorch_2" from www.cellpose.org to "C:\cellposeModels\nucleitorch_2".
Downloading "nucleitorch_3" from www.cellpose.org to "C:\cellposeModels\nucleitorch_3".

If you try to download a model that already exists in the model folder, then the function does not download the model, and warns you that it already exists.

downloadCellposeModels(Models=["cyto"],ModelFolder="C:\cellposeModels")
Warning: Model already exists: "C:\cellposeModels\cytotorch_0". 
> In downloadCellposeModels (line 67) 
Warning: Model already exists: "C:\cellposeModels\cytotorch_1". 
> In downloadCellposeModels (line 67) 
Warning: Model already exists: "C:\cellposeModels\cytotorch_2". 
> In downloadCellposeModels (line 67) 
Warning: Model already exists: "C:\cellposeModels\cytotorch_3". 
> In downloadCellposeModels (line 67) 

To download a new copy of the model, save it to a new model folder.

downloadCellposeModels(Models=["cyto"],ModelFolder="C:\cellposeModels_v2")
Downloading "cytotorch_0" from www.cellpose.org to "C:\cellposeModels_v2\cytotorch_0".
Downloading "cytotorch_1" from www.cellpose.org to "C:\cellposeModels_v2\cytotorch_1".
Downloading "cytotorch_2" from www.cellpose.org to "C:\cellposeModels_v2\cytotorch_2".
Downloading "cytotorch_3" from www.cellpose.org to "C:\cellposeModels_v2\cytotorch_3". 

Input Arguments

collapse all

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: downloadCellposeModels(Models=["cyto" "cyto2" "nuclei"]) downloads the cyto, cyto2, and nuclei models.

Models to download, specified as a string array containing one or more of these strings. By default, the function downloads all models. To learn more about the pretrained models and their training data, see the Cellpose Library Documentation.

  • "cyto"

  • "cyto2"

  • "CP"

  • "CPx"

  • "nuclei"

  • "livecell"

  • "LC1"

  • "LC2"

  • "LC3"

  • "LC4"

  • "tissuenet"

  • "TN1"

  • "TN2"

  • "TN3"

Example: ["cyto","cyto2","nuclei"]

Data Types: string

Model folder path, specified as a string scalar or character vector that contains the full path to the folder to save the models in. By default, ModelFolder is the subfolder cellposeModels within the folder returned by the userpath function.

Data Types: char | string

Download model ensembles, specified as a numeric or logical 1 (true) or 0 (false). For some pretrained models, including cyto, cyto2, and nuclei, the Cellpose Library offers multiple versions that have been trained using different initial parameter values. Set this argument to true to download all versions of a model.

Data Types: logical

References

[1] Stringer, Carsen, Tim Wang, Michalis Michaelos, and Marius Pachitariu. “Cellpose: A Generalist Algorithm for Cellular Segmentation.” Nature Methods 18, no. 1 (January 2021): 100–106. https://doi.org/10.1038/s41592-020-01018-x.

[2] Pachitariu, Marius, and Carsen Stringer. “Cellpose 2.0: How to Train Your Own Model.” Nature Methods 19, no. 12 (December 2022): 1634–41. https://doi.org/10.1038/s41592-022-01663-4.

Version History

Introduced in R2023b