How to use the pynetdicom.AE function in pynetdicom

To help you get started, we’ve selected a few pynetdicom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pydicom / pynetdicom / pynetdicom / apps / echoscu / echoscu.py View on Github external
except:
    transfer_syntax = [ImplicitVRLittleEndian]

#-------------------------- CREATE AE and ASSOCIATE ---------------------------

if args.version:
    print('echoscu.py v%s' %(VERSION))
    sys.exit()

APP_LOGGER.debug('echoscu.py v%s', VERSION)
APP_LOGGER.debug('')


# Create local AE
# Binding to port 0, OS will pick an available port
ae = AE(ae_title=args.calling_aet)

ae.add_requested_context(VerificationSOPClass, transfer_syntax)

# Set timeouts
ae.network_timeout = args.timeout
ae.acse_timeout = args.acse_timeout
ae.dimse_timeout = args.dimse_timeout

# Request association with remote AE
assoc = ae.associate(args.peer,
                     args.port,
                     ae_title=args.called_aet,
                     max_pdu=args.max_pdu)

# If we successfully Associated then send N DIMSE C-ECHOs
if assoc.is_established:
github pydicom / pynetdicom / pynetdicom / apps / storescp / storescp.py View on Github external
status_ds.Status = 0xA701

    return status_ds

handlers = [(evt.EVT_C_STORE, handle_store)]

# Test output-directory
if args.output_directory is not None:
    if not os.access(args.output_directory, os.W_OK|os.X_OK):
        APP_LOGGER.error('No write permissions or the output '
                     'directory may not exist:')
        APP_LOGGER.error("    {0!s}".format(args.output_directory))
        sys.exit()

# Create application entity
ae = AE(ae_title=args.aetitle)

# Add presentation contexts with specified transfer syntaxes
for context in StoragePresentationContexts:
    ae.add_supported_context(context.abstract_syntax, transfer_syntax)
for context in VerificationPresentationContexts:
    ae.add_supported_context(context.abstract_syntax, transfer_syntax)

ae.maximum_pdu_size = args.max_pdu

# Set timeouts
ae.network_timeout = args.timeout
ae.acse_timeout = args.acse_timeout
ae.dimse_timeout = args.dimse_timeout

ae.start_server((args.bind_addr, args.port), evt_handlers=handlers)
github pydicom / pynetdicom / pynetdicom / apps / movescp / movescp.py View on Github external
else:
        yield None, None

    # Number of matches
    yield len(dcm_files)

    # Matching datasets to send
    for dcm in dcm_files:
        ds = dcmread(dcm, force=True)
        yield 0xff00, ds


handlers = [(evt.EVT_C_MOVE, handle_move)]

# Create application entity
ae = AE(ae_title=args.aetitle)

# Add the requested Storage Service presentation contexts
# Used when sending the dataset to the move destination Storage SCP
for context in StoragePresentationContexts:
    ae.add_requested_context(context.abstract_syntax, transfer_syntax)

# Add the supported QR Service presentation contexts
for context in QueryRetrievePresentationContexts:
    ae.add_supported_context(context.abstract_syntax, transfer_syntax)

ae.maximum_pdu_size = args.max_pdu

# Set timeouts
ae.network_timeout = args.timeout
ae.acse_timeout = args.acse_timeout
ae.dimse_timeout = args.dimse_timeout
github sdnewhop / grinder / custom_scripts / py_scripts / dicom_getter / dicom_getter.py View on Github external
def __init__(self):
        """
        Init DICOM connector
        """
        self.ae = AE()
        self.ip = None
        self.port = None
        self.properties = list()
github pydicom / pynetdicom / pynetdicom / apps / getscu / getscu.py View on Github external
'error'    : logging.ERROR,
              'warn'     : logging.WARNING,
              'info'     : logging.INFO,
              'debug'    : logging.DEBUG}
    _setup_logging(levels[args.log_level])

if args.log_config:
    fileConfig(args.log_config)

APP_LOGGER.debug('$getscu.py v{0!s}'.format(VERSION))
APP_LOGGER.debug('')


# Create application entity
# Binding to port 0 lets the OS pick an available port
ae = AE(ae_title=args.calling_aet)

for context in QueryRetrievePresentationContexts:
    ae.add_requested_context(context.abstract_syntax)
for context in StoragePresentationContexts[:115]:
    ae.add_requested_context(context.abstract_syntax)

# Add SCP/SCU Role Selection Negotiation to the extended negotiation
# We want to act as a Storage SCP
ext_neg = []
for context in StoragePresentationContexts:
    ext_neg.append(build_role(context.abstract_syntax, scp_role=True))

# Create query dataset
d = Dataset()
d.PatientName = '*'
d.QueryRetrieveLevel = "PATIENT"
github pydicom / pynetdicom / pynetdicom / apps / getscp / getscp.py View on Github external
DATA_DIR = os.path.join(APP_DIR, '../', '../', 'tests', 'dicom_files')
        dcm_files = ['RTImageStorage.dcm', 'CTImageStorage.dcm']
        dcm_files = [os.path.join(DATA_DIR, x) for x in dcm_files]
        yield len(dcm_files)
    except:
        dcm_files = []
        yield 0

    for dcm in dcm_files:
        ds = dcmread(dcm, force=True)
        yield 0xFF00, ds

handlers = [(evt.EVT_C_GET, handle_get)]

# Create application entity
ae = AE(ae_title=args.aetitle)

for context in StoragePresentationContexts:
    ae.add_supported_context(
        context.abstract_syntax, transfer_syntax, scp_role=True, scu_role=False
    )
for context in QueryRetrievePresentationContexts:
    ae.add_supported_context(context.abstract_syntax, transfer_syntax)

ae.maximum_pdu_size = args.max_pdu

# Set timeouts
ae.network_timeout = args.timeout
ae.acse_timeout = args.acse_timeout
ae.dimse_timeout = args.dimse_timeout

ae.start_server(('', args.port), evt_handlers=handlers)
github pydicom / pynetdicom / pynetdicom / apps / storescu / storescu.py View on Github external
# Set Transfer Syntax options
transfer_syntax = [ExplicitVRLittleEndian,
                   ImplicitVRLittleEndian,
                   DeflatedExplicitVRLittleEndian,
                   ExplicitVRBigEndian]

if args.request_little:
    transfer_syntax = [ExplicitVRLittleEndian]
elif args.request_big:
    transfer_syntax = [ExplicitVRBigEndian]
elif args.request_implicit:
    transfer_syntax = [ImplicitVRLittleEndian]

# Bind to port 0, OS will pick an available port
ae = AE(ae_title=args.calling_aet)

for context in StoragePresentationContexts:
    ae.add_requested_context(context.abstract_syntax, transfer_syntax)

# Request association with remote
assoc = ae.associate(args.peer, args.port, ae_title=args.called_aet)

if assoc.is_established:
    APP_LOGGER.info('Sending file: {0!s}'.format(args.dcmfile_in))

    status = assoc.send_c_store(dataset)

    assoc.release()
github pydicom / pynetdicom / pynetdicom / apps / echoscp / echoscp.py View on Github external
if args.prefer_big and ExplicitVRBigEndian in transfer_syntax:
    transfer_syntax.remove(ExplicitVRBigEndian)
    transfer_syntax.insert(0, ExplicitVRBigEndian)


def handle_echo(event):
    """Optional implementation of the evt.EVT_C_ECHO handler."""
    # Return a Success response to the peer
    # We could also return a pydicom Dataset with a (0000, 0900) Status
    #   element
    return 0x0000

handlers = [(evt.EVT_C_ECHO, handle_echo)]

# Create application entity
ae = AE(ae_title=args.aetitle)
ae.add_supported_context(VerificationSOPClass, transfer_syntax)
ae.maximum_pdu_size = args.max_pdu

# Set timeouts
ae.network_timeout = args.timeout
ae.acse_timeout = args.acse_timeout
ae.dimse_timeout = args.dimse_timeout

ae.start_server(('', args.port), evt_handlers=handlers)
github pydicom / pynetdicom / pynetdicom / apps / findscp / findscp.py View on Github external
ds = Dataset()
        if 'QueryRetrieveLevel' in identifier:
            ds.QueryRetrieveLevel = identifier.QueryRetrieveLevel
        ds.RetrieveAETitle = args.aetitle
        ds.PatientName = data.PatientName

        status_ds = Dataset()
        status_ds.Status = 0xFF00
        yield status_ds, ds


handlers = [(evt.EVT_C_FIND, handle_find)]


# Create application entity
ae = AE(ae_title=args.aetitle)
for context in QueryRetrievePresentationContexts:
    ae.add_supported_context(context.abstract_syntax, transfer_syntax)

ae.maximum_pdu_size = args.max_pdu

# Set timeouts
ae.network_timeout = args.timeout
ae.acse_timeout = args.acse_timeout
ae.dimse_timeout = args.dimse_timeout

ae.start_server(('', args.port), evt_handlers=handlers)