Skip to content

Commit

Permalink
Merge branch 'main' into dev/multi-page-tiff
Browse files Browse the repository at this point in the history
  • Loading branch information
urubens committed Mar 25, 2022
2 parents 43a8a0b + ff15fb8 commit d1efbaf
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 26 deletions.
4 changes: 2 additions & 2 deletions pims/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 6 additions & 0 deletions pims/api/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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):
Expand All @@ -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)
}
)

Expand Down
15 changes: 8 additions & 7 deletions pims/formats/common/ometiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
32 changes: 17 additions & 15 deletions pims/importer/listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
)
)
Expand Down
4 changes: 2 additions & 2 deletions scripts/plugin-list.csv
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d1efbaf

Please sign in to comment.