Read the contents of a private dicom tag with dcm4che2 toolkit

211 views
Skip to first unread message

Thanasis Iliopoulos

unread,
May 20, 2015, 10:14:06 AM5/20/15
to dcm...@googlegroups.com

My question is quite simple: How can i read a private dicom TAG (e.g. 0019,105A) ny using the dcm4che2 toolkit?

I am able to parse/read "public" dicom tags by using:

try {
            DicomObject dcmObj5;
            DicomInputStream din5 = null;
            din5 = new DicomInputStream(file);
            dcmObj5 = din5.readDicomObject();
            tmpSeriesId = dcmObj5.getString(Tag.SeriesInstanceUID);
            din5.close(); 
    }
        catch (IOException e) {
                e.printStackTrace();
    }

Can i use somehow getString() to read a private dicom tag?

Dimitri Pianeta

unread,
May 20, 2015, 10:44:46 AM5/20/15
to dcm...@googlegroups.com
We can put
 tmpSeriesId = dcmObj5.getString(0x00020010);

My solution is following ;
try {
            DicomObject dcmObj5;
            DicomInputStream din5 = null;
            din5 = new DicomInputStream(file);
            dcmObj5 = din5.readDicomObject();
            tmpSeriesId = dcmObj5.getString(0x00020010);
            din5.close(); 
    }
        catch (IOException e) {
                e.printStackTrace();
    }

Thanasis Iliopoulos

unread,
May 20, 2015, 11:21:30 AM5/20/15
to dcm...@googlegroups.com
Thanks Dimitri!

An elementary question:

If for example if want to read the private TAG:  0019,105A

How the representation of form: 0x00020010 is derived? For tag: 0019,105A

i would use:

tmpSeriesId = dcmObj5.getString(0x019105A);

??

Dimitri Pianeta

unread,
May 20, 2015, 12:57:13 PM5/20/15
to dcm...@googlegroups.com

Use code following :
File input = new File();
DicomObject dcm = readDicomObject(input); 

String tmpSeriesId = getHeaderStringValue("0019,105A");
 
My codes : 

         
/**
         * Read the file into a dicom object
         * @param f the dicom file
         * @return the read dicom object
         */

       
public static DicomObject readDicomObject(File f) {
           
DicomObject dcmObj;
           
DicomInputStream din = null;
           
try {
                din
= new DicomInputStream(f);
                dcmObj
= din.readDicomObject();
               
return dcmObj;
           
}
           
catch (IOException e) {
                e
.printStackTrace();
               
return null;
           
}
           
finally {
               
try {
                    din
.close();
               
}
               
catch (IOException ignore) {
               
}
           
}
       
}

/**
         *reads the tag (group,element)
         * @param headerNr e.g. "0018,0050" to get Slice Thickness<br>
         * @return String
         * @throws DicomHeaderParseException
         */

       
public String getHeaderStringValue(String headerNr) {
            headerNr
= headerNr.replaceAll("xx", "00").replaceAll("XX", "00");
           
return getHeaderStringValue(toTagInt(headerNr));
       
}

 
/**
         * Converts the string representation of a header number
         * e.g. 0008,0010 to the corresponding integer as 0x00080010
         * as used in the @see org.dcm4che2.data.Tag
         * @param headerNr e.g. 0008,0010
         * @return 0x00080010 as int
         * @throws DicomHeaderParseException
         */

       
public static int toTagInt(String headerNr){
               
return Integer.parseInt(headerNr.replaceAll(",", ""), 16);
       
}














Reply all
Reply to author
Forward
0 new messages