@@ -674,10 +674,10 @@ def level_change(self, r):
674674 if self .loaded :
675675 sval = self .sliders [r ].value ()
676676 self .saturation [r ][self .currentZ ] = sval
677- if not self .autobtn .isChecked ():
678- for r in range (3 ):
679- for i in range (len (self .saturation [r ])):
680- self .saturation [r ][i ] = self .saturation [r ][self .currentZ ]
677+ # if not self.autobtn.isChecked():
678+ for r in range (3 ):
679+ for i in range (len (self .saturation [r ])):
680+ self .saturation [r ][i ] = self .saturation [r ][self .currentZ ]
681681 self .update_plot ()
682682
683683 def keyPressEvent (self , event ):
@@ -834,8 +834,7 @@ def enable_buttons(self):
834834 def disable_buttons_removeROIs (self ):
835835 if len (self .model_strings ) > 0 :
836836 self .ModelButtonC .setEnabled (False )
837- for i in range (len (self .StyleButtons )):
838- self .StyleButtons [i ].setEnabled (False )
837+ self .ModelButtonB .setEnabled (False )
839838 self .newmodel .setEnabled (False )
840839 self .loadMasks .setEnabled (False )
841840 self .saveSet .setEnabled (False )
@@ -1485,14 +1484,11 @@ def update_plot(self):
14851484 if self .color == 'rgb' :
14861485 self .img .setImage (image , autoLevels = False , lut = None )
14871486 if self .nchan > 1 :
1488- levels = np .array ([
1489- self .saturation [0 ][self .currentZ ],
1490- self .saturation [1 ][self .currentZ ],
1491- self .saturation [2 ][self .currentZ ]
1492- ])
1493- self .img .setLevels (levels )
1494- else :
1495- self .img .setLevels (self .saturation [0 ][self .currentZ ])
1487+ levels = np .array ([self .saturation [r ][self .currentZ ] for r in range (image .shape [- 1 ])])
1488+ else :
1489+ levels = self .saturation [0 ][self .currentZ ]
1490+ self .img .setLevels (levels )
1491+
14961492 elif self .color in rgb_list :
14971493 color_index = rgb_list .index (self .color )
14981494 if self .nchan > 1 :
@@ -1505,6 +1501,7 @@ def update_plot(self):
15051501 elif self .color == 'gray' :
15061502 if self .nchan > 1 :
15071503 # exclude channels with no data:
1504+ # TODO: save this when computing saturation
15081505 ranges = np .ptp (image , tuple (range (image .ndim - 1 )))
15091506 range_mask = ranges > 1e-5
15101507 image = image [..., range_mask ]
@@ -1881,12 +1878,30 @@ def compute_saturation(self, return_img=False):
18811878 else :
18821879 for n in range (self .NZ ):
18831880 self .saturation [- 1 ].append ([0 , 255. ])
1884- print (self .saturation [2 ][self .currentZ ])
1885-
1886- if img_norm .shape [- 1 ] == 1 :
1887- self .saturation .append (self .saturation [0 ])
1888- self .saturation .append (self .saturation [0 ])
1889-
1881+
1882+ elif len (self .saturation ) == 0 or len (self .saturation [0 ]) != self .NZ :
1883+ self .saturation = []
1884+ for r in range (3 ):
1885+ self .saturation .append ([])
1886+ for n in range (self .NZ ):
1887+ self .saturation [- 1 ].append ([0 , 255 ])
1888+
1889+ if img_norm .shape [- 1 ] == 1 :
1890+ if len (self .saturation ) > 1 :
1891+ self .saturation = [self .saturation [0 ]]
1892+ self .saturation .append (self .saturation [0 ])
1893+ self .saturation .append (self .saturation [0 ])
1894+ else :
1895+ self .saturation = [copy .deepcopy (self .saturation [r ]) for r in range (img_norm .shape [- 1 ])]
1896+ if len (self .saturation ) == 2 :
1897+ self .saturation .append ([])
1898+ for n in range (self .NZ ):
1899+ self .saturation [- 1 ].append ([0 , 255 ])
1900+
1901+ self .sliders [0 ].setValue (self .saturation [0 ][self .currentZ ])
1902+ self .sliders [1 ].setValue (self .saturation [1 ][self .currentZ ])
1903+ self .sliders [2 ].setValue (self .saturation [2 ][self .currentZ ])
1904+ # print(len(self.saturation), len(self.saturation[0]))
18901905
18911906 def get_model_path (self , custom = False ):
18921907 if custom :
0 commit comments