Skip to contents

Calls the bundled Python pipeline, performs dish detection and SmallUNet segmentation on each image, and returns a grayleafspot_run object with tidy results and template plots.

Usage

grayleafspot_analyze(
  input_dir,
  output_dir = "outputs",
  filenames = NULL,
  plate_diameter_mm = 90,
  run_name = NULL,
  save_outputs = TRUE,
  verbose = TRUE,
  python = NULL,
  engine_model = "localunet"
)

Arguments

input_dir

Character. Path to the folder containing plate images (JPEG, PNG, BMP, TIFF, or WEBP). Images must include a day token in their filename (e.g. *_d04_* for day 4).

output_dir

Character. Base output directory. A timestamped sub-folder is created for each run. Defaults to "outputs".

filenames

Optional character vector. Names of specific image files inside input_dir to analyze. If NULL, all supported images are processed.

plate_diameter_mm

Numeric. Known petri dish diameter in mm (default 90).

run_name

Optional character. Human-readable suffix appended to the timestamped run folder name.

save_outputs

Logical. If FALSE, outputs are written to a temporary directory and deleted after the results are returned.

verbose

Logical. Print the saved run path to the console.

python

Optional character. Advanced override: path to a specific Python executable. Overrides GRAYLEAFSPOTR_PYTHON and basilisk.

engine_model

Character. Must be "localunet".

Value

A grayleafspot_run S3 object with elements $run (manifest metadata), $results (per-image data frame), and $raw_results.

Details

Python dependencies are managed automatically through basilisk. No manual Python environment setup is required for normal use. The first call will download and configure the required packages (this may take a few minutes on a fresh installation). Subsequent calls use the cached environment.

Developers who maintain a local Python environment can bypass basilisk by setting the GRAYLEAFSPOTR_PYTHON environment variable to the path of their Python interpreter; this is not required for normal users.

See also

grayleafspot_run() for a simpler entry point returning raw JSON.

Examples

# \donttest{
  img_dir <- system.file("extdata", "testdata", "06FEB", package = "grayleafspotr")
  run <- grayleafspot_analyze(img_dir, output_dir = tempdir())
#> Installing pyenv ...
#> Done! pyenv has been installed to '/home/runner/.local/share/r-reticulate/pyenv/bin/pyenv'.
#> Using Python: /home/runner/.pyenv/versions/3.12.10/bin/python3.12
#> Creating virtual environment '/home/runner/.cache/R/basilisk/1.24.0/grayleafspotr/0.99.2/grayleafspotr_env_v1' ... 
#> + /home/runner/.pyenv/versions/3.12.10/bin/python3.12 -m venv /home/runner/.cache/R/basilisk/1.24.0/grayleafspotr/0.99.2/grayleafspotr_env_v1
#> Done!
#> Installing packages: pip, wheel, setuptools
#> + /home/runner/.cache/R/basilisk/1.24.0/grayleafspotr/0.99.2/grayleafspotr_env_v1/bin/python -m pip install --upgrade pip wheel setuptools
#> Installing packages: 'numpy==2.4.4', 'opencv-python==4.13.0.92', 'pillow==12.2.0', 'scipy==1.17.1', 'scikit-image==0.26.0', 'torch==2.11.0', 'torchvision==0.26.0', 'python-dotenv==1.2.2'
#> + /home/runner/.cache/R/basilisk/1.24.0/grayleafspotr/0.99.2/grayleafspotr_env_v1/bin/python -m pip install --upgrade --no-user 'numpy==2.4.4' 'opencv-python==4.13.0.92' 'pillow==12.2.0' 'scipy==1.17.1' 'scikit-image==0.26.0' 'torch==2.11.0' 'torchvision==0.26.0' 'python-dotenv==1.2.2'
#> Virtual environment '/home/runner/.cache/R/basilisk/1.24.0/grayleafspotr/0.99.2/grayleafspotr_env_v1' successfully created.
#> Saved run to: /tmp/Rtmp8FI5om/20260609T004018Z_localunet
# }