Friday, March 22, 2013

conquest dicom, dcmtk, Osirix test data and Slicer

For a project, I decided to have a look at Slicer. Since I am behind a corporate proxy the download of the demo data didn't work. So I decided to also roll a local Dicom Server and chose an old friend, Conquest DicomServer. I configured Conquest to use its own MySQL database, and to support JPEG2000 and store the images uncompressed with DCM file extension. Then I downloaded the Osirix sample dataset "PROSTATIX" from here. Turns out they are JPEG2000 compressed, and I needed a tool to store the images in Conquest. DCMTK and their storescu executable fit that bill. After tinkering with it for a while, I found that the -xv -xw cmd line options propose JPEG2000 lossless and lossy transfer:
storescu.exe -xv -xw +sd +sp *.dcm +r -aec CONQUESTSRV1 localhost 5678 ./
since I had entered
STORESCU  127.0.0.1 5678  un
as a known Dicom provider in Conquest where 'un' means uncompressed. I guess I could have specified another line
STORESCU_JL  127.0.0.1 5678  jl
and then called
storescu -aet STORESCU_JL ... 
. Anyway, the setup worked, and Conquest stored the files, responding
[CONQUESTSRV1] [recompress]: recompressed with mode = un (strip=0)
[CONQUESTSRV1] Written file: D:\data\conquest\91942\1.3.12.2.1107.5.1.4.48545.30000008100709320360900003740_0005_000437_13638632270744.dcm
Now I wanted to view the data in Slicer. After adding Conquest as a DICOM host in Slicer in the DICOM Module under "Dicom Browser->Query" and Slicer with its default AETITLE CTKSTORE, I was able to see the Osirix Dataset stored on Conquest. However, I was not able to retrieve it. I did get a Dialog Box saying that the Retrieve Process is finished", , but Looking at Slicer's log I see the following
Setting Transfer Syntaxes

About to retrieve 1.3.46.670589.5.2.10.2156913941.892665384.993397 from localhost
Starting to retrieve
Starting getStudy
Negotiating Association

I: Requesting Association
I: Association Accepted (Max Send PDV: 16372)

Setting Retrieve Parameters
Sending Get Request

setting value to 0
GET Request failed: No valid Study Root GET Presentation Context available

Retrieve success

I: Releasing Association
and no data in the Database! Here's the (useless) Conquest log:
[CONQUESTSRV1] UPACS THREAD 1605: STARTED AT: Fri Mar 22 16:31:18 2013
[CONQUESTSRV1] *** connection terminated
[CONQUESTSRV1] UPACS THREAD 1605: ENDED AT: Fri Mar 22 16:31:30 2013
[CONQUESTSRV1] UPACS THREAD 1605: TOTAL RUNNING TIME: 12 SECONDS
So what's going on? Here's the relevant snippet from
ctkDICOMRetrieve.cpp
:
//------------------------------------------------------------------------------
bool ctkDICOMRetrievePrivate::get ( const QString& studyInstanceUID,
                                         const QString& seriesInstanceUID,
                                         const RetrieveType retrieveType )
{
  Q_Q(ctkDICOMRetrieve);

  DcmDataset *retrieveParameters = new DcmDataset();
  if (! this->initializeSCU(studyInstanceUID, seriesInstanceUID, retrieveType, retrieveParameters) )
    {
    delete retrieveParameters;
    return false;
    }

  // Issue request
  logger.debug ( "Sending Get Request" );
  emit q->progress("Sending Get Request");
  emit q->progress(0);
  OFList responses;
  T_ASC_PresentationContextID presID = this->SCU.findPresentationContextID(
                                          UID_GETStudyRootQueryRetrieveInformationModel, 
                                          "" /* don't care about transfer syntax */ );
  if (presID == 0)
    {
    logger.error ( "GET Request failed: No valid Study Root GET Presentation Context available" );
    if (!this->KeepAssociationOpen)
      {
      this->SCU.closeAssociation(DCMSCU_RELEASE_ASSOCIATION);
      }
    delete retrieveParameters;
    return false;
    }

  emit q->progress("Found Presentation Context");
  emit q->progress(1);
Apparently the SCU.findPresentationContextID call didn't return a Presentation Context, but I don't understand why.