logger.setLevel(logging.INFO) pynetdicom_logger = logging.getLogger('PYNETDICOM3_') pynetdicom_logger.setLevel(logging.INFO) if args.debug: logger.setLevel(logging.DEBUG) pynetdicom_logger = logging.getLogger('pynetdicom3') pynetdicom_logger.setLevel(logging.DEBUG) logger.debug('$movescu.py v{0!s}'.format(VERSION)) logger.debug('') # Create application entity # Binding to port 0 lets the OS pick an available port ae = AE(ae_title=args.calling_aet, port=0) ae.requested_contexts = QueryRetrievePresentationContexts # Request association with remote AE assoc = ae.associate(args.peer, args.port, ae_title=args.called_aet) if assoc.is_established: # Create query dataset ds = Dataset() ds.PatientName = '*' ds.QueryRetrieveLevel = "PATIENT" if args.patient: query_model = 'P' elif args.study: query_model = 'S' elif args.psonly:
logger.setLevel(logging.INFO) pynetdicom_logger = logging.getLogger('pynetdicom3') pynetdicom_logger.setLevel(logging.INFO) if args.debug: logger.setLevel(logging.DEBUG) pynetdicom_logger = logging.getLogger('pynetdicom3') pynetdicom_logger.setLevel(logging.DEBUG) logger.debug('$findscu.py v{0!s}'.format(VERSION)) logger.debug('') # Create application entity # Binding to port 0 lets the OS pick an available port ae = AE(ae_title=args.calling_aet, port=0) ae.requested_contexts = (QueryRetrievePresentationContexts + BasicWorklistManagementPresentationContexts) # Request association with remote assoc = ae.associate(args.peer, args.port, ae_title=args.called_aet) if assoc.is_established: # Import query dataset # Check file exists and is readable and DICOM logger.debug('Checking input files') try: with open(args.dcmfile_in, 'rb') as f: dataset = dcmread(f, force=True) except IOError: logger.error('Cannot read input file {0!s}'.format(args.dcmfile_in)) assoc.release() sys.exit()
from pydicom import dcmread from pydicom.uid import ImplicitVRLittleEndian from pynetdicom3 import AE, VerificationPresentationContexts, StoragePresentationContexts from pynetdicom3.sop_class import CTImageStorage, MRImageStorage ae = AE(ae_title=b'MY_STORAGE_SCU') # We can also do the same thing with the requested contexts ae.requested_contexts = StoragePresentationContexts # Or we can use inbuilt objects like CTImageStorage. # The requested presentation context's transfer syntaxes can also # be specified using a str/UID or list of str/UIDs #ae.add_requested_context(CTImageStorage, #transfer_syntax=ImplicitVRLittleEndian) # Adding a presentation context with multiple transfer syntaxes #ae.add_requested_context(MRImageStorage, #transfer_syntax=[ImplicitVRLittleEndian, #'1.2.840.10008.1.2.1']) #ae.add_requested_context(VerificationPresentationContexts) assoc = ae.associate('127.0.0.1', 11112) if assoc.is_established: dataset = dcmread('test/dcm/CTImageStorage.dcm') # `status` is the response from the peer to the store request # but may be an empty pydicom Dataset if the peer timed out or # sent an invalid dataset. status = assoc.send_c_store(dataset) assoc.release()