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"
)
A list of subjectIDdate values, where each entry is in the format "subjectID-date" (e.g., "12345-20220101").
The root directory where the subject and date folders are stored.
The modality folder to search for images (e.g., "MRI", "CT").
The file extension to search for (default is "png").
The name of the output zip file (default is "images.zip").
Invisibly returns the name of the zip file that was created. If no images are found, the function stops with an error.
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")
} # }