[ome-users] Question about XML annotation file.

Qi Gong qigong at gwmail.gwu.edu
Wed Feb 22 21:19:02 GMT 2017


Hello Sebastien,

Thank you for your reply. Yes, the workflow is correct. In attachment, I
use matlab function "xmlwrite" to generate the xml file. We will also put
the function on GITHUB. I find the problem is that, the xml file is
generated by xmlwrite always has XML encoding tag "<?xml version="1.0"
encoding="UTF-8"?>". It prevents imagescope to load the XML. I have submit
a mathwork ticket. Hope I can get a solution. Thank you again.

Regards,
Qi

On Wed, Feb 22, 2017 at 3:42 PM, Sebastien Besson (Staff) <
s.besson at dundee.ac.uk> wrote:

>
> On 21 Feb 2017, at 16:09, Qi Gong <qigong at gwmail.gwu.edu> wrote:
>
> Hello everyone,
>
>
> Hi Qi
>
> We are using Bio-format to extract ROI from WSI image in Matlab. At the
> same time, we also want to open manufacturer viewer (imagescope) to open
> the WSI image with an annotation of the ROI. We have used matlab to
> generate the XML annotation file. But every time we have to manually use
> imagescope viewer GUI to load the XML file.
>
>
> Let me make sure we get your workflow right:
>
> - WSI images and their ROIs are read inside a MATLAB software using
> Bio-Formats
> - this MATLAB code also annotates the ROI and saves the output as an XML
> file
> - You would like both the WSI image and the annotated ROI to be opened
> jointly by
>   the Imagescope software
>
> Is that a correct representation of your workflow? Out of curiosity, is
> the code doing the
> annotation publicly available?
>
> We want to know, does Bioformat provides a function to use command line to
> apply XML file on WSI image.
>
>
> I assume that applying the XML file on WSI image means formatting your XML
> file in such a way that it can be detected by ImageScope.
>
> Within OME, we certainly have an existing ticket for reading these XML
> files in Bio-Formats [1]. I think this issue is symmetrical to
> to the enquiry you have about writing these files. One of our current
> limitations is that we do not have a proper specification for these
> annotation XML files. Do you happen to know if such a thing exists?
>
> For your use case, a secondary issue is to know how Imagescope detects an
> XML file associated with an WSI image. A simple
> assumption would be that this is based on some naming conventions but
> this would have to be checked with the constructor or
> confirmed by the community.
>
> [1] https://trac.openmicroscopy.org/ome/ticket/10504
>
>
> Is "xmlindent" a potential function? Thank you.
>
>
> I would not think this utility function will be of any help for this
> problem as its main purpose is to indent an existing XML.
>
>
> Regards,
> Qi
>
>
> Best,
> Sebastien
>
>
> --
> mobile phone: 2024060862 <(202)%20406-0862>
> _______________________________________________
> ome-users mailing list
> ome-users at lists.openmicroscopy.org.uk
> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
>
>
>
> The University of Dundee is a registered Scottish Charity, No: SC015096
>
> _______________________________________________
> ome-users mailing list
> ome-users at lists.openmicroscopy.org.uk
> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
>
>


-- 
mobile phone: 2024060862
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-users/attachments/20170222/4977a03c/attachment.html>
-------------- next part --------------
function success = exportXML(fullname,scan_scale, task_id,workdir,Left, Top, roi_w, roi_h)
%EXPORTXML Summary of this function goes here
% process data
try
    success = 0;
    length = 2*(roi_w + roi_h);
    lengthM = length*scan_scale;
    area= roi_w* roi_h;
    areaM= area * scan_scale *scan_scale;
    x1 = Left;
    y1 = Top;
    x2 = Left + roi_w;
    y2 = Top;
    x3 = Left + roi_w;
    y3 = Top + roi_h;
    x4 = Left; 
    y4 = Top + roi_h;
%     y1 = Left;
%     x1 = Top;
%     y2 = Left + roi_w;
%     x2 = Top;
%     y3 = Left + roi_w;
%     x3 = Top + roi_h;
%     y4 = Left; 
%     x4 = Top + roi_h;

  %  indexslash = findstr(fullname, '\');
    indexdot = findstr(fullname, '.');
  %  wsi_name = fullname((indexslash(end)+1):(indexdot(end)-1));
    imageDir = fullname(1:(indexdot(end)-1));
 %   workdir = [workdir, 'Temporary_Task_Images\'];
%     XMLfolder = [workdir, wsi_name,'XML\'];
%     filename = [XMLfolder,task_id,'.xml'];
  %  XMLname = [workdir, wsi_name];
    filename = [imageDir,'.xml'];
%     if isdir(XMLfolder)
%        delete(filename);
%     else
%        mkdir(XMLfolder);
%     end

    % generate xml
    % annotation information
    docNode = com.mathworks.xml.XMLUtils.createDocument('Annotations');
    docRootNode = docNode.getDocumentElement;
    docRootNode.setAttribute('MicronsPerPixel','0.250300');

    
    % image information
    entry_level_info = docNode.createElement('Image_information');
    entry_level_info.setAttribute('Full_path',fullname);
    docNode.getDocumentElement.appendChild(entry_level_info);
    
    entry_level1 = docNode.createElement('Annotation');
    entry_level1.setAttribute('MacroName','');
    entry_level1.setAttribute('MarkupImagePath','');
    entry_level1.setAttribute('Selected','1');
    entry_level1.setAttribute('Visible','1');
    entry_level1.setAttribute('LineColor','65280');
    entry_level1.setAttribute('Type','4');
    entry_level1.setAttribute('Incremental','0');
    entry_level1.setAttribute('LineColorReadOnly','0');
    entry_level1.setAttribute('NameReadOnly','0');
    entry_level1.setAttribute('ReadOnly','0');
    entry_level1.setAttribute('Name','');
    entry_level1.setAttribute('Id','1');
    docNode.getDocumentElement.appendChild(entry_level1);

    entry_level1_1 = docNode.createElement('Attributes');
    entry_level1.appendChild(entry_level1_1);

    entry_level1_1_1 = docNode.createElement('Attribute');
    entry_level1_1_1.setAttribute('Name','Description');
    entry_level1_1_1.setAttribute('Id','0');
    entry_level1_1_1.setAttribute('Value','');
    entry_level1_1.appendChild(entry_level1_1_1);


    entry_level1_2 = docNode.createElement('Regions');
    entry_level1.appendChild(entry_level1_2);
    entry_level1_2_1 = docNode.createElement('RegionAttributeHeaders');
    entry_level1_2.appendChild(entry_level1_2_1);
    entry_level1_2_1_1 = docNode.createElement('AttributeHeaders');
    entry_level1_2_1_1.setAttribute('Name','Region');
    entry_level1_2_1_1.setAttribute('Id','9999');
    entry_level1_2_1_1.setAttribute('ColumunWidth','-1');
    entry_level1_2_1.appendChild(entry_level1_2_1_1);

    entry_level1_2_1_2 = docNode.createElement('AttributeHeaders');
    entry_level1_2_1_2.setAttribute('Name','Length');
    entry_level1_2_1_2.setAttribute('Id','9997');
    entry_level1_2_1_2.setAttribute('ColumunWidth','-1');
    entry_level1_2_1.appendChild(entry_level1_2_1_2);

    entry_level1_2_1_3 = docNode.createElement('AttributeHeaders');
    entry_level1_2_1_3.setAttribute('Name','Area');
    entry_level1_2_1_3.setAttribute('Id','9996');
    entry_level1_2_1_3.setAttribute('ColumunWidth','-1');
    entry_level1_2_1.appendChild(entry_level1_2_1_3);

    entry_level1_2_1_4 = docNode.createElement('AttributeHeaders');
    entry_level1_2_1_4.setAttribute('Name','Text');
    entry_level1_2_1_4.setAttribute('Id','9998');
    entry_level1_2_1_4.setAttribute('ColumunWidth','-1');
    entry_level1_2_1.appendChild(entry_level1_2_1_4);

    entry_level1_2_1_5 = docNode.createElement('AttributeHeaders');
    entry_level1_2_1_5.setAttribute('Name','Description');
    entry_level1_2_1_5.setAttribute('Id','1');
    entry_level1_2_1_5.setAttribute('ColumunWidth','-1');
    entry_level1_2_1.appendChild(entry_level1_2_1_5);

    entry_level1_2_2 = docNode.createElement('Region');
    entry_level1_2.appendChild(entry_level1_2_2);
    entry_level1_2_2.setAttribute('Selected','1');
    entry_level1_2_2.setAttribute('Type','1');
    entry_level1_2_2.setAttribute('Id','1');
    entry_level1_2_2.setAttribute('DisplayId','1');
    entry_level1_2_2.setAttribute('Analyze','1');
    entry_level1_2_2.setAttribute('InputRegionId','0');
    entry_level1_2_2.setAttribute('NegativeROA','0');
    entry_level1_2_2.setAttribute('Text','');
    entry_level1_2_2.setAttribute('AreaMicrons',num2str(areaM));
    entry_level1_2_2.setAttribute('LengthMicrons',num2str(lengthM));
    entry_level1_2_2.setAttribute('Area',num2str(area));
    entry_level1_2_2.setAttribute('Length',num2str(length));
    entry_level1_2_2.setAttribute('ImageFocus','0');
    entry_level1_2_2.setAttribute('ImageLocation','');
    entry_level1_2_2.setAttribute('Zoom','0.022562');

    entry_level1_2_2_1 = docNode.createElement('Attributes');
    entry_level1_2_2.appendChild(entry_level1_2_2_1);

    entry_level1_2_2_2 = docNode.createElement('Vertices');
    entry_level1_2_2.appendChild(entry_level1_2_2_2);

    entry_level1_2_2_2_1 = docNode.createElement('Vertex');
    entry_level1_2_2_2.appendChild(entry_level1_2_2_2_1);
    entry_level1_2_2_2_1.setAttribute('Y',num2str(y1));
    entry_level1_2_2_2_1.setAttribute('X',num2str(x1));

    entry_level1_2_2_2_2 = docNode.createElement('Vertex');
    entry_level1_2_2_2.appendChild(entry_level1_2_2_2_2);
    entry_level1_2_2_2_2.setAttribute('Y',num2str(y2));
    entry_level1_2_2_2_2.setAttribute('X',num2str(x2));

    entry_level1_2_2_2_3 = docNode.createElement('Vertex');
    entry_level1_2_2_2.appendChild(entry_level1_2_2_2_3);
    entry_level1_2_2_2_3.setAttribute('Y',num2str(y3));
    entry_level1_2_2_2_3.setAttribute('X',num2str(x3));

    entry_level1_2_2_2_4 = docNode.createElement('Vertex');
    entry_level1_2_2_2.appendChild(entry_level1_2_2_2_4);
    entry_level1_2_2_2_4.setAttribute('Y',num2str(y4));
    entry_level1_2_2_2_4.setAttribute('X',num2str(x4));

    entry_level1_2_3 = docNode.createElement('plots');
    entry_level1_2.appendChild(entry_level1_2_3);

    xmlwrite(filename,docNode);
  %  type(outputAll);
   [status2,cmdout2]=system(fullname);
    %[status2,cmdout2]=system(fullname,'-echo');
    success = 1;
    
catch ME
    error_show(ME)
end

end



More information about the ome-users mailing list