diff --git a/mtor/__init__.py b/mtor/__init__.py index 4b53b1f..a23b340 100644 --- a/mtor/__init__.py +++ b/mtor/__init__.py @@ -15,7 +15,7 @@ __version__ = "0.1.0" def run_test(): - #pw = prescan_workflow("mtor-bilder", 50, 725 + 150, 300, 725) + # pw = prescan_workflow("mtor-bilder", 50, 725 + 150, 300, 725) pw = prescan_workflow("mtor-bilder-2", 125, 795, 275, 700) iw = image_workflow(pw.parameters) dw = data_workflow(iw.data, iw.parameters) diff --git a/mtor/commons.py b/mtor/commons.py index 2130b19..969d784 100644 --- a/mtor/commons.py +++ b/mtor/commons.py @@ -12,11 +12,7 @@ IMG_MAX_INTENSITY = 65535 # 2^16 - 1 LABEL_SELECTED = "selected" LABEL_DISCARDED = "discarded" -OUTPUT_FOLDER_NAMES = ( - "colored", - "cuts", - "data", -) +OUTPUT_FOLDER_NAMES = ("colored", "cuts", "data") RE_DIGITS = re.compile(r"(\d+)") diff --git a/mtor/dataproc.py b/mtor/dataproc.py index ac9c717..72a6e2c 100644 --- a/mtor/dataproc.py +++ b/mtor/dataproc.py @@ -116,7 +116,9 @@ def find_guard_threshold(data_frame, parameters): guard_data = numpy.histogram( guard_values, bins=parameters.guard_histogram_bins ) - guard_counts = numpy.concatenate([[0], guard_data[0]]).astype(numpy.float16) + guard_counts = numpy.concatenate([[0], guard_data[0]]).astype( + numpy.float16 + ) guard_edges = guard_data[1] # edges enclose the counts pyplot.clf() @@ -410,8 +412,9 @@ def create_report(data_frame, selected_df, extremas_df, parameters): text_and_graph( 4, ( - "The images with one of the guard values above the threshold " - "are discarded." + f"{num_discarded} images with one of the guard values above " + f"the threshold are discarded, leaving {num_selected} " + f"selected images." ), ), Image( diff --git a/mtor/gui.py b/mtor/gui.py index 222be87..af34509 100644 --- a/mtor/gui.py +++ b/mtor/gui.py @@ -27,6 +27,7 @@ from .workflows import ( PARAMETERS_FILE = "mia-gui-parameters.json" + class MtorImageAnalysis(QWidget): def __init__(self): super().__init__() @@ -89,14 +90,14 @@ class MtorImageAnalysis(QWidget): self.btn_exit.clicked.connect(QApplication.instance().quit) self.fields_map = { - 'folder': (self.dir_selected, str), - 'top': (self.roi_top_input, int), - 'right': (self.roi_right_input, int), - 'bottom': (self.roi_bottom_input, int), - 'left': (self.roi_left_input, int), - 'cut_pad_x': (self.pad_x_input, int), - 'cut_pad_y': (self.pad_y_input, int), - 'boost': (self.cc_boost_input, int), + "folder": (self.dir_selected, str), + "top": (self.roi_top_input, int), + "right": (self.roi_right_input, int), + "bottom": (self.roi_bottom_input, int), + "left": (self.roi_left_input, int), + "cut_pad_x": (self.pad_x_input, int), + "cut_pad_y": (self.pad_y_input, int), + "boost": (self.cc_boost_input, int), } # Layout @@ -203,7 +204,9 @@ class MtorImageAnalysis(QWidget): parameter_path = Path(parameters["folder"]) / PARAMETERS_FILE try: with parameter_path.open("w") as fh: - tmp = {k: v for k, v in parameters.items() if k != "folder"} + tmp = { + k: v for k, v in parameters.items() if k != "folder" + } print(tmp) json.dump(tmp, fh) except Exception: diff --git a/mtor/postproc.py b/mtor/postproc.py index 084f17e..459f4d2 100644 --- a/mtor/postproc.py +++ b/mtor/postproc.py @@ -67,4 +67,3 @@ def rename_cut_images(file_stems, parameters): ) new_path = path.with_name(f"{path.stem}_cut_{label}{path.suffix}") path.rename(new_path) - diff --git a/mtor/workflows.py b/mtor/workflows.py index a8aeaf1..b7f8e1a 100644 --- a/mtor/workflows.py +++ b/mtor/workflows.py @@ -53,12 +53,13 @@ def image_workflow(parameters): def data_workflow(stats_results, parameters): - from .dataproc import save_temp - print("3/5: Data analysis") set_plotting_styles() data_frame = construct_data_frame(stats_results, parameters) - # save_temp(data_frame, parameters) # enable this for the main run_test_data + + # uncomment the next two lines to use the main run_test_data + # from .dataproc import save_temp + # save_temp(data_frame, parameters) find_guard_threshold(data_frame, parameters) data_frame = check_guards(data_frame, parameters)