-
Hi all, I have a CZI file from which I want to extract the barcode number from the metadata. I managed to save the metadata as a XML file with the following code: from bioio import BioImage
img = BioImage("my_image.czi")
import xml.etree.ElementTree as ET
print(ET.ElementTree(img.metadata).write("the_metadata.xml")) And I can open the XML file with a text editor, and searching for "Barcode" leads to several matches among which I can find the relevant data: ET.ElementTree(img.metadata).find("barcode") Unfortunately, it returns Any help is appreciated. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I have written a function that seems to work for me. def extract_barcode(metadata):
barcode_element = metadata.find("Metadata/AttachmentInfos/AttachmentInfo/Label/Barcodes/Barcode/Content")
if barcode_element is None:
barcode = None
else:
barcode = barcode_element.text.split(" ")[-1]
return barcode The function above can be used like so: from bioio import BioImage
img = BioImage("my_image.czi")
print(extract_barcode(img.metadata) In my case, I only have a single or no barcode in the metadata. The barcode is in the |
Beta Was this translation helpful? Give feedback.
I have written a function that seems to work for me.
The function above can be used like so:
In my case, I only have a single or no barcode in the metadata. The barcode is in the
content
element:Metadata/AttachmentInfos/AttachmentInfo/Label/Barcodes/Barcode/Content
. Thetext
of thecontent
element is formatted as "lef…