Data Extraction

class ledsa.data_extraction.DataExtractor.DataExtractor(channels=0, load_config_file=True, build_experiment_infos=True, fit_leds=True)[source]

Bases: object

A class responsible for extracting data from experiment images.

Variables:
  • config (ConfigData) – Configuration data object.

  • channels (Tuple) – Channels to be processed.

  • fit_leds (bool :ivar fit_leds: Whether to fit LEDs or not.) – Whether to fit LEDs or not.

  • threshold (float, optional) – The threshold value used for LED detection.

  • line_indices (list[list[int]], optional) – 2D list with dimension (# of LED arrays) x (# of LEDs per array) or None.

find_search_areas() None[source]

Identify all LEDs in the reference image and define the areas where LEDs will be searched in the experiment images.

load_led_array_indices() None[source]

Load LED array indices from the ‘led_array_indices_{…}.csv’ files.

load_search_areas() None[source]

Load LED search areas from the ‘led_search_areas.csv’ file. #TODO be consistent with search areas and ROIS

match_leds_to_led_arrays() None[source]

Analyze which LEDs belong to which LED array and save this mapping.

plot_led_arrays(merge_led_arrays=False) None[source]

Plots the arrangement of LEDs as identified in the LED arrays and saves the plot as a PDF file.

Parameters:

merge_led_arrays (bool) – A flag indicating whether LED arrays have been merged. Affects the naming of the output file.

plot_search_areas(reorder_leds=False) None[source]

Plot the identified LED search areas with their ID labels.

Parameters:

reorder_leds (bool) – A flag indicating whether the LED IDs have been reordered. Affects the name of the output file.

process_image_data() None[source]

Process all the image data to detect changes in light intensity in the search areas across the images. Removes ‘images_to_process.csv’ file afterward.

process_img_file(img_filename: str) None[source]

Process a single image file to extract relevant data. This is a workaround for pool.map.

Parameters:

img_filename (str) – The name of the image file to be processed.

setup_restart() None[source]

Setup a restart in case the data extraction process was interrupted earlier.

setup_step3() None[source]

Setup the third step of the data extraction process by creating ‘image_infos_analysis.csv’ and ‘images_to_process.csv’ files.

write_search_areas(reorder_leds=False) None[source]

Writes LED search areas to a CSV file.

Parameters:

reorder_leds (bool) – A flag indicating whether the LED IDs have been reordered. Affects the header of the output file.

class ledsa.data_extraction.LEDAnalysisData.LEDAnalysisData(led_id, led_array, fit_leds)[source]

Bases: object

Represents LED analysis data, including its physical properties and fit results.

Variables:
  • led_id (int) – The ID of the LED.

  • led_array (int) – The array index the LED belongs to.

  • fit_leds (bool) – Indicates whether to fit LEDs or not.

  • led_center_x (float) – X-coordinate of LED’s center.

  • led_center_y (float) – Y-coordinate of LED’s center.

  • mean_color_value (float) – Mean color value of the LED over the search area.

  • sum_color_value (float) – Integrated color value of the LED over the search area.

  • max_color_value (float) – Maximum color value observed for the LED.

  • fit_results (OptimizeResult) – Fit results after fitting.

  • fit_time (float) – Time taken for fitting.

get_fit_data_string() str[source]

Provides the fitted LED data as a formatted string.

Returns:

Formatted string of fitted LED data.

Return type:

str

get_main_data_string() str[source]

Provides the main LED data as a formatted string.

Returns:

Formatted string containing led_id, led_array and pixel values.

Return type:

str