@@ -414,6 +414,22 @@ def num_images(self):
414414 else :
415415 return pe_in .num_images
416416
417+ def get_pixel_type (self , bits ):
418+ '''get the OME-XML pixel type string from the bits per pixel'''
419+ if bits == 8 :
420+ return 'uint8'
421+ elif bits == 16 :
422+ return 'uint16'
423+ raise ValueError ("Allocated bits not supported: %d" % bits )
424+
425+ def get_data_type (self , bits ):
426+ '''get numpy data type from bits per pixel'''
427+ if bits == 8 :
428+ return np .uint8
429+ elif bits == 16 :
430+ return np .uint16
431+ raise ValueError ("Allocated bits not supported: %d" % bits )
432+
417433 def wait_any (self , regions ):
418434 if self .sdk_v1 :
419435 return self .pixel_engine .waitAny (regions )
@@ -487,7 +503,7 @@ def write_metadata_xml(self, metadata_file):
487503 'pixels' : {
488504 'sizeX' : int (self .size_x ),
489505 'sizeY' : int (self .size_y ),
490- 'type' : get_pixel_type (int (self .bits_per_pixel )),
506+ 'type' : self . get_pixel_type (int (self .bits_per_pixel )),
491507 'bits_stored' : int (self .significant_bits ),
492508 'physicalSizeX' : self .pixel_size_x ,
493509 'physicalSizeY' : self .pixel_size_y
@@ -525,22 +541,6 @@ def write_metadata(self):
525541 )
526542 self .write_metadata_xml (metadata_file )
527543
528- def get_pixel_type (bits ):
529- '''get the OME-XML pixel type string from the bits per pixel'''
530- if bits == 8 :
531- return 'uint8'
532- elif bits == 16 :
533- return 'uint16'
534- raise ValueError ("Allocated bits not supported: %d" % bits )
535-
536- def get_data_type (bits ):
537- '''get numpy data type from bits per pixel'''
538- if bits == 8 :
539- return numpy .uint8
540- elif bits == 16 :
541- return numpy .uint16
542- raise ValueError ("Allocated bits not supported: %d" % bits )
543-
544544 def get_size (self , dim_range ):
545545 '''calculate the length in pixels of a dimension'''
546546 v = (dim_range [2 ] - dim_range [0 ]) / dim_range [1 ]
@@ -612,7 +612,7 @@ def create_tile_directory(self, series, resolution, width, height):
612612 "%s/%s" % (str (series ), str (resolution )),
613613 shape = (1 , 3 , 1 , height , width ),
614614 chunks = (1 , 1 , 1 , self .tile_height , self .tile_width ),
615- dtype = get_data_type (self .bits_per_pixel )
615+ dtype = self . get_data_type (self .bits_per_pixel )
616616 )
617617
618618 def make_planar (self , pixels , tile_width , tile_height ):
@@ -740,7 +740,7 @@ def write_tile(
740740 pixel_buffer_size = width * height * 3
741741 pixels = np .empty (
742742 pixel_buffer_size ,
743- dtype = get_data_type (self .bits_per_pixel )
743+ dtype = self . get_data_type (self .bits_per_pixel )
744744 )
745745 patch_id = patch_ids .pop (regions .index (region ))
746746 x_start , y_start = patch_id
0 commit comments