Skip to content

Commit

Permalink
few fixes in text and command line creation
Browse files Browse the repository at this point in the history
  • Loading branch information
RRobert92 committed Jul 24, 2024
1 parent fb1beca commit 353f80f
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 29 deletions.
14 changes: 13 additions & 1 deletion random_tests.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,20 @@
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": "",
"source": [
"from tardis_em.utils.load_data import load_image\n",
"\n",
"img, px = load_image('../test_data/20240321_b2g1_ts34.mrc')"
],
"id": "44ce4c5a9f09cd53"
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": "",
"id": "baa508263aec7bf6"
}
],
"metadata": {
Expand Down
1 change: 1 addition & 0 deletions src/napari_tardis_em/viewers/viewer_actin_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def __init__(self, viewer_actin_3d: Viewer):
self.output_instance = QComboBox()
self.output_instance.addItems(["None", "csv", "npy", "amSG", "mrc"])
self.output_instance.setToolTip("Select instance output format file.")
self.output_instance.setCurrentIndex(1)

self.output_formats = (
f"{self.output_semantic.currentText()}_{self.output_instance.currentText()}"
Expand Down
1 change: 1 addition & 0 deletions src/napari_tardis_em/viewers/viewer_mem_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def __init__(self, viewer_mem_2d: Viewer):
self.output_instance = QComboBox()
self.output_instance.addItems(["None", "csv", "npy", "amSG", "mrc"])
self.output_instance.setToolTip("Select instance output format file.")
self.output_instance.setCurrentIndex(1)

self.output_formats = (
f"{self.output_semantic.currentText()}_{self.output_instance.currentText()}"
Expand Down
1 change: 1 addition & 0 deletions src/napari_tardis_em/viewers/viewer_mem_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def __init__(self, viewer_mem_3d: Viewer):
self.output_instance = QComboBox()
self.output_instance.addItems(["None", "csv", "npy", "amSG", "stl", "mrc"])
self.output_instance.setToolTip("Select instance output format file.")
self.output_instance.setCurrentIndex(1)

self.output_formats = (
f"{self.output_semantic.currentText()}_{self.output_instance.currentText()}"
Expand Down
3 changes: 2 additions & 1 deletion src/napari_tardis_em/viewers/viewer_mt_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def __init__(self, viewer_mt_3d: Viewer):
self.output_instance = QComboBox()
self.output_instance.addItems(["None", "csv", "npy", "amSG", "mrc"])
self.output_instance.setToolTip("Select instance output format file.")
self.output_instance.setCurrentIndex(1)

self.output_formats = (
f"{self.output_semantic.currentText()}_{self.output_instance.currentText()}"
Expand Down Expand Up @@ -189,7 +190,7 @@ def __init__(self, viewer_mt_3d: Viewer):
"false/positives. Higher value will result in cleaner output but may \n"
"reduce recall."
)
self.cnn_threshold.valueChanged.connect(self.update_dist_graph)
self.dist_threshold.valueChanged.connect(self.update_dist_graph)

self.device = QComboBox()
self.device.addItems(get_list_of_device())
Expand Down
1 change: 1 addition & 0 deletions src/napari_tardis_em/viewers/viewer_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def __init__(self, viewer_predict: Viewer):
self.output_instance = QComboBox()
self.output_instance.addItems(["None", "csv", "npy", "amSG", "mrc"])
self.output_instance.setToolTip("Select instance output format file.")
self.output_instance.setCurrentIndex(1)

self.output_formats = (
f"{self.output_semantic.currentText()}_{self.output_instance.currentText()}"
Expand Down
70 changes: 43 additions & 27 deletions src/napari_tardis_em/viewers/viewer_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,14 +736,23 @@ def show_validation(self, init_=False):
)

def show_command(self):
ps = ("" if self.patch_size.currentText() == "64"
else f"-ps {int(self.patch_size.currentText())} ")
ps = (
""
if self.patch_size.currentText() == "64"
else f"-ps {int(self.patch_size.currentText())} "
)

px = ("" if self.pixel_size.text() == "None"
else f"-px {float(self.pixel_size.text())} ")
px = (
""
if self.pixel_size.text() == "None"
else f"-px {float(self.pixel_size.text())} "
)

ms = ("" if not int(self.mask_size.text()) == 150
else f"-ms {int(self.mask_size.text())} ")
ms = (
""
if not int(self.mask_size.text()) == 150
else f"-ms {int(self.mask_size.text())} "
)

cnn = (
""
Expand All @@ -752,80 +761,87 @@ def show_command(self):
)

co = (
"" if int(self.cnn_out_channel.text()) == 1
""
if int(self.cnn_out_channel.text()) == 1
else f"-co {int(self.cnn_out_channel.text())} "
)

b = (
"" if int(self.batch_size.text()) == 25
""
if int(self.batch_size.text()) == 25
else f"-b {int(self.batch_size.text())} "
)

cl = (
"" if int(self.cnn_layers.text()) == 5
""
if int(self.cnn_layers.text()) == 5
else f"-cl {int(self.cnn_layers.text())} "
)

cm = (
"" if int(self.cnn_scaler.currentText()) == 32
""
if int(self.cnn_scaler.currentText()) == 32
else f"-cm {int(self.cnn_scaler.currentText())} "
)

if self.image_type.currentText() == "2D":
cs = (
"" if self.cnn_structure.text() == "gcl"
""
if self.cnn_structure.text() == "gcl"
else f"-cs 2{self.cnn_structure.text()} "
)
else:
cs = (
"" if self.cnn_structure.text() == "gcl"
""
if self.cnn_structure.text() == "gcl"
else f"-cs 3{self.cnn_structure.text()} "
)

ck = (
"" if int(self.cnn_kernel.text()) == 3
""
if int(self.cnn_kernel.text()) == 3
else f"-ck {int(self.cnn_kernel.text())} "
)

cp = (
"" if int(self.cnn_padding.text()) == 1
""
if int(self.cnn_padding.text()) == 1
else f"-cp {int(self.cnn_padding.text())} "
)

cmpk = (
"" if int(self.cnn_max_pool.text()) == 2
""
if int(self.cnn_max_pool.text()) == 2
else f"-cmpk {int(self.cnn_max_pool.text())} "
)

l = (
"" if self.loss_function.currentText() == "BCELoss"
""
if self.loss_function.currentText() == "BCELoss"
else f"-l {self.loss_function.currentText()} "
)

lr = (
"" if float(self.learning_rate.text()) == 0.0005
""
if float(self.learning_rate.text()) == 0.0005
else f"-lr {float(self.learning_rate.text())} "
)

e = (
"" if int(self.epoch.text()) == 10000
else f"-e {int(self.epoch.text())} "
)
e = "" if int(self.epoch.text()) == 10000 else f"-e {int(self.epoch.text())} "

es = (
"" if int(self.early_stop.text()) == 10000
""
if int(self.early_stop.text()) == 10000
else f"-es {int(self.early_stop.text())} "
)

dp = (
"" if float(self.dropout_rate.text()) == 0.5
""
if float(self.dropout_rate.text()) == 0.5
else f"-dp {float(self.dropout_rate.text())} "
)

cch = (
"" if self.checkpoint_dir is None else
f"-cch {self.checkpoint_dir} "
)
cch = "" if self.checkpoint_dir is None else f"-cch {self.checkpoint_dir} "

show_info(
f"tardis_cnn_train "
Expand Down

0 comments on commit 353f80f

Please sign in to comment.