Search code examples
pythonpython-2.7serverdicompydicom

Is there a way to send DICOM data to specific directories on remote PACS server?


I am getting a hang of communication between SCU and SCP for DICOM servers and images. I am using a ClearCanas PACS server and have access to the web GUI. Using the following code, I am able to send DICOM dt from SCU(my computer) to SCP(remote server)

import sys
import argparse
from netdicom import AE
from netdicom.SOPclass import StorageSOPClass, VerificationSOPClass
from dicom.UID import ExplicitVRLittleEndian, ImplicitVRLittleEndian, \
    ExplicitVRBigEndian
from dicom import read_file


# parse commandline
parser = argparse.ArgumentParser(description='storage SCU example')
parser.add_argument('remotehost')
parser.add_argument('remoteport', type=int)
parser.add_argument('file', nargs='+')
parser.add_argument('-aet', help='calling AE title', default='PYNETDICOM')
parser.add_argument('-aec', help='called AE title', default='REMOTESCU')
parser.add_argument('-implicit', action='store_true',
                    help='negociate implicit transfer syntax only',
                    default=False)
parser.add_argument('-explicit', action='store_true',
                    help='negociate explicit transfer syntax only',
                    default=False)

args = parser.parse_args()

if args.implicit:
    ts = [ImplicitVRLittleEndian]
elif args.explicit:
    ts = [ExplicitVRLittleEndian]
else:
    ts = [
        ExplicitVRLittleEndian,
        ImplicitVRLittleEndian,
        ExplicitVRBigEndian
    ]

# call back


def OnAssociateResponse(association):
    print "Association response received"

# create application entity
MyAE = AE(args.aet, 0, [StorageSOPClass,  VerificationSOPClass], [], ts)
MyAE.OnAssociateResponse = OnAssociateResponse

# remote application entity
RemoteAE = dict(Address=args.remotehost, Port=args.remoteport, AET=args.aec)

# create association with remote AE
print "Request association"
assoc = MyAE.RequestAssociation(RemoteAE)

if not assoc:
    print "Could not establish association"
    sys.exit(1)
# perform a DICOM ECHO, just to make sure remote AE is listening
print "DICOM Echo ... ",
st = assoc.VerificationSOPClass.SCU(1)
print 'done with status "%s"' % st

# create some dataset
for ii in args.file:
    print
    print ii
    d = read_file(ii)
    print "DICOM StoreSCU ... ",
    try:
        st = assoc.SCU(d, 1)
        print 'done with status "%s"' % st
    except:
        raise
        print "problem", d.SOPClassUID
print "Release association"
assoc.Release(0)

# done
MyAE.Quit

My question is, is there a way to send the objects to different directories on the server / make directories remotely on the server and send the data to different directories?


Solution

  • Short answer - No

    A longer answer - DICOM standard does not care in any way or form, how the files are stored on the PACS server, that's left up to the implementation. The PACS server could use a robotic carving tool to engrave them on stone tablets and read the with OCR, if it could still receive and send them out according to the standard. Therefore there is no way to influence such details through the DICOM interface.

    From the standard's viewpoint - everything is already neatly organised hierarchically on the scale of Patient - Study - Series - Instance, where each levels has their only unique ID-s. These ID-s are stored in each and every DICOM file in the relevant DICOM tags and most PACS servers keep track of these ID-s using a database to facilitate quick lookups. The actual location of the DICOM file on the disk is also stored in the database, but that is internal implementation details and is not exposed via the DICOM interface.

    And frankly - I don't see what's the use case for this requirement anyway? The organisation is there already and You can query by these attributes using the DICOM interface.