Skip to content

2. px find

Rudolph Pienaar edited this page Sep 26, 2019 · 10 revisions

px-find

Overview

px-find is a wrapper around dcmtk findscu.

px-find finds series on a PACS server given a vast array of parameters. See px-find --help for the full list. In stand-alone cases, px-find will often be used to Query a PACS. The results can be presented in a console friendly formatted report.

px-find sends query keys to an SCP and awaits responses.
The application can be used to test SCPs of the Query/Retrieve 
and Basic Worklist Management Service Classes.
-- DCMTK, about findscu.

Help

px-find --desc

Synopsis

            _script mode_:
            px-find                                                 \
                [--aet <AETitle>]                                   \
                [--aec <CalledAETitle>]                             \
                [--serverIP <PACSserverIP>]                         \
                [--serverPort <PACSserverPort>]                     \
                [--findscu <findscuAbsolutePath>]                   \
                [--movescu <movescuAbsolutePath>]                   \
                [--PatientID <MRN>]                                 \
                [--PatientName <ExactPatientName>]                  \
                [--PatientSex <M_or_F>]                             \
                [--StudyDate <YYYY/MM/DD>]                          \
                [--ModalitiesInStudy <Modalities>]                  \
                [--Modality <ModalityToQuery>]                      \
                [--PerformedStationAETitle <StationTitle>]          \
                [--StudyDescription <studyDescription>]             \
                [--SeriesDescription <seriesDescription>]           \
                [--StudyInstanceUID <studyInstanceUID>]             \
                [--SeriesInstanceUID <seriesInstanceUID>]           \
                [--retrieve [--move]]                               \
                [--reportTags <JSONDesc>]                           \
                [--colorize light|dark]                             \
                [--printReport tabular|rawText|json]                \
                [--waitForUserTerminate]                            \
                [-x|--desc]                                         \
                [-y|--synopsis]                                     \
                [--version]                                         \
                [--debugToDir <dir>]                                \
                [--verbosity <level>]

Args

        [--aet <AETitle>]
        The AETitle of *this* entity.

        [--aec <CalledAETitle>]                             
        The called AETitle of *this* entity. Needed for some PACS systems.

        [--serverIP <PACSserverIP>]
        The IP of the PACS server.

        [--serverPort <PACSserverPort>]                     
        The port associated with the PACS server.

        [--executable <findscuAbsolutePath>]                
        The absolute location of the 'findscu' executable.
        
        [--PatientID <MRN>]
        The patient ID on which to Query.

        [--PatientName <ExactPatientName>]
        The patient name on which to Query.

        [--PatientSex <M_or_F>]                             
        The patient sex (largely irrelevant since open ended searches are
        not supported by most PACS servers).
        
        [--StudyDate <YYYY/MM/DD>]                          
        Filter results by <studyDate>.
        
        [--ModalitiesInStudy <Modalities>]   
        Filter by modalities in study.

        [--Modality <Modality>]   
        The modality to filter.

        [--PerformedStationAETitle <StationTitle>]          
        Filter by station ID.

        [--StudyDescription <studyDescription>]             
        Filter by study description.

        [--SeriesDescription <seriesDescription>]           
        Filter by series description.

        [--StudyInstanceUID <studyInstanceUID>]             
        Filter by study instance UID.

        [--SeriesInstanceUID <seriesInstanceUID>]           
        Filter by series instance UID.

        [--retrieve]
        If set, perform a DICOM movescu on the set of filtered 
        SeriesInstanceUIDs using internal calls.

        [--move]
        If set and called with [--retrieve], perform a DICOM movescu on the 
        set of filtered SeriesInstanceUIDs using the pypx/move module.

        [--reportTags <JSONdesc>]
        If specified, print only the JSON specified result tags from either the
        STUDY or SERIES level.

        [--colorize 'light'|'dark']
        An optional directive to colorize the report output, either for 'light'
        or 'dark' consoles.

        [--printReport tabular|rawText|json]               
        If specified, pretty print a report in a variety of formats.

        [--waitForUserTerminate]
        If specified, wait at program conclusion for explicit user termination.
        This is useful in dockerized runs since PACS data might still be 
        in flight when the program ends, and terminating the program then
        will result in non reception of outstanding data.                           

        [-x|--desc]                                     
        Provide an overview help page.

        [-y|--synopsis]
        Provide a synopsis help summary.

        [--version]
        Print internal version number and exit.

        [--debugToDir <dir>]
        A directory to contain various debugging output -- these are typically
        JSON object strings capturing internal state. If empty string (default)
        then no debugging outputs are captured/generated. If specified, then
        ``pfcon`` will check for dir existence and attempt to create if
        needed.

        [-v|--verbosity <level>]
        Set the verbosity level. "0" typically means no/minimal output. Allows for
        more fine tuned output control as opposed to '--quiet' that effectively
        silences everything.

CLI example use

        px-find                                                     \
            --aec CHRIS                                             \
            --aet FNNDSC-CHRISDEV                                   \
            --serverIP 134.174.12.21                                \
            --serverPort 104                                        \
            --PatientID 4777764                                     \
            --colorize dark                                         \
            --reportTags                                            \
            '{
                "header": 
                {
                    "study" : [
                            "PatientName",
                            "ScanDate",
                            "AccessionNumber",
                            "PatientID",
                            "PatientSex",
                            "PatientAge",
                            "PerformedStationAETitle",
                            "StudyDescription"
                            ]
                },
                "body": 
                {
                    "series" : [ 
                            "SeriesDescription"
                            ]
                }
            }'

        px-find                                                     \
            --aec CHIPS                                             \
            --aec ORTHANC                                           \
            --serverIP localhost                                    \
            --serverPort 4242                                       \
            --PatientID LILLA-9731                                  \
            --colorize dark                                         \
            --reportTags                                            \
            '{
                "header": 
                {
                    "study" : [
                            "PatientName",
                            "ScanDate",
                            "AccessionNumber",
                            "PatientID",
                            "PatientSex",
                            "PatientAge",
                            "PerformedStationAETitle",
                            "StudyDescription"
                            ]
                },
                "body": 
                {
                    "series" : [ 
                            "SeriesDescription"
                            ]
                }
            }'

Dockerized examples

        docker run  --rm -ti                                            \
            -p 10402:10402                                              \
            -v /tmp:/dicom                                              \
            fnndsc/pypx                                                 \
            --px-find                                                   \
            --aet CHIPS                                                 \
            --aec ORTHANC                                               \
            --serverIP  10.72.76.155                                    \
            --serverPort 4242                                           \
            --PatientID LILLA-9731                                      \
            --colorize dark                                             \
            --reportTags                                                \
            '{
                "header": 
                {
                    "study" : [
                            "PatientName",
                            "ScanDate",
                            "AccessionNumber",
                            "PatientID",
                            "PatientSex",
                            "PatientAge",
                            "PerformedStationAETitle",
                            "StudyDescription"
                            ]
                },
                "body": 
                {
                    "series" : [ 
                            "SeriesDescription"
                            ]
                }
            }'

        docker run  --rm -ti                                            \
            -p 10402:10402                                              \
            -v /tmp:/dicom                                              \
            fnndsc/pypx                                                 \
            --px-find                                                   \
            --aec CHRIS                                                 \
            --aet FNNDSC-CHRISDEV                                       \
            --serverIP 134.174.12.21                                    \
            --serverPort 104                                            \
            --PatientID 4777764                                         \
            --colorize dark                                             \
            --reportTags                                                \
            '{
                "header": 
                {
                    "study" : [
                            "PatientName",
                            "StudyDate",
                            "AccessionNumber",
                            "PatientID",
                            "PatientSex",
                            "PatientAge",
                            "PerformedStationAETitle",
                            "StudyDescription"
                            ]
                },
                "body": 
                {
                    "series" : [ 
                            "SeriesDescription"
                            ]
                }
            }'


## Python module syntax

px-find module
-------------------

```python
   # in yourscript.py
   import pypx

   pacs_settings = {
     'executable':  '/usr/bin/findscu',
     'aec':         'ORTHANC',
     'aet':         'CHIPS',
     'serverIP':    '127.0.0.1',
     'serverPort':  '4242',
   }

   # query parameters
   query_settings = {
       'PatientID': 'LILLA-9731'
    }

   # output parameters
   output_settings = {
       'printReport': 'json',
       'colorize':    'dark'
    }


   # python 3.5 ** syntax
   output = pypx.find({
               **pacs_settings, 
               **query_settings,
               **output_settings})

Will return in the output['report']['json']

[
  {
    "header": {
      "PatientName": "LILLA-9731",
      "PatientBirthDate": "19000101",
      "StudyDate": "20111206",
      "PatientAge": "017M",
      "PatientSex": "M",
      "AccessionNumber": "22268454",
      "PatientID": "LILLA-9731",
      "PerformedStationAETitle": "no value provided",
      "StudyDescription": "anonymized",
      "Modality": "MR"
    },
    "body": [
      { "SeriesDescription": "T2 SPC SAG OBL LT IAC" },
      { "SeriesDescription": "T2 SPC AXIAL THRU  IAC'S" },
      { "SeriesDescription": "T2 SPC SAG OBL RT IAC" },
      { "SeriesDescription": "AAHScout" },
      { "SeriesDescription": "AX MPRAGE RECON" },
      { "SeriesDescription": "mocoMEMPRAGE_192FOV RMS" },
      { "SeriesDescription": "COR MPRAGE RECON" },
      { "SeriesDescription": "ep_moco_nav_set (move FOV above shoulders)" },
      { "SeriesDescription": "AX T2 FLAIR" },
      { "SeriesDescription": "AAHScout_MPR" },
      { "SeriesDescription": "AX FSE T2" }
    ],
    "bodySeriesUID": [
      { "SeriesInstanceUID": "1.3.12.2.1107.5.2.32.35235.2011120608261498976230921.0.0.0" },
      { "SeriesInstanceUID": "1.3.12.2.1107.5.2.32.35235.2011120608154426308230611.0.0.0" },
      { "SeriesInstanceUID": "1.3.12.2.1107.5.2.32.35235.2011120608335936039431226.0.0.0" },
      { "SeriesInstanceUID": "1.3.12.2.1107.5.2.32.35235.2011120607520430264805764.0.0.0" },
      { "SeriesInstanceUID": "1.3.12.2.1107.5.2.32.35235.30000011120415032007800030559" },
      { "SeriesInstanceUID": "1.3.12.2.1107.5.2.32.35235.2011120607550716203206654.0.0.0" },
      { "SeriesInstanceUID": "1.3.12.2.1107.5.2.32.35235.30000011120415032007800029729" },
      { "SeriesInstanceUID": "1.3.12.2.1107.5.2.32.35235.2011120607550721381806658.0.0.0" },
      { "SeriesInstanceUID": "1.3.12.2.1107.5.2.32.35235.2011120608060183769230384.0.0.0" },
      { "SeriesInstanceUID": "1.3.12.2.1107.5.2.32.35235.2011120607520430331505768.0.0.0" },
      { "SeriesInstanceUID": "1.3.12.2.1107.5.2.32.35235.2011120608041225195630230.0.0.0" }
    ]
  }
]

-30-

Clone this wiki locally