Page History
...
Mask Editor is developed as a part of the integrated data processing environment for XCS time correlation experiments. In this project the Mask Editor is integrated as one of the system GUIs. Also it can be executed as a stand-alone application named med
. Stand-alone version of the Mask Editor can launched on any of psana
or psexport
node using command-line interface, for example, for all default parameters:
Code Block |
---|
sit_setup
med
|
List of optional parameters
...
In order to interactively communicate between the Mask Editor and other application(s) Marcin Sikorski requested to introduce the file exchange mechanism for image and mask. It is assumed that external event processing application periodically supplies averaged image, Mask Editor can load it and use for interactive ROI mask correction, and submit in response the mask, which will be used by the external application. This asynchronous data exchange mechanism was implemented in CorAna.ArrFileExchange class. Data exchange is implemented for This algorithm uses numpy arrays using with np.save(fname,arr)
and arr=np.load(fname)
methods. In order to get rid of collisions between reader and writer the "ring-buffer" (a.k.a. "round-robin") exchange mechanism is implemented. Data producer writes files with names numerated enumerated in the ring buffer. During writing data is saved in the file with temporary name. When the file is written, it is renamed to indexed name. This eliminates probability of the read/write collision. Data consumer checks availability of the new data and loads numpy array from the latest file if necessary.
Interface for class CorAna.ArrFileExchange
Code Block |
---|
#----------------------- # code in array producer #----------------------- afe = ArrFileExchange(prefix='./my-numpy-arr') # one call per object arr = ... # supply array here afe.save_arr(arr) # as many times as you need #----------------------- # code in array consumer #----------------------- afe = ArrFileExchange(prefix='./my-numpy-arr') # one call per object arr = afe.get_arr_latest() # as many times as you need # optional methodsmethod: status = afe.is_new_arr_available() # returns True/False if the new array IS/IS NOT available # since last call to arr = afe.get_arr_latest() |
...
med -f -i work/my-roi-img -m work/my-roi-mask,
assuming that path to the file directory work/
already exists. Options in this example brings new provide functionality as follows;
...
External application may communicate with launched med through the code pattern shown below
Code Block |
---|
from CorAna.ArrFileExchange import * ... # create reader/writer objects with file name prefixes # exactly like in the med command line for opposite party: afe_rd = ArrFileExchange(prefix='work/my-roi-mask') afe_wr = ArrFileExchange(prefix='work/my-roi-img') ... # image writer image = np.array(...) # supply numpy array for image afe_wr.save_arr(image) # image writer ... # mask reader if afe_rd.is_new_arr_available() : # check that the new data is available mask = afe_rd.get_arr_latest() # mask reader |
...
then, click on buttons "Load Image", "Save Mask", or "Save Inv-M" in the MaskEditor GUI.
Demonstration of features
Plots for
Image exchange with psana
The CorAna.ArrFileExchange
s file exchange algorithm is used in psana module imgalgos.image_save_in_file to generate image files within ring buffer.
Other file browser application
In addition to med, there is a file/image browsing application plims, which options can be seen by the command
plims -h
Code Block |
---|
[pyimgalgos.image_save_in_file]
source = DetInfo(MecTargetChamber.0:Cspad2x2.3)
key_in = cspad2x2_image
ofname = ./roi-img
mode = 3
delay_sec = 1
print_bits = 255 |
Demonstration of features
Plots for
- Input image
- Image with drawn forms on it
- Image for mask with forms on it
- Image for
- Input image
- Image with drawn forms on it
- Image for mask with forms on it
- Image for inversed mask with forms on it
- Help window
References
- imgalgos.image_save_in_file- ring-buffer image source in psana
plims -h
- Image browsing application