{"id":18841195,"url":"https://github.com/dcm4che/dcm4che-typeddicom","last_synced_at":"2025-04-14T07:08:22.384Z","repository":{"id":59490860,"uuid":"440463447","full_name":"dcm4che/dcm4che-typeddicom","owner":"dcm4che","description":"Adds Wrappers for dcm4che Attributes to make working with DICOM objects more convenient in Java","archived":false,"fork":false,"pushed_at":"2023-09-12T09:59:11.000Z","size":16164,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-04-14T07:08:14.604Z","etag":null,"topics":["dicom","java","types","wrapper"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dcm4che.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-21T09:39:07.000Z","updated_at":"2024-06-21T09:10:05.000Z","dependencies_parsed_at":"2024-11-08T02:50:30.574Z","dependency_job_id":null,"html_url":"https://github.com/dcm4che/dcm4che-typeddicom","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcm4che%2Fdcm4che-typeddicom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcm4che%2Fdcm4che-typeddicom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcm4che%2Fdcm4che-typeddicom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcm4che%2Fdcm4che-typeddicom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dcm4che","download_url":"https://codeload.github.com/dcm4che/dcm4che-typeddicom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837281,"owners_count":21169374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dicom","java","types","wrapper"],"created_at":"2024-11-08T02:50:22.596Z","updated_at":"2025-04-14T07:08:22.356Z","avatar_url":"https://github.com/dcm4che.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dcm4che - Typed DICOM\n\u003e :warning: **This project is under active development and not ready for production yet. Use at own risk.**\n\nThis library creates typed wrappers around dcm4che attributes to make DICOM objects easier and more intuitive to use in Java.\nWe tried our best to mimic a lot of the DICOM standard in this library but due to the complexity and openness of the standard we cannot possibly cover everything.\nIf you encounter unsupported fields you can always use the `getAttributes()` method and use dcm4che means to get whatever you want from the data.\n\n## Dependencies\nThis library is based on the \n* [DICOM Standard Version 2022e](https://dicom.nema.org/medical/dicom/2022e/output/chtml/part01/ps3.1.html).\n* [dcm4che version 5.31.0](https://github.com/dcm4che/dcm4che/releases/tag/5.31.0)\n\n## How to add it to your project\n### Standard Library\n#### Gradle\n##### Groovy\n```groovy\nrepositories {\n    // Add dicom4che repository\n    maven {\n        url \"https://www.dcm4che.org/maven2/\"\n    }\n}\n```\n\n```groovy\ndependencies {\n    implementation 'org.dcm4che:dcm4che-typeddicom-lib-std:0.5.5'\n}\n```\n\n##### Kotlin\n```kotlin\nrepositories {\n    // Add dicom4che repository\n    maven {\n        url = uri(\"https://www.dcm4che.org/maven2/\")\n    }\n}\n```\n\n```kotlin\ndependencies {\n    implementation(\"org.dcm4che:dcm4che-typeddicom-lib-std:0.5.5\")\n}\n```\n\n#### Maven\n\n```xml\n\u003c!-- Add dicom4che repository --\u003e\n\u003crepository\u003e\n  \u003cid\u003eDcm4Che\u003c/id\u003e\n  \u003cname\u003eDcm4Che\u003c/name\u003e\n  \u003curl\u003ehttps://www.dcm4che.org/maven2/\u003c/url\u003e\n\u003c/repository\u003e\n```\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.dcm4che\u003c/groupId\u003e\n    \u003cartifactId\u003edcm4che-typeddicom\u003c/artifactId\u003e\n    \u003cversion\u003e0.5.5\u003c/version\u003e\n\u003c/dependency\u003e\n```\n### Use private tags with the gradle plugin\n\nIn the ```build.gradle``` put:\n```groovy\nbuildscript {\n    repositories {\n        // Add dicom4che repository\n        maven {\n            url \"https://www.dcm4che.org/maven2/\"\n        }\n    }\n}\n\nplugins {\n    id 'java-library'\n    id 'org.dcm4che.typeddicom-java-generator' version '0.5.5'\n}\n\ngenerateTypeddicomJavaSources {\n    privateDicomMetamodelYamlDirectory = layout.projectDirectory.dir(\"src/main/resources\") // default - so this is optional when using this directory\n    generatedJavaOutputDirectory = layout.buildDirectory.dir(\"typeddicom\") // default - so this is optional when using this directory\n}\n```\nor put this into ```build.gradle.kts```:\n```kotlin\nbuildscript {\n    repositories {\n        // Add dicom4che repository\n        maven {\n            url = uri(\"https://www.dcm4che.org/maven2/\")\n        }\n    }\n}\n\nplugins {\n    id(\"java-library\")\n    id(\"org.dcm4che.typeddicom-java-generator\") version \"0.5.5\"\n}\n\ngenerateTypeddicomJavaSources {\n    privateDicomMetamodelYamlDirectory.set(layout.projectDirectory.dir(\"src/main/resources\")) // default - so this is optional when using this directory\n    generatedJavaOutputDirectory.set(layout.buildDirectory.dir(\"typeddicom\")) // default - so this is optional when using this directory\n}\n```\nPut your custom yaml file into the specified ```src/main/resources``` folder and populate it with your custom tags. Examples for this are plenty in ```dcm4che-typeddicom-java-generator-gradleplugin-\u003cversion\u003e.jar/std.dicom-meta-model.yaml```.\n\n* ```gradle generateJavaSourceFiles``` will generate the source files in the specified ```build/typeddicom``` folder.\n* You can do anything as with the usual `java-library` projects (see https://docs.gradle.org/current/userguide/java_library_plugin.html). The ```generateJavaSourceFiles``` task is properly integrated with them and will run when needed. \n\n## How to build it yourself\nRun ```.\\gradlew build```. The JAR-files are then located under: \n* ```dcm4che-typeddicom-skeleton\\build\\libs``` for the skeleton java library containing interfaces and abstract classes which are implemented and extended by the generated classes.\n* ```dcm4che-typeddicom-lib/dcm4che-typeddicom-lib-std\\build\\libs``` contains an easily usable library for all standard dicom IODs, Modules and Attributes.\n* ```dcm4che-typeddicom-parser/dcm4che-typeddicom-parser-dtos\\build\\libs``` contains the DTOs which are needed to parse the metadata representation of the dicom standard.\n* ```dcm4che-typeddicom-generator/dcm4che-typeddicom-java-generator-lib\\build\\libs``` contains a library to generate a typeddicom implementation with custom adaptations using additional yaml files.\n* ```dcm4che-typeddicom-generator/dcm4che-typeddicom-java-generator-gradleplugin\\build\\libs``` contains the plugin which generates a typeddicom java implementation from a provided private tags file.\nYou can also run ```.\\gradlew publishToMavenLocal``` to install all packages to your local Maven repository.\n## How to use\n### Reading fields\nInstead of\n```java\nAttributes attributes = readDicomFile(\"GSPS.dcm\");\n\nint[] untypedPixelAspectRatio = attributes.getSequence(Tag.DisplayedAreaSelectionSequence)\n.get(0)\n.getInts(Tag.PresentationPixelAspectRatio);\n\n```\nyou can now use\n```java\nAttributes attributes = readDicomFile(\"GSPS.dcm\");\n\nGrayscaleSoftcopyPresentationStateIOD gsps = new GrayscaleSoftcopyPresentationStateIOD(attributes);\nint[] typedDicomPixelAspectRatio = gsps.getDisplayedAreaSelectionSequence()\n        .get(0)\n        .getPresentationPixelAspectRatio()\n        .getInts();\n```\nWhere everything is checked for type-safety.\n\n### Synthesizing Dicom Attributes\nA fluent API was implemented to make DICOM attributes synthesizing easily read and writable.\nInstead of\n```java\nAttributes gspsClassic = new Attributes();\ngspsClassic.setString(Tag.PatientName, VR.PN, \"Niklas\");\nSequence referencedSeriesSequence = gspsClassic.newSequence(Tag.ReferencedSeriesSequence, 1);\nAttributes referencedSeriesSequenceItem = new Attributes();\nreferencedSeriesSequenceItem.setString(Tag.SeriesInstanceUID, VR.UI, \"1234567890.345678.3456789\");\nSequence referencedInstanceSequence = referencedSeriesSequenceItem.newSequence(Tag.ReferencedImageSequence, 2);\nAttributes referencedInstanceSequenceItem1 = new Attributes();\nreferencedInstanceSequenceItem1.setString(Tag.ReferencedSOPInstanceUID, VR.UI, \"3483648368436.483.864369.43648.368\");\nreferencedInstanceSequenceItem1.setString(Tag.ReferencedSOPClassUID, VR.UI, \"8646.36.54186.86408684371\");\nreferencedInstanceSequenceItem1.setInt(Tag.ReferencedFrameNumber, VR.IS, 1, 2, 3, 4, 5);\nreferencedInstanceSequence.add(referencedInstanceSequenceItem1);\nAttributes referencedInstanceSequenceItem2 = new Attributes();\nreferencedInstanceSequenceItem2.setString(Tag.ReferencedSOPInstanceUID, VR.UI, \"782583648368436.478754369.436487827\");\nreferencedInstanceSequenceItem2.setString(Tag.ReferencedSOPClassUID, VR.UI, \"7827287.5634836.8463841.3684.3\");\nreferencedInstanceSequenceItem2.setInt(Tag.ReferencedFrameNumber, VR.IS, 0, 1, 2, 3, 4);\nreferencedInstanceSequence.add(referencedInstanceSequenceItem2);\nreferencedSeriesSequence.add(referencedSeriesSequenceItem);\nSequence displayedAreaSelectionSequence = gspsClassic.newSequence(Tag.DisplayedAreaSelectionSequence, 1);\nAttributes displayedAreaSelectionSequenceItem = new Attributes();\ndisplayedAreaSelectionSequenceItem.setInt(Tag.DisplayedAreaTopLeftHandCorner, VR.SL, 1, 1);\ndisplayedAreaSelectionSequenceItem.setInt(Tag.DisplayedAreaBottomRightHandCorner, VR.SL, 1920, 1080);\ndisplayedAreaSelectionSequenceItem.setInt(Tag.PresentationPixelAspectRatio, VR.IS, 1, 1);\ndisplayedAreaSelectionSequence.add(displayedAreaSelectionSequenceItem);\n```\nyou can now use\n```java\nGrayscaleSoftcopyPresentationStateIOD gsps = GrayscaleSoftcopyPresentationStateIOD.builder()\n    .setPatientName().asString(\"Niklas\")\n    .setReferencedSeriesSequence(\n        ReferencedSeriesSequence.Item.builder()\n            .setSeriesInstanceUID().asString(\"1234567890.345678.3456789\")\n            .setReferencedImageSequence(\n                ReferencedImageSequence.Item.builder()\n                    .setReferencedSOPInstanceUID().asString(\"3483648368436.483.864369.43648.368\")\n                    .setReferencedSOPClassUID().asString(\"8646.36.54186.86408684371\")\n                    .setReferencedFrameNumber().asInts(1, 2, 3, 4, 5),\n                ReferencedImageSequence.Item.builder()\n                    .setReferencedSOPInstanceUID().asString(\"782583648368436.478754369.436487827\")\n                    .setReferencedSOPClassUID().asString(\"7827287.5634836.8463841.3684.3\")\n                    .setReferencedFrameNumber().asInts(0, 1, 2, 3, 4)\n            )\n    )\n    .setDisplayedAreaSelectionSequence(\n        DisplayedAreaSelectionSequence.Item.builder()\n            .setDisplayedAreaTopLeftHandCorner().asInts(1, 1)\n            .setDisplayedAreaBottomRightHandCorner().asInts(1920, 1080)\n            .setPresentationPixelAspectRatio().asInts(1, 1)\n    ).build();\n```\n### JavaDocs\nCheck out the javadocs. They should represent the stuff written in the DICOM Standard.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcm4che%2Fdcm4che-typeddicom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdcm4che%2Fdcm4che-typeddicom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcm4che%2Fdcm4che-typeddicom/lists"}