@@ -407,14 +407,22 @@ def _load_image(
407407 data = imread (path , ** imread_kwargs )
408408 if len (data .shape ) == 4 :
409409 # this happens for the cytassist, hires and lowres images; the umi image doesn't need processing
410- data = data .squeeze (). transpose ( 2 , 0 , 1 )
410+ data = data .squeeze ()
411411 else :
412412 if "MAX_IMAGE_PIXELS" in imread_kwargs :
413413 from PIL import Image as ImagePIL
414414
415415 ImagePIL .MAX_IMAGE_PIXELS = dict (imread_kwargs ).pop ("MAX_IMAGE_PIXELS" )
416416 # dask_image doesn't recognize .btf automatically and imageio v3 throws error due to pixel limit -> use imageio v2
417- data = imread2 (path , ** imread_kwargs ).squeeze ().transpose (2 , 0 , 1 )
417+ data = imread2 (path , ** imread_kwargs ).squeeze ()
418+
419+ if data .shape [- 1 ] == 3 : # HE image in RGB format
420+ data = data .transpose (2 , 0 , 1 )
421+ else :
422+ assert data .shape [0 ] == min (
423+ data .shape
424+ ), "When the image is not in RGB, the first dimension should be the number of channels."
425+
418426 image = DataArray (data , dims = ("c" , "y" , "x" ))
419427 parsed = Image2DModel .parse (image , scale_factors = scale_factors , rgb = None , ** image_models_kwargs )
420428 images [dataset_id + suffix ] = parsed
0 commit comments