Exemple #1
0
 def proportion_action(self):
     # TODO use get_parameters
     if self.chosen_element is None:
         item = self.profile_options.currentItem()
         self.chosen_element_area = self.get_parameters(
             deepcopy(item.stat),
             self.measurement_area_choose.get_value(),
             self.per_component.get_value(),
             self.power_num.value(),
         )
         if self.chosen_element_area is None:
             return
         self.chosen_element = item
         item.setIcon(QIcon(os.path.join(icons_dir, "task-accepted.png")))
     elif (self.profile_options.currentItem() == self.chosen_element
           and self.measurement_area_choose.get_value()
           == self.chosen_element_area.area
           and self.per_component.get_value()
           == self.chosen_element_area.per_component):
         self.chosen_element.setIcon(QIcon())
         self.chosen_element = None
     else:
         item: MeasurementListWidgetItem = self.profile_options.currentItem(
         )
         leaf = self.get_parameters(
             deepcopy(item.stat),
             self.measurement_area_choose.get_value(),
             self.per_component.get_value(),
             self.power_num.value(),
         )
         if leaf is None:
             return
         lw = MeasurementListWidgetItem(
             Node(op="/", left=self.chosen_element_area, right=leaf))
         lw.setToolTip("User defined")
         self.profile_options_chosen.addItem(lw)
         self.chosen_element.setIcon(QIcon())
         self.chosen_element = None
         self.chosen_element_area = None
         if self.good_name():
             self.save_butt.setEnabled(True)
             self.save_butt_with_name.setEnabled(True)
         if self.profile_options.count() == 0:
             self.choose_butt.setDisabled(True)
    def create_calculation_plan():
        parameters = {
            "channel": 1,
            "minimum_size": 200,
            "threshold": {
                "name": "Base/Core",
                "values": {
                    "core_threshold": {
                        "name": "Manual",
                        "values": {
                            "threshold": 30000
                        }
                    },
                    "base_threshold": {
                        "name": "Manual",
                        "values": {
                            "threshold": 13000
                        }
                    },
                },
            },
            "noise_filtering": {
                "name": "Gauss",
                "values": {
                    "dimension_type": DimensionType.Layer,
                    "radius": 1.0
                }
            },
            "side_connection": False,
            "sprawl_type": {
                "name": "Euclidean",
                "values": {}
            },
        }

        segmentation = ROIExtractionProfile(
            name="test",
            algorithm="Lower threshold with watershed",
            values=parameters)
        mask_suffix = MaskSuffix(name="", suffix="_mask")
        chosen_fields = [
            MeasurementEntry(
                name="Segmentation Volume",
                calculation_tree=Leaf(name="Volume",
                                      area=AreaType.ROI,
                                      per_component=PerComponent.No),
            ),
            MeasurementEntry(
                name="Segmentation Volume/Mask Volume",
                calculation_tree=Node(
                    left=Leaf(name="Volume",
                              area=AreaType.ROI,
                              per_component=PerComponent.No),
                    op="/",
                    right=Leaf(name="Volume",
                               area=AreaType.Mask,
                               per_component=PerComponent.No),
                ),
            ),
            MeasurementEntry(
                "Segmentation Components Number",
                calculation_tree=Leaf("Components number",
                                      area=AreaType.ROI,
                                      per_component=PerComponent.No),
            ),
        ]
        statistic = MeasurementProfile(name="base_measure",
                                       chosen_fields=chosen_fields,
                                       name_prefix="")
        statistic_calculate = MeasurementCalculate(
            channel=0,
            units=Units.µm,
            measurement_profile=statistic,
            name_prefix="")
        tree = CalculationTree(
            RootType.Image,
            [
                CalculationTree(mask_suffix, [
                    CalculationTree(segmentation,
                                    [CalculationTree(statistic_calculate, [])])
                ])
            ],
        )
        return CalculationPlan(tree=tree, name="test")