io_snc module

This module, io_snc.py, contains functions for handling input and output operations related to ArcCheck files.

The module includes the following functions:

  • parse_arccheck_header: Parses the header information from an ArcCheck file and returns it as a dictionary.

  • parse_arrays_from_file: Parses the array data from an ArcCheck file and returns it as a dictionary.

  • write_snc_txt_file: Writes the array data and header into a .txt file in the same format as it was read.

  • parse_acm_file: Parses an ACM file and returns the frame data, diode data, and background and calibration data.

  • detector_arrays: Rearranges the detector data from acl file into the one displayed in SNC Patient.

  • diode_numbers_in_snc_array: Reorganizes the detectors numbers in an acl measurement file into the planar array that is displayed in SNC Patient software.

This module is part of a larger project aimed at analyzing and correcting dose rate dependencies in ArcCheck measurements.

io_snc.detector_arrays(acl_detectors)[source]

Rearranges the detector data from acl file into the one displayed in SNC Patient.

Parameters:

acl_detectors (pandas.DataFrame) – The measurement data arranged in acl formal.

Returns:

A 3D numpy array created from the differential dose data.

Return type:

numpy.ndarray

Notes

The function initializes a 3D numpy array with zeros and fills it with the detector data.

io_snc.diode_numbers_in_snc_array()[source]

Reorganizes the detectors numbers in an acl measurement file into the planar array that is displayed in SNC Patient software.

Returns:

A 2D numpy array representing the reorganized detectors.

Return type:

numpy.ndarray

Notes

The function creates an initial array of size 41x131 filled with zeros and fills every second row and column with detector numbers.

io_snc.parse_acm_file(file_path)[source]

Parses an ACM file and returns the frame data, diode data, and background and calibration data.

Parameters:

file_path (str) – The path to the ACM file.

Returns:

A tuple containing three pandas DataFrames: frame_data_df, diode_data_df, bkrnd_and_calibration_df.

Return type:

tuple

Notes

The function reads the file line by line and splits each line at the tab character to separate keys and values.

io_snc.parse_arccheck_header(file_path)[source]

Parses the header information from an ArcCheck file and returns it as a dictionary.

Parameters:

file_path (str) – The path to the ArcCheck file.

Returns:

A dictionary containing the header information if the file exists and can be read successfully. Returns None if the file does not exist or an error occurs during reading.

Return type:

dict or None

Raises:

Exception – If an error occurs during file reading.

Notes

The function reads the file line by line and splits each line at the colon character to separate keys and values. The keys are predefined in the header_keys dictionary. If a key from the file matches a key in header_keys, the corresponding value is updated in the dictionary. The function also captures the full header text.

io_snc.parse_arrays_from_file(file_path)[source]

Parses the array data from an ArcCheck file and returns it as a dictionary.

Parameters:

file_path (str) – The path to the ArcCheck file.

Returns:

A dictionary containing the array data if the file exists and can be read successfully.

Return type:

dict

Notes

The function reads the file line by line and splits each line at the space character to separate keys and values. The keys are predefined in the valid_arrays list. If a key from the file matches a key in valid_arrays, the corresponding value is updated in the dictionary.

io_snc.write_snc_txt_file(array_data, header_data, file_path)[source]

Writes the array data and header into a .txt file in the same format as it was read.

Parameters:
  • array_data (dict) – Dictionary containing all the array data.

  • header_data (dict) – Dictionary containing all the header information, including ‘Full Header Text’.

  • file_path (str) – Path to the file where the data should be saved.

Notes

The function writes the full header text directly from the header_data dictionary. Then it writes each array, skipping None values and using tabs as delimiter.