25 #include <itkGDCMSeriesFileNames.h>
27 #include <gdcmAttribute.h>
28 #include <gdcmDirectory.h>
29 #include <gdcmPixmapReader.h>
30 #include <gdcmRAWCodec.h>
31 #include <gdcmScanner.h>
32 #include <gdcmSorter.h>
33 #include <gdcmStringFilter.h>
47 return "PartlySupported";
53 return "<unknown value of enum ReaderImplementationLevel>";
66 return "Unknown spacing";
68 return "<unknown value of enum PixelSpacingInterpretation>";
74 static bool initialized =
false;
88 dictionary[
"0010|0010"] =
"dicom.patient.PatientsName";
89 dictionary[
"0010|0020"] =
"dicom.patient.PatientID";
90 dictionary[
"0010|0030"] =
"dicom.patient.PatientsBirthDate";
91 dictionary[
"0010|0040"] =
"dicom.patient.PatientsSex";
92 dictionary[
"0010|0032"] =
"dicom.patient.PatientsBirthTime";
93 dictionary[
"0010|1000"] =
"dicom.patient.OtherPatientIDs";
94 dictionary[
"0010|1001"] =
"dicom.patient.OtherPatientNames";
95 dictionary[
"0010|2160"] =
"dicom.patient.EthnicGroup";
96 dictionary[
"0010|4000"] =
"dicom.patient.PatientComments";
97 dictionary[
"0012|0062"] =
"dicom.patient.PatientIdentityRemoved";
98 dictionary[
"0012|0063"] =
"dicom.patient.DeIdentificationMethod";
101 dictionary[
"0020|000d"] =
"dicom.study.StudyInstanceUID";
102 dictionary[
"0008|0020"] =
"dicom.study.StudyDate";
103 dictionary[
"0008|0030"] =
"dicom.study.StudyTime";
104 dictionary[
"0008|0090"] =
"dicom.study.ReferringPhysiciansName";
105 dictionary[
"0020|0010"] =
"dicom.study.StudyID";
106 dictionary[
"0008|0050"] =
"dicom.study.AccessionNumber";
107 dictionary[
"0008|1030"] =
"dicom.study.StudyDescription";
108 dictionary[
"0008|1048"] =
"dicom.study.PhysiciansOfRecord";
109 dictionary[
"0008|1060"] =
"dicom.study.NameOfPhysicianReadingStudy";
112 dictionary[
"0008|0060"] =
"dicom.series.Modality";
113 dictionary[
"0020|000e"] =
"dicom.series.SeriesInstanceUID";
114 dictionary[
"0020|0011"] =
"dicom.series.SeriesNumber";
115 dictionary[
"0020|0060"] =
"dicom.series.Laterality";
116 dictionary[
"0008|0021"] =
"dicom.series.SeriesDate";
117 dictionary[
"0008|0031"] =
"dicom.series.SeriesTime";
118 dictionary[
"0008|1050"] =
"dicom.series.PerformingPhysiciansName";
119 dictionary[
"0018|1030"] =
"dicom.series.ProtocolName";
120 dictionary[
"0008|103e"] =
"dicom.series.SeriesDescription";
121 dictionary[
"0008|1070"] =
"dicom.series.OperatorsName";
122 dictionary[
"0018|0015"] =
"dicom.series.BodyPartExamined";
123 dictionary[
"0018|5100"] =
"dicom.series.PatientPosition";
124 dictionary[
"0028|0108"] =
"dicom.series.SmallestPixelValueInSeries";
125 dictionary[
"0028|0109"] =
"dicom.series.LargestPixelValueInSeries";
128 dictionary[
"0028|1050"] =
"dicom.voilut.WindowCenter";
129 dictionary[
"0028|1051"] =
"dicom.voilut.WindowWidth";
130 dictionary[
"0028|1055"] =
"dicom.voilut.WindowCenterAndWidthExplanation";
133 dictionary[
"0028|0004"] =
"dicom.pixel.PhotometricInterpretation";
134 dictionary[
"0028|0010"] =
"dicom.pixel.Rows";
135 dictionary[
"0028|0011"] =
"dicom.pixel.Columns";
138 dictionary[
"0028|0030"] =
"dicom.PixelSpacing";
139 dictionary[
"0018|1164"] =
"dicom.ImagerPixelSpacing";
151 UpdateCallBackMethod callback,
157 filenames, *node, sort, check_4d, correctTilt, callback, preLoadedImageBlock))
159 if (filenames.empty())
177 UpdateCallBackMethod callback,
180 if (filenames.empty())
182 MITK_DEBUG <<
"Calling LoadDicomSeries with empty filename string container. Probably invalid application logic.";
191 if (io->CanReadFile(filenames.front().c_str()))
193 io->SetFileName(filenames.front().c_str());
194 io->ReadImageInformation();
196 if (io->GetPixelType() == itk::ImageIOBase::SCALAR || io->GetPixelType() == itk::ImageIOBase::RGB)
198 LoadDicom(filenames, node, sort, check_4d, correctTilt, callback, preLoadedImageBlock);
207 catch (itk::MemoryAllocationError &e)
209 MITK_ERROR <<
"Out of memory. Cannot load DICOM series: " << e.what();
211 catch (std::exception &e)
213 MITK_ERROR <<
"Error encountered when loading DICOM series:" << e.what();
217 MITK_ERROR <<
"Unspecified error encountered when loading DICOM series.";
227 return io->CanReadFile(filename.c_str());
234 if (io->CanReadFile(filename.c_str()))
238 reader.SetFileName(filename.c_str());
240 gdcm::DataSet &data_set = reader.GetFile().GetDataSet();
241 gdcm::StringFilter sf;
242 sf.SetFile(reader.GetFile());
244 if (data_set.FindDataElement(gdcm::Tag(0x3001, 0x0010)) &&
245 (sf.ToString(gdcm::Tag(0x3001, 0x0010)) ==
"Philips3D "))
257 gdcm::PixmapReader reader;
258 reader.SetFileName(filename.c_str());
260 gdcm::DataSet &data_set = reader.GetFile().GetDataSet();
261 gdcm::StringFilter sf;
262 sf.SetFile(reader.GetFile());
264 gdcm::Attribute<0x0028, 0x0011> dimTagX;
265 gdcm::Attribute<0x3001, 0x1001, gdcm::VR::UL, gdcm::VM::VM1>
267 gdcm::Attribute<0x0028, 0x0010> dimTagY;
268 gdcm::Attribute<0x0028, 0x0008> dimTagT;
269 gdcm::Attribute<0x0018, 0x602c> spaceTagX;
270 gdcm::Attribute<0x0018, 0x602e> spaceTagY;
271 gdcm::Attribute<0x3001, 0x1003, gdcm::VR::FD, gdcm::VM::VM1> spaceTagZ;
272 gdcm::Attribute<0x0018, 0x6024> physicalTagX;
273 gdcm::Attribute<0x0018, 0x6026> physicalTagY;
274 gdcm::Attribute<0x3001, 0x1002, gdcm::VR::US, gdcm::VM::VM1> physicalTagZ;
276 dimTagX.Set(data_set);
277 dimTagY.Set(data_set);
278 dimTagZ.Set(data_set);
279 dimTagT.Set(data_set);
280 spaceTagX.Set(data_set);
281 spaceTagY.Set(data_set);
282 spaceTagZ.Set(data_set);
283 physicalTagX.Set(data_set);
284 physicalTagY.Set(data_set);
285 physicalTagZ.Set(data_set);
287 unsigned int dimX = dimTagX.GetValue(), dimY = dimTagY.GetValue(), dimZ = dimTagZ.GetValue(),
288 dimT = dimTagT.GetValue(), physicalX = physicalTagX.GetValue(), physicalY = physicalTagY.GetValue(),
289 physicalZ = physicalTagZ.GetValue();
291 float spaceX = spaceTagX.GetValue(), spaceY = spaceTagY.GetValue(), spaceZ = spaceTagZ.GetValue();
294 spaceX = spaceX * 10;
297 spaceY = spaceY * 10;
300 spaceZ = spaceZ * 10;
305 const gdcm::Pixmap &pixels = reader.GetPixmap();
306 gdcm::RAWCodec codec;
308 codec.SetPhotometricInterpretation(gdcm::PhotometricInterpretation::MONOCHROME2);
309 codec.SetPixelFormat(pixels.GetPixelFormat());
310 codec.SetPlanarConfiguration(0);
312 gdcm::DataElement out;
313 codec.Decode(data_set.GetDataElement(gdcm::Tag(0x7fe0, 0x0010)), out);
315 const gdcm::ByteValue *bv = out.GetByteValue();
316 const char *new_pixels = bv->GetPointer();
319 typedef itk::Image<unsigned char, 4>
321 ImageType::RegionType myRegion;
322 ImageType::SizeType mySize;
323 ImageType::IndexType myIndex;
324 ImageType::SpacingType mySpacing;
327 mySpacing[0] = spaceX;
328 mySpacing[1] = spaceY;
329 mySpacing[2] = spaceZ;
339 myRegion.SetSize(mySize);
340 myRegion.SetIndex(myIndex);
341 imageItk->SetSpacing(mySpacing);
342 imageItk->SetRegions(myRegion);
343 imageItk->Allocate();
344 imageItk->FillBuffer(0);
346 itk::ImageRegionIterator<ImageType> iterator(imageItk, imageItk->GetLargestPossibleRegion());
347 iterator.GoToBegin();
348 unsigned long pixCount = 0;
349 unsigned long planeSize = dimX * dimY;
350 unsigned long planeCount = 0;
351 unsigned long timeCount = 0;
352 unsigned long numberOfSlices = dimZ;
354 while (!iterator.IsAtEnd())
356 unsigned long adressedPixel =
358 (numberOfSlices - 1 - planeCount) * planeSize
359 + timeCount * numberOfSlices * planeSize;
361 iterator.Set(new_pixels[adressedPixel]);
365 if (pixCount == planeSize)
370 if (planeCount == numberOfSlices)
375 if (timeCount == dimT)
387 bool successful =
false;
389 std::istringstream spacingReader(s);
391 if (std::getline(spacingReader, spacing,
'\\'))
393 spacingY = atof(spacing.c_str());
395 if (std::getline(spacingReader, spacing,
'\\'))
397 spacingX = atof(spacing.c_str());
411 std::istringstream originReader(s);
412 std::string coordinate;
414 while (std::getline(originReader, coordinate,
'\\') && dim < 3)
416 p[dim++] = atof(coordinate.c_str());
422 MITK_ERROR <<
"Reader implementation made wrong assumption on tag (0020,0032). Found " << dim
423 <<
" instead of 3 values.";
441 std::istringstream orientationReader(s);
442 std::string coordinate;
444 while (std::getline(orientationReader, coordinate,
'\\') && dim < 6)
448 right[dim++] = atof(coordinate.c_str());
452 up[dim++ - 3] = atof(coordinate.c_str());
459 MITK_ERROR <<
"Reader implementation made wrong assumption on tag (0020,0037). Found " << dim
460 <<
" instead of 6 values.";
476 const StringContainer &files,
bool groupImagesWithGantryTilt,
const gdcm::Scanner::MappingType &tagValueMappings_)
485 gdcm::Scanner::MappingType &tagValueMappings =
const_cast<gdcm::Scanner::MappingType &
>(tagValueMappings_);
486 const gdcm::Tag tagImagePositionPatient(0x0020, 0x0032);
487 const gdcm::Tag tagImageOrientation(0x0020, 0x0037);
488 const gdcm::Tag tagGantryTilt(0x0018, 0x1120);
491 fromFirstToSecondOrigin.Fill(0.0);
492 bool fromFirstToSecondOriginInitialized(
false);
494 thisOrigin.Fill(0.0f);
496 lastOrigin.Fill(0.0f);
498 lastDifferentOrigin.Fill(0.0f);
500 bool lastOriginInitialized(
false);
502 MITK_DEBUG <<
"--------------------------------------------------------------------------------";
503 MITK_DEBUG <<
"Analyzing files for z-spacing assumption of ITK's ImageSeriesReader (group tilted: "
504 << groupImagesWithGantryTilt <<
")";
505 unsigned int fileIndex(0);
506 for (
auto fileIter = files.begin(); fileIter != files.end(); ++fileIter, ++fileIndex)
508 bool fileFitsIntoPattern(
false);
509 std::string thisOriginString;
511 thisOriginString =
ConstCharStarToString(tagValueMappings[fileIter->c_str()][tagImagePositionPatient]);
513 if (thisOriginString.empty())
519 <<
" for later analysis (no position information)";
527 remainingFiles.insert(remainingFiles.end(), fileIter + 1, files.end());
530 fileFitsIntoPattern =
false;
537 fileFitsIntoPattern =
false;
542 bool ignoredConversionError(-42);
545 MITK_DEBUG <<
" " << fileIndex <<
" " << *fileIter <<
" at "
547 <<
"(" << thisOrigin[0] <<
"," << thisOrigin[1] <<
"," << thisOrigin[2] <<
")";
549 if (lastOriginInitialized && (thisOrigin == lastOrigin))
552 <<
" for separate time step";
554 fileFitsIntoPattern =
false;
558 if (!fromFirstToSecondOriginInitialized &&
559 lastOriginInitialized)
561 fromFirstToSecondOrigin = thisOrigin - lastDifferentOrigin;
562 fromFirstToSecondOriginInitialized =
true;
578 tagValueMappings[fileIter->c_str()][tagImageOrientation], right, up, ignoredConversionError);
582 if (tiltInfo.IsSheared())
597 if (groupImagesWithGantryTilt && tiltInfo.IsRegularGantryTilt())
600 if (tagValueMappings[fileIter->c_str()].find(tagGantryTilt) != tagValueMappings[fileIter->c_str()].end())
604 double angle = atof(tiltStr.c_str());
606 MITK_DEBUG <<
"Comparing recorded tilt angle " << angle <<
" against calculated value "
607 << tiltInfo.GetTiltAngleInDegrees();
613 if (fabs(angle) - tiltInfo.GetTiltAngleInDegrees() > 0.25)
616 fileFitsIntoPattern =
false;
624 fileFitsIntoPattern =
true;
633 fileFitsIntoPattern =
true;
639 fileFitsIntoPattern =
false;
645 fileFitsIntoPattern =
true;
648 else if (fromFirstToSecondOriginInitialized)
650 Point3D assumedOrigin = lastDifferentOrigin + fromFirstToSecondOrigin;
652 Vector3D originError = assumedOrigin - thisOrigin;
653 double norm = originError.GetNorm();
654 double toleratedError(0.005);
656 if (norm > toleratedError)
658 MITK_DEBUG <<
" File does not fit into the inter-slice distance pattern (diff = " << norm <<
", allowed "
659 << toleratedError <<
").";
660 MITK_DEBUG <<
" Expected position (" << assumedOrigin[0] <<
"," << assumedOrigin[1] <<
","
661 << assumedOrigin[2] <<
"), got position (" << thisOrigin[0] <<
"," << thisOrigin[1] <<
","
662 << thisOrigin[2] <<
")";
663 MITK_DEBUG <<
" ==> Sort away " << *fileIter <<
" for later analysis";
671 fileFitsIntoPattern =
false;
676 fileFitsIntoPattern =
true;
682 fileFitsIntoPattern =
true;
687 if (!lastOriginInitialized || (fileFitsIntoPattern && (thisOrigin != lastOrigin)))
689 lastDifferentOrigin = thisOrigin;
692 lastOrigin = thisOrigin;
693 lastOriginInitialized =
true;
713 bool groupImagesWithGantryTilt,
716 return GetSeries(files,
true, groupImagesWithGantryTilt, restrictions);
721 bool groupImagesWithGantryTilt,
741 gdcm::Scanner scanner;
742 const gdcm::Tag tagSOPClassUID(0x0008, 0x0016);
743 scanner.AddTag(tagSOPClassUID);
745 const gdcm::Tag tagSeriesInstanceUID(0x0020, 0x000e);
746 scanner.AddTag(tagSeriesInstanceUID);
748 const gdcm::Tag tagImageOrientation(0x0020, 0x0037);
749 scanner.AddTag(tagImageOrientation);
751 const gdcm::Tag tagPixelSpacing(0x0028, 0x0030);
752 scanner.AddTag(tagPixelSpacing);
754 const gdcm::Tag tagImagerPixelSpacing(0x0018, 0x1164);
755 scanner.AddTag(tagImagerPixelSpacing);
757 const gdcm::Tag tagSliceThickness(0x0018, 0x0050);
758 scanner.AddTag(tagSliceThickness);
760 const gdcm::Tag tagNumberOfRows(0x0028, 0x0010);
761 scanner.AddTag(tagNumberOfRows);
763 const gdcm::Tag tagNumberOfColumns(0x0028, 0x0011);
764 scanner.AddTag(tagNumberOfColumns);
766 const gdcm::Tag tagGantryTilt(0x0018, 0x1120);
767 scanner.AddTag(tagGantryTilt);
769 const gdcm::Tag tagModality(0x0008, 0x0060);
770 scanner.AddTag(tagModality);
772 const gdcm::Tag tagNumberOfFrames(0x0028, 0x0008);
773 scanner.AddTag(tagNumberOfFrames);
777 const gdcm::Tag tagImagePositionPatient(0x0020, 0x0032);
778 scanner.AddTag(tagImagePositionPatient);
785 if (!scanner.Scan(files))
787 MITK_ERROR <<
"gdcm::Scanner failed when scanning " << files.size() <<
" input files.";
792 for (
auto fileIter = scanner.Begin(); fileIter != scanner.End(); ++fileIter)
794 if (std::string(fileIter->first).empty())
796 if (std::string(fileIter->first) == std::string(
"DICOMDIR"))
810 std::string moreUniqueSeriesId =
812 result[moreUniqueSeriesId].AddFile(fileIter->first);
817 for (FileNamesGrouping::const_iterator groupIter = result.begin(); groupIter != result.end(); ++groupIter)
821 result[groupIter->first] =
841 for (FileNamesGrouping::const_iterator groupIter = result.begin(); groupIter != result.end(); ++groupIter)
844 StringContainer filesStillToAnalyze = groupIter->second.GetFilenames();
845 std::string groupUID = groupIter->first;
846 unsigned int subgroup(0);
847 MITK_DEBUG <<
"Analyze group " << groupUID <<
" of " << groupIter->second.GetFilenames().size() <<
" files";
849 while (!filesStillToAnalyze.empty())
852 filesStillToAnalyze, groupImagesWithGantryTilt, scanner.GetMappings());
855 std::stringstream newGroupUID;
856 newGroupUID << groupUID <<
'.' << subgroup;
860 std::string firstFileInBlock = thisBlock.
GetFilenames().front();
862 thisBlock.SetImageBlockUID(newGroupUID.str());
863 thisBlock.SetSeriesInstanceUID(
866 thisBlock.SetSOPClassUID(
868 thisBlock.SetNumberOfFrames(
870 thisBlock.SetModality(
872 thisBlock.SetPixelSpacingInformation(
875 thisBlock.SetHasMultipleTimePoints(
false);
877 groupsOf3DBlocks[newGroupUID.str()] = thisBlock;
881 MITK_DEBUG <<
"Result: sorted 3D group with " << groupsOf3DBlocks[newGroupUID.str()].GetFilenames().size()
884 for (StringContainer::const_iterator siter = debugOutputFiles.begin(); siter != debugOutputFiles.end(); ++siter)
890 for (StringContainer::const_iterator siter = filesStillToAnalyze.begin(); siter != filesStillToAnalyze.end();
908 groupsOf3DPlusTBlocks.insert(groupsOf3DBlocks.begin(), groupsOf3DBlocks.end());
914 MITK_DEBUG <<
"================================================================================";
917 unsigned int numberOfFilesInPreviousBlock(0);
918 std::string previousBlockKey;
920 for (FileNamesGrouping::const_iterator block3DIter = groupsOf3DBlocks.begin();
921 block3DIter != groupsOf3DBlocks.end();
924 unsigned int numberOfFilesInThisBlock = block3DIter->second.GetFilenames().size();
925 std::string thisBlockKey = block3DIter->first;
927 if (numberOfFilesInPreviousBlock == 0)
929 numberOfFilesInPreviousBlock = numberOfFilesInThisBlock;
930 groupsOf3DPlusTBlocks[thisBlockKey] = block3DIter->second;
932 previousBlockKey = thisBlockKey;
936 bool identicalOrigins;
942 const char *origin_value = scanner.GetValue(groupsOf3DBlocks[thisBlockKey].GetFilenames().front().c_str(),
943 tagImagePositionPatient),
944 *previous_origin_value = scanner.GetValue(
945 groupsOf3DBlocks[previousBlockKey].GetFilenames().front().c_str(), tagImagePositionPatient),
946 *destination_value = scanner.GetValue(
947 groupsOf3DBlocks[thisBlockKey].GetFilenames().back().c_str(), tagImagePositionPatient),
948 *previous_destination_value = scanner.GetValue(
949 groupsOf3DBlocks[previousBlockKey].GetFilenames().back().c_str(), tagImagePositionPatient);
951 if (!origin_value || !previous_origin_value || !destination_value || !previous_destination_value)
953 identicalOrigins =
false;
965 ((thisOriginString == previousOriginString) && (thisDestinationString == previousDestinationString));
970 identicalOrigins =
false;
973 if (identicalOrigins && (numberOfFilesInPreviousBlock == numberOfFilesInThisBlock))
976 groupsOf3DPlusTBlocks[previousBlockKey].AddFiles(block3DIter->second.GetFilenames());
977 groupsOf3DPlusTBlocks[previousBlockKey].SetHasMultipleTimePoints(
true);
978 MITK_DEBUG <<
" --> group enhanced with another timestep";
983 groupsOf3DPlusTBlocks[thisBlockKey] = block3DIter->second;
984 int numberOfTimeSteps =
985 groupsOf3DPlusTBlocks[previousBlockKey].GetFilenames().size() / numberOfFilesInPreviousBlock;
986 MITK_DEBUG <<
" ==> group closed with " << numberOfTimeSteps <<
" time steps";
987 previousBlockKey = thisBlockKey;
988 MITK_DEBUG <<
" 3D+t group " << thisBlockKey <<
" started";
992 numberOfFilesInPreviousBlock = numberOfFilesInThisBlock;
997 MITK_DEBUG <<
"================================================================================";
999 for (FileNamesGrouping::const_iterator groupIter = groupsOf3DPlusTBlocks.begin();
1000 groupIter != groupsOf3DPlusTBlocks.end();
1014 for (StringContainer::const_iterator siter = debugOutputFiles.begin(); siter != debugOutputFiles.end(); ++siter)
1017 MITK_DEBUG <<
"================================================================================";
1019 return groupsOf3DPlusTBlocks;
1023 bool groupImagesWithGantryTilt,
1026 gdcm::Directory directoryLister;
1027 directoryLister.Load(dir.c_str(),
false);
1028 return GetSeries(directoryLister.GetFilenames(), groupImagesWithGantryTilt, restrictions);
1032 const gdcm::Tag &tag)
1037 result =
IDifyTagValue(tagValueMap[tag] ? tagValueMap[tag] : std::string(
""));
1039 catch (std::exception &)
1050 const gdcm::Tag tagSeriesInstanceUID(0x0020, 0x000e);
1051 const gdcm::Tag tagImageOrientation(0x0020, 0x0037);
1052 const gdcm::Tag tagPixelSpacing(0x0028, 0x0030);
1053 const gdcm::Tag tagImagerPixelSpacing(0x0018, 0x1164);
1054 const gdcm::Tag tagSliceThickness(0x0018, 0x0050);
1055 const gdcm::Tag tagNumberOfRows(0x0028, 0x0010);
1056 const gdcm::Tag tagNumberOfColumns(0x0028, 0x0011);
1057 const gdcm::Tag tagNumberOfFrames(0x0028, 0x0008);
1059 const char *tagSeriesInstanceUid = tagValueMap[tagSeriesInstanceUID];
1060 if (!tagSeriesInstanceUid)
1062 mitkThrow() <<
"CreateMoreUniqueSeriesIdentifier() could not access series instance UID. Something is seriously "
1063 "wrong with this image, so stopping here.";
1065 std::string constructedID = tagSeriesInstanceUid;
1077 if (tagValueMap.find(tagImageOrientation) != tagValueMap.end())
1079 bool conversionError(
false);
1088 std::ostringstream ss;
1089 ss.setf(std::ios::fixed, std::ios::floatfield);
1091 ss << right[0] <<
"\\" << right[1] <<
"\\" << right[2] <<
"\\" << up[0] <<
"\\" << up[1] <<
"\\" << up[2];
1092 std::string simplifiedOrientationString(ss.str());
1094 constructedID +=
IDifyTagValue(simplifiedOrientationString);
1097 constructedID.resize(constructedID.length() - 1);
1099 return constructedID;
1104 std::string IDifiedValue(value);
1106 throw std::logic_error(
"IDifyTagValue() illegaly called with empty tag value");
1110 for (std::size_t i = 0; i < IDifiedValue.size(); i++)
1112 while (i < IDifiedValue.size() &&
1113 !(IDifiedValue[i] ==
'.' || (IDifiedValue[i] >=
'a' && IDifiedValue[i] <=
'z') ||
1114 (IDifiedValue[i] >=
'0' && IDifiedValue[i] <=
'9') ||
1115 (IDifiedValue[i] >=
'A' && IDifiedValue[i] <=
'Z')))
1117 IDifiedValue.erase(i, 1);
1121 IDifiedValue +=
".";
1122 return IDifiedValue;
1126 const std::string &series_uid,
1127 bool groupImagesWithGantryTilt,
1133 for (FileNamesGrouping::const_iterator idIter = allSeries.begin(); idIter != allSeries.end(); ++idIter)
1135 if (idIter->first.find(series_uid) == 0)
1137 return idIter->second.GetFilenames();
1141 return resultingFileList;
1160 gdcm::Sorter sorter;
1165 if (sorter.Sort(unsortedFilenames))
1167 return sorter.GetFilenames();
1171 MITK_WARN <<
"Sorting error. Leaving series unsorted.";
1172 return unsortedFilenames;
1175 catch (std::logic_error &)
1177 MITK_WARN <<
"Sorting error. Leaving series unsorted.";
1178 return unsortedFilenames;
1197 static const gdcm::Tag tagImagePositionPatient(0x0020, 0x0032);
1198 static const gdcm::Tag tagImageOrientation(0x0020, 0x0037);
1201 if (ds1.FindDataElement(tagImagePositionPatient) && ds1.FindDataElement(tagImageOrientation) &&
1202 ds2.FindDataElement(tagImagePositionPatient) && ds2.FindDataElement(tagImageOrientation))
1204 gdcm::Attribute<0x0020, 0x0032> image_pos1;
1205 gdcm::Attribute<0x0020, 0x0037> image_orientation1;
1207 image_pos1.Set(ds1);
1208 image_orientation1.Set(ds1);
1210 gdcm::Attribute<0x0020, 0x0032> image_pos2;
1211 gdcm::Attribute<0x0020, 0x0037> image_orientation2;
1213 image_pos2.Set(ds2);
1214 image_orientation2.Set(ds2);
1223 for (
unsigned int dim = 0; dim < 6; ++dim)
1225 if (fabs(image_orientation2[dim] - image_orientation1[dim]) > 0.0001)
1227 MITK_ERROR <<
"Dicom images have different orientations.";
1228 throw std::logic_error(
1229 "Dicom images have different orientations. Call GetSeries() first to separate images.");
1235 normal[0] = image_orientation1[1] * image_orientation1[5] - image_orientation1[2] * image_orientation1[4];
1236 normal[1] = image_orientation1[2] * image_orientation1[3] - image_orientation1[0] * image_orientation1[5];
1237 normal[2] = image_orientation1[0] * image_orientation1[4] - image_orientation1[1] * image_orientation1[3];
1239 double dist1 = 0.0, dist2 = 0.0;
1242 for (
unsigned char i = 0u; i < 3u; ++i)
1244 dist1 += normal[i] * image_pos1[i];
1245 dist2 += normal[i] * image_pos2[i];
1252 return dist1 < dist2;
1257 static const gdcm::Tag tagAcquisitionNumber(0x0020, 0x0012);
1258 if (ds1.FindDataElement(tagAcquisitionNumber) && ds2.FindDataElement(tagAcquisitionNumber))
1260 gdcm::Attribute<0x0020, 0x0012> acquisition_number1;
1261 gdcm::Attribute<0x0020, 0x0012> acquisition_number2;
1263 acquisition_number1.Set(ds1);
1264 acquisition_number2.Set(ds2);
1266 if (acquisition_number1 != acquisition_number2)
1268 return acquisition_number1 < acquisition_number2;
1273 static const gdcm::Tag tagAcquisitionTime(0x0008, 0x0032);
1274 if (ds1.FindDataElement(tagAcquisitionTime) && ds2.FindDataElement(tagAcquisitionTime))
1276 gdcm::Attribute<0x0008, 0x0032> acquisition_time1;
1277 gdcm::Attribute<0x0008, 0x0032> acquisition_time2;
1279 acquisition_time1.Set(ds1);
1280 acquisition_time2.Set(ds2);
1282 if (acquisition_time1 != acquisition_time2)
1284 return acquisition_time1 < acquisition_time2;
1289 static const gdcm::Tag tagTriggerTime(0x0018, 0x1060);
1290 if (ds1.FindDataElement(tagTriggerTime) && ds2.FindDataElement(tagTriggerTime))
1292 gdcm::Attribute<0x0018, 0x1060> trigger_time1;
1293 gdcm::Attribute<0x0018, 0x1060> trigger_time2;
1295 trigger_time1.Set(ds1);
1296 trigger_time2.Set(ds2);
1298 if (trigger_time1 != trigger_time2)
1300 return trigger_time1 < trigger_time2;
1314 static const gdcm::Tag tagSOPInstanceUID(0x0008, 0x0018);
1315 if (ds1.FindDataElement(tagSOPInstanceUID) && ds2.FindDataElement(tagSOPInstanceUID))
1318 <<
"Dicom images are missing attributes for a meaningful sorting, falling back to SOP instance UID comparison.";
1319 gdcm::Attribute<0x0008, 0x0018> SOPInstanceUID1;
1320 gdcm::Attribute<0x0008, 0x0018> SOPInstanceUID2;
1322 SOPInstanceUID1.Set(ds1);
1323 SOPInstanceUID2.Set(ds2);
1325 return SOPInstanceUID1 < SOPInstanceUID2;
1332 std::string error_message(
"Malformed DICOM images, which do not even contain a SOP Instance UID.");
1334 throw std::logic_error(error_message);
1340 std::stringstream configuration;
1341 configuration <<
"MITK_USE_GDCMIO: ";
1342 configuration <<
"true";
1343 configuration <<
"\n";
1345 configuration <<
"GDCM_VERSION: ";
1346 #ifdef GDCM_MAJOR_VERSION
1347 configuration << GDCM_VERSION;
1351 return configuration.str();
1355 const gdcm::Scanner::MappingType &tagValueMappings_,
1360 std::list<StringContainer> imageBlock;
1361 imageBlock.push_back(filenames);
1366 const gdcm::Scanner::MappingType &tagValueMappings_,
1379 gdcm::Scanner::MappingType &tagValueMappings =
const_cast<gdcm::Scanner::MappingType &
>(tagValueMappings_);
1382 const gdcm::Tag tagSliceLocation(0x0020, 0x1041);
1384 const gdcm::Tag tagInstanceNumber(0x0020, 0x0013);
1386 const gdcm::Tag tagSOPInstanceNumber(0x0008, 0x0018);
1387 unsigned int timeStep(0);
1389 std::string propertyKeySliceLocation =
"dicom.image.0020.1041";
1390 std::string propertyKeyInstanceNumber =
"dicom.image.0020.0013";
1391 std::string propertyKeySOPInstanceNumber =
"dicom.image.0008.0018";
1394 for (
auto i = imageBlock.begin(); i != imageBlock.end(); i++, timeStep++)
1397 unsigned int slice(0);
1398 for (
auto fIter = files.begin(); fIter != files.end(); ++fIter, ++slice)
1401 gdcm::Scanner::TagToValue tagValueMapForFile = tagValueMappings[fIter->c_str()];
1402 if (tagValueMapForFile.find(tagSliceLocation) != tagValueMapForFile.end())
1403 sliceLocationForSlices.
SetTableValue(slice, tagValueMapForFile[tagSliceLocation]);
1404 if (tagValueMapForFile.find(tagInstanceNumber) != tagValueMapForFile.end())
1405 instanceNumberForSlices.
SetTableValue(slice, tagValueMapForFile[tagInstanceNumber]);
1406 if (tagValueMapForFile.find(tagSOPInstanceNumber) != tagValueMapForFile.end())
1407 SOPInstanceNumberForSlices.
SetTableValue(slice, tagValueMapForFile[tagSOPInstanceNumber]);
1415 std::ostringstream postfix;
1416 postfix <<
".t" << timeStep;
1418 propertyKeySliceLocation.append(postfix.str());
1419 propertyKeyInstanceNumber.append(postfix.str());
1420 propertyKeySOPInstanceNumber.append(postfix.str());
1424 image->
SetProperty(propertyKeySOPInstanceNumber.c_str(),
1432 const itk::MetaDataDictionary &dict = io->GetMetaDataDictionary();
1435 auto dictIter = dict.Begin();
1436 while (dictIter != dict.End())
1440 if (itk::ExposeMetaData<std::string>(dict, dictIter->first, value))
1444 auto valuePosition = propertyLookup.find(dictIter->first);
1445 if (valuePosition != propertyLookup.end())
1447 std::string propertyKey = valuePosition->second;
1455 MITK_WARN <<
"Tag " << dictIter->first <<
" not read as string as expected. Ignoring...";
1463 "dicomseriesreader.ReaderImplementationLevelString",
1465 image->
SetProperty(
"dicomseriesreader.ReaderImplementationLevel",
1467 image->
SetProperty(
"dicomseriesreader.PixelSpacingInterpretationString",
1469 image->
SetProperty(
"dicomseriesreader.PixelSpacingInterpretation",
1486 imageBlockDescriptor.GetDesiredMITKImagePixelSpacing(desiredSpacingX, desiredSpacingY);
1488 MITK_DEBUG <<
"Loaded spacing: " << imageSpacingX <<
"/" << imageSpacingY;
1489 MITK_DEBUG <<
"Corrected spacing: " << desiredSpacingX <<
"/" << desiredSpacingY;
1491 imageSpacing[0] = desiredSpacingX;
1492 imageSpacing[1] = desiredSpacingY;
1501 UpdateCallBackMethod callback,
1505 std::locale previousCppLocale(std::cin.getloc());
1511 const gdcm::Tag tagImagePositionPatient(0x0020, 0x0032);
1512 const gdcm::Tag tagImageOrientation(0x0020, 0x0037);
1513 const gdcm::Tag tagSeriesInstanceUID(0x0020, 0x000e);
1514 const gdcm::Tag tagSOPClassUID(0x0008, 0x0016);
1515 const gdcm::Tag tagModality(0x0008, 0x0060);
1516 const gdcm::Tag tagPixelSpacing(0x0028, 0x0030);
1517 const gdcm::Tag tagImagerPixelSpacing(0x0018, 0x1164);
1518 const gdcm::Tag tagNumberOfFrames(0x0028, 0x0008);
1524 bool initialize_node =
false;
1532 initialize_node =
true;
1537 bool canLoadAs4D(
true);
1538 gdcm::Scanner scanner;
1542 gdcm::Scanner::MappingType &tagValueMappings =
const_cast<gdcm::Scanner::MappingType &
>(scanner.GetMappings());
1544 std::list<StringContainer> imageBlocks =
1546 unsigned int volume_count = imageBlocks.size();
1548 imageBlockDescriptor.SetSeriesInstanceUID(
1550 imageBlockDescriptor.SetSOPClassUID(
1552 imageBlockDescriptor.SetModality(
1554 imageBlockDescriptor.SetNumberOfFrames(
1556 imageBlockDescriptor.SetPixelSpacingInformation(
1564 if (!imageBlocks.empty() && imageBlocks.front().size() > 1 && correctTilt)
1569 std::string firstFilename(imageBlocks.front().front());
1571 std::string secondFilename(imageBlocks.front().back());
1573 std::string imagePosition1(
1575 std::string imageOrientation(
1577 std::string imagePosition2(
1580 bool ignoredConversionError(-42);
1595 correctTilt =
false;
1598 imageBlockDescriptor.SetHasGantryTiltCorrected(correctTilt);
1600 if (volume_count == 1 || !canLoadAs4D || !load4D)
1604 imageBlocks.front(), correctTilt, tiltInfo, io, command, preLoadedImageBlock);
1606 imageBlockDescriptor.AddFiles(imageBlocks.front());
1607 imageBlockDescriptor.SetHasMultipleTimePoints(
false);
1612 initialize_node =
true;
1614 else if (volume_count > 1)
1616 imageBlockDescriptor.AddFiles(filenames);
1617 imageBlockDescriptor.SetHasMultipleTimePoints(
true);
1621 imageBlocks, imageBlockDescriptor, correctTilt, tiltInfo, io, command, preLoadedImageBlock);
1623 initialize_node =
true;
1627 if (initialize_node)
1632 std::string patientName =
"NoName";
1633 if (node.
GetProperty(
"dicom.patient.PatientsName"))
1638 std::cin.imbue(previousCppLocale);
1641 MITK_DEBUG <<
"--------------------------------------------------------------------------------";
1650 << image->GetGeometry()->GetSpacing()[0] <<
"/" << image->GetGeometry()->GetSpacing()[0];
1653 MITK_DEBUG <<
"--------------------------------------------------------------------------------";
1655 catch (std::exception &e)
1658 std::cin.imbue(previousCppLocale);
1660 MITK_DEBUG <<
"Caught exception in DicomSeriesReader::LoadDicom";
1668 const gdcm::Tag tagImagePositionPatient(0x0020, 0x0032);
1669 scanner.AddTag(tagImagePositionPatient);
1671 const gdcm::Tag tagSeriesInstanceUID(0x0020, 0x000e);
1672 scanner.AddTag(tagSeriesInstanceUID);
1674 const gdcm::Tag tagImageOrientation(0x0020, 0x0037);
1675 scanner.AddTag(tagImageOrientation);
1677 const gdcm::Tag tagSliceLocation(0x0020, 0x1041);
1678 scanner.AddTag(tagSliceLocation);
1680 const gdcm::Tag tagInstanceNumber(0x0020, 0x0013);
1681 scanner.AddTag(tagInstanceNumber);
1683 const gdcm::Tag tagSOPInstanceNumber(0x0008, 0x0018);
1684 scanner.AddTag(tagSOPInstanceNumber);
1686 const gdcm::Tag tagPixelSpacing(0x0028, 0x0030);
1687 scanner.AddTag(tagPixelSpacing);
1689 const gdcm::Tag tagImagerPixelSpacing(0x0018, 0x1164);
1690 scanner.AddTag(tagImagerPixelSpacing);
1692 const gdcm::Tag tagModality(0x0008, 0x0060);
1693 scanner.AddTag(tagModality);
1695 const gdcm::Tag tagSOPClassUID(0x0008, 0x0016);
1696 scanner.AddTag(tagSOPClassUID);
1698 const gdcm::Tag tagNumberOfFrames(0x0028, 0x0008);
1699 scanner.AddTag(tagNumberOfFrames);
1701 scanner.Scan(filenames);
1706 const gdcm::Scanner::MappingType &tagValueMappings,
1710 std::list<StringContainer> imageBlocks;
1715 std::string firstPosition;
1716 unsigned int numberOfBlocks(0);
1718 static const gdcm::Tag tagImagePositionPatient(0x0020, 0x0032);
1719 const gdcm::Tag tagModality(0x0008, 0x0060);
1722 for (StringContainer::const_iterator fileIter = sorted_filenames.begin(); fileIter != sorted_filenames.end();
1725 gdcm::Scanner::TagToValue tagToValueMap = tagValueMappings.find(fileIter->c_str())->second;
1727 if (tagToValueMap.find(tagImagePositionPatient) == tagToValueMap.end())
1729 const std::string &modality = tagToValueMap.find(tagModality)->second;
1730 if (modality.compare(
"RTIMAGE ") == 0 || modality.compare(
"RTIMAGE") == 0)
1732 MITK_WARN <<
"Modality " << modality <<
" is not fully supported yet.";
1739 assert(presortedFilenames.size() == 1);
1745 std::string position = tagToValueMap.find(tagImagePositionPatient)->second;
1746 MITK_DEBUG <<
" " << *fileIter <<
" at " << position;
1747 if (firstPosition.empty())
1749 firstPosition = position;
1752 if (position == firstPosition)
1762 MITK_DEBUG <<
" ==> Assuming " << numberOfBlocks <<
" time steps";
1764 if (numberOfBlocks == 0)
1768 unsigned int numberOfExpectedSlices(0);
1769 for (
unsigned int block = 0; block < numberOfBlocks; ++block)
1773 for (StringContainer::const_iterator fileIter = sorted_filenames.begin() + block;
1774 fileIter != sorted_filenames.end();
1778 filesOfCurrentBlock.push_back(*fileIter);
1779 for (
unsigned int b = 0; b < numberOfBlocks; ++b)
1781 if (fileIter != sorted_filenames.end())
1786 imageBlocks.push_back(filesOfCurrentBlock);
1790 numberOfExpectedSlices = filesOfCurrentBlock.size();
1794 if (filesOfCurrentBlock.size() != numberOfExpectedSlices)
1797 <<
"DicomSeriesReader expected " << numberOfBlocks <<
" image blocks of " << numberOfExpectedSlices
1798 <<
" images each. Block " << block <<
" got " << filesOfCurrentBlock.size()
1799 <<
" instead. Cannot load this as 3D+t";
1801 canLoadAs4D =
false;
1817 io->SetFileName(filenames.front().c_str());
1818 io->ReadImageInformation();
1820 if (io->GetPixelType() == itk::ImageIOBase::SCALAR)
1824 else if (io->GetPixelType() == itk::ImageIOBase::RGB)
1843 io->SetFileName(imageBlocks.front().front().c_str());
1844 io->ReadImageInformation();
1846 if (io->GetPixelType() == itk::ImageIOBase::SCALAR)
1849 imageBlocks, imageBlockDescriptor, correctTilt, tiltInfo, io, command, preLoadedImageBlock);
1851 else if (io->GetPixelType() == itk::ImageIOBase::RGB)
1854 imageBlocks, imageBlockDescriptor, correctTilt, tiltInfo, io, command, preLoadedImageBlock);
PixelSpacingInterpretation
How the mitk::Image spacing should be interpreted.
mitk::PropertyList * GetPropertyList(const mitk::BaseRenderer *renderer=nullptr) const
Get the PropertyList of the renderer. If renderer is NULL, the BaseRenderer-independent PropertyList ...
distances are mm within a patient
StringContainer GetBlockFilenames()
Grouping result, all same origin-to-origin distance w/o gaps.
std::map< std::string, std::string > TagToPropertyMapType
Maps DICOM tags to MITK properties.
void AddFilesToUnsortedBlock(const StringContainer &filenames)
StringContainer GetFilenames() const
List of files in this group.
itk::SmartPointer< Self > Pointer
static itk::SmartPointer< Image > MultiplexLoadDICOMByITK4DScalar(std::list< StringContainer > &imageBlocks, ImageBlockDescriptor imageBlockDescriptor, bool correctTilt, const GantryTiltInformation &tiltInfo, DcmIoType::Pointer &io, CallbackCommand *command, itk::SmartPointer< Image > preLoadedImageBlock)
static bool DICOMStringToSpacing(const std::string &s, ScalarType &spacingX, ScalarType &spacingY)
Safely convert a string into pixel spacing x and y.
void SetSpacing(const mitk::Vector3D &aSpacing, bool enforceSetSpacing=false)
Set the spacing (m_Spacing).
Return type of GetSeries, describes a logical group of files.
void SetTableValue(IdentifierType id, ValueType value)
bool HasGantryTiltCorrected() const
Whether or not the block contains a gantry tilt which will be "corrected" during loading.
static Point3D DICOMStringToPoint3D(const std::string &s, bool &successful)
Convert DICOM string describing a point to Point3D.
std::string GetImageBlockUID() const
A unique ID describing this bloc (enhanced Series Instance UID).
static void ScanForSliceInformation(const StringContainer &filenames, gdcm::Scanner &scanner)
Scan for slice image information.
distances are mm at detector surface
static void FixSpacingInformation(Image *image, const ImageBlockDescriptor &imageBlockDescriptor)
void UndoPrematureGrouping()
Only meaningful for use by AnalyzeFileForITKImageSeriesReaderSpacingAssumption.
static std::string GetConfigurationString()
Provide combination of preprocessor defines that was active during compilation.
virtual void SetData(mitk::BaseData *baseData)
Set the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
std::vector< std::string > StringContainer
Lists of filenames.
static bool ReadPhilips3DDicom(const std::string &filename, itk::SmartPointer< Image > output_image)
Read a Philips3D ultrasound DICOM file and put into an mitk::Image.
static DataNode::Pointer LoadDicomSeries(const StringContainer &filenames, bool sort=true, bool load4D=true, bool correctGantryTilt=true, UpdateCallBackMethod callback=nullptr, itk::SmartPointer< Image > preLoadedImageBlock=nullptr)
DataCollection - Class to facilitate loading/accessing structured data.
const mitk::Vector3D GetSpacing() const
Get the spacing (size of a pixel).
void ConcatenatePropertyList(PropertyList *pList, bool replace=false)
Set a property object in the list/map by reference.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
static itk::SmartPointer< Image > MultiplexLoadDICOMByITKRGBPixel(const StringContainer &, bool correctTilt, const GantryTiltInformation &tiltInfo, DcmIoType::Pointer &io, CallbackCommand *command, itk::SmartPointer< Image > preLoadedImageBlock)
std::string GetModality() const
Series Modality (CT, MR, etc.)
mitk::BaseProperty * GetProperty(const char *propertyKey, const mitk::BaseRenderer *renderer=nullptr) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList of the rendere...
StringContainer GetUnsortedFilenames()
Remaining files, which could not be grouped.
static std::string CreateSeriesIdentifierPart(gdcm::Scanner::TagToValue &tagValueMap, const gdcm::Tag &tag)
Helper for CreateMoreUniqueSeriesIdentifier.
static std::string ReaderImplementationLevelToString(const ReaderImplementationLevel &enumValue)
static itk::SmartPointer< Image > MultiplexLoadDICOMByITK4DRGBPixel(std::list< StringContainer > &imageBlocks, ImageBlockDescriptor imageBlockDescriptor, bool correctTilt, const GantryTiltInformation &tiltInfo, DcmIoType::Pointer &io, CallbackCommand *command, itk::SmartPointer< Image > preLoadedImageBlock)
std::string GetSOPClassUIDAsString() const
SOP Class UID as readable string (Computed Tomography Image Storage, Secondary Capture Image Storage...
static std::string ConstCharStarToString(const char *s)
Safely convert const char* to std::string.
loader code is implemented but not accompanied by tests
static std::string PixelSpacingInterpretationToString(const PixelSpacingInterpretation &enumValue)
static std::string IDifyTagValue(const std::string &value)
Helper for CreateMoreUniqueSeriesIdentifier.
void SetProperty(const char *propertyKey, BaseProperty *property)
map::core::discrete::Elements< 3 >::InternalImageType ImageType
static void LoadDicom(const StringContainer &filenames, DataNode &node, bool sort, bool check_4d, bool correctTilt, UpdateCallBackMethod callback, itk::SmartPointer< Image > preLoadedImageBlock)
Performs actual loading of a series and creates an image having the specified pixel type...
Convenience class to temporarily change the current locale.
static std::list< StringContainer > SortIntoBlocksFor3DplusT(const StringContainer &presortedFilenames, const gdcm::Scanner::MappingType &tagValueMappings_, bool sort, bool &canLoadAs4D)
Sort files into time step blocks of a 3D+t image.
static const std::string filename
virtual std::string GetValueAsString() const
static FileNamesGrouping GetSeries(const std::string &dir, bool groupImagesWithGantryTilt, const StringContainer &restrictions=StringContainer())
see other GetSeries().
static void DICOMStringToOrientationVectors(const std::string &s, Vector3D &right, Vector3D &up, bool &successful)
Convert DICOM string describing a point two Vector3D.
void AddFileToSortedBlock(const std::string &filename)
Meant for internal use by AnalyzeFileForITKImageSeriesReaderSpacingAssumption only.
Image class for storing images.
bool HasMultipleTimePoints() const
3D+t or not
virtual void SetName(const char *name)
Extra convenience access method to set the name of an object.
std::string GetSeriesInstanceUID() const
The Series Instance UID.
bool ContainsGantryTilt()
Wheter or not the grouped result contain a gantry tilt.
Progress callback for DicomSeriesReader.
static bool IsPhilips3DDicom(const std::string &filename)
Checks if a specific file is a Philips3D ultrasound DICOM file.
static itk::SmartPointer< Image > MultiplexLoadDICOMByITKScalar(const StringContainer &, bool correctTilt, const GantryTiltInformation &tiltInfo, DcmIoType::Pointer &io, CallbackCommand *command, itk::SmartPointer< Image > preLoadedImageBlock)
static bool IsDicom(const std::string &filename)
Checks if a specific file contains DICOM data.
loader code and tests are established
bool IsMultiFrameImage() const
Multi-frame image(s) or not.
Return type of DicomSeriesReader::AnalyzeFileForITKImageSeriesReaderSpacingAssumption.
void CastToMitkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, itk::SmartPointer< mitk::Image > &mitkoutputimage)
Cast an itk::Image (with a specific type) to an mitk::Image.
static void CopyMetaDataToImageProperties(StringContainer filenames, const gdcm::Scanner::MappingType &tagValueMappings_, DcmIoType *io, const ImageBlockDescriptor &blockInfo, Image *image)
Copy information about files and DICOM tags from ITK's MetaDataDictionary and from the list of input ...
static itk::SmartPointer< Image > MultiplexLoadDICOMByITK4D(std::list< StringContainer > &imageBlocks, ImageBlockDescriptor imageBlockDescriptor, bool correctTilt, const GantryTiltInformation &tiltInfo, DcmIoType::Pointer &io, CallbackCommand *command, itk::SmartPointer< Image > preLoadedImageBlock)
ReaderImplementationLevel GetReaderImplementationLevel() const
Confidence of the reader that this block can be read successfully.
void FlagGantryTilt()
Meant for internal use by AnalyzeFileForITKImageSeriesReaderSpacingAssumption only.
MITKCORE_EXPORT const ScalarType eps
static const TagToPropertyMapType & GetDICOMTagsToMITKPropertyMap()
Map between DICOM tags and MITK properties.
void AddFileToUnsortedBlock(const std::string &filename)
Meant for internal use by AnalyzeFileForITKImageSeriesReaderSpacingAssumption only.
std::map< std::string, ImageBlockDescriptor > FileNamesGrouping
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
PixelSpacingInterpretation GetPixelSpacingType() const
How the mitk::Image spacing can meaningfully be interpreted.
itk::GDCMImageIO DcmIoType
static std::string CreateMoreUniqueSeriesIdentifier(gdcm::Scanner::TagToValue &tagValueMap)
Construct a UID that takes into account sorting criteria from GetSeries().
static itk::SmartPointer< Image > MultiplexLoadDICOMByITK(const StringContainer &, bool correctTilt, const GantryTiltInformation &tiltInfo, DcmIoType::Pointer &io, CallbackCommand *command, itk::SmartPointer< Image > preLoadedImageBlock)
static StringContainer SortSeriesSlices(const StringContainer &unsortedFilenames)
Sort a set of file names in an order that is meaningful for loading them into an mitk::Image.
ReaderImplementationLevel
Describes how well the reader is tested for a certain file type.
static bool GdcmSortFunction(const gdcm::DataSet &ds1, const gdcm::DataSet &ds2)
Defines spatial sorting for sorting by GDCM 2.
Class for nodes of the DataTree.
static SliceGroupingAnalysisResult AnalyzeFileForITKImageSeriesReaderSpacingAssumption(const StringContainer &files, bool groupsOfSimilarImages, const gdcm::Scanner::MappingType &tagValueMappings_)
Ensure an equal z-spacing for a group of files.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.