从Pacs服务器检索Dicom图像

时间:2014-05-08 12:52:49

标签: java dicom

我正在使用DcmQR从远程Pacs服务器查询/检索dicom图像,我能够按指定条件获取Dicom对象列表。 1.编写dicom对象时,其尺寸仅为1 kb。 2.打印对象数据时,每个数据打印为空。 我很新,请帮帮我.. :(

     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));

    }

//输出 清单大小= 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 ReferPhysicianName:null StudyDescription:null SeriesDescription:null

1 个答案:

答案 0 :(得分:1)

您是否可能只保存查询响应?有两种方法可以从PACS中检索图像,一种是将移动目标AE设置为DICOM监听器的AE发送C-MOVE。第二种方法,虽然不常见,但是发送C-GET请求。