Skip to content

DTYPE not properly parsed [NotImplemented] #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ggirelli opened this issue Nov 9, 2020 · 2 comments
Open

DTYPE not properly parsed [NotImplemented] #44

ggirelli opened this issue Nov 9, 2020 · 2 comments
Milestone

Comments

@ggirelli
Copy link
Contributor

ggirelli commented Nov 9, 2020

See here.

@rbnvrw rbnvrw added this to the Version 3.3.1 milestone Nov 10, 2021
@rbnvrw
Copy link
Member

rbnvrw commented Nov 10, 2021

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).

@ggirelli
Copy link
Contributor Author

ggirelli commented Nov 11, 2021

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants