swectral.make_roi_func#
- swectral.make_roi_func(func, name_suffix='roi_only', *fixed_args, **fixed_kwargs)[source]#
Create a function from the given function that accepts only image path and region of interest (ROI) coordinates, fixing other parameters.
- Parameters:
- func
callable() Original function with signature
func(image_path, roi_coordinates, *args, **kwargs).- name_suffix
str,optional The name suffix for the output function, default is
"roi_only".- ``*fixed_args``
Positional arguments to fix.
- ``**fixed_kwargs``
Keyword arguments to fix.
- func
- Returns:
callable()A function that accepts only image path and ROI coordinates.
- Return type:
Examples
Suppose the original function is used as follows:
>>> roi_spectra_array = roi_processing_function( ... "/image1.tif", [[(0, 0), (0, 10), (10, 0), (0, 0)]], param1=1, param2=2)
A version that only requires image path and ROI coordinates is created as follows:
>>> func_accept_img_roi = make_roi_func(roi_processing_function, param1=1, param2=2)
Usage of the modified function:
>>> roi_spectra_array = func_accept_img_roi("/image1.tif", [[(0, 0), (0, 10), (10, 0), (0, 0)]])