1010# local modules
1111
1212pg .mkQApp ()
13- pg .setConfigOption ('imageAxisOrder' , 'col -major' )
13+ pg .setConfigOption ('imageAxisOrder' , 'row -major' )
1414
1515base_path = Path (__file__ ).parent
1616file_path = (base_path / "image_analysis_gui.ui" ).resolve ()
@@ -36,8 +36,9 @@ def __init__(self):
3636 self .imv = pg .ImageView ()
3737 self .imv .getView ().setAspectLocked (lock = False , ratio = 1 )
3838 self .imv .getView ().setMouseEnabled (x = True , y = True )
39- self .imv .getView ().invertY (False )
39+ # self.imv.getView().invertY(False)
4040 self .roi = self .imv .roi
41+
4142 self .roi .translateSnap = True
4243 self .roi .scaleSnap = True
4344 self .update_camera () #initialize camera pixel size
@@ -62,7 +63,7 @@ def load_image(self):
6263 try :
6364 file = QtWidgets .QFileDialog .getOpenFileName (self , 'Open file' , os .getcwd ())
6465 self .original_image = Image .open (file [0 ])
65- self .original_image = self .original_image .rotate (- 90 , expand = True ) #correct image orientation
66+ # self.original_image = self.original_image.rotate(-90, expand=True) #correct image orientation
6667 self .resize_to_scaling_factor (self .original_image )
6768 except Exception as err :
6869 print (format (err ))
@@ -73,18 +74,29 @@ def resize_to_scaling_factor(self, image):
7374 """
7475 self .update_camera () #initialize camera pixel size
7576 self .update_scaling_factor () #initialize scaling_factor
76- image = image .resize ((round (image .size [0 ]* self .scaling_factor ), round (image .size [1 ]* self .scaling_factor )))
77+
78+ if self .ui .pixera_radioButton .isChecked ():
79+ image = self .original_image
80+ elif self .ui .spot_radioButton .isChecked ():
81+ image = self .original_image .resize ((round (image .size [0 ]* self .scaling_factor ), round (image .size [1 ]* self .scaling_factor )))
82+
7783 if self .ui .greyscale_checkBox .isChecked ():
7884 image = image .convert ("L" ) #convert to greyscale
79- image_array = np .array (image )
8085
86+ image_array = np .array (image )
8187 width = image_array .shape [0 ]
8288 height = image_array .shape [1 ]
89+ if self .ui .pixera_radioButton .isChecked ():
90+ width = width * self .scaling_factor
91+ height = height * self .scaling_factor
92+
8393 try :
84- x_vals = np .arange (width ) #imv x-axis
94+ x_vals = np .arange (width )
8595 self .imv .setImage (image_array , xvals = x_vals )
86- self .roi .setPos ((0 ,0 ))
87- self .roi .setSize ([width , self .camera_pixel_size ])
96+
97+ roi_height = self .scaling_factor * height
98+ self .roi .setPos ((0 ,height - roi_height ))
99+ self .roi .setSize ([width , roi_height ])
88100
89101 scale = pg .ScaleBar (size = 1 ,suffix = 'um' )
90102 scale .setParentItem (self .imv .view )
@@ -151,8 +163,10 @@ def switch_custom_pixel_size(self):
151163 def update_camera (self ):
152164 if self .ui .spot_radioButton .isChecked ():
153165 self .camera_pixel_size = 7.4
166+ self .ui .greyscale_checkBox .setChecked (False )
154167 elif self .ui .pixera_radioButton .isChecked ():
155168 self .camera_pixel_size = 3
169+ self .ui .greyscale_checkBox .setChecked (True )
156170
157171 def close_application (self ):
158172 choice = QtGui .QMessageBox .question (self , 'EXIT!' ,
0 commit comments