pacsifier.core.dcmtk.commands module

This module contains functions to execute DCMTK commands.

pacsifier.core.dcmtk.commands.echo(server_address: str = 'www.dicomserver.co.uk', port: int = 104, server_aet: str = 'theServertAET', aet: str = 'AET', log_dir: str = './logs', timeout: int = 10) str[source]

Checks that the PACS server can be reached and accepts associations.

Parameters:
  • server_address – PACS server IP address.

  • port – PACS server port for incoming requests. Default is 104.

  • server_aet – PACS server AET. Default is “theServerAET”.

  • aet – AET of the calling entity. Default is “AET”.

  • log_dir – Folder for the logs where the log file (log.txt) and the fails file (fails.txt) produced by run() will be written. Default is “./logs” e.g. the logs/ folder in the current working directory.

  • timeout – time in seconds to wait for a response from the server. Default is 30.

Returns:

The log lines.

Return type:

string

pacsifier.core.dcmtk.commands.find(aet: str, server_address: str = 'www.dicomserver.co.uk', server_aet: str = 'theServerAET', port: int = 104, query_retrieval_level: str = 'SERIES', patient_id: str = '', study_uid: str = '', series_instance_uid: str = '', series_description: str = '', protocol_name: str = '', acquisition_date: str = '', patient_name: str = '', patient_birthdate: str = '', study_date: str = '', device_serial_number: str = '', modality: str = '', image_type: str = '', study_description: str = '', accession_number: str = '', sequence_name: str = '', log_dir: str = './logs') str[source]

Builds a query for findscu of QueryRetrieveLevel of series using the parameters passed as arguments.

Parameters:
  • aet – called AET.

  • server_address – PACS server IP address. Default is “www.dicomserver.co.uk”.

  • server_aet – PACS server AET. Default is “theServerAET”.

  • port – PACS server port for incoming requests. Default is 104.

  • query_retrieval_level – query retrieval level which can only take values in {SERIES, STRUDY, PATIENT, IMAGE}. Default is “SERIES”.

  • patient_id – patient id. Default is “”.

  • study_uid – study unique identifier. Default is “”.

  • series_instance_uid – series Instance UID. Default is “”.

  • series_description – series Description. Default is “”.

  • protocol_name – protocol name. Default is “”.

  • acquisition_date – acquisition date. Default is “”.

  • patient_name – patient’s name. Default is “”.

  • patient_birthdate – patient’s birth date. Default is “”.

  • study_date – study Date. Default is “”.

  • device_serial_number – MRI device serial number. Default is “”.

  • modality – modality. Default is “”.

  • image_type – image type. Default is “”.

  • study_description – description of the study. Default is “”.

  • accession_number – accession number. Default is “”.

  • sequence_name – sequence name. Default is “”.

  • log_dir – Folder for the logs where the log file (log.txt) and the fails file (fails.txt) produced by run() will be written. Default is “./logs” e.g. the logs/ folder in the current working directory.

Returns:

The log lines.

Return type:

string

pacsifier.core.dcmtk.commands.get(aet: str, study_date: str, server_address: str = 'www.dicomserver.co.uk', server_aet: str = 'theServerAET', port: int = 104, patient_id: str = '"PAT004"', study_instance_uid: str = '"1.2.276.0.7230010.3.1.4.2032403683.11008.1512470699.461"', series_instance_uid: str = '"1.2.276.0.7230010.3.1.4.2032403683.11008.1512470699.462"', move_port: int = 4006, output_dir: str = '.', log_dir: str = './logs') str[source]

Builds a query for movescu.

Parameters:
  • aet – called AET.

  • study_date – study date.

  • server_address – PACS server IP address. Default is “www.dicomserver.co.uk”.

  • server_aet – PACS server AET. Default is “theServerAET”.

  • port – PACS server port for incoming requests. Default is 104.

  • patient_id – patient id. Default is pacsifier.core.execute_commands.patient_id.

  • study_instance_uid – study instance unique idetifier. Default is pacsifier.core.execute_commands.study_instance_uid.

  • series_instance_uid – series instance unique identifier. Default is pacsifier.core.execute_commands.series_instance_uid.

  • move_port – port used for movescu command. Default is 4006.

  • output_dir – directory of output files. Default is “.” e.g. the current working directory.

  • log_dir – Folder for the logs where the log file (log.txt) and the fails file (fails.txt) produced by run() will be written. Default is “./logs” e.g. the logs/ folder in the current working directory.

Returns:

The log lines.

Return type:

string

pacsifier.core.dcmtk.commands.move_remote(aet: str, study_date: str, server_address: str = 'www.dicomserver.co.uk', server_aet: str = 'theServerAET', port: int = 104, patient_id: str = '"PAT004"', study_instance_uid: str = '"1.2.276.0.7230010.3.1.4.2032403683.11008.1512470699.461"', series_instance_uid: str = '"1.2.276.0.7230010.3.1.4.2032403683.11008.1512470699.462"', move_aet: str = 'theMoveAET', log_dir: str = './logs') str[source]

Builds a query for movescu.

Parameters:
  • aet – called AET.

  • study_date – study date.

  • server_address – PACS server IP address. Default is “www.dicomserver.co.uk”.

  • server_aet – PACS server AET. Default is “theServerAET”.

  • port – PACS server port for incoming requests. Default is 104.

  • patient_id – patient id. Default is pacsifier.core.execute_commands.patient_id.

  • study_instance_uid – study instance unique idetifier. Default is pacsifier.core.execute_commands.study_instance_uid.

  • series_instance_uid – series instance unique identifier. Default is pacsifier.core.execute_commands.series_instance_uid.

  • move_aet – AET where to move the images. Default is “theMoveAET”.

  • log_dir – Folder for the logs where the log file (log.txt) and the fails file (fails.txt) produced by run() will be written. Default is “./logs” e.g. the logs/ folder in the current working directory.

Returns:

The log lines.

Return type:

string

pacsifier.core.dcmtk.commands.replace_default_params(parameters: str, AET: str, server_address: str, server_aet: str, port: int) str[source]

Helper function to replace default parameters in queries by new parameters.

Parameters:
  • parameters – The string containing default parameters for dicomserver

  • AET – Called AET

  • server_address – PACS server IP address

  • server_aet – PACS server AET

  • port – PACS server port for incoming requests

Returns:

modified parameters with input values.

Return type:

string

pacsifier.core.dcmtk.commands.run(query: str, log_dir: str = '.') str[source]

Runs the command passed as parameter.

Parameters:
  • query – Query command line to be executed.

  • log_dir – Directory where the log file (log.txt) and the fails file (fails.txt) will be written. Default is “.” e.g. the current working directory.

Returns:

The log lines.

Return type:

string

pacsifier.core.dcmtk.commands.upload(aet: str, dicom_dir: str, server_address: str = 'www.dicomserver.co.uk', server_aet: str = 'theServerAET', port: int = 4242, log_dir: str = './logs')[source]

Build a query for storescu to upload dicom files to a PACS server.

Parameters:
  • aet – called AET.

  • dicom_dir – directory of dicom files to upload.

  • server_address – PACS server IP address. Default is “www.dicomserver.co.uk”.

  • server_aet – PACS server AET. Default is “theServerAET”.

  • port – PACS server port for incoming requests. Default is 4242.

  • log_dir – Folder for the logs where the log file (log.txt) and the fails file (fails.txt) produced by run() will be written. Default is “./logs” e.g. the logs/ folder in the current working directory.

pacsifier.core.dcmtk.commands.write_file(results: str, file: str = 'output.txt') None[source]

Writes results in file passed in parameters using the parameters passed as arguments.

Parameters:
  • results – a str of lines of logs

  • file – path to text file where the log lines in results will be written