moved additional checks inside function

This commit is contained in:
2024-07-30 22:23:28 +02:00
parent 12e008aeba
commit 1db20f8b82
2 changed files with 19 additions and 8 deletions

View File

@ -1,10 +1,25 @@
import numpy as np
def calc_roi(results, data, roi_x1, roi_x2, roi_y1, roi_y2, pixel_mask_pf, threshold_value_choice):
def calc_roi(results, data, pixel_mask_pf, threshold_value_choice):
if pixel_mask_pf is None:
return
for k in ("roi_x1", "roi_x2", "roi_y1", "roi_y2"):
if k not in results:
return
roi_x1 = results["roi_x1"]
roi_x2 = results["roi_x2"]
roi_y1 = results["roi_y1"]
roi_y2 = results["roi_y2"]
if len(roi_x1) == 0:
return
if not (len(roi_x1) == len(roi_x2) == len(roi_y1) == len(roi_y2)):
return
roi_results = [0] * len(roi_x1)
roi_results_normalised = [0] * len(roi_x1)

View File

@ -196,13 +196,9 @@ def work(backend_address, accumulator_host, accumulator_port, visualisation_host
pfdata[pfdata > threshold_max] = threshold_value
# if roi calculation request is present, make it
roi_x1 = results.get("roi_x1", [])
roi_x2 = results.get("roi_x2", [])
roi_y1 = results.get("roi_y1", [])
roi_y2 = results.get("roi_y2", [])
if len(roi_x1) > 0 and len(roi_x1) == len(roi_x2) == len(roi_y1) == len(roi_y2):
calc_roi(results, pfdata, roi_x1, roi_x2, roi_y1, roi_y2, pixel_mask_pf, threshold_value_choice)
do_roi = ("roi_x1" in results)
if do_roi:
calc_roi(results, pfdata, pixel_mask_pf, threshold_value_choice)
# SPI analysis
do_spi_analysis = results.get("do_spi_analysis", False)