Browse Source

linted the project

master
Holger Frey 6 years ago
parent
commit
7a3826d01a
  1. 6
      mtor/commons.py
  2. 9
      mtor/dataproc.py
  3. 21
      mtor/gui.py
  4. 1
      mtor/postproc.py
  5. 7
      mtor/workflows.py

6
mtor/commons.py

@ -12,11 +12,7 @@ IMG_MAX_INTENSITY = 65535 # 2^16 - 1
LABEL_SELECTED = "selected" LABEL_SELECTED = "selected"
LABEL_DISCARDED = "discarded" LABEL_DISCARDED = "discarded"
OUTPUT_FOLDER_NAMES = ( OUTPUT_FOLDER_NAMES = ("colored", "cuts", "data")
"colored",
"cuts",
"data",
)
RE_DIGITS = re.compile(r"(\d+)") RE_DIGITS = re.compile(r"(\d+)")

9
mtor/dataproc.py

@ -116,7 +116,9 @@ def find_guard_threshold(data_frame, parameters):
guard_data = numpy.histogram( guard_data = numpy.histogram(
guard_values, bins=parameters.guard_histogram_bins 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 guard_edges = guard_data[1] # edges enclose the counts
pyplot.clf() pyplot.clf()
@ -410,8 +412,9 @@ def create_report(data_frame, selected_df, extremas_df, parameters):
text_and_graph( text_and_graph(
4, 4,
( (
"The images with one of the guard values above the threshold " f"{num_discarded} images with one of the guard values above "
"are discarded." f"the threshold are discarded, leaving {num_selected} "
f"selected images."
), ),
), ),
Image( Image(

21
mtor/gui.py

@ -27,6 +27,7 @@ from .workflows import (
PARAMETERS_FILE = "mia-gui-parameters.json" PARAMETERS_FILE = "mia-gui-parameters.json"
class MtorImageAnalysis(QWidget): class MtorImageAnalysis(QWidget):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
@ -89,14 +90,14 @@ class MtorImageAnalysis(QWidget):
self.btn_exit.clicked.connect(QApplication.instance().quit) self.btn_exit.clicked.connect(QApplication.instance().quit)
self.fields_map = { self.fields_map = {
'folder': (self.dir_selected, str), "folder": (self.dir_selected, str),
'top': (self.roi_top_input, int), "top": (self.roi_top_input, int),
'right': (self.roi_right_input, int), "right": (self.roi_right_input, int),
'bottom': (self.roi_bottom_input, int), "bottom": (self.roi_bottom_input, int),
'left': (self.roi_left_input, int), "left": (self.roi_left_input, int),
'cut_pad_x': (self.pad_x_input, int), "cut_pad_x": (self.pad_x_input, int),
'cut_pad_y': (self.pad_y_input, int), "cut_pad_y": (self.pad_y_input, int),
'boost': (self.cc_boost_input, int), "boost": (self.cc_boost_input, int),
} }
# Layout # Layout
@ -203,7 +204,9 @@ class MtorImageAnalysis(QWidget):
parameter_path = Path(parameters["folder"]) / PARAMETERS_FILE parameter_path = Path(parameters["folder"]) / PARAMETERS_FILE
try: try:
with parameter_path.open("w") as fh: 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) print(tmp)
json.dump(tmp, fh) json.dump(tmp, fh)
except Exception: except Exception:

1
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}") new_path = path.with_name(f"{path.stem}_cut_{label}{path.suffix}")
path.rename(new_path) path.rename(new_path)

7
mtor/workflows.py

@ -53,12 +53,13 @@ def image_workflow(parameters):
def data_workflow(stats_results, parameters): def data_workflow(stats_results, parameters):
from .dataproc import save_temp
print("3/5: Data analysis") print("3/5: Data analysis")
set_plotting_styles() set_plotting_styles()
data_frame = construct_data_frame(stats_results, parameters) 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) find_guard_threshold(data_frame, parameters)
data_frame = check_guards(data_frame, parameters) data_frame = check_guards(data_frame, parameters)

Loading…
Cancel
Save