pypocquant.lib.pipeline

Module Contents

Functions

run_pool(files, raw_auto_stretch, raw_auto_wb, input_folder_path, results_folder_path, strip_try_correct_orientation, strip_try_correct_orientation_rects, strip_text_to_search, strip_text_on_right, min_sensor_score, qr_code_border, perform_sensor_search, sensor_size, sensor_center, sensor_search_area, sensor_thresh_factor, sensor_border, peak_expected_relative_location, control_band_index, subtract_background, force_fid_search, sensor_band_names, verbose, qc, max_workers=4)

Run a thread pool for the analysis.

run_pipeline(input_folder_path: Path, results_folder_path: Path, raw_auto_stretch: bool = False, raw_auto_wb: bool = False, strip_try_correct_orientation: bool = False, strip_try_correct_orientation_rects: tuple = (0.52, 0.15, 0.09), strip_text_to_search: str = 'COVID', strip_text_on_right: bool = True, min_sensor_score: float = 0.85, qr_code_border: int = 30, perform_sensor_search: bool = True, sensor_size: tuple = (61, 249), sensor_center: tuple = (178, 667), sensor_search_area: tuple = (71, 259), sensor_thresh_factor: float = 2, sensor_border: tuple = (7, 7), peak_expected_relative_location: tuple = (0.25, 0.53, 0.79), control_band_index: int = -1, subtract_background: bool = True, force_fid_search: bool = False, sensor_band_names: tuple = ('igm', 'igg', 'ctl'), verbose: bool = False, qc: bool = False, max_workers: int = 2)

Run the whole processing and analysis pipeline.

run(filename, raw_auto_stretch, raw_auto_wb, input_folder_path: Path, results_folder_path: Path, strip_try_correct_orientation: bool, strip_try_correct_orientation_rects: tuple, strip_text_to_search: str, strip_text_on_right: bool, min_sensor_score: float = 0.85, qr_code_border: int = 30, perform_sensor_search: bool = False, sensor_size: tuple = (37, 185), sensor_center: tuple = (119, 471), sensor_search_area: tuple = (50, 195), sensor_thresh_factor: float = 2, sensor_border: tuple = (7, 7), peak_expected_relative_location: tuple = (0.27, 0.55, 0.79), control_band_index: int = -1, subtract_background: bool = True, force_fid_search: bool = False, sensor_band_names: tuple = ('igm', 'igg', 'ctl'), verbose: bool = False, qc: bool = False)

Runnable which runs the analysis on a worker

pypocquant.lib.pipeline.run_pool(files, raw_auto_stretch, raw_auto_wb, input_folder_path, results_folder_path, strip_try_correct_orientation, strip_try_correct_orientation_rects, strip_text_to_search, strip_text_on_right, min_sensor_score, qr_code_border, perform_sensor_search, sensor_size, sensor_center, sensor_search_area, sensor_thresh_factor, sensor_border, peak_expected_relative_location, control_band_index, subtract_background, force_fid_search, sensor_band_names, verbose, qc, max_workers=4)

Run a thread pool for the analysis.

Parameters
  • files (list) – List with image file names to be processed

  • raw_auto_stretch (bool) – Whether to automatically correct the white balance of RAW images on load. This does not affect JPEG images!

  • raw_auto_wb (bool) – Whether to automatically stretch image intensities of RAW images on load. This does not affect JPEG images!

  • input_folder_path (str) – Folder with the raw images to process.

  • results_folder_path (str) – Target folder, where all results and quality control figures are written.

  • strip_try_correct_orientation (bool) – Try to assess and possibly correct for wrong orientation of the strip by searching for the position of the injection inlet.

  • strip_try_correct_orientation_rects (tuple) –

    Tuple containing information about the relative position of the two rectangles to be searched for the inlet on both sides of the center of the image:

    rectangle_props[0]: relative (0..1) vertical height of the rectangle with

    respect to the image height.

    rectangle_props[1]: relative (0..1) distance of the left edge of the right rectangle

    with respect to the center of the image.

    rectangle_props[2]: relative (0..1) distance of the left edge of the left rectangle

    with respect to the center of the image.

  • strip_text_to_search (str) – Text to search on the strip to assess orientation. Set to “” to skip.

  • strip_text_on_right (bool) – Assuming the strip is oriented horizontally, whether the ‘strip_text_to_search’ text is assumed to be on the right. If ‘strip_text_on_right’ is True and the text is found on the left hand-side of the strip, the strip will be rotated 180 degrees. Ignored if strip_text_to_search is “”.

  • min_sensor_score (float) – Minimum segmentation score for the sensor to be considered peak analysis (0.0 <= min_sensor_score <= 1.0). This is currently ignored.

  • qr_code_border (int) – Lateral and vertical extension of the (white) border around each QR code.

  • perform_sensor_search (bool) – If True, the (inverted) sensor is searched within ‘sensor_search_area’ around the expected ‘sensor_center’; if False, the sensor of size ‘sensor_size’ is simply extracted from the strip image centered at the relative strip position ‘sensor_center’.

  • sensor_size (tuple) – Area of the sensor to be extracted (height, width).

  • sensor_center (tuple) – Coordinates of the center of the sensor with respect to the strip image (y, x).

  • sensor_search_area (tuple) – Search area around the sensor (height, width). Used only if ‘skip_sensor_search’ is False.

  • sensor_thresh_factor (int) – Set the number of (robust) standard deviations away from the median band background for a peak to be considered valid.

  • sensor_border (tuple) – Lateral and vertical sensor border to be ignored in the analysis to avoid border effects.

  • peak_expected_relative_location (tuple) – Expected relative peak positions as a function of the width of the sensor (= 1.0)

  • control_band_index (int) – Index of the control band in the peak_expected_relative_location. (Optional, default -1 := right-most)

  • subtract_background (bool) – If True, estimate and subtract the background of the sensor intensity profile.

  • force_fid_search (bool) – If True, apply a series of search fall-back approaches to extract patient data from the image. Only use this if the expected QR code with patient data was not added to the image or could not be extracted.

  • sensor_band_names (tuple) – Names of the bands for the data frame header. Please notice: the third ([2]) band is always the control band.

  • verbose (bool) – Toggle verbose output.

  • qc (bool) – Toggle creation of quality control figures.

  • max_workers (int) – Number of max cores to use for running the pipeline

Returns

res

Return type

list

Returns

log_list

Return type

list

pypocquant.lib.pipeline.run_pipeline(input_folder_path: Path, results_folder_path: Path, raw_auto_stretch: bool = False, raw_auto_wb: bool = False, strip_try_correct_orientation: bool = False, strip_try_correct_orientation_rects: tuple = (0.52, 0.15, 0.09), strip_text_to_search: str = 'COVID', strip_text_on_right: bool = True, min_sensor_score: float = 0.85, qr_code_border: int = 30, perform_sensor_search: bool = True, sensor_size: tuple = (61, 249), sensor_center: tuple = (178, 667), sensor_search_area: tuple = (71, 259), sensor_thresh_factor: float = 2, sensor_border: tuple = (7, 7), peak_expected_relative_location: tuple = (0.25, 0.53, 0.79), control_band_index: int = - 1, subtract_background: bool = True, force_fid_search: bool = False, sensor_band_names: tuple = ('igm', 'igg', 'ctl'), verbose: bool = False, qc: bool = False, max_workers: int = 2)

Run the whole processing and analysis pipeline.

Parameters
  • input_folder_path (str) – Folder with the raw images to process.

  • results_folder_path (str) – Target folder, where all results and quality control figures are written.

  • raw_auto_stretch (bool) – Whether to automatically correct the white balance of RAW images on load. This does not affect JPEG images!

  • raw_auto_wb (bool) – Whether to automatically stretch image intensities of RAW images on load. This does not affect JPEG images!

  • strip_try_correct_orientation (bool) – Try to assess and possibly correct for wrong orientation of the strip by searching for the position of the injection inlet.

  • strip_try_correct_orientation_rects (tuple) –

    Tuple containing information about the relative position of the two rectangles to be searched for the inlet on both sides of the center of the image:

    rectangle_props[0]: relative (0..1) vertical height of the rectangle with

    respect to the image height.

    rectangle_props[1]: relative (0..1) distance of the left edge of the right rectangle

    with respect to the center of the image.

    rectangle_props[2]: relative (0..1) distance of the left edge of the left rectangle

    with respect to the center of the image.

  • strip_text_to_search (str) – Text to search on the strip to assess orientation. Set to “” to skip.

  • strip_text_on_right (bool) – Assuming the strip is oriented horizontally, whether the ‘strip_text_to_search’ text is assumed to be on the right. If ‘strip_text_on_right’ is True and the text is found on the left hand-side of the strip, the strip will be rotated 180 degrees. Ignored if strip_text_to_search is “”.

  • min_sensor_score (float) – Minimum segmentation score for the sensor to be considered peak analysis (0.0 <= min_sensor_score <= 1.0). This is currently ignored.

  • qr_code_border (int) – Lateral and vertical extension of the (white) border around each QR code.

  • perform_sensor_search (bool) – If True, the (inverted) sensor is searched within ‘sensor_search_area’ around the expected ‘sensor_center’; if False, the sensor of size ‘sensor_size’ is simply extracted from the strip image centered at the relative strip position ‘sensor_center’.

  • sensor_size (tuple) – Area of the sensor to be extracted (height, width).

  • sensor_center (tuple) – Coordinates of the center of the sensor with respect to the strip image (y, x).

  • sensor_search_area (tuple) – Search area around the sensor (height, width). Used only if ‘skip_sensor_search’ is False.

  • sensor_thresh_factor (int) – Set the number of (robust) standard deviations away from the median band background for a peak to be considered valid.

  • sensor_border (tuple) – Lateral and vertical sensor border to be ignored in the analysis to avoid border effects.

  • peak_expected_relative_location (tuple) – Expected relative peak positions as a function of the width of the sensor (= 1.0)

  • control_band_index (int) – Index of the control band in the peak_expected_relative_location. (Optional, default -1 := right-most)

  • subtract_background (bool) – If True, estimate and subtract the background of the sensor intensity profile.

  • force_fid_search (bool) – If True, apply a series of search fall-back approaches to extract patient data from the image. Only use this if the expected QR code with patient data was not added to the image or could not be extracted.

  • sensor_band_names (tuple) – Names of the bands for the data frame header. Please notice: the third ([2]) band is always the control band.

  • verbose (bool) – Toggle verbose output.

  • qc (bool) – Toggle creation of quality control figures.

  • max_workers (int) – Number of max cores to use for running the pipeline

pypocquant.lib.pipeline.run(filename, raw_auto_stretch, raw_auto_wb, input_folder_path: Path, results_folder_path: Path, strip_try_correct_orientation: bool, strip_try_correct_orientation_rects: tuple, strip_text_to_search: str, strip_text_on_right: bool, min_sensor_score: float = 0.85, qr_code_border: int = 30, perform_sensor_search: bool = False, sensor_size: tuple = (37, 185), sensor_center: tuple = (119, 471), sensor_search_area: tuple = (50, 195), sensor_thresh_factor: float = 2, sensor_border: tuple = (7, 7), peak_expected_relative_location: tuple = (0.27, 0.55, 0.79), control_band_index: int = - 1, subtract_background: bool = True, force_fid_search: bool = False, sensor_band_names: tuple = ('igm', 'igg', 'ctl'), verbose: bool = False, qc: bool = False)

Runnable which runs the analysis on a worker

Parameters
  • filename (list) – Image file name to be processed

  • raw_auto_stretch (bool) – Whether to automatically correct the white balance of RAW images on load. This does not affect JPEG images!

  • raw_auto_wb (bool) – Whether to automatically stretch image intensities of RAW images on load. This does not affect JPEG images!

  • input_folder_path (str) – Folder with the raw images to process.

  • results_folder_path (str) – Target folder, where all results and quality control figures are written.

  • strip_try_correct_orientation (bool) – Try to assess and possibly correct for wrong orientation of the strip by searching for the position of the injection inlet.

  • strip_try_correct_orientation_rects (tuple) –

    Tuple containing information about the relative position of the two rectangles to be searched for the inlet on both sides of the center of the image:

    rectangle_props[0]: relative (0..1) vertical height of the rectangle with

    respect to the image height.

    rectangle_props[1]: relative (0..1) distance of the left edge of the right rectangle

    with respect to the center of the image.

    rectangle_props[2]: relative (0..1) distance of the left edge of the left rectangle

    with respect to the center of the image.

  • strip_text_to_search (str) – Text to search on the strip to assess orientation. Set to “” to skip.

  • strip_text_on_right (bool) – Assuming the strip is oriented horizontally, whether the ‘strip_text_to_search’ text is assumed to be on the right. If ‘strip_text_on_right’ is True and the text is found on the left hand-side of the strip, the strip will be rotated 180 degrees. Ignored if strip_text_to_search is “”.

  • min_sensor_score (float) – Minimum segmentation score for the sensor to be considered peak analysis (0.0 <= min_sensor_score <= 1.0). This is currently ignored.

  • qr_code_border (int) – Lateral and vertical extension of the (white) border around each QR code.

  • perform_sensor_search (bool) – If True, the (inverted) sensor is searched within ‘sensor_search_area’ around the expected ‘sensor_center’; if False, the sensor of size ‘sensor_size’ is simply extracted from the strip image centered at the relative strip position ‘sensor_center’.

  • sensor_size (tuple) – Area of the sensor to be extracted (height, width).

  • sensor_center (tuple) – Coordinates of the center of the sensor with respect to the strip image (y, x).

  • sensor_search_area (tuple) – Search area around the sensor (height, width). Used only if ‘skip_sensor_search’ is False.

  • sensor_thresh_factor (int) – Set the number of (robust) standard deviations away from the median band background for a peak to be considered valid.

  • sensor_border (tuple) – Lateral and vertical sensor border to be ignored in the analysis to avoid border effects.

  • peak_expected_relative_location (tuple) – Expected relative peak positions as a function of the width of the sensor (= 1.0)

  • control_band_index (int) – Index of the control band in the peak_expected_relative_location. (Optional, default -1 := right-most)

  • subtract_background (bool) – If True, estimate and subtract the background of the sensor intensity profile.

  • force_fid_search (bool) – If True, apply a series of search fall-back approaches to extract patient data from the image. Only use this if the expected QR code with patient data was not added to the image or could not be extracted.

  • sensor_band_names (tuple) – Names of the bands for the data frame header. Please notice: the third ([2]) band is always the control band.

  • verbose (bool) – Toggle verbose output.

  • qc (bool) – Toggle creation of quality control figures.

Returns

row_data

Returns

image_log