diff --git a/pims/__version__.py b/pims/__version__.py index c444c42..5eacbbf 100644 --- a/pims/__version__.py +++ b/pims/__version__.py @@ -16,8 +16,8 @@ # KEEP ENCODING - so that __version__ can be read even if py2.7 is used. -VERSION = (0, 10, 2) -API_VERSION = (0, 9, 0) +VERSION = (0, 11, 0) +API_VERSION = (0, 11, 0) __title__ = 'pims' __description__ = 'Cytomine Python Image Server' diff --git a/pims/api/metadata.py b/pims/api/metadata.py index 405f1cb..cbe5b20 100644 --- a/pims/api/metadata.py +++ b/pims/api/metadata.py @@ -38,6 +38,7 @@ from pims.files.file import FileRole, FileType, Path from pims.formats.utils.structures.metadata import MetadataType from pims.processing.image_response import AssociatedResponse +from pims.utils.dtypes import dtype_to_bits router = APIRouter() api_tags = ['Metadata'] @@ -205,6 +206,10 @@ class ImageInfo(BaseModel): ..., description='The number of bits within the type storing each pixel that are significant.', ) + bits: conint(ge=1) = Field( + ..., + description='The number of bits used by the type storing each pixel.' + ) @classmethod def from_image(cls, image): @@ -229,6 +234,7 @@ def from_image(cls, image): "description": image.description, "pixel_type": PixelType[str(image.pixel_type)], "significant_bits": image.significant_bits, + "bits": dtype_to_bits(image.pixel_type) } ) diff --git a/pims/formats/common/ometiff.py b/pims/formats/common/ometiff.py index 5773ceb..66e15eb 100644 --- a/pims/formats/common/ometiff.py +++ b/pims/formats/common/ometiff.py @@ -246,16 +246,17 @@ def parse_main_metadata(self) -> ImageMetadata: # information is already extracted. break - colors = [infer_channel_color( - parse_int(attr.get('Color')), - cc_idx, - shape[axes.index('C')] - )] * spp - - if spp == 3 and colors[0] is None: + if spp == 3: + # If RGB channel, Color attribute is ignored (Icy behavior) colors = [ infer_channel_color(None, i, 3) for i in range(spp) ] + else: + colors = [infer_channel_color( + parse_int(attr.get('Color')), + cc_idx, + shape[axes.index('C')] + )] * spp names = [attr.get('Name')] * spp if names[0] is None: diff --git a/pims/importer/listeners.py b/pims/importer/listeners.py index e0ee2b4..ff6d9d2 100644 --- a/pims/importer/listeners.py +++ b/pims/importer/listeners.py @@ -413,13 +413,8 @@ def end_successful_import(self, path: Path, image: Image, *args, **kwargs): # Cytomine "channels" = number of concrete channels ai.channels = image.n_concrete_channels - # Cytomine "extrinsicChannels" = number of channels - # (n_concrete_channels * n_samples) - ai.extrinsicChannels = image.n_channels - # Cytomine "samplePerPixel" = number of samples - ai.samplePerPixel = image.n_samples - # Cytomine "bitPerSample" = number of bits to store a sample - ai.bitPerSample = dtype_to_bits(image.pixel_type) + ai.samples = image.n_samples + ai.bits = dtype_to_bits(image.pixel_type) if image.physical_size_x: ai.physicalSizeX = round( @@ -443,19 +438,26 @@ def end_successful_import(self, path: Path, image: Image, *args, **kwargs): self.abstract_images.append(ai) asc = AbstractSliceCollection() - set_channel_names = image.n_concrete_channels == image.n_channels - for c in range(image.n_concrete_channels): - name = None - color = None - if set_channel_names: - name = image.channels[c].suggested_name - color = image.channels[c].hex_color + for cc in range(image.n_concrete_channels): + first_c = cc * image.n_samples + + name = image.channels[first_c].suggested_name + color = image.channels[first_c].hex_color + if image.n_samples != 1: + names = [ + image.channels[i].suggested_name + for i in range(first_c, first_c + image.n_samples) + ] + names = list(dict.fromkeys(names)) # ordered uniqueness + name = '|'.join(names) + color = None + for z in range(image.depth): for t in range(image.duration): mime = "image/pyrtiff" # TODO: remove asc.append( AbstractSlice( - ai.id, uf.id, mime, c, z, t, + ai.id, uf.id, mime, cc, z, t, channelName=name, channelColor=color ) ) diff --git a/scripts/plugin-list.csv b/scripts/plugin-list.csv index eea09ea..8377b76 100644 --- a/scripts/plugin-list.csv +++ b/scripts/plugin-list.csv @@ -1,3 +1,3 @@ enabled,name,git_url,git_branch -1,pims-plugin-format-openslide,https://github.com/Cytomine-ULiege/pims-plugin-format-openslide.git,0851dca4ed92bab33ae30200a86ce8e56c655a71 -1,pims-plugin-format-bioformats,https://github.com/Cytomine-ULiege/pims-plugin-format-bioformats.git,c25da92ccf706834adf12e3e0d9fd1362e793c48 +1,pims-plugin-format-openslide,https://github.com/Cytomine-ULiege/pims-plugin-format-openslide.git,5f8a92e37d2a47145f0b375db541b591490361bc +1,pims-plugin-format-bioformats,https://github.com/Cytomine-ULiege/pims-plugin-format-bioformats.git,f67580116ff21cc994a3d9cfe25c98bd4aaffef9