MCPcopy Create free account
hub / github.com/Tom94/tev / dicomDataSetToAttributeNode

Function dicomDataSetToAttributeNode

src/imageio/DicomImageLoader.cpp:380–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378}
379
380AttributeNode dicomDataSetToAttributeNode(const gdcm::DataSet& ds, string_view nodeName) {
381 AttributeNode result;
382 result.name = nodeName;
383
384 for (auto it = ds.Begin(); it != ds.End(); ++it) {
385 const gdcm::DataElement& de = *it;
386 const gdcm::Tag& tag = de.GetTag();
387
388 // Skip group-length elements; they're structural and carry no user-facing meaning.
389 if (tag.GetElement() == 0x0000) {
390 continue;
391 }
392
393 const gdcm::VR::VRType vr = de.GetVR();
394
395 if (vr == gdcm::VR::SQ || (de.GetValueAsSQ() && de.GetVR() == gdcm::VR::INVALID)) {
396 auto seqNode = dicomSequenceToAttributeNode(de, dicomTagName(tag));
397 if (!seqNode.children.empty() || !seqNode.value.empty()) {
398 result.children.emplace_back(std::move(seqNode));
399 }
400
401 continue;
402 }
403
404 ostringstream oss;
405 if (!de.IsEmpty()) {
406 de.GetValue().Print(oss);
407 } else {
408 oss << "n/a";
409 }
410
411 result.children.emplace_back(
412 AttributeNode{
413 .name = dicomTagName(tag),
414 .value = std::move(oss).str(),
415 .type = dicomVrToString(vr),
416 .children = {},
417 }
418 );
419 }
420
421 return result;
422}
423
424struct DicomImageData {
425 ImageData imageData;

Callers 2

readDicomImageFunction · 0.85

Calls 4

dicomTagNameFunction · 0.85
dicomVrToStringFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected