diff --git a/active_plugins/runcellpose.py b/active_plugins/runcellpose.py index 29d76c9..fcbbefc 100644 --- a/active_plugins/runcellpose.py +++ b/active_plugins/runcellpose.py @@ -61,13 +61,13 @@ You can run this module using Cellpose installed to the same Python environment as CellProfiler. See our documentation at https://plugins.cellprofiler.org/runcellpose.html for more information on installation. -Alternatively, you can run this module using Cellpose in a Docker that the module will automatically download for you so you do not have to perform any installation yourself. +Alternatively, you can run this module using Cellpose in a Docker or Podman container that the module will automatically download for you so you do not have to perform any installation yourself. On the first time loading into CellProfiler, Cellpose will need to download some model files from the internet. This may take some time. If you want to use a GPU to run the model, you'll need a compatible version of PyTorch and a supported GPU. Instructions are avaiable at this link: {CUDA_LINK} -Note that RunCellpose supports the Cellpose 3 functionality of using image restoration models to improve the input images before segmentation for both Docker and Python methods. +Note that RunCellpose supports the Cellpose 3 functionality of using image restoration models to improve the input images before segmentation for both container and Python methods. However, it only supports saving out or visualizing the intermediate restored images when using the Python method. Stringer, C., Wang, T., Michaelos, M. et al. Cellpose: a generalist algorithm for cellular segmentation. Nat Methods 18, 100–106 (2021). {Cellpose_link} @@ -137,19 +137,20 @@ def create_settings(self): text="Rescale images before running Cellpose", value=True, doc="""\ -Reminds the user that the normalization step will be performed to ensure suimilar segmentation behaviour in the RunCellpose +Reminds the user that the normalization step will be performed to ensure similar segmentation behaviour in the RunCellpose module and the Cellpose app. """ ) self.docker_or_python = Choice( - text="Run CellPose in docker or local python environment", - choices=["Docker", "Python"], + text="Run CellPose in a Docker/Podman container or local python environment", + choices=["Docker", "Podman", "Python"], value="Docker", doc="""\ If Docker is selected, ensure that Docker Desktop is open and running on your -computer. On first run of the RunCellpose plugin, the Docker container will be +computer; likewise for Podman, ensure Podman Desktop is running. On first run +of the RunCellpose plugin, the Docker container will be downloaded. However, this slow downloading process will only have to happen once. @@ -539,7 +540,7 @@ def visible_settings(self): if self.cellpose_version.value == 'omnipose': vis_settings += [self.omni] - if self.docker_or_python.value == "Docker": + if self.docker_or_python.value in ["Docker","Podman"]: if self.cellpose_version.value == 'omnipose': vis_settings += [self.docker_image_omnipose] elif self.cellpose_version.value == 'v2': @@ -936,9 +937,12 @@ def run(self, workspace): if self.remove_edge_masks: y_data = utils.remove_edge_masks(y_data) - elif self.docker_or_python.value == "Docker": - # Define how to call docker - docker_path = "docker" if sys.platform.lower().startswith("win") else "/usr/local/bin/docker" + else: + if self.docker_or_python.value == "Docker": + # Define how to call docker + docker_path = "docker" if sys.platform.lower().startswith("win") else "/usr/local/bin/docker" + else: + docker_path = "podman" if sys.platform.lower().startswith("win") else "/opt/podman/bin/podman" # Create a UUID for this run unique_name = str(uuid.uuid4()) # Directory that will be used to pass images to the docker container @@ -1021,7 +1025,7 @@ def run(self, workspace): workspace.display_data.denoised_image = denoised_image if self.save_probabilities.value: - if self.docker_or_python.value == "Docker": + if self.docker_or_python.value in ["Docker", "Podman"]: # get rid of extra dimension prob_map = numpy.squeeze(flows[1], axis=0) # ranges 0-255 else: diff --git a/active_plugins/runilastik.py b/active_plugins/runilastik.py index 8f5499d..f26d88c 100644 --- a/active_plugins/runilastik.py +++ b/active_plugins/runilastik.py @@ -82,12 +82,13 @@ def create_settings(self): super(Runilastik, self).create_settings() self.docker_or_local = Choice( - text="Run ilastik in docker or local environment", - choices=["Docker", "Local"], + text="Run ilastik in a container (Docker or Podman) or local environment", + choices=["Docker", "Podman", "Local"], value="Docker", doc="""\ If Docker is selected, ensure that Docker Desktop is open and running on your -computer. On first run of the Runilastik plugin, the Docker container will be +computer; likewise for Podman, ensure Podman Desktop is running. On first run +of the Runilastik plugin, the Docker container will be downloaded. However, this slow downloading process will only have to happen once. @@ -165,7 +166,7 @@ def settings(self): def visible_settings(self): vis_settings = [self.docker_or_local] - if self.docker_or_local.value == "Docker": + if self.docker_or_local.value in ["Docker","Podman"]: vis_settings += [self.docker_choice] if self.docker_choice == "select your own": @@ -225,9 +226,27 @@ def run(self, workspace): fout.close() - if self.docker_or_local.value == "Docker": - # Define how to call docker - docker_path = "docker" if sys.platform.lower().startswith("win") else "/usr/local/bin/docker" + if self.docker_or_local.value == "Local": + + if self.executable.value[-4:] == ".app": + executable = os.path.join(self.executable.value, "Contents/MacOS/ilastik") + else: + executable = self.executable.value + + fout_name = fout.name + fin_name = fin.name + + cmd = [ + executable, + "--headless", + "--project", self.project_file.value] + + else: + if self.docker_or_local.value == "Docker": + # Define how to call docker + docker_path = "docker" if sys.platform.lower().startswith("win") else "/usr/local/bin/docker" + else: + docker_path = "podman" if sys.platform.lower().startswith("win") else "/opt/podman/bin/podman" # The project file is stored in a directory which can be pointed to the docker model_file = self.project_file.value model_directory = os.path.dirname(os.path.abspath(model_file)) @@ -250,21 +269,6 @@ def run(self, workspace): "--project", f"/model/{os.path.basename(model_file)}" ] - if self.docker_or_local.value == "Local": - - if self.executable.value[-4:] == ".app": - executable = os.path.join(self.executable.value, "Contents/MacOS/ilastik") - else: - executable = self.executable.value - - fout_name = fout.name - fin_name = fin.name - - cmd = [ - executable, - "--headless", - "--project", self.project_file.value] - cmd += ["--output_format", "hdf5"]