Skip to content

DTYPE not properly parsed [NotImplemented] #44

Description

@ggirelli

See here.

Activity

  1. added this to the Version 3.3.1 milestone on Nov 10, 2021
  2. rbnvrw commented on Nov 10, 2021

    @rbnvrw
    Member

    Thank you for your report @ggirelli and sorry for the late reply.
    Do you have a suggestion on how to implement this? Otherwise I'll decide what to do with it before the next release (either try to decide from the metadata or leave it as-is).

  3. ggirelli commented on Nov 11, 2021

    @ggirelli
    ContributorAuthor

    So, the Parser._raw_metadata.SLxImageAttributes.ePixelType tag seems to match the SampleFormat TIFFTag. Hence, possible values should be:

    1 = unsigned integer data
    2 = two's complement signed integer data
    3 = IEEE floating point data
    4 = undefined data format
    

    We can combine this with the bits per pixel from the Parser.SLxImageAttributes.uiBpcInMemory tag to build a dtype compatible with numpy. How about something like:

    def propose_dtype(parser) -> str:
        bits_per_pixel = parser._raw_metadata.image_attributes[
                six.b("SLxImageAttributes")][six.b("uiBpcInMemory")]
        pixel_type_tag = parser._raw_metadata.image_attributes[
                six.b("SLxImageAttributes")][six.b("ePixelType")]
    
        dtype_base: DefaultDict = defaultdict(lambda: "float")
        dtype_base[1] = "uint"
        dtype_base[2] = "int"
    
        proposed_dtype = f"{dtype_base[pixel_type_tag]}{bits_per_pixel}"
    
        supported_dtypes = ("uint8", "uint16", "uint32",
                            "int8", "int16", "int32",
                            "float8", "float16", "float32")
        return "float64" if proposed_dtype not in supported_dtypes else proposed_dtype

    Hope this makes sense 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions