Skip to content

Commit

Permalink
Remove splitting
Browse files Browse the repository at this point in the history
Decided burden of preparing the data on the end user. Fiji can be used to crop the image to make processing faster, split it to only include one laser pass and to bin it if denoising is required. However, I will keep the h5 reader as part of this plugin to make the conversion from h5 to tif easier.
  • Loading branch information
faymanns committed Oct 13, 2023
1 parent c470e22 commit 3f4e15b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 48 deletions.
18 changes: 7 additions & 11 deletions src/napari_melt_pool_tracker/_tests/test_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,24 @@ def test_example_q_widget(make_napari_viewer, capsys):
widget = MeltPoolTrackerQWidget(viewer)

# test widget methods
widget.split_groupbox.comboboxs["Input"].setCurrentText("test_image")
widget._split()
widget.speed_pos_groupbox.comboboxs["Input"].setCurrentText("test_image_0")
widget.speed_pos_groupbox.comboboxs["Input"].setCurrentText("test_image")
widget._determine_laser_speed_and_position()
widget.window_groupbox.comboboxs["Stack"].setCurrentText("test_image_0")
widget.window_groupbox.comboboxs["Line"].setCurrentText(
"test_image_0_line"
)
widget.window_groupbox.comboboxs["Stack"].setCurrentText("test_image")
widget.window_groupbox.comboboxs["Line"].setCurrentText("test_image_line")
widget._reslice_with_moving_window()
widget.filter_groupbox.comboboxs["Input"].setCurrentText(
"test_image_0_resliced"
"test_image_resliced"
)
widget._filter()
widget.radial_groupbox.comboboxs["Input"].setCurrentText(
"test_image_0_resliced_filtered"
"test_image_resliced_filtered"
)
widget._calculate_radial_gradient()
widget.annotate_surface_groupbox.comboboxs["Input"].setCurrentText(
"test_image_0_resliced_filtered_radial_gradient"
"test_image_resliced_filtered_radial_gradient"
)
widget.annotate_surface_groupbox.comboboxs["Surface"].setCurrentText(
"test_image_0_resliced_filtered"
"test_image_resliced_filtered"
)
widget._annotate_surface_features()

Expand Down
43 changes: 6 additions & 37 deletions src/napari_melt_pool_tracker/_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,11 @@ def __init__(self, napari_viewer):
self.viewer = napari_viewer
self.comboboxs = []

#####################
# Spliting
#####################
self.split_groupbox = StepWidget(name="1. Split")
self.split_groupbox.btn.clicked.connect(self._split)
self._populate_combobox(
self.split_groupbox.comboboxs["Input"], "image"
)
self.comboboxs.append(
(self.split_groupbox.comboboxs["Input"], "image")
)

#####################
# Laser position
#####################
self.speed_pos_groupbox = StepWidget(
name="2. Determine laser speed and position",
name="1. Determine laser speed and position",
)
self.speed_pos_groupbox.btn.clicked.connect(
self._determine_laser_speed_and_position
Expand All @@ -115,7 +103,7 @@ def __init__(self, napari_viewer):
# Reslice
#####################
self.window_groupbox = StepWidget(
name="3. Reslice with moving window",
name="2. Reslice with moving window",
include_auto_run_and_overwrite=True,
comboboxs=["Stack", "Line"],
sliders={
Expand Down Expand Up @@ -148,7 +136,7 @@ def __init__(self, napari_viewer):
# Denoise image
#####################
self.filter_groupbox = StepWidget(
name="4. Filter image",
name="3. Filter image",
include_auto_run_and_overwrite=True,
sliders={
"Kernel t": (1, 15, 7),
Expand All @@ -172,7 +160,7 @@ def __init__(self, napari_viewer):
#####################
# Radial gradient
#####################
self.radial_groupbox = StepWidget(name="5. Calculate radial gradient")
self.radial_groupbox = StepWidget(name="4. Calculate radial gradient")
self.radial_groupbox.btn.clicked.connect(
self._calculate_radial_gradient
)
Expand All @@ -187,7 +175,7 @@ def __init__(self, napari_viewer):
# Surface annotation
#####################
self.annotate_surface_groupbox = StepWidget(
name="6. Annotate surface features",
name="5. Annotate surface features",
comboboxs=["Input", "Surface"],
)
self.annotate_surface_groupbox.btn.clicked.connect(
Expand All @@ -209,7 +197,7 @@ def __init__(self, napari_viewer):
#####################
# Depth annotation
#####################
annotate_depth_groupbox = QGroupBox("7. Annotate depths")
annotate_depth_groupbox = QGroupBox("6. Annotate depths")
annotate_depth_layout = QVBoxLayout()
annotate_depth_groupbox.setLayout(annotate_depth_layout)
annotate_depth_layout.addWidget(
Expand All @@ -229,7 +217,6 @@ def __init__(self, napari_viewer):
self.scroll_content.setLayout(self.scroll_layout)

# Add individual widges to plugin
self.scroll_layout.addWidget(self.split_groupbox)
self.scroll_layout.addWidget(self.speed_pos_groupbox)
self.scroll_layout.addWidget(self.window_groupbox)
self.scroll_layout.addWidget(self.filter_groupbox)
Expand All @@ -244,24 +231,6 @@ def __init__(self, napari_viewer):

self.parameters = {}

def _split(self):
selected_layers = self.viewer.layers.selection
t = self.viewer.dims.current_step[0]
self.parameters["split_t"] = t
layer = selected_layers.pop()
data, meta, layer_type = layer.as_layer_data_tuple()
if layer_type != "image":
raise ValueError(
"Can only split image layers. You have selected a layer of type {layer_type}."
)
data0 = data[:t]
data1 = data[t:]
name = meta["name"]
meta["name"] = name + "_0"
self.viewer.add_image(data0, **meta)
meta["name"] = name + "_1"
self.viewer.add_image(data1, **meta)

def _determine_laser_speed_and_position(self):
name = self.speed_pos_groupbox.comboboxs["Input"].currentText()
layer_names = [
Expand Down

0 comments on commit 3f4e15b

Please sign in to comment.