Skip to content

Commit 368e473

Browse files
committed
Fix rebase deletions
1 parent a23a8a6 commit 368e473

File tree

7 files changed

+56
-96
lines changed

7 files changed

+56
-96
lines changed

napari_cellseg3d/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.1rc4"
1+
__version__ = "0.0.2rc1"

napari_cellseg3d/code_models/model_workers.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -138,25 +138,23 @@ def show_progress(count, block_size, total_size):
138138
)
139139
with tarfile.open(filename, mode="r:gz") as tar:
140140
def is_within_directory(directory, target):
141-
142-
abs_directory = os.path.abspath(directory)
143-
abs_target = os.path.abspath(target)
144-
145-
prefix = os.path.commonprefix([abs_directory, abs_target])
146-
147-
return prefix == abs_directory
148-
141+
142+
abs_directory = Path(directory).resolve()
143+
abs_target = Path(target).resolve()
144+
# prefix = os.path.commonprefix([abs_directory, abs_target])
145+
return abs_target in abs_directory.parents
146+
149147
def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
150-
148+
151149
for member in tar.getmembers():
152-
member_path = os.path.join(path, member.name)
150+
member_path = str(Path(path) / member.name)
153151
if not is_within_directory(path, member_path):
154152
raise Exception("Attempted Path Traversal in Tar File")
155-
156-
tar.extractall(path, members, numeric_owner=numeric_owner)
157-
158-
153+
154+
tar.extractall(path, members, numeric_owner=numeric_owner)
155+
159156
safe_extract(tar, pretrained_folder_path)
157+
# tar.extractall(pretrained_folder_path)
160158
else:
161159
raise ValueError(
162160
f"Unknown model: {model_name}. Should be one of {', '.join(neturls)}"

napari_cellseg3d/code_plugins/plugin_crop.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -423,15 +423,16 @@ def _add_crop_sliders(
423423
dims = [self._x, self._y, self._z]
424424
[logger.debug(f"{dim}") for dim in dims]
425425
logger.debug("SET DIMS ATTEMPT")
426-
if not self.create_new_layer.isChecked():
427-
self._x = x
428-
self._y = y
429-
self._z = z
430-
[logger.debug(f"{dim}") for dim in dims]
431-
else:
432-
[self._reset_dim(dim) for dim in dims]
433-
[logger.debug(f"{dim}") for dim in dims]
426+
# if not self.create_new_layer.isChecked():
427+
# self._x = x
428+
# self._y = y
429+
# self._z = z
430+
# [logger.debug(f"{dim}") for dim in dims]
431+
# else:
432+
# [self._reset_dim(dim) for dim in dims]
433+
# [logger.debug(f"{dim}") for dim in dims]
434434
#############
435+
435436
# logger.debug(f"Crop variables")
436437
# logger.debug(im1_stack.shape)
437438

@@ -502,9 +503,9 @@ def set_slice(
502503
highres_crop_layer.translate = scale * izyx
503504
highres_crop_layer.refresh()
504505

505-
self._check_for_empty_layer(
506-
highres_crop_layer, highres_crop_layer.data
507-
)
506+
# self._check_for_empty_layer(
507+
# highres_crop_layer, highres_crop_layer.data
508+
# )
508509

509510
if crop_lbls and labels_crop_layer is not None:
510511
labels_crop_layer.data = im2_stack[

napari_cellseg3d/code_plugins/plugin_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self, viewer: "napari.viewer.Viewer"):
3737
self.logo_label.setToolTip("Open Github page")
3838

3939
self.info_label = ui.make_label(
40-
f"You are using napari-cellseg3d v.{'0.0.1rc4'}\n\n"
40+
f"You are using napari-cellseg3d v.{'0.0.2rc1'}\n\n"
4141
f"Plugin for cell segmentation developed\n"
4242
f"by the Mathis Lab of Adaptive Motor Control\n\n"
4343
f"Code by :\nCyril Achard\nMaxime Vidal\nJessy Lauer\nMackenzie Mathis\n"

napari_cellseg3d/code_plugins/plugin_model_inference.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ def __init__(self, viewer: "napari.viewer.Viewer", parent=None):
144144
)
145145

146146
self.window_infer_box = ui.CheckBox("Use window inference")
147-
148-
self.window_infer_box.clicked.connect(self.toggle_display_window_size)
147+
self.window_infer_box.clicked.connect(self._toggle_display_window_size)
149148

150149
sizes_window = ["8", "16", "32", "64", "128", "256", "512"]
151150
# (
@@ -169,6 +168,7 @@ def __init__(self, viewer: "napari.viewer.Viewer", parent=None):
169168
parent=self,
170169
text_label="Overlap %",
171170
)
171+
172172
self.keep_data_on_cpu_box = ui.CheckBox("Keep data on CPU")
173173

174174
window_size_widgets = ui.combine_blocks(
@@ -238,19 +238,9 @@ def _set_tooltips(self):
238238
"DO NOT CHANGE if you are using the provided pre-trained weights"
239239
)
240240

241-
self.thresholding_checkbox.setToolTip(thresh_desc)
242-
self.thresholding_count.setToolTip(thresh_desc)
243-
self.window_infer_box.setToolTip(
244-
"Sliding window inference runs the model on parts of the image"
245-
"\nrather than the whole image, to reduce memory requirements."
246-
"\nUse this if you have large images."
247-
)
248-
self.window_size_choice.setToolTip(
249-
"Size of the window to run inference with (in pixels)"
250-
)
251-
252-
self.window_overlap_counter.set_all_tooltips(
253-
"Percentage of overlap between windows to use when using sliding window"
241+
thresh_desc = (
242+
"Thresholding : all values in the image below the chosen probability"
243+
" threshold will be set to 0, and all others to 1."
254244
)
255245

256246
self.thresholding_checkbox.setToolTip(thresh_desc)

napari_cellseg3d/interface.py

Lines changed: 25 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -317,18 +317,33 @@ def add_label(widget, label, label_before=True, horizontal=True):
317317
return combine_blocks(label, widget, horizontal=horizontal)
318318

319319

320-
def add_label(widget, label, label_before=True, horizontal=True):
321-
if label_before:
322-
return combine_blocks(widget, label, horizontal=horizontal)
323-
else:
324-
return combine_blocks(label, widget, horizontal=horizontal)
320+
class ContainerWidget(QWidget):
321+
def __init__(
322+
self, l=0, t=0, r=1, b=11, vertical=True, parent=None, fixed=True
323+
):
324+
"""
325+
Creates a container widget that can contain other widgets
326+
Args:
327+
l: left margin in pixels
328+
t: top margin in pixels
329+
r: right margin in pixels
330+
b: bottom margin in pixels
331+
vertical: if True, renders vertically. Horizontal otherwise
332+
parent: parent QWidget
333+
fixed: uses QLayout.SetFixedSize if True
334+
"""
325335

336+
super().__init__(parent)
337+
self.layout = None
326338

327-
def add_label(widget, label, label_before=True, horizontal=True):
328-
if label_before:
329-
return combine_blocks(widget, label, horizontal=horizontal)
330-
else:
331-
return combine_blocks(label, widget, horizontal=horizontal)
339+
if vertical:
340+
self.layout = QVBoxLayout(self)
341+
else:
342+
self.layout = QHBoxLayout(self)
343+
344+
self.layout.setContentsMargins(l, t, r, b)
345+
if fixed:
346+
self.layout.setSizeConstraint(QLayout.SetFixedSize)
332347

333348

334349
class RadioButton(QRadioButton):
@@ -1244,49 +1259,6 @@ def create_single_widget_group(
12441259
layout.addWidget(group)
12451260

12461261

1247-
1248-
class GroupedWidget(QGroupBox):
1249-
"""Subclass of QGroupBox designed to easily group widgets belonging to a same category"""
1250-
1251-
def __init__(self, title, l=7, t=20, r=7, b=11, parent=None):
1252-
super().__init__(title, parent)
1253-
1254-
self.setSizePolicy(QSizePolicy.Fixed)
1255-
1256-
self.layout = QVBoxLayout()
1257-
self.layout.setContentsMargins(l, t, r, b)
1258-
self.layout.setSizeConstraint(QLayout.SetFixedSize)
1259-
1260-
@property
1261-
def layout(self) -> "QLayout":
1262-
return self.layout
1263-
1264-
@classmethod
1265-
def create_single_widget_group(
1266-
cls, title, widget, layout, l=7, t=20, r=7, b=11
1267-
):
1268-
group, group_layout = cls(title, l, t, r, b)
1269-
group_layout.addWidget(widget)
1270-
group.setLayout(group_layout)
1271-
layout.addWidget(group)
1272-
1273-
1274-
class ContainerWidget(QWidget): # TODO convert calls
1275-
def __init__(self, l=0, t=0, r=1, b=11, vertical=True, parent=None):
1276-
1277-
super().__init__(parent)
1278-
self.layout = None
1279-
1280-
if vertical:
1281-
self.layout = QVBoxLayout(self)
1282-
else:
1283-
self.layout = QHBoxLayout(self)
1284-
1285-
self.layout.setContentsMargins(l, t, r, b)
1286-
if fixed:
1287-
self.layout.setSizeConstraint(QLayout.SetFixedSize)
1288-
1289-
12901262
def add_widgets(layout, widgets, alignment=LEFT_AL):
12911263
"""Adds all widgets in the list to layout, with the specified alignment.
12921264
If alignment is None, no alignment is set.

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ install_requires =
5252
torch>=1.11
5353
monai[nibabel,scikit-image,itk,einops]>=0.9.0
5454
tqdm
55-
monai==0.9.0
5655
nibabel
5756
scikit-image
5857
pillow

0 commit comments

Comments
 (0)