How to download DICOM image from PACS.

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
tariq2305
Posts: 16
Joined: Tue, 2012-04-03, 13:44

How to download DICOM image from PACS.

#1 Post by tariq2305 »

Hi,

I am developing an iPad application using dcmtk lib to view DICOM images. my code from getting the connection to PACS, to sendMoveRequest is here :


Code: Select all

#define APPLICATIONTITLE     "TEST-SCU" 

// host name of the peer machine 
#define PEERHOSTNAME         "www.dicomserver.co.uk" 

// TCP/IP port to connect to the peer machine 
#define PEERPORT 11112 

// application entity title of the peer machine 
#define PEERAPPLICATIONTITLE "MOVESCP" 

// MOVE destination AE Title 
#define MOVEAPPLICATIONTITLE "MOVESCP" 



in main :

 DcmSCU scu; 
    // set AE titles 
    scu.setAETitle(APPLICATIONTITLE); 
    scu.setPeerHostName(PEERHOSTNAME); 
    scu.setPeerPort(PEERPORT); 
    scu.setPeerAETitle(PEERAPPLICATIONTITLE); 
    // Use presentation context for FIND/MOVE in study root, propose all uncompressed transfer syntaxes 
    OFList<OFString> ts; 
    ts.push_back(UID_LittleEndianExplicitTransferSyntax);  
    ts.push_back(UID_BigEndianExplicitTransferSyntax); 
    ts.push_back(UID_LittleEndianImplicitTransferSyntax); 
    scu.addPresentationContext(UID_FINDStudyRootQueryRetrieveInformationModel, ts); 
    scu.addPresentationContext(UID_MOVEStudyRootQueryRetrieveInformationModel, ts); 
    scu.addPresentationContext(UID_VerificationSOPClass, ts); 
    
    /* Initialize network */ 
    OFCondition result = scu.initNetwork(); 
    if (result.bad()) 
    { 
        DCMNET_ERROR("Unable to set up the network: " << result.text()); 
        return ; 
    } 
    
    /* Negotiate Association */ 
    result = scu.negotiateAssociation(); 
    if (result.bad()) 
    { 
        DCMNET_ERROR("Unable to negotiate association: " << result.text()); 
        return ; 
    } 
    
    /* Let's look whether the server is listening: 
     Assemble and send C-ECHO request 
     */ 
    result = scu.sendECHORequest(0); 
    if (result.bad()) 
    { 
        DCMNET_ERROR("Could not process C-ECHO with the server: " << result.text()); 
        return ; 
    } 
    
    
    //Construction et envoi d'une requete C-FIND, pour trouver les examens 
      OFList<QRResponse*> OFfindResponses; 
    
    DcmDataset req; 
    req.putAndInsertOFStringArray(DCM_QueryRetrieveLevel, "STUDY"); 
    req.putAndInsertOFStringArray(DCM_StudyInstanceUID, ""); 
    req.putAndInsertOFStringArray( DCM_PatientID, "TEST2");
    
    T_ASC_PresentationContextID presID = findUncompressedPC(UID_FINDStudyRootQueryRetrieveInformationModel, scu); 
    if (presID == 0) 
    {
        DCMNET_ERROR("There is no uncompressed presentation context for Study Root FIND"); 
        return ; 
        
    } 
     result = scu.sendFINDRequest(presID, &req, &OFfindResponses); 
    if (result.bad()) 
    {
        DCMNET_ERROR("There is no uncompressed presentation context for Study Root FIND"); 
        return ; 
        
    } 
    else 
    { 
        
    } 
    
    //Construction et envoi d'une requete C-MOVE, pour tous les examens identifiés au dessus 
    presID = findUncompressedPC(UID_MOVEStudyRootQueryRetrieveInformationModel, scu); 
    if (presID == 0) 
    {
        DCMNET_ERROR("There is no uncompressed presentation context for Study Root FIND"); 
        return ; 
        
    } 
    
    OFListIterator(QRResponse*) study = OFfindResponses.begin(); 
    Uint32 studyCount = 1; 
    OFBool failed = OFFalse; 
    while (study != OFfindResponses.end() && result.good()) 
    { 
        // Pour chaque boucle en réponse, soit chaque examen, toutes les images seront récupérées 
        OFList<RetrieveResponse*> moveResponses;//MOVEResponses moveResponses; 
        
        if ( (*study)->m_dataset != NULL) //Il faut etre certain que ce n'est pas la derniere réponse, elle ne contient pas d'information 
        { 
            OFString studyInstanceUID; 
            result = (*study)->m_dataset->findAndGetOFStringArray(DCM_StudyInstanceUID, studyInstanceUID); 
            // only try to get study if we actually have study instance uid, otherwise skip it 
            if (result.good()) 
            { 
                req.putAndInsertOFStringArray(DCM_StudyInstanceUID, studyInstanceUID); 
                // fetches all images of this particular study 
                OFString OFmonAet = OFmonAet; 
                 result = scu.sendMOVERequest(presID, MOVEAPPLICATIONTITLE, &req, NULL /* we are not interested into responses*/); 
        
                if (result.good()) 
                { 
                    DCMNET_INFO("Received study #" << std::setw(7) << studyCount << ": " << studyInstanceUID); 
                    
                    studyCount++;      
                
                } 
            } 
        } 
        study++; 
    } 
    
    if (result.bad()) 
    { 
        DCMNET_ERROR("Unable to retrieve all studies: " << result.text()); 
    }
    while (!OFfindResponses.empty())
    {
        delete OFfindResponses.front();
        OFfindResponses.pop_front();
    }
 


I have 3 questions here :

First is : if my MOVEAPPLICATIONTITLE is "MOVESCP" ,by running this code i am getting the "Move destination unknown" error in console.
and if MOVEAPPLICATIONTITLE is "TEST-SCU" i m getting the error : "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 61.12.14.178:11112] # 202, 1 ErrorComment"

what should be the Proper MOVEAPPLICATIONTITLE should be here? and what should i do to stop it?

Second is: I know that DcmSCU.sendMoveRequest(....), can only tell the PACS to send the data somewhere, to a place we tell the PACS by giving an AE title. but there I just read an statement :
"When a PACS receives this move request, it internally looks up (in the configuration) the ip adress and port of the system with the AE title you specified (thus, every receiver has to be configured on the PACS) and then opens up a _new_ association to that adress and port. On that second connection, the images are sent with C-STORE then. "
can you just clarify it some more, by giving any example.and what does that mean "receiver has to be configured on the PACS"?

Third is which is mostly related to Second : to download images, that is, to listen from PACS we need storescp. but i didn't find any example of how to use it. can you please provide an example of what is storescp and how to use it to listen from PACS, and download images for ipad.

Oban
Posts: 19
Joined: Thu, 2014-07-24, 08:14

Re: How to download DICOM image from PACS.

#2 Post by Oban »

Hi, most of the time you cannot query a PACS if your calling AET (eventually AET/IP/port) is not declared in it.
And if your AET is declared, your capabilities might not be fully granted (e.g. be a SCU only, not Q&R authorized).
Cheers.

Michael Onken
DCMTK Developer
Posts: 2049
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: How to download DICOM image from PACS.

#3 Post by Michael Onken »

Hi,
First is : if my MOVEAPPLICATIONTITLE is "MOVESCP" ,by running this code i am getting the "Move destination unknown" error in console.
and if MOVEAPPLICATIONTITLE is "TEST-SCU" i m getting the error : "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 61.12.14.178:11112] # 202, 1 ErrorComment"

what should be the Proper MOVEAPPLICATIONTITLE should be here? and what should i do to stop it?
The PACS must have configured the application entitity MOVESCP, i.e. you must configure somewhere on the PACS the IP address and port of "MOVESCP".

Obviously you configured "TEST-SCU" on the PACS (at least it seems so from the error message if you use TEST-SCU), however, at the IP address/port configured (61.12.14.178:11112) at the PACS no storage service is listening for incoming storage requests.
Second is: I know that DcmSCU.sendMoveRequest(....), can only tell the PACS to send the data somewhere, to a place we tell the PACS by giving an AE title. but there I just read an statement :
"When a PACS receives this move request, it internally looks up (in the configuration) the ip adress and port of the system with the AE title you specified (thus, every receiver has to be configured on the PACS) and then opens up a _new_ association to that adress and port. On that second connection, the images are sent with C-STORE then. "
can you just clarify it some more, by giving any example.and what does that mean "receiver has to be configured on the PACS"?
See my explanation to your first issue.

Third is which is mostly related to Second : to download images, that is, to listen from PACS we need storescp. but i didn't find any example of how to use it. can you please provide an example of what is storescp and how to use it to listen from PACS, and download images for ipad.
Search the forum for storescp. Read the storescp online documentation, which is the first storescp search result in google. Shortcut: Use "storescp 11112 -d".

Overall, read my detailed explanation on the wiki how to use DCMTK tools to work with PACSes.

Best,
Michael

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest