Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion transforms/images/apply-flatfield-tool/.bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.0.1
current_version = 2.0.2-dev0
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<dev>\d+))?
Expand Down
7 changes: 3 additions & 4 deletions transforms/images/apply-flatfield-tool/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand All @@ -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"]
2 changes: 1 addition & 1 deletion transforms/images/apply-flatfield-tool/README.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion transforms/images/apply-flatfield-tool/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.1
2.0.2-dev0
4 changes: 2 additions & 2 deletions transforms/images/apply-flatfield-tool/plugin.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"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)",
"institution": "National Center for Advancing Translational Sciences, National Institutes of Health",
"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",
Expand Down
13 changes: 6 additions & 7 deletions transforms/images/apply-flatfield-tool/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <nicholas.schaub@nih.gov>",
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from . import utils
from .apply_flatfield import apply

__version__ = "2.0.1"
__version__ = "2.0.2-dev0"
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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))]
Expand All @@ -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()
3 changes: 3 additions & 0 deletions transforms/images/apply-flatfield-tool/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.