@@ -180,32 +180,41 @@ def _make_default_grid(self):
180180 )
181181
182182 def _get_position_coords (self ):
183- row_max = 0
184- col_max = 0
185- coords_list = []
183+ """Get the position coordinates from the reader metadata.
184+
185+ Raises:
186+ ValueError: If stage positions are not available.
187+
188+ Returns:
189+ list: XY stage position coordinates.
190+ int: Number of grid rows.
191+ int: Number of grid columns.
192+ """
193+ rows = set ()
194+ cols = set ()
195+ xy_coords = []
186196
187- # TODO: read rows, cols directly from XY corods
188197 # TODO: account for non MM2gamma meta?
189198 if not self .reader .stage_positions :
190199 raise ValueError ("Stage positions not available." )
191200 for idx , pos in enumerate (self .reader .stage_positions ):
192- stage_pos = pos .get ("XYStage" ) or pos .get ("XY" )
201+ stage_pos = (
202+ pos .get ("XYStage" ) or pos .get ("XY" ) or pos .get ("XY Stage" )
203+ )
193204 if stage_pos is None :
194205 raise ValueError (
195206 f"Stage position is not available for position { idx } "
196207 )
197- coords_list .append (stage_pos )
208+ xy_coords .append (stage_pos )
198209 try :
199- row = pos ["GridRow" ]
200- col = pos ["GridCol" ]
210+ rows . add ( pos ["GridRow" ])
211+ cols . add ( pos ["GridCol" ])
201212 except KeyError :
202213 raise ValueError (
203214 f"Grid indices not available for position { idx } "
204215 )
205- row_max = row if row > row_max else row_max
206- col_max = col if col > col_max else col_max
207216
208- return coords_list , row_max + 1 , col_max + 1
217+ return xy_coords , len ( rows ), len ( cols )
209218
210219 def _get_pos_names (self ):
211220 """Append a list of pos names in ascending order
0 commit comments