Browse Source

linted the project

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

2
mtor/__init__.py

@ -15,7 +15,7 @@ __version__ = "0.1.0" @@ -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)

6
mtor/commons.py

@ -12,11 +12,7 @@ IMG_MAX_INTENSITY = 65535 # 2^16 - 1 @@ -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+)")

9
mtor/dataproc.py

@ -116,7 +116,9 @@ def find_guard_threshold(data_frame, parameters): @@ -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): @@ -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(

21
mtor/gui.py

@ -27,6 +27,7 @@ from .workflows import ( @@ -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): @@ -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): @@ -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:

1
mtor/postproc.py

@ -67,4 +67,3 @@ def rename_cut_images(file_stems, parameters): @@ -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)

7
mtor/workflows.py

@ -53,12 +53,13 @@ def image_workflow(parameters): @@ -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)

Loading…
Cancel
Save