Skip to content

Barcode from CZI metadata #44

Closed Answered by Omnistic
Omnistic asked this question in Q&A
Discussion options

You must be logged in to vote

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 content element: Metadata/AttachmentInfos/AttachmentInfo/Label/Barcodes/Barcode/Content. The text of the content element is formatted as "lef…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Omnistic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant