| 18 | namespace py = pybind11; |
| 19 | |
| 20 | void InitDICOMTagPath(py::module_& m) |
| 21 | { |
| 22 | py::class_<mitk::DICOMTag>(m, "DICOMTag", |
| 23 | R"(A single DICOM tag identified by ``(group, element)``. |
| 24 | |
| 25 | DICOM tags are hexadecimal pairs identifying a data element in the DICOM |
| 26 | standard, 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 | |
| 32 | Args: |
| 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 | |
| 55 | A ``DICOMTagPath`` is to :py:class:`DICOMTag` what :py:class:`PropertyKeyPath` |
| 56 | is to a property name: a structured, manipulable representation. Used to |
| 57 | address tags inside sequences or nested data sets. |
| 58 | |
| 59 | Convert 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 | |
| 62 | Examples: |
| 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); }), |
no test coverage detected