diff --git a/transforms/images/apply-flatfield-tool/.bumpversion.cfg b/transforms/images/apply-flatfield-tool/.bumpversion.cfg index a2f2fd1cf..7e04619e2 100644 --- a/transforms/images/apply-flatfield-tool/.bumpversion.cfg +++ b/transforms/images/apply-flatfield-tool/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.0.1 +current_version = 2.0.2-dev0 commit = False tag = False parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\-(?P[a-z]+)(?P\d+))? diff --git a/transforms/images/apply-flatfield-tool/Dockerfile b/transforms/images/apply-flatfield-tool/Dockerfile index b05d29200..e78052878 100644 --- a/transforms/images/apply-flatfield-tool/Dockerfile +++ b/transforms/images/apply-flatfield-tool/Dockerfile @@ -1,4 +1,4 @@ -FROM polusai/bfio:2.3.3 +FROM python:3.13-slim # environment variables defined in polusai/bfio ENV EXEC_DIR="/opt/executables" @@ -9,7 +9,7 @@ ENV POLUS_LOG="INFO" # Work directory defined in the base container WORKDIR ${EXEC_DIR} -# TODO: Change the tool_dir to the tool directory + ENV TOOL_DIR="transforms/images/apply-flatfield-tool" # Copy the repository into the container @@ -19,7 +19,6 @@ COPY . ${EXEC_DIR}/image-tools # Install the tool RUN pip3 install "${EXEC_DIR}/image-tools/${TOOL_DIR}" --no-cache-dir -# Set the entrypoint -# TODO: Change the entrypoint to the tool entrypoint + ENTRYPOINT ["python3", "-m", "polus.images.transforms.images.apply_flatfield"] CMD ["--help"] diff --git a/transforms/images/apply-flatfield-tool/README.md b/transforms/images/apply-flatfield-tool/README.md index c2ce5d8b9..bbf07e16a 100644 --- a/transforms/images/apply-flatfield-tool/README.md +++ b/transforms/images/apply-flatfield-tool/README.md @@ -1,4 +1,4 @@ -# Apply Flatfield Plugin (v2.0.1) +# Apply Flatfield Plugin (v2.0.2-dev0) This WIPP plugin applies a flatfield operation on every image in a collection. The algorithm used to apply the flatfield is as follows: diff --git a/transforms/images/apply-flatfield-tool/VERSION b/transforms/images/apply-flatfield-tool/VERSION index 38f77a65b..7e0cb63a1 100644 --- a/transforms/images/apply-flatfield-tool/VERSION +++ b/transforms/images/apply-flatfield-tool/VERSION @@ -1 +1 @@ -2.0.1 +2.0.2-dev0 diff --git a/transforms/images/apply-flatfield-tool/plugin.json b/transforms/images/apply-flatfield-tool/plugin.json index 60a1bafda..0b7197e80 100644 --- a/transforms/images/apply-flatfield-tool/plugin.json +++ b/transforms/images/apply-flatfield-tool/plugin.json @@ -1,6 +1,6 @@ { "name": "Apply Flatfield", - "version": "2.0.1", + "version": "2.0.2-dev0", "title": "Apply Flatfield", "description": "Apply a flatfield algorithm to a collection of images.", "author": "Nick Schaub (Nick.Schaub@nih.gov), Najib Ishaq (najib.ishaq@nih.gov)", @@ -8,7 +8,7 @@ "repository": "https://github.com/labshare/polus-plugins", "website": "https://ncats.nih.gov/preclinical/core/informatics", "citation": "", - "containerId": "polusai/apply-flatfield-tool:2.0.1", + "containerId": "polusai/apply-flatfield-tool:2.0.2-dev0", "baseCommand": [ "python3", "-m", diff --git a/transforms/images/apply-flatfield-tool/pyproject.toml b/transforms/images/apply-flatfield-tool/pyproject.toml index cf82fd99d..b831b3e24 100644 --- a/transforms/images/apply-flatfield-tool/pyproject.toml +++ b/transforms/images/apply-flatfield-tool/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "polus-images-transforms-images-apply-flatfield" -version = "2.0.1" +version = "2.0.2-dev0" description = "" authors = [ "Nick Schaub ", @@ -10,13 +10,12 @@ readme = "README.md" packages = [{include = "polus", from = "src"}] [tool.poetry.dependencies] -python = ">=3.9,<3.12" -bfio = { version = "^2.3.3", extras = ["all"] } -filepattern = "2.0.4" -typer = { version = "^0.7.0", extras = ["all"] } -numpy = "^1.24.3" +python = ">=3.12" +bfio = ">=2.5.0" +filepattern = ">=2.1.4" +typer = ">=0.24.0" +numpy = ">=2.4.3" tqdm = "^4.65.0" -preadator = "0.4.0-dev2" [tool.poetry.group.dev.dependencies] bump2version = "^1.0.1" diff --git a/transforms/images/apply-flatfield-tool/src/polus/images/transforms/images/apply_flatfield/__init__.py b/transforms/images/apply-flatfield-tool/src/polus/images/transforms/images/apply_flatfield/__init__.py index ab03b2528..4f95c94cd 100644 --- a/transforms/images/apply-flatfield-tool/src/polus/images/transforms/images/apply_flatfield/__init__.py +++ b/transforms/images/apply-flatfield-tool/src/polus/images/transforms/images/apply_flatfield/__init__.py @@ -3,4 +3,4 @@ from . import utils from .apply_flatfield import apply -__version__ = "2.0.1" +__version__ = "2.0.2-dev0" diff --git a/transforms/images/apply-flatfield-tool/src/polus/images/transforms/images/apply_flatfield/apply_flatfield.py b/transforms/images/apply-flatfield-tool/src/polus/images/transforms/images/apply_flatfield/apply_flatfield.py index d81ef71da..86bc1fc69 100644 --- a/transforms/images/apply-flatfield-tool/src/polus/images/transforms/images/apply_flatfield/apply_flatfield.py +++ b/transforms/images/apply-flatfield-tool/src/polus/images/transforms/images/apply_flatfield/apply_flatfield.py @@ -4,10 +4,10 @@ import operator import pathlib import typing +from concurrent.futures import ProcessPoolExecutor import bfio import numpy -import preadator import tqdm from filepattern import FilePattern @@ -145,18 +145,14 @@ def _unshade_batch( df_image: component to be used for flatfield correction """ # Load images - with preadator.ProcessManager( - name="unshade_batch::load", - num_processes=utils.MAX_WORKERS, - threads_per_process=2, - ) as load_executor: + with ProcessPoolExecutor(max_workers=utils.MAX_WORKERS) as load_executor: load_futures = [] for i, inp_path in enumerate(batch_paths): load_futures.append( - load_executor.submit_process(utils.load_img, inp_path, i), + load_executor.submit(utils.load_img, inp_path, i), ) - load_executor.join_processes() + [f.result() for f in load_futures] images = [f.result() for f in load_futures] images = [img for _, img in sorted(images, key=operator.itemgetter(0))] @@ -169,11 +165,10 @@ def _unshade_batch( img_stack /= ff_image + 1e-8 # Save outputs - with preadator.ProcessManager( - name="unshade_batch::save", - num_processes=utils.MAX_WORKERS, - threads_per_process=2, - ) as save_executor: + with ProcessPoolExecutor(max_workers=utils.MAX_WORKERS) as save_executor: for inp_path, img in zip(batch_paths, img_stack): - save_executor.submit_process(utils.save_img, inp_path, img, out_dir) - save_executor.join_processes() + save_futures = [ + save_executor.submit(utils.save_img, inp_path, img, out_dir), + ] + for f in save_futures: + f.result() diff --git a/transforms/images/apply-flatfield-tool/uv.lock b/transforms/images/apply-flatfield-tool/uv.lock new file mode 100644 index 000000000..bda020730 --- /dev/null +++ b/transforms/images/apply-flatfield-tool/uv.lock @@ -0,0 +1,3 @@ +version = 1 +revision = 3 +requires-python = ">=3.13"