MCPcopy Create free account
hub / github.com/MITK/MITK / InitDICOMTagPath

Function InitDICOMTagPath

Wrapping/Python/mitk/DICOMTagPath.cpp:20–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18namespace py = pybind11;
19
20void InitDICOMTagPath(py::module_& m)
21{
22 py::class_<mitk::DICOMTag>(m, "DICOMTag",
23 R"(A single DICOM tag identified by ``(group, element)``.
24
25DICOM tags are hexadecimal pairs identifying a data element in the DICOM
26standard, e.g. ``(0x0010, 0x0010)`` is "Patient's Name".
27)")
28 .def(py::init<int, int>(),
29 py::arg("group"), py::arg("element"),
30 R"(Construct a DICOM tag.
31
32Args:
33 group: Tag group number (typically hexadecimal, e.g. ``0x0010``).
34 element: Tag element number (typically hexadecimal, e.g. ``0x0010``).
35)")
36 .def("__eq__", &mitk::DICOMTag::operator==,
37 py::arg("other"),
38 "Check if two DICOM tags are equal.")
39 .def("__repr__",
40 [](const mitk::DICOMTag& self)
41 {
42 return "<mitk.DICOMTag: (" +
43 std::to_string(self.GetGroup()) + ", " +
44 std::to_string(self.GetElement()) + ")>";
45 })
46 .def_property_readonly("group", &mitk::DICOMTag::GetGroup,
47 "The DICOM tag group number.")
48 .def_property_readonly("element", &mitk::DICOMTag::GetElement,
49 "The DICOM tag element number.")
50 ;
51
52 py::class_<mitk::DICOMTagPath>(m, "DICOMTagPath",
53 R"(Path through nested DICOM tags.
54
55A ``DICOMTagPath`` is to :py:class:`DICOMTag` what :py:class:`PropertyKeyPath`
56is to a property name: a structured, manipulable representation. Used to
57address tags inside sequences or nested data sets.
58
59Convert to/from MITK's flat property-name form via :py:meth:`from_string`,
60:py:meth:`from_property_name`, ``str(path)``, and :py:meth:`to_property_name`.
61
62Examples:
63 >>> p = mitk.DICOMTagPath(0x0010, 0x0010)
64 >>> p.to_property_name()
65 'DICOM.0010.0010'
66)")
67 .def(py::init<>(), "Construct an empty path.")
68
69 // Construction from DICOM tag
70 .def(py::init([](int group, int element)
71 { return mitk::DICOMTagPath(mitk::DICOMTag(group, element)); }),
72 py::arg("group"), py::arg("element"),
73 "Create a DICOMTagPath from a DICOM tag (group, element).")
74
75 // Construction from DICOMTag object
76 .def(py::init([](const mitk::DICOMTag& tag)
77 { return mitk::DICOMTagPath(tag); }),

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls 4

GetGroupMethod · 0.45
GetElementMethod · 0.45
GetNodesMethod · 0.45

Tested by

no test coverage detected