Package: cellpose-omni-acdc
Cellpose backend for Omnipose in Cell-ACDCThis is a fork of the Cellpose used by Omnipose where we removed GUI dependencies toallow installation of Omnipose into Cell-ACDC.
See below the original README.Cellpose backend for OmniposeThis fork of Cellpose continues the generalizations first introduced by Omnipose. Because Omnipose will not be incorporated into Cellpose 2.0, this fork will continue to be maintained by the author of Omnipose (@kevinjohncutler), with the current goal of updating to support Cellpose 2.0 when it is released and if it shows substantial improvements. For now, I will be providing addtional updates and bugfixes based on Cellpose 1.0 from January 2022. This fork will remain backwards-compatible with Cellpose. See the main Cellpose repo for basic Cellpose usage, and the Omnipose repo for Omnipose-specific settings.The main generalization introduced in this fork is true 3D segmentation - that is, direct prediction of 3D flow field as opposed to merging flow components from 2D predictions. Use the--dimflag to specify whether or not you want to train/evaluate on 2D or 3D volumes.As training 3D models are for more resource-intensive, the code has also been somewhat optimized for multi-GPU training. The main branch of Cellpose cannot use multiple GPUs, but this branch can. We have tested this only on AWS instances.The GUI has also been greatly improved with bugfixes and additional features. The most important new feature is the ability to easily copy the parameters for replicating the GUI results in a Jupyter Notebook. This work is ongoing.Future GUI goals:optional parameter output in CLI format (not just function API for python scripts)time lapse stack handling3D Omnipose optionsadd boundary output for visualizationallow gamma and percentile range to be segmentation parameters (just for visualization now)give in to my OCD around GUI elements and make it prettierThis version of the GUI defaults to Omnipose parameters and models.Run cellpose without local python installationYou can quickly try out Cellpose on thewebsitefirst (some features disabled).You can also run Cellpose in google colab with a GPU:a code-based notebook:a more user-friendly notebook for 2D segmentation written by@pr4deepr:a user-friendlyZeroCostDL4Micnotebook that includes training cellpose models, written by@guijacquemet:The colab notebooks are recommended if you have issues with MKL or run speed on your local computer (and are running 3D volumes). Colab does not allow you to run the GUI, but you can save*_seg.npyfiles in colab that you can download and open in the GUI.Executable file: You can download an executable file forWindows 10or forMac OS(High Sierra or greater) that were made using PyInstaller on Intel processors (MKL acceleration works, but no GPU support). Note in both cases it will take a few seconds to open.TheMac OSfile will download ascellpose_macORcellpose_mac.dms. You will need to make it into an executable file and run it through the terminal:Open a terminal and runcd ~/Downloads/.Runchmod 777 cellpose_macORchmod 777 cellpose_mac.dmsto make the file executable.Run./cellpose_macOR./cellpose_mac.dmsto open the cellpose GUI. Messages from cellpose will be printed in the terminal.You can also run using the command line interface, e.g. as./cellpose_mac --dir ~/Pictures/ --chan 2 --save_png.TheWindows 10file is an exe and you can click on it to run the GUI. You can also run using the command line interface, e.g. ascellpose.exe --dir Pictures/ --chan 2 --save_pngDetailed documentation atwww.cellpose.org/docs.System requirementsLinux, Windows and Mac OS are supported for running the code. For running the graphical interface you will need a Mac OS later than Yosemite. At least 8GB of RAM is required to run the software. 16GB-32GB may be required for larger images and 3D volumes. The software has been heavily tested on Windows 10 and Ubuntu 18.04 and less well-tested on Mac OS. Please open an issue if you have problems with installation.Local installationIf you have an oldercellposeenvironment you can remove it withconda env remove -n cellposebefore creating a new one.If you are using a GPU, make sure its drivers and the cuda libraries are correctly installed.Install anAnacondadistribution of Python -- ChoosePython 3.8and your operating system. Note you might need to use an anaconda prompt if you did not add anaconda to the path.Open an anaconda prompt / command prompt withcondaforpython 3in the pathCreate a new environment withconda create --name cellpose python=3.8.To activate this new environment, runconda activate cellposeTo install the minimal version of cellpose, runpython -m pip install cellpose.To install cellpose, omnipose and the GUI, runpython -m pip install cellpose[all]. If you're on a zsh server, you may need to use ' ' around the cellpose[all] call: `python -m pip install 'cellpose[all]'.To upgrade cellpose (packagehere), run the following in the environment:python-mpipinstallcellpose--upgradeNote you will always have to runconda activate cellposebefore you run cellpose. If you want to run jupyter notebooks in this environment, then alsoconda install jupyterandpython -m pip install matplotlib.You can also try to install cellpose, omnipose and the GUI dependencies from your base environment using the commandpython-mpipinstallcellpose[all]If you haveissueswith installation, see thedocsfor more details. You can also use the cellpose environment file included in the repository and create a cellpose environment withconda env create -f environment.ymlwhich may solve certain dependency issues.If these suggestions fail, open an issue.GPU version (CUDA) on Windows or LinuxIf you plan on running many images, you may want to install a GPU version oftorch(if it isn't already installed).Before installing the GPU version, remove the CPU version:pip uninstall torchFollow the instructionshereto determine what version to install. The Anaconda install is strongly recommended, and then choose the CUDA version that is supported by your GPU (newer GPUs may need newer CUDA versions > 10.2). For instance this command will install the 10.2 version on Linux and Windows (note thetorchvisionandtorchaudiocommands are removed because cellpose doesn't require them):conda install pytorch cudatoolkit=10.2 -c pytorchFor the GPU version of mxnet, you will need to install the cuda toolkit first if you haven't already (on Windows it may be necessary to install via anaconda as below):conda install -c anaconda cudatoolkitWhen upgrading GPU Cellpose in the future, you will want to ignore dependencies (to ensure that the pip version of torch does not install):pip install --no-deps cellpose --upgradeInstallation of github versionFollow steps from above to install the dependencies. Then runpip install git+https://www.github.com/mouseland/cellpose.gitIf you want edit ability to the code, in the github repository folder, runpip install -e .. If you want to go back to the pip version of cellpose, then saypip install cellpose.Download of pretrained modelsThe models will be downloaded automatically from thewebsitewhen you first run a pretrained model in cellpose. If you are having issues with the downloads, you can download them from thisgoogle drive zip file, unzip the file and put the models in your home directory under the path .cellpose/models/, e.g. on Windows this would be C:/Users/YOUR_USERNAME/.cellpose/models/ or on Linux this would be /home/YOUR_USERNAME/.cellpose/models/, so /home/YOUR_USERNAME/.cellpose/models/cyto_0 is the full path to one model for example. If you cannot access google drive, the models are also available on baidu: Link：https://pan.baidu.com/s/1CARpRGCBHIYaz7KeyoX-fg; Fetch code：pose ; thanks to @qixinbo!Running cellposeThe quickest way to start is to open the GUI from a command line terminal. You might need to open an anaconda prompt if you did not add anaconda to the path:python -m cellposeThe first time cellpose runs it downloads the latest available trained model weights from the website.You can nowdrag and dropany images (*.tif, *.png, *.jpg, *.gif) into the GUI and run Cellpose, and/or manually segment them. When the GUI is processing, you will see the progress bar fill up and during this time you cannot click on anything in the GUI. For more information about what the GUI is doing you can look at the terminal/prompt you opened the GUI with. For example data, seewebsiteor this google drivefolder. For best accuracy and runtime performance, resize images so cells are less than 100 pixels across.Step-by-step demoDownload the google drivefolderand unzip it. These are a subset of the test images from the paper.Start the GUI withpython -m cellpose.Drag an image from the folder into the GUI.Set the model (in demo all arecyto) and the channel you want to segment (in demo all aregreen). Optionally set the second channel if you are segmentingcytoand have an available nucleus channel.Click thecalibratebutton to estimate the size of the objects in the image. Alternatively you can set thecell diameterby hand and press ENTER. You will see the size you set as a red disk at the bottom left of the image.Click therun segmentationbutton. If MASKS ON is checked, you should see masks drawn on the image.Now you can click the LEFT/RIGHT arrow keys to move through the folder and segment another image.On the demo images each of these steps should run in less than a few seconds on a standard laptop or desktop (with mkl working).3D segmentationFor multi-channel, multi-Z tiff's, the expected format is Z x channels x Ly x Lx.Contributing training dataWe are very excited about receiving community contributions to the training data and re-training the cytoplasm model to make it better. Please follow these guidelines:Run cellpose on your data to see how well it does. Try varying the diameter, which can change results a little.If there are relatively few mistakes, it won't help much to contribute labelled data.If there are consistent mistakes, your data is likely very different from anything in the training set, and you should expect major improvements from contributing even just a few manually segmented images.For images that you contribute, the cells should be at least 10 pixels in diameter, and there should beat leastseveral dozens of cells per image, ideally ~100. If your images are too small, consider combining multiple images into a single big one and then manually segmenting that. If they are too big, consider splitting them into smaller crops.For the manual segmentation, please try to outline the boundaries of the cell, so that everything (membrane, cytoplasm, nucleus) is inside the boundaries. Do not just outline the cytoplasm and exclude the membrane, because that would be inconsistent with our own labelling and we wouldn't be able to use that.Do not use the results of the algorithm in any way to do contributed manual segmentations. This can reinforce a vicious circle of mistakes, and compromise the dataset for further algorithm development.If you are having problems with the nucleus model, please open an issue before contributing data. Nucleus images are generally much less diverse, and we think the current training dataset already covers a very large set of modalities.Using the GUIThe GUI serves two main functions:Running the segmentation algorithm.Manually labelling data.There is a help window in the GUI that provides more instructions and
a page in the documentationhere.
Also, if you hover over certain words in the GUI, their definitions are revealed as tooltips.
Here is a summary of their functions:In a notebookSeerun_cellpose.ipynb.From the command lineRunpython -m cellposeand specify parameters as below. For instance to run on a folder with images where cytoplasm is green and nucleus is blue and save the output as a png:python -m cellpose --dir ~/images_cyto/test/ --pretrained_model cyto --chan 2 --chan2 3 --save_pngYou can specify the diameter for all the images or set to 0 if you want the algorithm to estimate it on an image by image basis. Here is how to run on nuclear data (grayscale) where the diameter is automatically estimated:python -m cellpose --dir ~/images_nuclei/test/ --pretrained_model nuclei --diameter 0. --save_pngSee thedocsfor more info.TimingYou can check if cellpose is running the MKL version (if you are using the CPU not the GPU) by adding the flag--check_mkl. If you are not using MKL cellpose will be much slower. Here are Cellpose run times divided into the time it takes to run the deep neural network (DNN) and the time for postprocessing (gradient tracking, segmentation, quality control etc.). The DNN runtime is shown using either a GPU (Nvidia GTX 1080Ti) or a CPU (Intel 10-core 7900X), with or without network ensembling (4net vs 1net). The postprocessing runtime is similar regardless of ensembling or CPU/GPU version. Runtime is shown for different image sizes, all with a cell diameter of 30 pixels (the average from our training set).256 pix512 pix1024 pixDNN (1net, GPU)0.054 s0.12 s0.31 sDNN (1net, CPU)0.30 s0.65 s2.4 sDNN (4net, GPU)0.23 s0.41 s1.3 sDNN (4net, CPU)1.3 s2.5 s9.1 sPostprocessing (CPU)0.32 s1.2 s6.1 sOutputsSee thedocsfor info.Dependenciescellpose relies on the following excellent packages (which are automatically installed with conda/pip if missing):mxnet_mklpyqtgraphPyQt6numpy(>=1.16.0)numbascipynatsort