python-bioformats icon indicating copy to clipboard operation
python-bioformats copied to clipboard

Is bioformats.OMEXML.set_image_count() implemented correctly?

Open alam-shahul opened this issue 5 years ago • 0 comments

Forgive me if I'm not understanding how it's supposed to work, but it seems that this line might not be implemented correctly?

Shouldn't it be

image_nodes = root.findall(qn(self.ns['ome'], "Image"))

instead of

image_nodes = root.find(qn(self.ns['ome'], "Image"))

I'm pasting the relevant function here, as well:

 def set_image_count(self, value):
        '''Add or remove image nodes as needed'''
        assert value > 0
        root = self.root_node
        if self.image_count > value:
            image_nodes = root.find(qn(self.ns['ome'], "Image"))
            for image_node in image_nodes[value:]:
                root.remove(image_node)
        while(self.image_count < value):
            new_image = self.Image(ElementTree.SubElement(root, qn(self.ns['ome'], "Image")))
            new_image.ID = str(uuid.uuid4())
            new_image.Name = "default.png"
            new_image.AcquisitionDate = xsd_now()
            new_pixels = self.Pixels(
                ElementTree.SubElement(new_image.node, qn(self.ns['ome'], "Pixels")))
            new_pixels.ID = str(uuid.uuid4())
            new_pixels.DimensionOrder = DO_XYCTZ
            new_pixels.PixelType = PT_UINT8
            new_pixels.SizeC = 1
            new_pixels.SizeT = 1
            new_pixels.SizeX = 512
            new_pixels.SizeY = 512
            new_pixels.SizeZ = 1
            new_channel = self.Channel(
                ElementTree.SubElement(new_pixels.node, qn(self.ns['ome'], "Channel")))
            new_channel.ID = "Channel%d:0" % self.image_count
            new_channel.Name = new_channel.ID
            new_channel.SamplesPerPixel = 1

alam-shahul avatar Jul 23 '20 05:07 alam-shahul