def test_base_settings_history(self, tmp_path, qtbot, monkeypatch): settings = base_settings.BaseSettings(tmp_path) assert settings.history_size() == 0 assert settings.history_redo_size() == 0 hist_elem = HistoryElement({"a": 1}, None, MaskProperty.simple_mask(), BytesIO()) hist_elem2 = HistoryElement({"a": 2}, None, MaskProperty.simple_mask(), BytesIO()) hist_elem3 = HistoryElement({"a": 3}, None, MaskProperty.simple_mask(), BytesIO()) settings.add_history_element(hist_elem) assert settings.history_size() == 1 assert settings.history_redo_size() == 0 settings.add_history_element(hist_elem2) assert settings.history_size() == 2 assert settings.history_redo_size() == 0 assert settings.history_pop().roi_extraction_parameters["a"] == 2 assert settings.history_current_element( ).roi_extraction_parameters["a"] == 1 assert settings.history_next_element( ).roi_extraction_parameters["a"] == 2 assert settings.history_redo_size() == 1 assert settings.history_size() == 1 assert len(settings.get_history()) == 1 assert settings.get_history()[-1].roi_extraction_parameters["a"] == 1 settings.add_history_element(hist_elem3) settings.history_pop() settings.history_redo_clean() assert settings.history_redo_size() == 0 settings.history_pop() assert settings.history_pop() is None assert settings.history_size() == 0 assert settings.history_redo_size() == 1 settings.set_history([hist_elem, hist_elem2]) assert settings.get_history()[-1].roi_extraction_parameters["a"] == 2 assert settings.history_size() == 2 assert settings.history_redo_size() == 0 settings.history_pop() monkeypatch.setattr(settings, "cmp_history_element", lambda x, y: True) settings.add_history_element(hist_elem3)
def create_mask_operation_plan(mask_op): parameters = { "channel": 0, "minimum_size": 200, "threshold": { "name": "Manual", "values": { "threshold": 13000 } }, "noise_filtering": { "name": "Gauss", "values": { "dimension_type": DimensionType.Layer, "radius": 1.0 } }, "side_connection": False, } parameters2 = dict(**parameters) parameters2["channel"] = 1 segmentation = ROIExtractionProfile(name="test", algorithm="Lower threshold", values=parameters) segmentation2 = ROIExtractionProfile(name="test2", algorithm="Lower threshold", values=parameters2) chosen_fields = [ MeasurementEntry( name="Segmentation Volume", calculation_tree=Leaf(name="Volume", area=AreaType.ROI, per_component=PerComponent.No), ), ] statistic = MeasurementProfile(name="base_measure", chosen_fields=chosen_fields, name_prefix="") statistic_calculate = MeasurementCalculate( channel=-1, units=Units.µm, measurement_profile=statistic, name_prefix="") tree = CalculationTree( RootType.Image, [ CalculationTree( segmentation, [ CalculationTree( MaskCreate( name="test1", mask_property=MaskProperty.simple_mask()), []) ], ), CalculationTree( segmentation2, [ CalculationTree( MaskCreate( name="test2", mask_property=MaskProperty.simple_mask()), []) ], ), CalculationTree(mask_op, [ CalculationTree(segmentation2, [CalculationTree(statistic_calculate, [])]) ]), ], ) return CalculationPlan(tree=tree, name="test")
def test_simple_mask(self): assert MaskProperty.simple_mask() == MaskProperty( RadiusType.NO, 0, RadiusType.NO, 0, False, False)