55import cv2
66import numpy as np
77import scipy .interpolate
8- from tqdm import tqdm
8+ from tqdm . auto import tqdm
99import matplotlib .pyplot as plt
1010
1111from .util import FR_Module
@@ -144,7 +144,20 @@ def __init__(
144144 )
145145 self .set_point_positions (point_positions ) if point_positions is not None else None
146146
147+ self ._fill_config_runInfo_runData (
148+ path_file = self ._path_file ,
149+ coords_rois = self .roi_points ,
150+ point_positions = self .point_positions ,
151+ mask_images = self .mask_images ,
152+ )
147153
154+ def _fill_config_runInfo_runData (
155+ self ,
156+ path_file = None ,
157+ coords_rois = None ,
158+ point_positions = None ,
159+ mask_images = None ,
160+ ):
148161 ## For FR_Module compatibility
149162 self .config = {
150163 "select_mode" : self ._select_mode ,
@@ -164,8 +177,6 @@ def __init__(
164177 "point_positions" : self .point_positions ,
165178 "exampleImage" : self .exampleImage ,
166179 }
167- # ## Append the self.run_info data to self.run_data
168- # self.run_data.update(self.run_info)
169180
170181 def make_points (self , rois , point_spacing = 10 ):
171182 """
@@ -329,8 +340,34 @@ def plot_rois(self, image=None, **kwargs_imshow):
329340 ## show figure
330341 plt .show ()
331342 return fig , ax
343+
344+ def fliplr (self ):
345+ """
346+ Flip the ROIs left-right. In place
347+ """
348+ if hasattr (self , 'exampleImage' ):
349+ if self .exampleImage is not None :
350+ self .exampleImage = np .fliplr (self .exampleImage )
332351
333-
352+ if hasattr (self , 'mask_images' ):
353+ if self .mask_images is not None :
354+ self .mask_images = {k : np .fliplr (m ) for k , m in self .mask_images .items ()}
355+
356+ if hasattr (self , 'roi_points' ):
357+ if self .roi_points is not None :
358+ for k , p in self .roi_points .items ():
359+ self .roi_points [k ][:, 0 ] = self .img_hw [1 ] - p [:, 0 ]
360+
361+ if hasattr (self , 'point_positions' ):
362+ if self .point_positions is not None :
363+ self .point_positions [:, 0 ] = self .img_hw [1 ] - self .point_positions [:, 0 ]
364+
365+ self ._fill_config_runInfo_runData (
366+ path_file = self ._path_file ,
367+ coords_rois = self .roi_points ,
368+ point_positions = self .point_positions ,
369+ mask_images = self .mask_images ,
370+ )
334371
335372class _Select_ROI :
336373 """
0 commit comments