moved additional checks inside function
This commit is contained in:
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user