@@ -59,20 +59,28 @@ def __init__(self, **config):
5959 pass
6060
6161 def analyze_image (
62- self , image : Union [Array1D , Array2D ], auxiliary_data : Optional [dict ] = None
62+ self ,
63+ image : Union [Array1D , Array2D , list [Array1D ], list [Array2D ]],
64+ auxiliary_data : Optional [dict ] = None ,
6365 ) -> ImageAnalyzerResult :
64- """Calculate metrics from an image.
66+ """Calculate metrics from an image or list of images .
6567
6668 This function should be implemented by each device's ImageAnalyzer subclass,
6769 to run on an image from that device (obviously).
6870
6971 Should take full-size (i.e. uncropped) image.
7072
73+ For multi-device analyzers (e.g. multi-camera diagnostics), a list of
74+ arrays may be passed — one per device. The analyzer is responsible for
75+ combining them as needed and returning a single result.
76+
7177 Parameters
7278 ----------
73- image : 2d array (e.g. MxN) or standard y vs x data (eg. Nx2)
74- auxiliary_data : dict
75- Additional data used by the image image_analyzer for this image, such as
79+ image : Union[Array1D, Array2D, list[Array1D], list[Array2D]]
80+ A single 2D array (e.g. MxN), a single 1D dataset (e.g. Nx2),
81+ or a list of such arrays for multi-device analysis.
82+ auxiliary_data : dict, optional
83+ Additional data used by the image analyzer for this image, such as
7684 image range.
7785
7886 Returns
@@ -84,16 +92,23 @@ def analyze_image(
8492 raise NotImplementedError ()
8593
8694 def analyze_image_file (
87- self , image_filepath : Path , auxiliary_data : Optional [dict ] = None
95+ self ,
96+ image_filepath : Union [Path , list [Path ]],
97+ auxiliary_data : Optional [dict ] = None ,
8898 ) -> ImageAnalyzerResult :
8999 """
90- Method to enable the use of a file path rather than Array2D.
100+ Method to enable the use of a file path (or list of paths) rather than arrays.
101+
102+ For multi-device analyzers, a list of file paths can be passed — one
103+ per device. The paths are loaded via :meth:`load_image` and the
104+ resulting array(s) are passed to :meth:`analyze_image`.
91105
92106 Parameters
93107 ----------
94- image_filepath : Path
95- auxiliary_data : dict
96- Additional data used by the image image_analyzer for this image, such as
108+ image_filepath : Union[Path, list[Path]]
109+ A single file path or a list of file paths for multi-device analysis.
110+ auxiliary_data : dict, optional
111+ Additional data used by the image analyzer for this image, such as
97112 image range.
98113
99114 Returns
@@ -106,23 +121,34 @@ def analyze_image_file(
106121
107122 return self .analyze_image (image , auxiliary_data )
108123
109- def load_image (self , file_path : Path ) -> Union [Array1D , Array2D ]:
124+ def load_image (
125+ self , file_path : Union [Path , list [Path ]]
126+ ) -> Union [Array1D , Array2D , list [Union [Array1D , Array2D ]]]:
110127 """
111- Load an image from a path.
128+ Load an image from a path, or multiple images from a list of paths .
112129
113- By default, the read_imaq_png function is used.
114- For file types not directly supported by this method, e.g. .himg files from a
115- Haso device type, this method be implemented in that device's ImageAnalyzer
116- subclass.
130+ When given a single path, loads and returns a single array using
131+ :func:`read_imaq_image` (or subclass override).
132+
133+ When given a list of paths, recursively calls ``self.load_image`` on
134+ each path and returns a list of arrays. This means subclasses that
135+ override ``load_image`` for custom file formats (e.g. ``.himg``)
136+ automatically get list support for free.
117137
118138 Parameters
119139 ----------
120- file_path : Path
140+ file_path : Union[Path, list[Path]]
141+ A single file path or a list of file paths for multi-device loading.
121142
122143 Returns
123144 -------
124- image : Union[Array1D,Array2D]
145+ Union[Array1D, Array2D, list[Union[Array1D, Array2D]]]
146+ A single array for a single path, or a list of arrays for a list
147+ of paths.
125148 """
149+ if isinstance (file_path , list ):
150+ return [self .load_image (p ) for p in file_path ]
151+
126152 image = read_imaq_image (file_path )
127153
128154 return image
0 commit comments