简体   繁体   中英

Retrieve Dicom image from Pacs server

I am Querying / retrieving dicom image from remote Pacs server using DcmQR , i able to get list of Dicom objects by specified criteria. 1. when writing dicom object its showing 1 kb in size only. 2. When print object data its printing each data null. I am very new in this please help me out .. :(

     My code :

    public static void main(String args[]){

    dcmqr = new DcmQR("DCM4CHEE");
    dcmqr.setCalledAET("DCM4CHEE", true);
    dcmqr.setRemoteHost("remote ip");
    dcmqr.setRemotePort(remote port);
    dcmqr.getKeys();
    dcmqr.setDateTimeMatching(true);
    dcmqr.setCFind(true);
    dcmqr.setCGet(true);


    dcmqr.setQueryLevel(DcmQR.QueryRetrieveLevel.IMAGE);
    dcmqr.addMatchingKey(Tag.toTagPath("PatientName"),"Vicens^DICOM");
    dcmqr.configureTransferCapability(true);

    List<DicomObject> result = null;    
    try {
    dcmqr.start();
    dcmqr.open();
    result = dcmqr.query();
    dcmqr.get(result);
    System.out.println("List Size : " + result.size());
    displayObjectDetails(result);
    for (DicomObject dco : result) {
               Byte data[] = toByteArray(dco);

               // here how can get dicom image ??


    }

    } catch (Exception e) {
        System.out.println("error " + e);
    }
    try {
      if (dcmqr != null) {
        dcmqr.stop();
        dcmqr.close();
      }
    } catch (Exception e) {
       e.printStackTrace();
      }
    }

// toByteArray Method here 
private static byte[] toByteArray(DicomObject obj) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        BufferedOutputStream bos = new BufferedOutputStream(baos);
        DicomOutputStream dos = new DicomOutputStream(bos);
        dos.writeDicomFile(obj);
        dos.close();          
        byte[] data = baos.toByteArray();  
        return data;
}

// display object details

private static void displayObjectDetails(List resultimg) {

DicomObject obj = new BasicDicomObject();
List<String> listimg = new ArrayList<String>();
for (int i = 0; i < resultimg.size(); i++) {
    obj = resultimg.get(i);

    System.out.println("InstanceNumber : "+obj.getString(Tag.InstanceNumber, VR.IS));
    System.out.println("ImageType : "+obj.getString(Tag.ImageType, VR.CS));
    System.out.println("ImageID : "+obj.getString(Tag.ImageID, VR.SH));
    System.out.println("RetrieveAETitle : "+obj.getString(Tag.RetrieveAETitle, VR.AE));
    System.out.println("SOPInstanceUID : "+obj.getString(Tag.SOPInstanceUID, VR.UI));

    System.out.println("PatientName : "+obj.getString(Tag.PatientName, VR.PN));
    System.out.println("PatientBirthDate : "+obj.getString(Tag.PatientBirthDate, VR.DA));
    System.out.println("PatientSex : "+obj.getString(Tag.PatientSex, VR.CS));
    System.out.println("ReferringPhysicianName : "+obj.getString(Tag.ReferringPhysicianName, VR.PN));
    System.out.println("StudyDescription : "+obj.getString(Tag.StudyDescription, VR.LO));
    System.out.println("SeriesDescription : "+obj.getString(Tag.SeriesDescription, VR.LO));

    }

// Output List Size = 8 InstanceNumber : 1 ImageType : null ImageType : null RetrieveAETitle : DCM4CHEE SOPInstanceUID : 1.3.12.2.1107.5.2.5.11090.5.0.582504825601085 PatientName : null PatientBirthDate : null PatientSex : null ReferringPhysicianName : null StudyDescription : null SeriesDescription : null

Is it possible that you are only saving the query response? There are two ways to retrieve images from PACS, one is to send C-MOVE with the move destination AE set as your DICOM listener's AE. The second way, although it is not very common, is to send a C-GET request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM