pacsifier.cli.pacsifier module

Script to query, retrieve, and upload DICOM images from / to a PACS server.

pacsifier.cli.pacsifier.check_query_table_allowed_filters(table: <Mock name='mock.DataFrame' id='140068351616112'>, allowed_filters: ~typing.List[str] = ['StudyDate', 'StudyTime', 'SeriesDescription', 'PatientID', 'ProtocolName', 'StudyInstanceUID', 'SeriesInstanceUID', 'PatientName', 'PatientBirthDate', 'DeviceSerialNumber', 'AcquisitionDate', 'Modality', 'ImageType', 'SeriesNumber', 'StudyDescription', 'AccessionNumber', 'SequenceName', 'new_ids']) None

Check if the csv table passed as input has only attributes that are allowed.

Parameters:
  • table – table containing all filters

  • allowed_filters – list of allowed attribute names

pacsifier.cli.pacsifier.get_parser() ArgumentParser

Return the parser object for this script.

pacsifier.cli.pacsifier.main()

Main function of the script that calls retrieve_dicoms_using_table().

pacsifier.cli.pacsifier.parse_findscu_dump_file(filename: str) List[Dict[str, str]]

Extract all useful information from the text file generated by dumping the output of the findscu command.

Parameters:

filename – path to textfile to be read

Returns:

list dictionaries each containing the attributes of a series

Return type:

list

pacsifier.cli.pacsifier.parse_query_table(table: <Mock name='mock.DataFrame' id='140068351616112'>, allowed_filters: ~typing.List[str] = ['StudyDate', 'StudyTime', 'SeriesDescription', 'PatientID', 'ProtocolName', 'StudyInstanceUID', 'SeriesInstanceUID', 'PatientName', 'PatientBirthDate', 'DeviceSerialNumber', 'AcquisitionDate', 'Modality', 'ImageType', 'SeriesNumber', 'StudyDescription', 'AccessionNumber', 'SequenceName', 'new_ids']) List[Dict[str, str]]

Take the query table passed as input to the script and parse it using attributes in the query / retrieve command.

Parameters:
  • table – input csv table

  • allowed_filters – list of allowed attributes to be filtered

Returns:

list of dictionaries each containing the corresponding value

of each attribute in allowed_filters (in the case an attribute has no corresponding column in the csv table, an empty string is given)

Return type:

list

pacsifier.cli.pacsifier.process_person_names(name: str) str

Modify patient name for the query input.

It convert all characters to uppercase, prepends a * to the last name and returns the new name.

Parameters:

name – patient’s name

Returns:

patient name in the format it will be used in the query

Return type:

string

pacsifier.cli.pacsifier.readLineByLine(filename: str) Iterator[str]

Return a list of lines of a text file located at the path filename.

Parameters:

filename – path to text file to be read

Yields:

Iterator – list of text lines of the file

pacsifier.cli.pacsifier.retrieve_dicoms_using_table(table: <Mock name='mock.DataFrame' id='140068351616112'>, parameters: ~typing.Dict[str, str], output_dir: str, save: bool, info: bool, move: bool, resume: bool = False, verbose: bool = False) None

Query and retrieve dicom images or / and their info dumps using the input query table.

Parameters:
  • table – query table

  • parameters – query/retrieve parameters

  • output_dir – path to the output directory

  • save – option to save the images

  • info – option to save info dumps

  • move – option to move images to remote destination

  • resume – option to skip already downloaded series

pacsifier.cli.pacsifier.upload_dicoms(dicom_dir: str, parameters: Dict[str, str]) None

Upload dicoms to a PACS server.

Parameters:
  • dicom_dir

    path to the directory containing the dicoms. The directory should adopt the structure adopted by PACSIFIER output directory when using the –save command. This means that it should contain a subdirectory for each patient, which in turn should contain a subdirectory for each study, which in turn should contain a subdirectory for each series, such as:

    dicom_dir

    ├── sub-01 │ ├── ses-01 │ │ ├── 00001-First_series │ │ │ ├── image1.dcm │ │ │ ├── image2.dcm │ │ │ ├── … │ │ ├── 00002-Second_series │ │ │ ├── image1.dcm │ │ │ ├── image2.dcm │ │ │ ├── … ├── sub-02 │ ├── ses-01 │ │ ├── 00001-First_series │ │ │ ├── image1.dcm

  • parameters – parameters from PACSIFIER configuration file