This function collects image files from subfolders based on a list of subject-date IDs and zips them into a single archive. The user specifies the root directory, the modality folder, and the file extension. The zip file name is also user-defined.

collect_and_zip_images(
  subjectIDdate_list,
  root_path,
  modality,
  extension = "png",
  zip_filename = "images.zip"
)

Arguments

subjectIDdate_list

A list of subjectIDdate values, where each entry is in the format "subjectID-date" (e.g., "12345-20220101").

root_path

The root directory where the subject and date folders are stored.

modality

The modality folder to search for images (e.g., "MRI", "CT").

extension

The file extension to search for (default is "png").

zip_filename

The name of the output zip file (default is "images.zip").

Value

Invisibly returns the name of the zip file that was created. If no images are found, the function stops with an error.

Examples

if (FALSE) { # \dontrun{
# Example usage:
subjectIDdate_list <- c("121771-20220818", "42444-20210507", "56789-20210429")
root_path <- "/path/to/images"
modality <- "MRI"
zip_file <- collect_and_zip_images(subjectIDdate_list, root_path, modality, "png", "collected_images.zip")
} # }