Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
AnniekStok committed Dec 6, 2024
1 parent e38bd93 commit 2f393e7
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 28 deletions.
6 changes: 3 additions & 3 deletions src/napari_segmentation_correction/_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
QFileDialog,
QHBoxLayout,
QLineEdit,
QMessageBox,
QPushButton,
QScrollArea,
QTabWidget,
Expand All @@ -23,17 +22,18 @@
)
from skimage import measure

from .copy_label_widget import CopyLabelWidget
from .connected_components import ConnectedComponents
from .copy_label_widget import CopyLabelWidget
from .custom_table_widget import ColoredTableWidget
from .erosion_dilation_widget import ErosionDilationWidget
from .image_calculator import ImageCalculator
from .layer_manager import LayerManager
from .point_filter import PointFilter
from .select_delete_widget import SelectDeleteMask
from .size_filter_widget import SizeFilterWidget
from .smoothing_widget import SmoothingWidget
from .threshold_widget import ThresholdWidget
from .select_delete_widget import SelectDeleteMask


class AnnotateLabelsND(QWidget):
"""Widget for manual correction of label data, for example to prepare ground truth data for training a segmentation model"""
Expand Down
15 changes: 9 additions & 6 deletions src/napari_segmentation_correction/connected_components.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import os
import shutil

import dask.array as da
import napari
import numpy as np
from skimage.measure import label
import tifffile
from qtpy.QtWidgets import (
QFileDialog,
QGroupBox,
QMessageBox,
QPushButton,
QVBoxLayout,
QWidget,
QFileDialog
)
import os
import shutil
import tifffile
from skimage.io import imread
from skimage.measure import label

from .layer_manager import LayerManager


class ConnectedComponents(QWidget):
"""Widget to run connected component analysis"""

Expand Down Expand Up @@ -88,7 +91,7 @@ def _conn_comp(self):
)
return True
else:
self.label_manager.selected_layer = self.viewer.add_labels(label(self.label_manager.selected_layer.data),
self.label_manager.selected_layer = self.viewer.add_labels(label(self.label_manager.selected_layer.data),
name=self.label_manager.selected_layer.name + "_conn_comp",
)
self.label_manager._update_labels(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
import numpy as np
import tifffile
from qtpy.QtWidgets import (
QFileDialog,
QGroupBox,
QHBoxLayout,
QLabel,
QMessageBox,
QPushButton,
QSpinBox,
QVBoxLayout,
QWidget,
QFileDialog
)
from scipy import ndimage
from scipy.ndimage import binary_erosion
Expand Down
10 changes: 5 additions & 5 deletions src/napari_segmentation_correction/label_option_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ def cell_copied(layer, event):
mask = (
self.data[coords[0], coords[1], :, :] == selected_label
)
elif ndims == 3:
elif ndims == 3:
mask = (
self.data[coords[0], :, :] == selected_label
)
else:
else:
print('This number of dimensions is currently not supported', ndims)
return

Expand Down Expand Up @@ -80,7 +80,7 @@ def cell_copied(layer, event):
orig_label = self.label_manager.selected_layer.data[
coords[-3], coords[-2], coords[-1]
]

if orig_label != 0:
self.label_manager.selected_layer.data[coords[-3]][
self.label_manager.selected_layer.data[coords[-3]] == orig_label] = 0 # set the original label to zero in current slice only
Expand Down Expand Up @@ -145,11 +145,11 @@ def cell_copied(layer, event):
mask = (
self.data[coords[0], :, :, :] == selected_label
)
elif ndims == 3:
elif ndims == 3:
mask = (
self.data[:, :, :] == selected_label
)
else:
else:
print('This number of dimensions is currently not supported', ndims)
return

Expand Down
3 changes: 1 addition & 2 deletions src/napari_segmentation_correction/size_filter_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
import numpy as np
import tifffile
from qtpy.QtWidgets import (
QFileDialog,
QGroupBox,
QHBoxLayout,
QLabel,
QMessageBox,
QPushButton,
QSpinBox,
QVBoxLayout,
QWidget,
QFileDialog
)
from skimage import measure
from skimage.io import imread
Expand Down
20 changes: 10 additions & 10 deletions src/napari_segmentation_correction/threshold_widget.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import os
import shutil

import dask.array as da
import numpy as np
import napari
import numpy as np
import tifffile
from napari.layers import Image, Labels
from qtpy.QtWidgets import (
QFileDialog,
QGroupBox,
QHBoxLayout,
QLabel,
QMessageBox,
QPushButton,
QSpinBox,
QVBoxLayout,
QWidget,
QFileDialog
)
from skimage.io import imread

from .layer_dropdown import LayerDropdown
from skimage.io import imread
import os
import tifffile
import shutil


class ThresholdWidget(QWidget):
Expand Down Expand Up @@ -82,7 +82,7 @@ def _threshold(self):
if isinstance(self.threshold_layer.data, da.core.Array):
if self.outputdir is None:
self.outputdir = QFileDialog.getExistingDirectory(self, "Select Output Folder")

outputdir = os.path.join(
self.outputdir,
(self.threshold_layer.name + "_threshold"),
Expand All @@ -97,7 +97,7 @@ def _threshold(self):
data = self.threshold_layer.data[
i
].compute() # Compute the current stack

thresholded = (
data >= int(self.min_threshold.value())
) & (data <= int(self.max_threshold.value()))
Expand Down Expand Up @@ -125,7 +125,7 @@ def _threshold(self):
name=self.threshold_layer.name + "_thresholded",
)

else:
else:
thresholded = (
self.threshold_layer.data >= int(self.min_threshold.value())
) & (self.threshold_layer.data <= int(self.max_threshold.value()))
Expand Down

0 comments on commit 2f393e7

Please sign in to comment.