Skip to content
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

fix z ordering issue #53

Closed
wants to merge 1 commit into from
Closed

Conversation

AlanWu886
Copy link

Here is the reasoning for the proposed change from the original post:
I tried to line 647 in reader.py from:

                if 3 in dims_dict.keys() and len(dims) > 2:
                    channels = item.findall("./Data/Image/ImageDescription/"
                                            "Channels/ChannelDescription")
                    channel_max = sum([int(c.attrib["BytesInc"]) for c in channels])

                    bytes_inc_channel = channel_max
                    cytes_inc_z = int(dims[2].attrib["BytesInc"])

                    channel_as_second_dim = bytes_inc_channel > cytes_inc_z

                else:
                    channel_as_second_dim = False

to:

                if 3 in dims_dict.keys() and len(dims) > 2:
                    channels = item.findall("./Data/Image/ImageDescription/"
                                            "Channels/ChannelDescription")
                    channel_max = sum([int(c.attrib["BytesInc"]) for c in channels])

                    bytes_inc_channel = channel_max
                    cytes_inc_z = int(dims[2].attrib["BytesInc"])

                    channel_as_second_dim = bytes_inc_channel < cytes_inc_z

                else:
                    channel_as_second_dim = False

To tell whether channel is the second dimension, the original code tries to do so by comparing the "byte jump" ("BytesInc" attribute of channels) to the "BytesInc" of z dimension.
In my humble opinion, I feel it is more reasonable to tell by checking the value of "BytesInc" of z dimension. In my case, both the x and y axis size are 1024 pixels with 16 bits depth. With "BytesInc" of z dimension being 12582912 (1024 * 1024 * 2 * 6) I feel channel should not be the second dimension...

         <dimensions>
          <dimensiondescription bitinc="0" bytesinc="2" dimid="1" length="9.226190e-05" numberofelements="1024" 
              origin="1.376765e-20" unit="m">
          </dimensiondescription>
          <dimensiondescription bitinc="0" bytesinc="2048" dimid="2" length="9.226190e-05" numberofelements="1024" 
              origin="1.376765e-20" unit="m">
          </dimensiondescription>
          <dimensiondescription bitinc="0" bytesinc="12582912" dimid="3" length="1.799585e-06" numberofelements="7" 
              origin="-6.220585e-06" unit="m">
          </dimensiondescription>
         </dimensions>

The original comment is here: #44 (comment)
I have tested with couples of images I have and results turned out to be correct it seemed.
If possible, would you please do perform a more extensive test before the merge?

Thanks a lot!
Alan

@AlanWu886 AlanWu886 closed this May 13, 2024
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

Successfully merging this pull request may close these issues.

1 participant