Skip to content

Commit

Permalink
fix for command line
Browse files Browse the repository at this point in the history
  • Loading branch information
RRobert92 committed Jul 24, 2024
1 parent 58365b3 commit fb1beca
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 9 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ setuptools>=70.3.0
napari>=0.5.0

torch>=2.3.0
tardis_em>=0.2.8
tardis_em>=0.2.9

numpy>=2.0.0

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ author_email = [email protected]
license = MIT
license_files = LICENSE
classifiers =
Development Status :: 4 - Beta
Development Status :: 5 - Production/Stable
Framework :: napari
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Expand Down
2 changes: 1 addition & 1 deletion src/napari_tardis_em/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "0.2.9"
version = "0.2.10"
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 @@ -232,6 +232,7 @@ def __init__(self, viewer_actin_3d: Viewer):

self.export_command = QPushButton("Export command for high-throughput")
self.export_command.setMinimumWidth(225)
self.export_command.clicked.connect(self.show_command)

###########################
# Optional Actin Filters #
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 @@ -232,6 +232,7 @@ def __init__(self, viewer_mem_2d: Viewer):

self.export_command = QPushButton("Export command for high-throughput")
self.export_command.setMinimumWidth(225)
self.export_command.clicked.connect(self.show_command)

#############################
# Optional Membrane Filters #
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 @@ -231,6 +231,7 @@ def __init__(self, viewer_mem_3d: Viewer):

self.export_command = QPushButton("Export command for high-throughput")
self.export_command.setMinimumWidth(225)
self.export_command.clicked.connect(self.show_command)

"""""" """""" """
UI Setup
Expand Down
1 change: 1 addition & 0 deletions src/napari_tardis_em/viewers/viewer_mt_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ def __init__(self, viewer_mt_3d: Viewer):

self.export_command = QPushButton("Export command for high-throughput")
self.export_command.setMinimumWidth(225)
self.export_command.clicked.connect(self.show_command)

#################################
# Optional Microtubules Filters #
Expand Down
12 changes: 6 additions & 6 deletions src/napari_tardis_em/viewers/viewer_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ def __init__(self, viewer_predict: Viewer):

self.export_command = QPushButton("Export command for high-throughput")
self.export_command.setMinimumWidth(225)
self.export_command.clicked.connect(self.show_command)

#################################
# Optional Filament Filters #
Expand Down Expand Up @@ -722,22 +723,21 @@ def predict_dist():
worker.start()

def show_command(self):
mask = "" if not bool(self.mask.checkState()) else "-ms True"
ms = "" if not bool(self.mask.checkState()) else "-ms True"

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

if self.px is not None:
correct_px = (
px = (
""
if self.px == float(self.correct_px.text())
else f"-px {float(self.correct_px.text())} "
)

px = "" if not bool(self.mask.checkState()) else "-ms True "

ch = (
""
if self.checkpoint.text() == "None"
Expand Down Expand Up @@ -777,7 +777,7 @@ def show_command(self):
show_info(
f"tardis_predict "
f"-dir {self.out_} "
f"{mask}"
f"{ms}"
f"{px}"
f"{fi}"
f"{it}"
Expand Down
120 changes: 120 additions & 0 deletions src/napari_tardis_em/viewers/viewer_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ def __init__(self, viewer_train: Viewer):
self.stop_button = QPushButton("Stop Training")
self.stop_button.setMinimumWidth(225)

self.export_command = QPushButton("Export command for high-throughput")
self.export_command.setMinimumWidth(225)
self.export_command.clicked.connect(self.show_command)

"""""" """""" """
UI Setup
""" """""" """"""
Expand Down Expand Up @@ -325,6 +329,7 @@ def __init__(self, viewer_train: Viewer):

layout.addRow("", self.train_button)
layout.addRow("", self.stop_button)
layout.addRow("", self.export_command)

self.setLayout(layout)

Expand Down Expand Up @@ -729,3 +734,118 @@ def show_validation(self, init_=False):
visibility=True,
range_=(0, 1),
)

def show_command(self):
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())} ")

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

cnn = (
""
if self.cnn_type.currentText() == "unet"
else f"-cnn {self.cnn_type.currentText()} "
)

co = (
"" 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
else f"-b {int(self.batch_size.text())} "
)

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

cm = (
"" 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"
else f"-cs 2{self.cnn_structure.text()} "
)
else:
cs = (
"" if self.cnn_structure.text() == "gcl"
else f"-cs 3{self.cnn_structure.text()} "
)

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

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

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

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

lr = (
"" 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())} "
)

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

dp = (
"" 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} "
)

show_info(
f"tardis_cnn_train "
f"-dir {self.out_} "
f"{ps}"
f"{px}"
f"{ms}"
f"{cnn}"
f"{co}"
f"{b}"
f"{cl}"
f"{cm}"
f"{cs}"
f"{cp}"
f"{cmpk}"
f"{l}"
f"{lr}"
f"{e}"
f"{es}"
f"{dp}"
f"{cch}"
f"-dv {self.device.currentText()}"
)

0 comments on commit fb1beca

Please sign in to comment.