@@ -467,10 +467,12 @@ def __init__(self, node: Node) -> None:
467467 LOGGER .debug (f"Plate created with ZarrLocation fmt:{ self .zarr .fmt } " )
468468
469469 self .first_field = "0"
470- self .plate_data = self .get_plate_zarr ().root_attrs .get ("plate" , {})
470+ # For Plate, plate_zarr is same as self.zarr, but for PlateLabels
471+ # (node at /plate.zarr/labels) this is the parent at /plate.zarr node.
472+ self .plate_zarr = self .get_plate_zarr ()
473+ self .plate_data = self .plate_zarr .root_attrs .get ("plate" , {})
471474
472475 LOGGER .info ("plate_data: %s" , self .plate_data )
473- print ("Plate --- self.plate_data --> " , self .plate_data )
474476 self .rows = self .plate_data .get ("rows" )
475477 self .columns = self .plate_data .get ("columns" )
476478 self .row_names = [row ["name" ] for row in self .rows ]
@@ -483,11 +485,10 @@ def __init__(self, node: Node) -> None:
483485 self .column_count = len (self .columns )
484486
485487 img_path = self .get_image_path (self .well_paths [0 ])
486- print ("Plate.__init__ - img_path ------> " , img_path )
487488 if not img_path :
488489 # E.g. PlateLabels subclass has no Labels
489490 return
490- image_zarr = self .get_plate_zarr () .create (img_path )
491+ image_zarr = self .plate_zarr .create (img_path )
491492 # Create a Node for image, with no 'root'
492493 self .first_well_image = Node (image_zarr , [])
493494
@@ -496,7 +497,7 @@ def __init__(self, node: Node) -> None:
496497 # Load possible node data
497498 child_zarr = self .zarr .create ("labels" )
498499 # This is a 'virtual' path to plate.zarr/labels
499- node .add (child_zarr , visibility = False )
500+ node .add (child_zarr )
500501
501502 def get_plate_zarr (self ) -> ZarrLocation :
502503 return self .zarr
@@ -546,7 +547,7 @@ def get_tile(tile_name: str) -> np.ndarray:
546547 LOGGER .debug (f"LOADING tile... { path } with shape: { tile_shape } " )
547548
548549 try :
549- data = self .zarr .load (path )
550+ data = self .plate_zarr .load (path )
550551 except ValueError as e :
551552 LOGGER .error (f"Failed to load { path } " )
552553 LOGGER .debug (f"{ e } " )
@@ -572,15 +573,13 @@ def get_tile(tile_name: str) -> np.ndarray:
572573class PlateLabels (Plate ):
573574 @staticmethod
574575 def matches (zarr : ZarrLocation ) -> bool :
575- print ("PlateLabels matches" , zarr .path )
576576 # If the path ends in plate/labels...
577577 if not zarr .path .endswith ("labels" ):
578578 return False
579579
580580 # and the parent is a plate
581581 path = zarr .path
582582 parent_path = path [: path .rfind ("/" )]
583- print ("parent_path" , parent_path )
584583 parent = zarr .create (parent_path )
585584 return "plate" in parent .root_attrs
586585
@@ -614,27 +613,22 @@ def get_plate_zarr(self) -> ZarrLocation:
614613 path = self .zarr .path
615614 # remove the /labels
616615 parent_path = path [: path .rfind ("/" )]
617- print ("get_plate_zarr parent_path" , parent_path )
618616 return self .zarr .create (parent_path )
619617
620618 def get_image_path (self , well_path : str ) -> Optional [str ]:
621619 """Returns path to .zattr for Well labels, e.g. /A/1/0/labels/my_cells/"""
622620 labels_attrs = self .well_labels_zattrs .get (well_path )
623- print ("PlateLabels get_image_path well_path" , well_path )
624621 if labels_attrs is None :
625622 # if not cached, load...
626623 path = f"{ well_path } /{ self .first_field } /labels/"
627624 LOGGER .info ("loading labels/.zattrs: %s.zattrs" , path )
628- # print("labels_path", path)
629625 plate_zarr = self .get_plate_zarr ()
630- # print("check plate_zarr", plate_zarr.root_attrs.get("plate", {}))
631626 first_field_labels = plate_zarr .create (path )
632- # print("first_field_labels zarr", first_field_labels)
633627 # loads labels/.zattrs when new ZarrLocation is created
634628 labels_attrs = first_field_labels .root_attrs
635- # print("labels_attrs", labels_attrs)
636629 self .well_labels_zattrs [well_path ] = labels_attrs
637630 label_paths = labels_attrs .get ("labels" , [])
631+ LOGGER .debug ("label_paths: %s" , label_paths )
638632 if len (label_paths ) > 0 :
639633 return f"{ well_path } /{ self .first_field } /labels/{ label_paths [0 ]} /"
640634 return None
0 commit comments