Medical Imaging Interaction Toolkit
2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
|
Go to the documentation of this file.
13 #ifndef mitkDicomSeriesReader_h
14 #define mitkDicomSeriesReader_h
19 #include <itkGDCMImageIO.h>
21 #include <itkCommand.h>
22 #include <itkImageSeriesReader.h>
29 #include <gdcmConfigure.h>
38 #include <gdcmDataSet.h>
39 #include <gdcmScanner.h>
446 void AddFile(
const std::string &file);
449 void SetImageBlockUID(
const std::string &uid);
451 void SetSeriesInstanceUID(
const std::string &uid);
453 void SetModality(
const std::string &modality);
455 void SetNumberOfFrames(
const std::string &);
457 void SetSOPClassUID(
const std::string &mediaStorageSOPClassUID);
459 void SetHasGantryTiltCorrected(
bool);
461 void SetPixelSpacingInformation(
const std::string &pixelSpacing,
const std::string &imagerPixelSpacing);
463 void SetHasMultipleTimePoints(
bool);
468 std::string m_ImageBlockUID;
469 std::string m_SeriesInstanceUID;
470 std::string m_Modality;
471 std::string m_SOPClassUID;
472 bool m_HasGantryTiltCorrected;
473 std::string m_PixelSpacing;
474 std::string m_ImagerPixelSpacing;
475 bool m_HasMultipleTimePoints;
476 bool m_IsMultiFrameImage;
492 static bool IsDicom(
const std::string &filename);
500 bool groupImagesWithGantryTilt,
512 const std::string &series_uid,
513 bool groupImagesWithGantryTilt,
542 bool groupImagesWithGantryTilt,
551 bool groupImagesWithGantryTilt,
568 bool correctGantryTilt =
true,
589 bool correctGantryTilt =
true,
697 unsigned int numberOfSlicesApart);
778 const StringContainer &files,
bool groupsOfSimilarImages,
const gdcm::Scanner::MappingType &tagValueMappings_);
810 template <
typename ImageType>
811 static typename ImageType::Pointer
875 void Execute(
const itk::Object *caller,
const itk::EventObject &)
override
877 (*this->
m_Callback)(
static_cast<const itk::ProcessObject *
>(caller)->GetProgress());
880 void Execute(itk::Object *caller,
const itk::EventObject &)
override
882 (*this->
m_Callback)(
static_cast<itk::ProcessObject *
>(caller)->GetProgress());
916 template <
typename PixelType>
920 DcmIoType::Pointer &io,
927 DcmIoType::Pointer &io,
934 DcmIoType::Pointer &io,
941 DcmIoType::Pointer &io,
945 template <
typename PixelType>
950 DcmIoType::Pointer &io,
958 DcmIoType::Pointer &io,
966 DcmIoType::Pointer &io,
974 DcmIoType::Pointer &io,
993 const gdcm::Scanner::MappingType &tagValueMappings_,
1003 static bool GdcmSortFunction(
const gdcm::DataSet &ds1,
const gdcm::DataSet &ds2);
1011 const gdcm::Scanner::MappingType &tagValueMappings_,
1016 const gdcm::Scanner::MappingType &tagValueMappings_,
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 ...
void AddFileToUnsortedBlock(const std::string &filename)
Meant for internal use by AnalyzeFileForITKImageSeriesReaderSpacingAssumption only.
static DataNode::Pointer LoadDicomSeries(const StringContainer &filenames, bool sort=true, bool load4D=true, bool correctGantryTilt=true, UpdateCallBackMethod callback=nullptr, itk::SmartPointer< Image > preLoadedImageBlock=nullptr)
bool HasMultipleTimePoints() const
3D+t or not
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)
static const TagToPropertyMapType & GetDICOMTagsToMITKPropertyMap()
Map between DICOM tags and MITK properties.
static std::string ReaderImplementationLevelToString(const ReaderImplementationLevel &enumValue)
void Execute(const itk::Object *caller, const itk::EventObject &) override
StringContainer GetFilenames() const
List of files in this group.
static itk::SmartPointer< Image > MultiplexLoadDICOMByITKScalar(const StringContainer &, bool correctTilt, const GantryTiltInformation &tiltInfo, DcmIoType::Pointer &io, CallbackCommand *command, itk::SmartPointer< Image > preLoadedImageBlock)
static StringContainer SortSeriesSlices(const StringContainer &unsortedFilenames)
static SliceGroupingAnalysisResult AnalyzeFileForITKImageSeriesReaderSpacingAssumption(const StringContainer &files, bool groupsOfSimilarImages, const gdcm::Scanner::MappingType &tagValueMappings_)
Ensure an equal z-spacing for a group of files.
static itk::SmartPointer< Image > LoadDICOMByITK4D(std::list< StringContainer > &imageBlocks, ImageBlockDescriptor imageBlockDescriptor, bool correctTilt, const GantryTiltInformation &tiltInfo, DcmIoType::Pointer &io, CallbackCommand *command, itk::SmartPointer< Image > preLoadedImageBlock)
std::pair< StringContainer, StringContainer > TwoStringContainers
for internal sorting.
void AddFilesToUnsortedBlock(const StringContainer &filenames)
Progress callback for DicomSeriesReader.
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)
static void FixSpacingInformation(Image *image, const ImageBlockDescriptor &imageBlockDescriptor)
Return type of DicomSeriesReader::AnalyzeFileForITKImageSeriesReaderSpacingAssumption.
void Execute(itk::Object *caller, const itk::EventObject &) override
@ PixelSpacingInterpretation_SpacingInPatient
StringContainer GetBlockFilenames()
Grouping result, all same origin-to-origin distance w/o gaps.
static bool IsPhilips3DDicom(const std::string &filename)
Checks if a specific file is a Philips3D ultrasound DICOM file.
bool PixelSpacingRelatesToPatient() const
Whether or not mitk::Image spacing relates to the patient.
static std::string ConstCharStarToString(const char *s)
Safely convert const char* to std::string.
SliceGroupingAnalysisResult()
Image class for storing images.
static itk::SmartPointer< Image > MultiplexLoadDICOMByITK(const StringContainer &, bool correctTilt, const GantryTiltInformation &tiltInfo, DcmIoType::Pointer &io, CallbackCommand *command, itk::SmartPointer< Image > preLoadedImageBlock)
static FileNamesGrouping GetSeries(const std::string &dir, bool groupImagesWithGantryTilt, const StringContainer &restrictions=StringContainer())
see other GetSeries().
void(* UpdateCallBackMethod)(float)
Interface for the progress callback.
bool HasGantryTiltCorrected() const
Whether or not the block contains a gantry tilt which will be "corrected" during loading.
static std::string CreateMoreUniqueSeriesIdentifier(gdcm::Scanner::TagToValue &tagValueMap)
Construct a UID that takes into account sorting criteria from GetSeries().
std::map< std::string, ImageBlockDescriptor > FileNamesGrouping
@ PixelSpacingInterpretation_SpacingAtDetector
distances are mm within a patient
bool PixelSpacingIsUnknown() const
Whether or not mitk::Image spacing is of unknown origin.
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.
@ PixelSpacingInterpretation_SpacingUnknown
distances are mm at detector surface
std::string GetSOPClassUIDAsString() const
SOP Class UID as readable string (Computed Tomography Image Storage, Secondary Capture Image Storage,...
static bool IsDicom(const std::string &filename)
Checks if a specific file contains DICOM data.
Find image slices visible on a given plane.
PixelSpacingInterpretation GetPixelSpacingType() const
How the mitk::Image spacing can meaningfully be interpreted.
ReaderImplementationLevel GetReaderImplementationLevel() const
Confidence of the reader that this block can be read successfully.
std::map< std::string, std::string > TagToPropertyMapType
Maps DICOM tags to MITK properties.
bool IsMultiFrameImage() const
Multi-frame image(s) or not.
@ ReaderImplementationLevel_Unsupported
loader code is implemented but not accompanied by tests
StringContainer m_GroupedFiles
std::string GetImageBlockUID() const
A unique ID describing this bloc (enhanced Series Instance UID).
Return type of GetSeries, describes a logical group of files.
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.
CallbackCommand(UpdateCallBackMethod callback)
StringContainer GetUnsortedFilenames()
Remaining files, which could not be grouped.
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.
bool ContainsGantryTilt()
Whether or not the grouped result contain a gantry tilt.
static Point3D DICOMStringToPoint3D(const std::string &s, bool &successful)
Convert DICOM string describing a point to Point3D.
static bool GdcmSortFunction(const gdcm::DataSet &ds1, const gdcm::DataSet &ds2)
Defines spatial sorting for sorting by GDCM 2.
static void DICOMStringToOrientationVectors(const std::string &s, Vector3D &right, Vector3D &up, bool &successful)
Convert DICOM string describing a point two Vector3D.
static std::string PixelSpacingInterpretationToString(const PixelSpacingInterpretation &enumValue)
static std::string CreateSeriesIdentifierPart(gdcm::Scanner::TagToValue &tagValueMap, const gdcm::Tag &tag)
Helper for CreateMoreUniqueSeriesIdentifier.
ReaderImplementationLevel
Describes how well the reader is tested for a certain file type.
void FlagGantryTilt()
Meant for internal use by AnalyzeFileForITKImageSeriesReaderSpacingAssumption only.
static ImageType::Pointer InPlaceFixUpTiltedGeometry(ImageType *input, const GantryTiltInformation &tiltInfo)
bool PixelSpacingRelatesToDetector() const
Whether or not mitk::Image spacing relates to the detector surface.
static bool ReadPhilips3DDicom(const std::string &filename, itk::SmartPointer< Image > output_image)
Read a Philips3D ultrasound DICOM file and put into an mitk::Image.
StringContainer m_UnsortedFiles
static itk::SmartPointer< Image > MultiplexLoadDICOMByITKRGBPixel(const StringContainer &, bool correctTilt, const GantryTiltInformation &tiltInfo, DcmIoType::Pointer &io, CallbackCommand *command, itk::SmartPointer< Image > preLoadedImageBlock)
UpdateCallBackMethod m_Callback
void UndoPrematureGrouping()
Only meaningful for use by AnalyzeFileForITKImageSeriesReaderSpacingAssumption.
std::string GetModality() const
Series Modality (CT, MR, etc.)
std::string GetSOPClassUID() const
SOP Class UID as DICOM UID.
PixelSpacingInterpretation
How the mitk::Image spacing should be interpreted.
void AddFileToSortedBlock(const std::string &filename)
Meant for internal use by AnalyzeFileForITKImageSeriesReaderSpacingAssumption only.
@ ReaderImplementationLevel_Implemented
std::string GetSeriesInstanceUID() const
The Series Instance UID.
static std::string GetConfigurationString()
Provide combination of preprocessor defines that was active during compilation.
@ ReaderImplementationLevel_PartlySupported
loader code and tests are established
std::vector< std::string > StringContainer
Lists of filenames.
@ ReaderImplementationLevel_Supported
static void ScanForSliceInformation(const StringContainer &filenames, gdcm::Scanner &scanner)
Scan for slice image information.
Class for nodes of the DataTree.
itk::GDCMImageIO DcmIoType
static itk::SmartPointer< Image > LoadDICOMByITK(const StringContainer &, bool correctTilt, const GantryTiltInformation &tiltInfo, DcmIoType::Pointer &io, CallbackCommand *command, itk::SmartPointer< Image > preLoadedImageBlock)
Feed files into itk::ImageSeriesReader and retrieve a 3D MITK image.
static std::string IDifyTagValue(const std::string &value)
Helper for CreateMoreUniqueSeriesIdentifier.