<HTML>
<HEAD>
<TITLE>Re: [ome-users] ImageProcessorReader.getSeriesMetadata() for extracting DICOM tags</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Dear Dr. Flynn,<BR>
<BR>
Many thanks for your response. We have uploaded three sample images to qa.openmicroscopy.org.uk. Please let me know if I can provide additional details.<BR>
<BR>
Best wishes,<BR>
M. Samarah<BR>
<BR>
<BR>
-- <BR>
Mohammad Samarah, PhD<BR>
Email: <a href="msamarah@alumni.fit.edu">msamarah@alumni.fit.edu</a><BR>
Time zone: EST/EDT, UTC/GMT -5 hours, UTC/GMT -4 hours<BR>
<BR>
<BR>
<HR ALIGN=CENTER SIZE="3" WIDTH="95%"><B>From: </B>Helen Flynn <<a href="h.flynn@dundee.ac.uk">h.flynn@dundee.ac.uk</a>><BR>
<B>Date: </B>Wed, 16 Apr 2014 08:38:24 +0000<BR>
<B>To: </B>"<a href="msamarah@alumni.fit.edu">msamarah@alumni.fit.edu</a>" <<a href="msamarah@alumni.fit.edu">msamarah@alumni.fit.edu</a>><BR>
<B>Cc: </B>"<<a href="melissa@glencoesoftware.com>">melissa@glencoesoftware.com></a>" <<a href="melissa@glencoesoftware.com">melissa@glencoesoftware.com</a>>, "<a href="ome-users@lists.openmicroscopy.org.uk">ome-users@lists.openmicroscopy.org.uk</a>" <<a href="ome-users@lists.openmicroscopy.org.uk">ome-users@lists.openmicroscopy.org.uk</a>><BR>
<B>Subject: </B>Re: [ome-users] ImageProcessorReader.getSeriesMetadata() for extracting DICOM tags<BR>
<BR>
Dear Mohammad, <BR>
<BR>
Sorry to hear this still isn't working for you. Could you submit the image file via <a href="http://qa.openmicroscopy.org.uk">http://qa.openmicroscopy.org.uk</a> so we can do further testing please?<BR>
<BR>
Regards,<BR>
<BR>
Helen<BR>
<BR>
<BR>
Dr Helen Flynn<BR>
OME Technical Writer<BR>
Centre for Gene Regulation & Expression<BR>
Open Microscopy Environment<BR>
University of Dundee<BR>
<a href="http://openmicroscopy.org">http://openmicroscopy.org</a><BR>
<BR>
On 11 Apr 2014, at 16:25, Mohammad Samarah <<a href="isamarah@mac.com">isamarah@mac.com</a>> wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Hi Melissa,<BR>
<BR>
We tried both options. We are unable to retrieve the nested DICOM tags. Here<BR>
is the code fragment in question.<BR>
<BR>
Thanks for your help,<BR>
M. Samarah<BR>
<BR>
<BR>
ServiceFactory factory = new ServiceFactory();<BR>
OMEXMLService service = factory.getInstance(OMEXMLService.class);<BR>
IMetadata meta = service.createOMEXMLMetadata();<BR>
<BR>
log_message("INFO: Examining file " + imagePath);<BR>
r.setMetadataStore(meta);<BR>
r.setGroupFiles(false);<BR>
r.setId(imagePath);<BR>
<BR>
CoreMetadata data[] = r.getCoreMetadata();<BR>
metadata = data[r.getCoreIndex()].seriesMetadata;<BR>
Set<String> keys = metadata.keySet();<BR>
<BR>
for(String key: keys)<BR>
{<BR>
   System.out.println("Value of "+key+" is: "+metadata.get(key));<BR>
}<BR>
<BR>
Object obj = r.getSeriesMetadataValue("0008,2228 Primary Anatomic Structure<BR>
Sequence");<BR>
<BR>
if (obj instance of List)<BR>
{<BR>
   System.out.println("obj is a list");<BR>
   // order they were found<BR>
   //  List values = (List) obj;<BR>
   // Object firstCodeMeaning = values.get(0);<BR>
}<BR>
else {<BR>
   // single value<BR>
   System.out.println("obj is a single value");<BR>
}<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>From: Melissa Linkert <<a href="melissa@glencoesoftware.com">melissa@glencoesoftware.com</a>><BR>
Reply-To: <<a href="melissa@glencoesoftware.com">melissa@glencoesoftware.com</a>><BR>
Date: Mon, 07 Apr 2014 18:59:58 -0500<BR>
To: "<a href="msamarah@alumni.fit.edu">msamarah@alumni.fit.edu</a>" <<a href="msamarah@alumni.fit.edu">msamarah@alumni.fit.edu</a>><BR>
Cc: "<a href="ome-users@lists.openmicroscopy.org.uk">ome-users@lists.openmicroscopy.org.uk</a>"<BR>
<<a href="ome-users@lists.openmicroscopy.org.uk">ome-users@lists.openmicroscopy.org.uk</a>><BR>
Subject: Re: [ome-users] ImageProcessorReader.getSeriesMetadata() for<BR>
extracting DICOM tags<BR>
<BR>
Hi Mohammad,<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>We are using ImageProcessorReader to extract DICOM tags from an RVG image.<BR>
All seems to be well, however it does not seem to return repeating tags<BR>
particularly tag id 0008,0104.  Are there specific options needed to extract<BR>
repeated tags? And are there known limitations with the Imetadata class? I<BR>
have attached the DICOM tags table and Java code in question below.<BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
Typically if there would be multiple entries in the metadata hashtable<BR>
that have the same key, then a suffix is appended to the relevant keys.<BR>
I would expect something like this to work:<BR>
<BR>
    metadata = r.getSeriesMetadata();<BR>
    Object firstCodeMeaning = metadata.get("Code Meaning #0");<BR>
    Object secondCodeMeaning = metadata.get("Code Meaning #1");<BR>
    Object thirdCodeMeaning = metadata.get("Code Meaning #2");<BR>
<BR>
Alternately, you can do this to preserve the original key and access the<BR>
values as a List:<BR>
<BR>
   metadata = r.getCoreMetadataList().get(r.getCoreIndex()).seriesMetadata;<BR>
   Object value = metadata.get("Code Meaning");<BR>
   if (value instanceof List) {<BR>
     // multiple values for the same key; values are stored in the<BR>
     // order they were found<BR>
     List values = (List) value;<BR>
     Object firstCodeMeaning = values.get(0);<BR>
   }<BR>
   else {<BR>
     // single value<BR>
   }<BR>
<BR>
If neither of those options work, please let us know.<BR>
<BR>
Regards,<BR>
-Melissa<BR>
<BR>
On Fri, Apr 04, 2014 at 01:48:30AM -0400, Mohammad Samarah wrote:<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>We are using ImageProcessorReader to extract DICOM tags from an RVG image.<BR>
All seems to be well, however it does not seem to return repeating tags<BR>
particularly tag id 0008,0104.  Are there specific options needed to extract<BR>
repeated tags? And are there known limitations with the Imetadata class? I<BR>
have attached the DICOM tags table and Java code in question below.<BR>
<BR>
Thanks for your help,<BR>
M. Samarah<BR>
<a href="msamarah@alumni.fit.edu">msamarah@alumni.fit.edu</a><BR>
<BR>
<BR>
Tag ID                          VR    VM   Len    Description       Value<BR>
(0008,2228)                SQ    0      0       Primary Anatomic Structure<BR>
Sequence<BR>
  (FFFE,E000)<BR>
     (0008,0100)<BR>
     (0008,0102)<BR>
     (0008,0104)          LO  1        34      Code Meaning    Maxillary<BR>
right third molar tooth<BR>
  (FFFE,E000)<BR>
     (0008,0100)<BR>
     (0008,0102)<BR>
     (0008,0104)          LO  1        34      Code Meaning    Maxillary<BR>
right second molar tooth<BR>
  (FFFE,E000)<BR>
     (0008,0100)<BR>
     (0008,0102)<BR>
     (0008,0104)       LO  1           34      Code Meaning    Maxillary<BR>
right first molar tooth<BR>
<BR>
<BR>
ImageProcessorReader r = new ImageProcessorReader(new<BR>
ChannelSeparator(LociPrefs.makeImageReader()));<BR>
try<BR>
{<BR>
   ServiceFactory factory = new ServiceFactory();<BR>
   OMEXMLService service = factory.getInstance(OMEXMLService.class);<BR>
    IMetadata meta = service.createOMEXMLMetadata();<BR>
    log_message("INFO: Examining file " + imagePath);<BR>
    r.setMetadataStore(meta);<BR>
    r.setGroupFiles(false);<BR>
    r.setId(imagePath);<BR>
 <BR>
   metadata = r.getSeriesMetadata();<BR>
   Set<String> keys = metadata.keySet();<BR>
   for(String key: keys)<BR>
   {<BR>
       System.out.println("Value of "+key+" is: "+metadata.get(key));<BR>
    }<BR>
}<BR>
<BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>_______________________________________________<BR>
ome-users mailing list<BR>
<a href="ome-users@lists.openmicroscopy.org.uk">ome-users@lists.openmicroscopy.org.uk</a><BR>
<a href="http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users">http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users</a><BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
<BR>
_______________________________________________<BR>
ome-users mailing list<BR>
<a href="ome-users@lists.openmicroscopy.org.uk">ome-users@lists.openmicroscopy.org.uk</a><BR>
<a href="http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users">http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users</a><BR>
</SPAN></FONT></BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'><BR>
<BR>
</SPAN><FONT SIZE="2"><SPAN STYLE='font-size:10pt'>The University of Dundee is a registered Scottish Charity, No: SC015096</SPAN></FONT><SPAN STYLE='font-size:11pt'><BR>
</SPAN></FONT>
</BODY>
</HTML>