zeiss-microscopy / libCZI

Open Source Cross-Platform C++ library to read CZI image files
GNU General Public License v3.0
71 stars 19 forks source link

Reading Attachments #51

Closed edswangren closed 3 years ago

edswangren commented 3 years ago

Newer versions of ZEN embed the scan profile name as an attachment

<AttachmentInfos>
 <AttachmentInfo Id="Label:1">
  <Label>
   <Barcodes>
    <Barcode Id="Barcode:1">
     <Type>Type: DataMatrix
lue: 071140J
ientation: Top To Bottom
gle: 94.080002
ror Correction Level: 0
m Errors Corrected: 0
mension: 12x12
Type>
     <Content>071140J</Content>
    </Barcode>
   </Barcodes>
   <OCRs>
    <OCR Id="OCR:1">
     <Content />
    </OCR>
   </OCRs>
  </Label>
  <Profile>
   <ProfileName>Matsunami_10X_ER_CLC_v1.0.0.czspf</ProfileName>
   <IsProfileModified>False</IsProfileModified>
  </Profile>
 </AttachmentInfo>
</AttachmentInfos>

I'm not sure how I'm expected to read the value Matsunami_10X_ER_CLC_v1.0.0.czspf. I can find the attachment itself no problem, but ReadAttachment returns a ~37KB blob (!). It says the file type is "Zip-Comp", but it sure doesn't appear to be a zip archive, and why would it be?

reader->EnumerateSubset(nullptr, "Profile", [&](int index, const libCZI::AttachmentInfo& info)->bool {  
    auto attachment = reader->ReadAttachment(index);
    size_t sz = 0;
    auto data = attachment->GetRawData(&sz);
        // do stuff

    return false;       
});

The docs aren't clear here (just auto generated stuff). All I want is the ProfileName value. It appears as though these chunks of XML are just pointers to an actual file in the CZI, but really... I just want that metadata.

I realize that I can parse the XML myself, but is there a nicer/more robust way to extract the data here? You'd think it would come with the attachment info object, but I don't see it.

Just out of curiosity... If I use cziCMD to extract the attachment it adds a Zip-Comp extension. What is a Zip-Comp file?!