diff --git a/package/PartSegImage/tifffile_fixes.py b/package/PartSegImage/tifffile_fixes.py index a3b53167b..7020b2b2e 100644 --- a/package/PartSegImage/tifffile_fixes.py +++ b/package/PartSegImage/tifffile_fixes.py @@ -19,7 +19,7 @@ def asarray(self, *args, **kwargs): self.parent.report_func() return res - def _dummy_report_func(self): # noqa: ARG001 + def _dummy_report_func(self): """dummy function for report_func""" TiffFile.report_func = _dummy_report_func diff --git a/package/tests/conftest.py b/package/tests/conftest.py index a06eaaa48..dc09f7630 100644 --- a/package/tests/conftest.py +++ b/package/tests/conftest.py @@ -45,7 +45,7 @@ def bundle_test_dir(): return Path(os.path.join(os.path.dirname(__file__), "test_data")) -@pytest.fixture() +@pytest.fixture def image(tmp_path): data = np.zeros([20, 20, 20, 2], dtype=np.uint16) data[10:-1, 1:-1, 1:-1, 0] = 20 @@ -56,7 +56,7 @@ def image(tmp_path): return Image(data, (10**-3, 10**-3, 10**-3), axes_order="ZYXC", file_path=str(tmp_path / "test.tiff")) -@pytest.fixture() +@pytest.fixture def image2(image, tmp_path): data = np.zeros([20, 20, 20, 1], dtype=np.uint8) data[10:-1, 1:-1, 1:-1, 0] = 20 @@ -65,14 +65,14 @@ def image2(image, tmp_path): return img -@pytest.fixture() +@pytest.fixture def image2d(tmp_path): data = np.zeros([20, 20], dtype=np.uint8) data[10:-1, 1:-1] = 20 return Image(data, (10**-3, 10**-3), axes_order="YX", file_path=str(tmp_path / "test.tiff")) -@pytest.fixture() +@pytest.fixture def stack_image(): data = np.zeros([20, 40, 40, 2], dtype=np.uint8) for x, y in itertools.product([0, 20], repeat=2): @@ -85,7 +85,7 @@ def stack_image(): return MaskProjectTuple("test_path", Image(data, (2, 1, 1), axes_order="ZYXC", file_path="test_path")) -@pytest.fixture() +@pytest.fixture def algorithm_parameters(): algorithm_parameters = { "algorithm_name": "Lower threshold", @@ -100,7 +100,7 @@ def algorithm_parameters(): return deepcopy(algorithm_parameters) -@pytest.fixture() +@pytest.fixture def roi_extraction_profile(): return ROIExtractionProfile( name="test", @@ -109,7 +109,7 @@ def roi_extraction_profile(): ) -@pytest.fixture() +@pytest.fixture def mask_segmentation_parameters(): return ROIExtractionProfile( name="", @@ -128,7 +128,7 @@ def mask_segmentation_parameters(): ) -@pytest.fixture() +@pytest.fixture def stack_segmentation1(stack_image: MaskProjectTuple, mask_segmentation_parameters): data = np.zeros([20, 40, 40], dtype=np.uint8) for i, (x, y) in enumerate(itertools.product([0, 20], repeat=2), start=1): @@ -140,7 +140,7 @@ def stack_segmentation1(stack_image: MaskProjectTuple, mask_segmentation_paramet ) -@pytest.fixture() +@pytest.fixture def analysis_segmentation(stack_image: MaskProjectTuple): data = np.zeros([20, 40, 40], dtype=np.uint8) for i, (x, y) in enumerate(itertools.product([0, 20], repeat=2), start=1): @@ -149,13 +149,13 @@ def analysis_segmentation(stack_image: MaskProjectTuple): return ProjectTuple(file_path=stack_image.file_path, image=stack_image.image, roi_info=data) -@pytest.fixture() +@pytest.fixture def analysis_segmentation2(analysis_segmentation: ProjectTuple): mask = (analysis_segmentation.roi_info.roi > 0).astype(np.uint8) return dataclasses.replace(analysis_segmentation, mask=mask) -@pytest.fixture() +@pytest.fixture def stack_segmentation2(stack_image: MaskProjectTuple, mask_segmentation_parameters): data = np.zeros([20, 40, 40], dtype=np.uint8) for i, (x, y) in enumerate(itertools.product([0, 20], repeat=2), start=1): @@ -168,12 +168,12 @@ def stack_segmentation2(stack_image: MaskProjectTuple, mask_segmentation_paramet ) -@pytest.fixture() +@pytest.fixture def mask_property(): return MaskProperty.simple_mask() -@pytest.fixture() +@pytest.fixture def mask_property_non_default(): return MaskProperty( dilate=RadiusType.R2D, @@ -186,7 +186,7 @@ def mask_property_non_default(): ) -@pytest.fixture() +@pytest.fixture def measurement_profiles(): statistics = [ MeasurementEntry( @@ -221,14 +221,14 @@ def measurement_profiles(): ) -@pytest.fixture() +@pytest.fixture def border_rim_profile(): return ROIExtractionProfile( name="border_profile", algorithm=BorderRim.get_name(), values=BorderRim.get_default_values() ) -@pytest.fixture() +@pytest.fixture def lower_threshold_profile(): return ROIExtractionProfile( name="lower_profile", @@ -237,7 +237,7 @@ def lower_threshold_profile(): ) -@pytest.fixture() +@pytest.fixture def mask_threshold_profile(): return ROIExtractionProfile( name="mask_profile", @@ -246,7 +246,7 @@ def mask_threshold_profile(): ) -@pytest.fixture() +@pytest.fixture def sample_pipeline(border_rim_profile, lower_threshold_profile, mask_property): return SegmentationPipeline( name="sample_pipeline", @@ -255,7 +255,7 @@ def sample_pipeline(border_rim_profile, lower_threshold_profile, mask_property): ) -@pytest.fixture() +@pytest.fixture def sample_pipeline2(border_rim_profile, lower_threshold_profile, mask_property): return SegmentationPipeline( name="sample_pipeline2", @@ -264,7 +264,7 @@ def sample_pipeline2(border_rim_profile, lower_threshold_profile, mask_property) ) -@pytest.fixture() +@pytest.fixture def history_element(image, lower_threshold_profile): roi = np.zeros(image.shape, dtype=np.uint8) roi[0, 2:10] = 1 diff --git a/package/tests/test_PartSeg/conftest.py b/package/tests/test_PartSeg/conftest.py index 36e5d10e7..28cd9dc06 100644 --- a/package/tests/test_PartSeg/conftest.py +++ b/package/tests/test_PartSeg/conftest.py @@ -11,14 +11,14 @@ from PartSeg.common_gui import napari_image_view -@pytest.fixture() +@pytest.fixture def base_settings(image, tmp_path, measurement_profiles): settings = BaseSettings(tmp_path) settings.image = image return settings -@pytest.fixture() +@pytest.fixture def part_settings(image, tmp_path, measurement_profiles): settings = PartSettings(tmp_path) settings.image = image @@ -27,7 +27,7 @@ def part_settings(image, tmp_path, measurement_profiles): return settings -@pytest.fixture() +@pytest.fixture def stack_settings(tmp_path, image): settings = StackSettings(tmp_path) settings.image = image @@ -37,7 +37,7 @@ def stack_settings(tmp_path, image): chose.deleteLater() -@pytest.fixture() +@pytest.fixture def part_settings_with_project(image, analysis_segmentation2, tmp_path): settings = PartSettings(tmp_path) settings.image = image diff --git a/package/tests/test_PartSeg/roi_analysis/test_batch.py b/package/tests/test_PartSeg/roi_analysis/test_batch.py index 4ae528dc6..4d27912d2 100644 --- a/package/tests/test_PartSeg/roi_analysis/test_batch.py +++ b/package/tests/test_PartSeg/roi_analysis/test_batch.py @@ -5,7 +5,7 @@ from PartSegCore.analysis.calculation_plan import CalculationPlan, CalculationTree, MaskSuffix, RootType -@pytest.fixture() +@pytest.fixture def calculation_prepare(tmp_path, part_settings, qtbot): def _constructor(file_list, calculation_plan=None): if calculation_plan is None: diff --git a/package/tests/test_PartSeg/roi_analysis/test_export_batch.py b/package/tests/test_PartSeg/roi_analysis/test_export_batch.py index 09e402143..25e9d117c 100644 --- a/package/tests/test_PartSeg/roi_analysis/test_export_batch.py +++ b/package/tests/test_PartSeg/roi_analysis/test_export_batch.py @@ -18,7 +18,7 @@ ) -@pytest.fixture() +@pytest.fixture def _dummy_tiffs(tmp_path): for i in range(1, 11): (tmp_path / f"stack1_component{i}.tif").touch() @@ -74,7 +74,7 @@ def test_fail_export_empty_excel(tmp_path): list(export_to_archive(tmp_path / "empty.xlsx", tmp_path, tmp_path / "arch.tar.gz")) -@pytest.fixture() +@pytest.fixture def zenodo_kwargs(): return { "zenodo_token": "sample_token", diff --git a/package/tests/test_PartSeg/roi_analysis/test_image_view.py b/package/tests/test_PartSeg/roi_analysis/test_image_view.py index a4a386e08..c3de314aa 100644 --- a/package/tests/test_PartSeg/roi_analysis/test_image_view.py +++ b/package/tests/test_PartSeg/roi_analysis/test_image_view.py @@ -7,7 +7,7 @@ from PartSegCore.roi_info import ROIInfo -@pytest.mark.windows_ci_skip() +@pytest.mark.windows_ci_skip def test_synchronize(part_settings, image2, qtbot): prop = ChannelProperty(part_settings, "test1") view1 = ResultImageView(part_settings, prop, "test1") @@ -36,7 +36,7 @@ def test_synchronize(part_settings, image2, qtbot): view2.hide() -@pytest.mark.windows_ci_skip() +@pytest.mark.windows_ci_skip def test_synchronize_change_image_dim(part_settings, image2, image2d, qtbot): part_settings.image = image2d prop = ChannelProperty(part_settings, "test1") @@ -101,7 +101,7 @@ def test_setting_properties(self, part_settings, image2, qtbot): part_settings.set_in_profile("test.image_state.only_border", False) assert not view.only_border.isChecked() - @pytest.mark.windows_ci_skip() + @pytest.mark.windows_ci_skip def test_resize(self, part_settings, image2, qtbot): prop = ChannelProperty(part_settings, "test") view = ResultImageView(part_settings, prop, "test") @@ -118,7 +118,7 @@ def test_resize(self, part_settings, image2, qtbot): assert view.btn_layout2.count() == 2 view.hide() - @pytest.mark.windows_ci_skip() + @pytest.mark.windows_ci_skip def test_with_roi_alternatives(self, part_settings, image2, qtbot): prop = ChannelProperty(part_settings, "test") view = ResultImageView(part_settings, prop, "test") diff --git a/package/tests/test_PartSeg/roi_analysis/test_main_window.py b/package/tests/test_PartSeg/roi_analysis/test_main_window.py index 95252802d..d00c6a0a6 100644 --- a/package/tests/test_PartSeg/roi_analysis/test_main_window.py +++ b/package/tests/test_PartSeg/roi_analysis/test_main_window.py @@ -12,7 +12,7 @@ class TestAnalysisMainWindow: # @pytest.mark.skipif((platform.system() == "Linux") and CI_BUILD, reason="debug test fail") - @pytest.mark.pyside_skip() + @pytest.mark.pyside_skip def test_opening(self, qtbot, tmpdir): main_window = MainWindow(tmpdir, initial_image=False) qtbot.addWidget(main_window) @@ -22,7 +22,7 @@ def test_opening(self, qtbot, tmpdir): main_window.advanced_window.close() qtbot.wait(50) - @pytest.mark.pyside_skip() + @pytest.mark.pyside_skip def test_change_theme(self, qtbot, tmpdir): main_window = MainWindow(tmpdir, initial_image=False) qtbot.addWidget(main_window) @@ -30,7 +30,7 @@ def test_change_theme(self, qtbot, tmpdir): main_window.settings.theme_name = "dark" assert main_window.raw_image.viewer.theme == "dark" - @pytest.mark.pyside_skip() + @pytest.mark.pyside_skip def test_scale_bar(self, qtbot, tmpdir): main_window = MainWindow(tmpdir, initial_image=False) qtbot.addWidget(main_window) @@ -51,7 +51,7 @@ def test_get_project_info(self, image, tmp_path): assert set(res.roi_info.bound_info) == {1} -@pytest.fixture() +@pytest.fixture def analysis_options(qtbot, part_settings): ch_property = ChannelProperty(part_settings, "test") qtbot.addWidget(ch_property) diff --git a/package/tests/test_PartSeg/roi_mask/test_batch.py b/package/tests/test_PartSeg/roi_mask/test_batch.py index c2d6b4bfb..8c3111d42 100644 --- a/package/tests/test_PartSeg/roi_mask/test_batch.py +++ b/package/tests/test_PartSeg/roi_mask/test_batch.py @@ -4,7 +4,7 @@ from PartSegCore.mask.io_functions import SaveROIOptions -@pytest.fixture() +@pytest.fixture def batch_task(stack_image, mask_threshold_profile): return BatchTask(stack_image, mask_threshold_profile, None) diff --git a/package/tests/test_PartSeg/roi_mask/test_main_window.py b/package/tests/test_PartSeg/roi_mask/test_main_window.py index 451f79692..9fe6c7d58 100644 --- a/package/tests/test_PartSeg/roi_mask/test_main_window.py +++ b/package/tests/test_PartSeg/roi_mask/test_main_window.py @@ -9,13 +9,13 @@ class TestMaskMainWindow: # @pytest.mark.skipif((platform.system() == "Linux") and CI_BUILD, reason="vispy problem") - @pytest.mark.pyside_skip() + @pytest.mark.pyside_skip def test_opening(self, qtbot, tmpdir): main_window = MainWindow(tmpdir, initial_image=False) qtbot.addWidget(main_window) qtbot.wait(50) - @pytest.mark.pyside_skip() + @pytest.mark.pyside_skip def test_change_theme(self, qtbot, tmpdir): main_window = MainWindow(tmpdir, initial_image=False) qtbot.addWidget(main_window) @@ -23,7 +23,7 @@ def test_change_theme(self, qtbot, tmpdir): main_window.settings.theme_name = "dark" assert main_window.image_view.viewer.theme == "dark" - @pytest.mark.pyside_skip() + @pytest.mark.pyside_skip def test_scale_bar(self, qtbot, tmpdir): main_window = MainWindow(tmpdir, initial_image=False) qtbot.addWidget(main_window) @@ -43,7 +43,7 @@ def test_get_project_info(self, image, tmp_path): res = MainWindow.get_project_info(str(tmp_path / "test.tiff"), image, ROIInfo(roi)) assert res.roi_extraction_parameters == {1: None} - @pytest.mark.pyside_skip() + @pytest.mark.pyside_skip def test_window_title(self, tmpdir, image, image2, qtbot): main_window = MainWindow(tmpdir, initial_image=False) qtbot.addWidget(main_window) diff --git a/package/tests/test_PartSeg/test_analysis.py b/package/tests/test_PartSeg/test_analysis.py index 60e1c43b5..a782342ea 100644 --- a/package/tests/test_PartSeg/test_analysis.py +++ b/package/tests/test_PartSeg/test_analysis.py @@ -28,8 +28,8 @@ def test_missed_mask(self, qmessagebox_path, qtbot, analysis_segmentation, part_ qmessagebox_path.information.assert_called_once() assert qmessagebox_path.information.call_args[0][1] == "Need mask" - @pytest.mark.enablethread() - @pytest.mark.enabledialog() + @pytest.mark.enablethread + @pytest.mark.enabledialog def test_base(self, qtbot, analysis_segmentation, part_settings): widget = MeasurementWidget(part_settings) qtbot.addWidget(widget) @@ -46,8 +46,8 @@ def test_base(self, qtbot, analysis_segmentation, part_settings): assert widget.info_field.columnCount() == 2 assert widget.info_field.rowCount() == 2 - @pytest.mark.enablethread() - @pytest.mark.enabledialog() + @pytest.mark.enablethread + @pytest.mark.enabledialog def test_base2(self, qtbot, analysis_segmentation2, part_settings): widget = MeasurementWidget(part_settings) qtbot.addWidget(widget) @@ -64,8 +64,8 @@ def test_base2(self, qtbot, analysis_segmentation2, part_settings): assert widget.info_field.columnCount() == 3 assert widget.info_field.rowCount() == 2 - @pytest.mark.enablethread() - @pytest.mark.enabledialog() + @pytest.mark.enablethread + @pytest.mark.enabledialog def test_base_channels(self, qtbot, analysis_segmentation2, part_settings): widget = MeasurementWidget(part_settings) qtbot.addWidget(widget) @@ -83,8 +83,8 @@ def test_base_channels(self, qtbot, analysis_segmentation2, part_settings): class TestSimpleMeasurementsWidget: - @pytest.mark.enablethread() - @pytest.mark.enabledialog() + @pytest.mark.enablethread + @pytest.mark.enabledialog def test_base(self, stack_settings, stack_segmentation1, qtbot): widget = SimpleMeasurements(stack_settings) qtbot.addWidget(widget) diff --git a/package/tests/test_PartSeg/test_base_widgets.py b/package/tests/test_PartSeg/test_base_widgets.py index 8fc1c1d44..ffa2ca023 100644 --- a/package/tests/test_PartSeg/test_base_widgets.py +++ b/package/tests/test_PartSeg/test_base_widgets.py @@ -81,7 +81,7 @@ def test_get_colormaps(self, qtbot, part_settings): qtbot.addWidget(main_window) assert len(main_window.get_colormaps()) == part_settings.image.channels - @pytest.mark.windows_ci_skip() + @pytest.mark.windows_ci_skip def test_napari_viewer(self, qtbot, part_settings): main_window = BaseMainWindow(settings=part_settings) qtbot.addWidget(main_window) @@ -105,8 +105,8 @@ def test_napari_viewer_additional_layers_empty(self, qtbot, part_settings, monke assert not main_window.viewer_list information_mock.assert_called_once() - @pytest.mark.windows_ci_skip() - @pytest.mark.pyside6_skip() + @pytest.mark.windows_ci_skip + @pytest.mark.pyside6_skip def test_napari_viewer_additional_layers(self, qtbot, part_settings, monkeypatch): main_window = BaseMainWindow(settings=part_settings) qtbot.addWidget(main_window) diff --git a/package/tests/test_PartSeg/test_channel_control.py b/package/tests/test_PartSeg/test_channel_control.py index 4131044e9..430f1d994 100644 --- a/package/tests/test_PartSeg/test_channel_control.py +++ b/package/tests/test_PartSeg/test_channel_control.py @@ -35,19 +35,19 @@ def array_from_image(image: QImage): return np.frombuffer(image.bits(), dtype=np.uint8, count=size * image.depth() // 8) -@pytest.fixture() +@pytest.fixture def base_settings(tmp_path, qapp): return BaseSettings(tmp_path) -@pytest.fixture() +@pytest.fixture def ch_property(base_settings, qtbot): ch_prop = ChannelProperty(base_settings, start_name="test") qtbot.add_widget(ch_prop) return ch_prop -@pytest.fixture() +@pytest.fixture def image_view(base_settings, ch_property, qtbot): image_view = ImageView(base_settings, ch_property, "test") qtbot.add_widget(image_view) @@ -284,7 +284,7 @@ def check_parameters(name, index): with qtbot.assert_not_emitted(box.coloring_update), qtbot.assert_not_emitted(box.change_channel): ch_property.filter_radius.setValue(0.5) - @pytest.mark.windows_ci_skip() + @pytest.mark.windows_ci_skip @pytest.mark.parametrize("filter_value", NoiseFilterType.__members__.values()) def test_image_view_integration_filter(self, qtbot, tmp_path, filter_value, ch_property, image_view): image_view.channel_control.set_active(1) @@ -306,7 +306,7 @@ def check_parameters(name, index): filter_value == NoiseFilterType.No and np.any(image4 == 255) ) - @pytest.mark.windows_ci_skip() + @pytest.mark.windows_ci_skip def test_image_view_integration(self, qtbot, tmp_path, ch_property, image_view): image_view.viewer_widget.screenshot(flash=False) image1 = image_view.viewer_widget._render() @@ -377,7 +377,7 @@ def check_parameters(name, index): assert np.any(image3 != image5) assert np.any(image4 != image5) - @pytest.mark.windows_ci_skip() + @pytest.mark.windows_ci_skip def test_image_view_integration_gauss(self, qtbot, tmp_path, ch_property, image_view): def check_parameters(name, index): return name == "test" and index == 1 diff --git a/package/tests/test_PartSeg/test_check_release.py b/package/tests/test_PartSeg/test_check_release.py index 6ed2690db..c9aa654a5 100644 --- a/package/tests/test_PartSeg/test_check_release.py +++ b/package/tests/test_PartSeg/test_check_release.py @@ -13,7 +13,7 @@ from PartSeg._launcher.check_version import IGNORE_FILE -@pytest.mark.enablethread() +@pytest.mark.enablethread @pytest.mark.parametrize("thread", [False, True]) @pytest.mark.parametrize("package_name", ["PartSeg", "sample_name"]) def test_fetching(thread, package_name, monkeypatch, qtbot): diff --git a/package/tests/test_PartSeg/test_common_backend.py b/package/tests/test_PartSeg/test_common_backend.py index d38a33e6b..32a8851ef 100644 --- a/package/tests/test_PartSeg/test_common_backend.py +++ b/package/tests/test_PartSeg/test_common_backend.py @@ -464,13 +464,13 @@ def question(*args, **kwargs): assert not (tmp_path / "0.13.13").exists() -@pytest.fixture() +@pytest.fixture def image(tmp_path): data = np.random.default_rng().uniform(size=(10, 10, 2)) return Image(data=data, image_spacing=(10, 10), axes_order="XYC", file_path=str(tmp_path / "test.tiff")) -@pytest.fixture() +@pytest.fixture def roi(): data = np.zeros((10, 10), dtype=np.uint8) data[2:-2, 2:5] = 1 diff --git a/package/tests/test_PartSeg/test_common_gui.py b/package/tests/test_PartSeg/test_common_gui.py index d66e26df1..5748d2687 100644 --- a/package/tests/test_PartSeg/test_common_gui.py +++ b/package/tests/test_PartSeg/test_common_gui.py @@ -148,7 +148,7 @@ def __str__(self): return f"{self.name} eee" -@pytest.fixture() +@pytest.fixture def _example_tiff_files(tmp_path): for i in range(5): ImageWriter.save( @@ -157,7 +157,7 @@ def _example_tiff_files(tmp_path): ) -@pytest.fixture() +@pytest.fixture def mf_widget(qtbot, part_settings): res = MultipleFileWidget( part_settings, @@ -170,7 +170,7 @@ def mf_widget(qtbot, part_settings): return res -@pytest.fixture() +@pytest.fixture def _example_mask_project_files(tmp_path): data = np.zeros((10, 10), dtype=np.uint8) data[:5] = 1 @@ -200,7 +200,7 @@ def test_enum2(self, qtbot): widget.set_value(Enum2.test2) -@pytest.fixture() +@pytest.fixture def _mock_accept_files(monkeypatch): def accept(*_): return True @@ -208,7 +208,7 @@ def accept(*_): monkeypatch.setattr(select_multiple_files.AcceptFiles, "exec_", accept) -@pytest.fixture() +@pytest.fixture def mock_warning(monkeypatch): warning_show = [0] @@ -561,8 +561,8 @@ def test_create(self, part_settings, qtbot): def check_load_files(parameter, custom_name): return not custom_name and os.path.basename(parameter.file_path) == "img_4.tif" - @pytest.mark.enablethread() - @pytest.mark.enabledialog() + @pytest.mark.enablethread + @pytest.mark.enabledialog @pytest.mark.usefixtures("_example_tiff_files") def test_load_recent(self, part_settings, qtbot, monkeypatch, tmp_path, mf_widget): file_list = [ @@ -588,8 +588,8 @@ def test_load_recent(self, part_settings, qtbot, monkeypatch, tmp_path, mf_widge assert part_settings.get_last_files_multiple() == file_list assert mf_widget.file_view.topLevelItemCount() == 5 - @pytest.mark.enablethread() - @pytest.mark.enabledialog() + @pytest.mark.enablethread + @pytest.mark.enabledialog @pytest.mark.usefixtures("_example_tiff_files") def test_load_files(self, part_settings, qtbot, monkeypatch, tmp_path, mf_widget): file_list = [[[str(tmp_path / f"img_{i}.tif")], LoadStackImage.get_name()] for i in range(5)] @@ -613,8 +613,8 @@ def test_load_files(self, part_settings, qtbot, monkeypatch, tmp_path, mf_widget part_settings.load() assert part_settings.get_last_files_multiple() == file_list - @pytest.mark.enablethread() - @pytest.mark.enabledialog() + @pytest.mark.enablethread + @pytest.mark.enabledialog @pytest.mark.usefixtures("_example_mask_project_files") def test_load_mask_project(self, part_settings, qtbot, monkeypatch, tmp_path, mf_widget): load_property = LoadProperty( @@ -645,8 +645,8 @@ def test_create(self, tmp_path, qtbot): window = BaseMainWindow(config_folder=tmp_path) qtbot.add_widget(window) - @pytest.mark.enablethread() - @pytest.mark.enabledialog() + @pytest.mark.enablethread + @pytest.mark.enabledialog def test_recent(self, tmp_path, qtbot, monkeypatch): load_mock = MagicMock() load_mock.load = MagicMock(return_value=1) diff --git a/package/tests/test_PartSeg/test_main_windows.py b/package/tests/test_PartSeg/test_main_windows.py index 8a9bdffc4..f45802dfc 100644 --- a/package/tests/test_PartSeg/test_main_windows.py +++ b/package/tests/test_PartSeg/test_main_windows.py @@ -25,9 +25,9 @@ def test_opening(self, qtbot): qtbot.addWidget(main_window) # @pytest.mark.skipif((platform.system() == "Linux") and CI_BUILD, reason="vispy problem") - @pytest.mark.enablethread() - @pytest.mark.pyside_skip() - @pytest.mark.windows_ci_skip() + @pytest.mark.enablethread + @pytest.mark.pyside_skip + @pytest.mark.windows_ci_skip def test_open_mask(self, qtbot, monkeypatch, tmp_path): monkeypatch.setattr(mask_main_window, "CONFIG_FOLDER", str(tmp_path)) if platform.system() == "Linux" and GITHUB_ACTIONS: @@ -42,9 +42,9 @@ def test_open_mask(self, qtbot, monkeypatch, tmp_path): qtbot.wait(50) # @pytest.mark.skipif((platform.system() == "Linux") and CI_BUILD, reason="vispy problem") - @pytest.mark.enablethread() - @pytest.mark.windows_ci_skip() - @pytest.mark.pyside_skip() + @pytest.mark.enablethread + @pytest.mark.windows_ci_skip + @pytest.mark.pyside_skip def test_open_analysis(self, qtbot, monkeypatch, tmp_path): monkeypatch.setattr(analysis_main_window, "CONFIG_FOLDER", str(tmp_path)) if platform.system() in {"Darwin", "Linux"} and GITHUB_ACTIONS: diff --git a/package/tests/test_PartSeg/test_napari_image_view.py b/package/tests/test_PartSeg/test_napari_image_view.py index d7eebcb63..d7088a555 100644 --- a/package/tests/test_PartSeg/test_napari_image_view.py +++ b/package/tests/test_PartSeg/test_napari_image_view.py @@ -62,7 +62,7 @@ def test_print_dict(): assert lines[2].startswith(" e") -@pytest.fixture() +@pytest.fixture def image_view(base_settings, image2, qtbot, request): ch_prop = ChannelProperty(base_settings, "test") view = ImageView(base_settings, channel_property=ch_prop, name=request.function.__name__) @@ -181,7 +181,7 @@ def test_mask_rendering(self, base_settings, image_view, qtbot, tmp_path): image_view.update_spacing_info() assert np.all(image_view.image_info[str(tmp_path / "test2.tiff")].mask.scale == (1, 10**5, 10**5, 10**5)) - @pytest.mark.windows_ci_skip() + @pytest.mark.windows_ci_skip def test_mask_control_visibility(self, base_settings, image_view, qtbot): image_view.show() assert not image_view.mask_chk.isVisible() @@ -203,7 +203,7 @@ def test_points_rendering(self, base_settings, image_view): image_view.toggle_points_visibility() assert not image_view.points_layer.visible - @pytest.mark.windows_ci_skip() + @pytest.mark.windows_ci_skip def test_points_button_visibility(self, base_settings, image_view): image_view.show() assert not image_view.points_view_button.isVisible() @@ -255,7 +255,7 @@ def test_marking_component(self, base_settings, image_view, tmp_path): image_view.component_mark(10, False) assert not image_view.image_info[str(tmp_path / "test2.tiff")].highlight.visible - @pytest.mark.enablethread() + @pytest.mark.enablethread def test_marking_component_flash(self, base_settings, image_view, tmp_path, qtbot): roi = np.zeros(base_settings.image.get_channel(0).shape, dtype=np.uint8) roi[..., 2:-2, 2:-2, 2:-2] = 1 @@ -321,15 +321,15 @@ def test_calculate_filter(self, filter_type, radius, image): assert filtered.shape == ch.shape assert (filter_type == NoiseFilterType.No) != (filtered is not ch) - @pytest.mark.no_patch_add_layer() - @pytest.mark.enablethread() + @pytest.mark.no_patch_add_layer + @pytest.mark.enablethread def test_add_layer_util_check_init(self, image_view, qtbot): def has_layers(): return len(image_view.viewer.layers) > 0 qtbot.waitUntil(has_layers) - @pytest.mark.no_patch_add_layer() + @pytest.mark.no_patch_add_layer def test_add_layer_util(self, image_view, qtbot): def has_layers(): return len(image_view.viewer.layers) > 0 diff --git a/package/tests/test_PartSeg/test_napari_widgets.py b/package/tests/test_PartSeg/test_napari_widgets.py index a5a88b883..3423213c9 100644 --- a/package/tests/test_PartSeg/test_napari_widgets.py +++ b/package/tests/test_PartSeg/test_napari_widgets.py @@ -221,8 +221,8 @@ def test_simple_measurement_create(make_napari_viewer, qtbot): assert measurement.calculate_btn.enabled -@pytest.mark.enablethread() -@pytest.mark.enabledialog() +@pytest.mark.enablethread +@pytest.mark.enabledialog @pytest.mark.usefixtures("qtbot") def test_measurement_create(make_napari_viewer, bundle_test_dir, monkeypatch): from PartSeg.plugins.napari_widgets.measurement_widget import Measurement @@ -291,7 +291,7 @@ def test_mask_create(make_napari_viewer, qtbot): assert "Mask" in viewer.layers -@pytest.fixture() +@pytest.fixture def _shutdown_timers(monkeypatch): register = [] old_start = QTimer.start @@ -312,7 +312,7 @@ def mock_start(self, interval=None): assert not timer.isActive() -@pytest.mark.enablethread() +@pytest.mark.enablethread @pytest.mark.usefixtures("_shutdown_timers") def test_search_labels(make_napari_viewer, qtbot): viewer = make_napari_viewer() @@ -339,7 +339,7 @@ def test_search_labels(make_napari_viewer, qtbot): search.component_selector.value = 2 -@pytest.fixture() +@pytest.fixture def viewer_with_data(make_napari_viewer): viewer = make_napari_viewer() data = np.zeros((10, 10), dtype=np.uint8) @@ -410,7 +410,7 @@ def ndim_param(request): return request.param -@pytest.fixture() +@pytest.fixture def napari_image(ndim_param): shape = (1,) * max(ndim_param - 3, 0) + (10,) * min(ndim_param, 3) slice_ = (slice(None),) * max(ndim_param - 3, 0) + (slice(2, 8),) * min(ndim_param, 3) @@ -420,7 +420,7 @@ def napari_image(ndim_param): return NapariImage(data) -@pytest.fixture() +@pytest.fixture def napari_labels(ndim_param): shape = (1,) * max(ndim_param - 3, 0) + (10,) * min(ndim_param, 3) slice_ = (slice(None),) * max(ndim_param - 3, 0) + (slice(2, 8),) * min(ndim_param, 3) @@ -533,7 +533,7 @@ def test_split_core_objects_model(napari_labels): assert model.run_calculation()["layer_type"] == "labels" -@pytest.fixture() +@pytest.fixture def napari_labels2(): data = np.zeros((10, 10, 10), dtype=np.uint8) data[5, 2:-2, 2:5] = 1 @@ -551,7 +551,7 @@ def throttle(self, *args): self.triggered.emit() -@pytest.fixture() +@pytest.fixture def copy_labels(make_napari_viewer, qtbot, napari_labels2, monkeypatch): monkeypatch.setattr("PartSeg.plugins.napari_widgets.copy_labels.QSignalDebouncer", MockDebouncer) viewer = make_napari_viewer() diff --git a/package/tests/test_PartSeg/test_roi_analysis_batch.py b/package/tests/test_PartSeg/test_roi_analysis_batch.py index ad278d3a8..539168401 100644 --- a/package/tests/test_PartSeg/test_roi_analysis_batch.py +++ b/package/tests/test_PartSeg/test_roi_analysis_batch.py @@ -163,7 +163,7 @@ def test_select_file(self, qtbot, monkeypatch): assert widget.first_text.text() == "file_path" -@pytest.fixture() +@pytest.fixture def calculation_plan(measurement_profiles): roi_extraction = AnalysisAlgorithmSelection.get_default() return prepare_plan_widget.CalculationPlan( diff --git a/package/tests/test_PartSeg/test_settings.py b/package/tests/test_PartSeg/test_settings.py index cccebfc4a..b5f0b4dfa 100644 --- a/package/tests/test_PartSeg/test_settings.py +++ b/package/tests/test_PartSeg/test_settings.py @@ -24,7 +24,7 @@ from PartSegImage import Image -@pytest.fixture() +@pytest.fixture def stack_settings(qtbot, tmp_path): settings = StackSettings(tmp_path) chose = ChosenComponents() diff --git a/package/tests/test_PartSeg/test_viewer.py b/package/tests/test_PartSeg/test_viewer.py index e21b9ae8a..a91e81d42 100644 --- a/package/tests/test_PartSeg/test_viewer.py +++ b/package/tests/test_PartSeg/test_viewer.py @@ -19,7 +19,7 @@ class TestResultImageView: - @pytest.mark.windows_ci_skip() + @pytest.mark.windows_ci_skip @pyside_skip def test_simple(self, qtbot, part_settings, image): prop = ChannelProperty(part_settings, "test") @@ -38,7 +38,7 @@ def test_simple(self, qtbot, part_settings, image): assert not viewer.available_alternatives() viewer.hide() - @pytest.mark.windows_ci_skip() + @pytest.mark.windows_ci_skip @pyside_skip def test_set_roi(self, qtbot, part_settings, image): prop = ChannelProperty(part_settings, "test") @@ -63,7 +63,7 @@ def test_set_roi(self, qtbot, part_settings, image): @pyside_skip -@pytest.mark.windows_ci_skip() +@pytest.mark.windows_ci_skip class TestNapariViewer: def test_base(self, image, analysis_segmentation2, tmp_path): settings = BaseSettings(tmp_path) diff --git a/package/tests/test_PartSegCore/test_analysis_batch.py b/package/tests/test_PartSegCore/test_analysis_batch.py index af183165e..4c971b9f2 100644 --- a/package/tests/test_PartSegCore/test_analysis_batch.py +++ b/package/tests/test_PartSegCore/test_analysis_batch.py @@ -99,7 +99,7 @@ def calculation_run(self, report_fun: Callable[[str, int], None]) -> ROIExtracti return ROIExtractionResult(np.ones(self.image.shape, dtype=np.uint8), self.get_segmentation_profile()) -@pytest.fixture() +@pytest.fixture def _register_dummy_extraction(): assert "Dummy" not in AnalysisAlgorithmSelection.__register__ AnalysisAlgorithmSelection.register(DummyExtraction) @@ -108,7 +108,7 @@ def _register_dummy_extraction(): assert "Dummy" not in AnalysisAlgorithmSelection.__register__ -@pytest.fixture() +@pytest.fixture def _register_dummy_spacing(): assert "Dummy" not in AnalysisAlgorithmSelection.__register__ AnalysisAlgorithmSelection.register(DummySpacingCheck) @@ -117,7 +117,7 @@ def _register_dummy_spacing(): assert "Dummy" not in AnalysisAlgorithmSelection.__register__ -@pytest.fixture() +@pytest.fixture def _prepare_spacing_data(tmp_path): data = np.zeros((4, 1, 10, 10), dtype=np.uint8) data[:, :, 2:-2, 2:-2] = 1 @@ -127,7 +127,7 @@ def _prepare_spacing_data(tmp_path): ImageWriter.save(image, image.file_path) -@pytest.fixture() +@pytest.fixture def _prepare_mask_project_data(tmp_path): data = np.zeros((4, 10, 10), dtype=np.uint8) data[:, 2:4, 2:4] = 1 @@ -150,7 +150,7 @@ def _prepare_mask_project_data(tmp_path): SaveROI.save(tmp_path / "test.seg", proj, SaveROIOptions()) -@pytest.fixture() +@pytest.fixture def ltww_segmentation(): parameters = LowerThresholdFlowAlgorithm.__argument_class__( channel=1, @@ -170,7 +170,7 @@ def ltww_segmentation(): return ROIExtractionProfile(name="test", algorithm="Lower threshold with watershed", values=parameters) -@pytest.fixture() +@pytest.fixture def measurement_list(): chosen_fields = [ MeasurementEntry( @@ -194,7 +194,7 @@ def measurement_list(): return MeasurementCalculate(channel=0, units=Units.µm, measurement_profile=statistic, name_prefix="") -@pytest.fixture() +@pytest.fixture def simple_measurement_list(): chosen_fields = [ MeasurementEntry( @@ -206,7 +206,7 @@ def simple_measurement_list(): return MeasurementCalculate(channel=-1, units=Units.µm, measurement_profile=statistic, name_prefix="") -@pytest.fixture() +@pytest.fixture def calculation_plan_dummy(simple_measurement_list): tree = CalculationTree( RootType.Mask_project, @@ -220,13 +220,13 @@ def calculation_plan_dummy(simple_measurement_list): return CalculationPlan(tree=tree, name="test") -@pytest.fixture() +@pytest.fixture def calculation_plan_dummy_spacing(calculation_plan_dummy): calculation_plan_dummy.execution_tree.operation = RootType.Image return calculation_plan_dummy -@pytest.fixture() +@pytest.fixture def calculation_plan(ltww_segmentation, measurement_list): mask_suffix = MaskSuffix(name="", suffix="_mask") tree = CalculationTree( @@ -238,7 +238,7 @@ def calculation_plan(ltww_segmentation, measurement_list): return CalculationPlan(tree=tree, name="test") -@pytest.fixture() +@pytest.fixture def calculation_plan_long(ltww_segmentation, measurement_list): mask_suffix = MaskSuffix(name="", suffix="_mask") children = [] @@ -257,7 +257,7 @@ def calculation_plan_long(ltww_segmentation, measurement_list): return CalculationPlan(tree=tree, name="test") -@pytest.fixture() +@pytest.fixture def calculation_plan2(ltww_segmentation, measurement_list): ltww_segmentation.values.channel = 0 @@ -267,7 +267,7 @@ def calculation_plan2(ltww_segmentation, measurement_list): return CalculationPlan(tree=tree, name="test2") -@pytest.fixture() +@pytest.fixture def simple_plan(simple_measurement_list): def _create_simple_plan(root_type: RootType, save: Save): parameters = { @@ -287,7 +287,7 @@ def _create_simple_plan(root_type: RootType, save: Save): return _create_simple_plan -@pytest.fixture() +@pytest.fixture def calculation_plan3(ltww_segmentation): mask_suffix = MaskSuffix(name="", suffix="_mask") chosen_fields = [ diff --git a/package/tests/test_PartSegCore/test_io.py b/package/tests/test_PartSegCore/test_io.py index bdcddff08..c56319954 100644 --- a/package/tests/test_PartSegCore/test_io.py +++ b/package/tests/test_PartSegCore/test_io.py @@ -130,7 +130,7 @@ def analysis_project_reversed() -> ProjectTuple: return ProjectTuple("test_data.tiff", image, roi_info=roi_info, mask=mask) -@pytest.fixture() +@pytest.fixture def mask_prop(): return MaskProperty.simple_mask() diff --git a/package/tests/test_PartSegCore/test_measurements.py b/package/tests/test_PartSegCore/test_measurements.py index dea0c7dff..ac4978339 100644 --- a/package/tests/test_PartSegCore/test_measurements.py +++ b/package/tests/test_PartSegCore/test_measurements.py @@ -839,7 +839,7 @@ def test_square(self): ) -@pytest.fixture() +@pytest.fixture def two_comp_img(): data = np.zeros((30, 30, 60), dtype=np.uint16) data[5:-5, 5:-5, 5:29] = 60 @@ -2144,7 +2144,7 @@ def test_variants(self, feature, distance): Haralick.calculate_property(mask, data, distance=distance, feature=feature) -@pytest.fixture() +@pytest.fixture def roi_to_roi_extract(): parameters = LowerThresholdAlgorithm.get_default_values() parameters.threshold.values.threshold = 1 diff --git a/package/tests/test_PartSegCore/test_napari_plugins.py b/package/tests/test_PartSegCore/test_napari_plugins.py index 36c3773f4..0d493fba5 100644 --- a/package/tests/test_PartSegCore/test_napari_plugins.py +++ b/package/tests/test_PartSegCore/test_napari_plugins.py @@ -59,7 +59,7 @@ def test_project_to_layers_mask(stack_segmentation1): assert res[0][2] == "image" -@pytest.fixture() +@pytest.fixture def load_data(data_test_dir): def _load_data(file_name, reader_hook): file_path = os.path.join(data_test_dir, file_name) diff --git a/tutorials/tutorial_neuron_types/Neuron_types_example.ipynb b/tutorials/tutorial_neuron_types/Neuron_types_example.ipynb index 15c104e78..852b8103a 100644 --- a/tutorials/tutorial_neuron_types/Neuron_types_example.ipynb +++ b/tutorials/tutorial_neuron_types/Neuron_types_example.ipynb @@ -53,14 +53,15 @@ "source": [ "# install PartSeg\n", "from PartSegCore.roi_info import ROIInfo\n", + "\n", "!pip install PartSeg\n", "\n", - "#download data \n", + "#download data\n", "import urllib.request\n", "import zipfile\n", "\n", "zip_file_path, _ = urllib.request.urlretrieve(\"https://bokota.pl/typy_neuronow2.zip\")\n", - "with open(zip_file_path, 'rb') as ff:\n", + "with open(zip_file_path, \"rb\") as ff:\n", " z_file = zipfile.ZipFile(ff)\n", " z_file.extractall()\n" ] @@ -79,29 +80,28 @@ "outputs": [], "source": [ "import os\n", - "import numpy as np \n", "from collections import defaultdict\n", - "import SimpleITK as sitk\n", - "from glob import glob \n", - "from PartSegImage.image_reader import TiffImageReader \n", - "from PartSegImage.image import Image\n", + "from glob import glob\n", "from math import pi\n", "\n", - "from PartSegCore.mask import load_metadata as load_mask_metadata\n", - "from PartSegCore.segmentation.segmentation_algorithm import ThresholdAlgorithm\n", - "from PartSegCore.mask.io_functions import load_stack_segmentation, save_components\n", - "from PartSegCore.analysis.measurement_calculation import Diameter, Volume\n", - "from PartSegCore.mask.algorithm_description import MaskAlgorithmSelection\n", - "from PartSegCore.convex_fill import convex_fill\n", + "import numpy as np\n", + "import SimpleITK as sitk\n", + "from matplotlib import pyplot as plt\n", "\n", "from PartSegCore.analysis import load_metadata as load_analysis_metadata\n", "from PartSegCore.analysis.algorithm_description import AnalysisAlgorithmSelection\n", + "from PartSegCore.analysis.measurement_calculation import Diameter, Volume\n", + "from PartSegCore.convex_fill import convex_fill\n", + "from PartSegCore.mask import load_metadata as load_mask_metadata\n", + "from PartSegCore.mask.algorithm_description import MaskAlgorithmSelection\n", + "from PartSegCore.mask.io_functions import load_stack_segmentation, save_components\n", + "from PartSegCore.segmentation.segmentation_algorithm import ThresholdAlgorithm\n", "from PartSegCore.universal_const import Units\n", - "\n", - "from matplotlib import pyplot as plt\n", + "from PartSegImage.image import Image\n", + "from PartSegImage.image_reader import TiffImageReader\n", "\n", "\n", - "# import PartSeg.plugins \n", + "# import PartSeg.plugins\n", "# PartSeg.plugins.register() # Load PartSeg plugins" ] }, @@ -160,16 +160,17 @@ "outputs": [], "source": [ "from PartSegCore.segmentation.noise_filtering import DimensionType\n", - "parameters2 = {'channel': 3,\n", - " 'threshold': {'name': 'Manual', 'values': {'threshold': 19000}},\n", - " 'minimum_size': 8000,\n", - " 'close_holes': True,\n", - " 'close_holes_size': 200,\n", - " 'smooth_border': {\"name\": \"None\", \"values\": {}},\n", - " 'noise_filtering': {'name': 'Gauss',\n", - " 'values': {'dimension_type': DimensionType.Layer, 'radius': 1.0}},\n", - " 'side_connection': False,\n", - " 'use_convex': True}" + "\n", + "parameters2 = {\"channel\": 3,\n", + " \"threshold\": {\"name\": \"Manual\", \"values\": {\"threshold\": 19000}},\n", + " \"minimum_size\": 8000,\n", + " \"close_holes\": True,\n", + " \"close_holes_size\": 200,\n", + " \"smooth_border\": {\"name\": \"None\", \"values\": {}},\n", + " \"noise_filtering\": {\"name\": \"Gauss\",\n", + " \"values\": {\"dimension_type\": DimensionType.Layer, \"radius\": 1.0}},\n", + " \"side_connection\": False,\n", + " \"use_convex\": True}" ] }, { @@ -214,7 +215,7 @@ "metadata": {}, "outputs": [], "source": [ - "# or \n", + "# or\n", "Algorithm = MaskAlgorithmSelection[segmentation_description.algorithm]\n", "segment = Algorithm()\n", "segment.set_image(image)\n", @@ -272,9 +273,9 @@ "good_neurons = []\n", "for component_number in range(1, segmentation.max() + 1):\n", " current_component_area = segmentation == component_number\n", - " # checking if touch borders \n", + " # checking if touch borders\n", " coords = np.nonzero(current_component_area)\n", - " if 0 == np.min(coords):\n", + " if np.min(coords) == 0:\n", " continue\n", " touch = False\n", " for axis_cords, max_size in zip(coords, current_component_area.shape):\n", @@ -288,7 +289,7 @@ " # calculate shericity\n", " # print(component_number, (4/3 * pi * (diameter/2)**3)/volume, diameter)\n", " if (4/3 * pi * (diameter/2)**3)/volume > 4:\n", - " continue \n", + " continue\n", " good_neurons.append(component_number)\n", "print(good_neurons)" ] @@ -338,8 +339,7 @@ " continue\n", " neuron_type_dict[\"inhibitory\"].append(component_number)\n", "print(neuron_type_dict)\n", - " \n", - " " + "\n" ] }, { @@ -401,7 +401,7 @@ " segmentation = segmentation[0]\n", " for component_number in range(1, segmentation.max() + 1):\n", " current_component_area = segmentation == component_number\n", - " # checking if touch borders \n", + " # checking if touch borders\n", " coords = np.nonzero(current_component_area)\n", " if np.min(coords) == 0:\n", " continue\n", @@ -446,17 +446,17 @@ " else:\n", " neuron_type_dict[\"unexpected\"].append(component_number)\n", " continue\n", - " elif value_green > 7000:\n", + " if value_green > 7000:\n", " neuron_type_dict[\"pyramidal\"].append(component_number)\n", " continue\n", " neuron_type_dict[\"inhibitory\"].append(component_number)\n", " if \"unexpected\" in neuron_type_dict:\n", - " items = len(neuron_type_dict['unexpected'])\n", + " items = len(neuron_type_dict[\"unexpected\"])\n", " print(f\"deleted {items} neurons {neuron_type_dict['unexpected']}\")\n", " del neuron_type_dict[\"unexpected\"]\n", " # print(neuron_type_dict)\n", " return neuron_type_dict\n", - " \n", + "\n", "def segmentation_function(path_to_file, segment_object):\n", " def empty(_x, _y):\n", " pass\n", @@ -464,11 +464,11 @@ " segment_object.set_image(image)\n", " result = segment_object.calculation_run(empty)\n", " segmentation = result.roi\n", - " \n", + "\n", " good_neurons = get_good_neurons(image, segmentation)\n", " segmentation = convex_fill(segmentation)\n", " classified_neurons = classify_neurons(image, segmentation, good_neurons)\n", - " \n", + "\n", " nucleus_dict = defaultdict(list)\n", " for neuron_type, compenents_list in classified_neurons.items():\n", " for component_number in compenents_list:\n", @@ -497,7 +497,7 @@ "for file_path in glob(os.path.join(data_path, \"*.lsm\")):\n", " print(\"process\", os.path.basename(file_path))\n", " cutted_neurons_dict[file_path] = segmentation_function(file_path, segment)\n", - " \n" + "\n" ] }, { @@ -537,7 +537,7 @@ "outputs": [], "source": [ "neuron_measurment_description = load_analysis_metadata(os.path.join(data_path, \"neuron_types_measurment.json\"))\n", - " \n", + "\n", "print(str(neuron_measurment_description[\"neuron_types\"]))\n", "measurment_object = neuron_measurment_description[\"neuron_types\"]" ] @@ -555,12 +555,11 @@ " for nucleus_type, nucleus_list in nucleus_group_dict.items():\n", " for _, nucleus in nucleus_list:\n", " neuron_segment.set_image(nucleus)\n", - " neuron_segment.set_mask(nucleus.mask[0]) # do not touch time \n", + " neuron_segment.set_mask(nucleus.mask[0]) # do not touch time\n", " neuron_segment.set_parameters(neuron_segmentation_profile.values)\n", " result = neuron_segment.calculation_run(empty)\n", " measurment_dict[nucleus_type].append(\n", - " measurment_object.calculate(nucleus, 2 , result.roi, Units.nm))\n", - " " + " measurment_object.calculate(nucleus, 2 , result.roi, Units.nm))\n" ] }, { @@ -619,13 +618,14 @@ "metadata": {}, "outputs": [], "source": [ - "from matplotlib import pyplot as plt \n", + "from matplotlib import pyplot as plt\n", "from matplotlib.colors import ListedColormap, Normalize\n", "\n", + "\n", "def color_image_fun(data, colors, min_max):\n", " res = []\n", " for i, cmap_base in enumerate(colors):\n", - " if cmap_base is None: \n", + " if cmap_base is None:\n", " continue\n", " cmap = ListedColormap(cmap_base.map(np.linspace(0, 1, 255)))\n", " res.append(cmap(Normalize(min_max[i][0], min_max[i][1])(data[i])))\n", @@ -638,8 +638,9 @@ "metadata": {}, "outputs": [], "source": [ - "from PartSegCore.color_image import add_labels \n", - "from PartSegCore.color_image.base_colors import sitk_labels \n", + "from PartSegCore.color_image import add_labels\n", + "from PartSegCore.color_image.base_colors import sitk_labels\n", + "\n", "default_labels = np.array(sitk_labels, dtype=np.uint8)" ] }, @@ -661,6 +662,7 @@ "outputs": [], "source": [ "from PartSegCore.color_image import default_colormap_dict\n", + "\n", "layer_num = 28\n", "layer = image_app.get_data_by_axis(t=0, z=layer_num)\n", "components_to_show = np.ones(segmentation_app.max()+1, dtype=np.uint8)\n", @@ -688,7 +690,9 @@ "outputs": [], "source": [ "import tifffile\n", + "\n", "from PartSegCore.color_image import default_colormap_dict\n", + "\n", "colormaps_list = [default_colormap_dict.get(x, None) for x in [\"red\", \"green\", \"blue\", None]]\n", "colored_stack = []\n", "for i in range(image_app.layers):\n", @@ -716,10 +720,10 @@ "metadata": {}, "outputs": [], "source": [ - "import os \n", - "from glob import glob \n", + "import os\n", + "from glob import glob\n", "\n", - "from PartSegCore.mask.io_functions import SaveROI, MaskProjectTuple\n", + "from PartSegCore.mask.io_functions import MaskProjectTuple, SaveROI\n", "from PartSegCore.segmentation.segmentation_algorithm import ThresholdAlgorithm\n", "from PartSegImage.image_reader import TiffImageReader\n" ]