@@ -36,3 +36,39 @@ function writexlsx(filename::AbstractString, seg::SegmentedImage)
3636 spotdict, stimulus = spots (seg)
3737 writexlsx (filename, spotdict, stimulus, imgsize)
3838end
39+
40+ """
41+ process_images(outfile::AbstractString, glob::GlobMatch; dirname=pwd())
42+ process_images(outfile::AbstractString, glob::AbstractString; dirname=pwd())
43+
44+ Process all images with filenames matching `glob` and save the results to `outfile`.
45+ Each image will be a separate sheet in the Excel file.
46+
47+ Optionally specify the `dirname` containing the images.
48+
49+ # Examples
50+
51+ To process a collection of images in a different directory, and save the results to
52+ that same directory:
53+
54+ ```julia
55+ julia> process_images("2025-03-15/results.xlsx", glob"*.png"; dirname="2025-03-15")
56+ ```
57+ """
58+ function process_images (outfile:: AbstractString , glob:: Glob.GlobMatch ; dirname= pwd ())
59+ i = 0
60+ XLSX. openxlsx (outfile; mode= " w" ) do xf
61+ for filename in readdir (glob, dirname)
62+ img = load (filename)
63+ seg = segment_image (img)
64+ imgsize = size (labels_map (seg))
65+ spotdict, stimulus = spots (seg)
66+ sheetname = splitext (basename (filename))[1 ]
67+ sheet = xf[i+= 1 ]
68+ XLSX. rename! (sheet, sheetname)
69+ makesheet! (sheet, spotdict, stimulus, imgsize)
70+ end
71+ end
72+ end
73+ process_images (outfile:: AbstractString , glob:: AbstractString ; kwargs... ) =
74+ process_images (outfile, Glob. GlobMatch (glob); kwargs... )
0 commit comments