MeVisLab Toolbox Reference
|
Tool functions for the extraction and handling of information of specific DICOM frames. More...
Classes | |
class | DCMTreeInfo |
Small container for statistical information about a DCMTree. More... | |
class | DicomFrameSetMinMaxCalculation |
Class to collect incrementally per frame all min/max related parameters of a DICOM frame set. More... | |
struct | DICOMPixelReadAndCopyParameterResults |
Container storing parameters needed to copy data from DICOM pixel data into a SubImage. More... | |
class | DICOMPixelReadAndCopyParameters |
Small container storing and validating all input and result parameters needed to copy data from a DCMTree given by a DICOMCachedIOFileHandle into a SubImage. More... | |
struct | FrameSpecificTag |
A struct containing a information about a specific frame (position, tagId, tagPtr, and whether it's from tree root). More... | |
struct | FrameSpecificTags |
Helper structure to store a z, t, u position of a frame in a structured multi-frame tree, and a tag belonging to that frame. More... | |
struct | FrameSpecificValueTag |
A struct containing a information about a specific frame (position, tagId, tagPtr, and whether it's from tree root) as well as an associated value retrieved from the tag and the value validity. More... | |
class | NeedsSignednessCorrectionShiftingOrMasking |
Tool class to retrieve the values of HightBit, BitsAllocated, BitsStored, and PixelRepresentation from dcmTree and to set needsCorrection to true if pixel data needs post processing such as masking of retired overlay planes, sign extension, or shifting. More... | |
struct | PositionSpecificDouble |
Helper structure to store a z, t, u position with an associated double value. More... | |
Typedefs | |
typedef std::vector< FrameSpecificTags > | FrameSpecificTagsVector |
Often used std::vector type of FrameSpecificTag elements. | |
typedef std::vector< PositionSpecificDouble > | PositionSpecificDoubleVector |
Often used std::vector type of PositionSpecificDouble elements. | |
Functions | |
MLDICOM_TO_ML_TOOLS_EXPORT FrameSpecificTagsVector | getFrameSpecificTagSet (const DCMTree::Const_StructuredMFPtr &smfTree, const std::vector< DCMTree::RawTagId > &tagIds) |
Returns an entry for each frame and each tag id from tagIds in which any tagId can be found and store the corresponding z, t, and u location in the entry as well as the found pointer to the tag. | |
MLDICOM_TO_ML_TOOLS_EXPORT FrameSpecificTagsVector | getFrameSpecificTags (const DCMTree::Const_StructuredMFPtr &smfTree, DCMTree::RawTagId tagId) |
Returns an entry for each frame in which a tag with id tagId can be found and store the corresponding z, t, and u location in the entry as well as the found pointer to the tag. | |
MLDICOM_TO_ML_TOOLS_EXPORT size_t | convertToFrameSpecificDoubles (const FrameSpecificTagsVector &frameSpecificTags, PositionSpecificDoubleVector &frameSpecificDoubles) |
Converts first entries of each entries in FrameSpecificTagsVector to a PositionSpecificDoubleVector object. | |
MLDICOM_TO_ML_TOOLS_EXPORT bool | applyFrameSpecificOperation (const VoxelDoubleOperations &operationMode, const SubImage &srcSubImage, SubImage &dstSubImage, const PositionSpecificDoubleVector &positionDoubles, const VoxelDoubleOperations dummyOperationMode=Copy, const MLdouble dummyOperationValue=0.0, PositionSpecificDoubleVector *valueFreePositions=nullptr, bool isOldMultiFrameDICOM=false) |
Copy voxels from overlapping regions of srcSubImage to dstSubImage and apply the operationMode if for the z, t, u position of the slice an entry can be found in positionDoubles whose double value can be used for modification. | |
MLDICOM_TO_ML_TOOLS_EXPORT const FrameSpecificTags * | getFrameSpecificTagsSet (const FrameSpecificTagsVector &tagSet, MLint z, MLint t, MLint u) |
Returns pointer to the first occurrence of a FrameSpecificTags entry which has the given z, t, and u positions or nullptr if not found. | |
MLDICOM_TO_ML_TOOLS_EXPORT bool | isVolumeCovered (const PositionSpecificDoubleVector &positions, const SubImageBox &volume) |
Returns true if the (z,t,u) positions in positions cover all (z,t,u) slices in volume, otherwise false is returned. | |
MLDICOM_TO_ML_TOOLS_EXPORT bool | getPositionSpecificDoubleProperties (const PositionSpecificDoubleVector &positions, double &rangeMin, double &rangeMax, bool &hasFractionalParts) |
Returns some properties of the double values in valuePositions, the minimum / maximum range, and whether any value is a non integer one. | |
MLDICOM_TO_ML_TOOLS_EXPORT std::vector< DCMTree::RawTagId > | getOverlayTagSet () |
Create a vector with all possible ids of type 1 and important type 3 overlay tags. | |
MLDICOM_TO_ML_TOOLS_EXPORT void | setUpOverlayOutputProperties (DCMTree::Const_TreePtr dcmTree, PagedImage &overlayPagedImg, DicomToMLTools::FrameSpecificTagsVector &overlayTagSet) |
Determine DICOM overlay information from dcmTree, configures (or if necessary invalidates) the passed overlayPagedImg such that it can display these overlays correctly, and sets up overlayTagSet such that it provides all required DICOM tags to display them properly in calculateOutputSubImage. | |
MLDICOM_TO_ML_TOOLS_EXPORT std::string | createOverlayBitSubImages (const FrameSpecificTagsVector &tagSet, MLint z, MLint t, MLint u, std::vector< BitImage > &bitImages) |
Create and return a BitImage in bitSubImages for each overlay for which all required type 1 tags are found in the first z,t,u frame occurrence. | |
MLDICOM_TO_ML_TOOLS_EXPORT std::string | rasterOverlays (DicomToMLTools::FrameSpecificTagsVector &overlayTagSet, SubImage &outSubImg) |
Takes overlay DICOM tags from overlayTagSet matching the x/y plane of outSubImage.getBox().v1, create BitImages from them and copies them into outSubImage where the entire background it filled with 0, and valid overlay bits are set to 1. | |
void | getFrameSpecificDoubleTag (const DCMTree::StructuredMF &smfTree, const unsigned int z, const unsigned int t, const unsigned int u, const DCMTree::RawTagId rawTagId, FrameSpecificValueTag< double > &valTagInfos) |
Retrieves a double tag value from a frame specific tag with id rawTagId at (z,t,u) from smfTree, and returns all result information in valTagInfos; if the value cannot be retrieved from the given frame then it is tried to get it from the tree root. | |
void | getFrameSpecificStringTag (const DCMTree::StructuredMF &smfTree, const unsigned int z, const unsigned int t, const unsigned int u, const DCMTree::RawTagId rawTagId, FrameSpecificValueTag< std::string > &valTagInfos) |
Same as getFrameSpecificDoubleTag() but for std::string values. | |
MLDICOM_TO_ML_TOOLS_EXPORT MLErrorCode | copyFromDCMTreeToSubImg (const DICOMCachedIOFileHandle &dcmFileHandle, DCMTree::Const_TreePtr alternativeDCMTree, SubImage &outSubImg, bool force, DicomMessageCollector &dcmMsgCollector) |
Tries to fill the given output subimage outSubImg with pixel data from the DICOM tree given by either dcmFileHandle or alternativeDCMTree. | |
MLDICOM_TO_ML_TOOLS_EXPORT MLErrorCode | convertDCMTreeToSubImage (const DICOMCachedIOFileHandle &dcmFrameHandle, DCMTree::Const_TreePtr alternativeDCMTree, SubImage &subImage, DicomMessageCollector &dcmMsgCollector) |
Reads the DICOM file given by dcmFrameHandle via the MLDICOMCachedIOTreeCache (or uses alternativeDCMTree if dcmFrameHandle is empty), and updates subImage to its data content. | |
MLDICOM_TO_ML_TOOLS_EXPORT void | convertToImageProperties (DCMTree::StructuredMFPtr &baseSMFPtr, const std::string &firstFileName, PagedImage &resultImgProps, FillPageMethods *fillPageMethod, const ZTUFileNameSet *setOfFileHandles, double defaultFillValue, CalculateMinMaxFromDicomModes minMaxCalcMode, const std::string &versionString, bool anonymize, bool removePrivateMultiFrameSQTag, bool forceOrthogonalWorldMatrix, bool copyPrivateTopLevelSrcTags, DicomMessageCollector &dcmMsgCollector) |
Determines as much PagedImage information from baseSMFPtr as possible and. | |
MLDICOM_TO_ML_TOOLS_EXPORT size_t | getVoxelSize (DCMTree::Const_TreePtr treePtr, double &voxSizeX, double &voxSizeY, double &voxSizeZ, bool replaceOnlyIfFound, bool *isPrecise, std::vector< DCMTree::RawTagId > *usedTags, DicomMessageCollector &dcmMsgCollector) |
Determine the voxel size from the DICOM tags and returns the number of found extents. | |
MLDICOM_TO_ML_TOOLS_EXPORT bool | applyPaletteInfosToPagedImage (const DICOMTagTools::DicomPaletteInfo &paletteInfos, PagedImage &pagedImage, const bool adjustToLUTType=false) |
If possible then this function modifies pagedImage according to the settings paletteInfos. | |
MLDICOM_TO_ML_TOOLS_EXPORT bool | applySubImageColorLookUp (const SubImage &inSubImg, const DICOMTagTools::DicomPaletteInfo &paletteInfo, SubImage &outSubImg) |
Applies an intensity to color look up from valid region of inSubImg and paletteInfo to outSubImg. | |
MLDICOM_TO_ML_TOOLS_EXPORT bool | applyPhotometricInterpretationChangesToPagedImage (const DCMTree::Const_TreePtr &dcmTree, PagedImage &pagedImage) |
If possible then this function modifies pagedImage according to the photometric interpretation such that pixel values can be translated correctly. | |
MLDICOM_TO_ML_TOOLS_EXPORT bool | applyPhotometricInterpretationToSubImg (DCMTree::Const_TreePtr dcmTree, const SubImage &inSubImg, const double minVoxelValue, const double maxVoxelValue, SubImage &outSubImg) |
Applies a color format conversion from input subimage to output subimage according to the photometric interpretation tag in dcmTree. | |
MLDICOM_TO_ML_TOOLS_EXPORT void | getSpectDICOMImageProperties (DCMTree::Const_TreePtr treePtr, const std::string &fileNameUTF8, PagedImage &outInfos, Vector4 &rotAxisAndRadians, Vector3 &ipp, Vector3 &relMRSPositionVector, Vector3 &mrsPositionVector, Vector3 &voiVector, Vector3 &fovVector, bool useOldWorldMatrixCalculation, DicomMessageCollector &dcmMsgCollector) |
Extract spectroscopy image properties and some other infos from the passed DICOM tree. | |
MLDICOM_TO_ML_TOOLS_EXPORT bool | copySpectData (SubImage &outSubImg, const ImageVector &outImgExtent, const DICOMTagTools::SpectComplex *mrsData, size_t spectDataSizeInBytes) |
Copies the complex spectroscopy data from mrsData to the output subimage assuming appropriate sizes of mrsData which must have been calculated successfully with getSpectDICOMImageProperties and which must match the PagedImage properties calculated in the same routine. | |
MLDICOM_TO_ML_TOOLS_EXPORT bool | isImageFrameNotOfBits (DCMTree::Const_TreePtr treePtr) |
Returns true if the DICOM tree seems to describe a sensible image with column and row extents > 1 as well as pixels with more than one bit per pixel, otherwise false. | |
MLDICOM_TO_ML_TOOLS_EXPORT void | setWorldMatrixFromDcmTree (DCMTree::Const_TreePtr treePtr, PagedImage &outInfos, DicomMessageCollector &dcmMsgCollector) |
If possible all image properties from the DcmTree needed to set up the world matrix are searched and converted to a world matrix and voxel size and set in outInfos. | |
MLDICOM_TO_ML_TOOLS_EXPORT MLDataType | getMLDataTypeFromDCMTree (DCMTree::Const_TreePtr treePtr, DicomMessageCollector &dcmMsgCollector) |
Determines the ML data type of pixel data in the given DICOM tree treePtr. | |
MLDICOM_TO_ML_TOOLS_EXPORT void | checkAndCorrectImageExtentAccordingToPixelData (DCMTree::Const_TreePtr treePtr, size_t pixelDataSizeInBytes, ImageVector &imgExt, DicomMessageCollector &dcmMsgCollector) |
Check especially whether the extent of the image given in imgExt is larger by a multiple than the pixel data where the multiple is the same as imgExt.z, imgExt.t or imgExt.z*imgExt.t. | |
MLDICOM_TO_ML_TOOLS_EXPORT bool | determineImageExtentsFromDCMTree (DCMTree::Const_TreePtr treePtr, ImageVector &imgExt, std::vector< std::string > *cDimInfos, bool overrideBadTagInfos, DicomMessageCollector &dcmMsgCollector) |
Update imgExt and - if non nullptr - cDimInfos from treePtr if possible, otherwise they are left unchanged. | |
MLDICOM_TO_ML_TOOLS_EXPORT void | getAnyDICOMImageProperties (DCMTree::Const_TreePtr treePtr, PagedImage &outInfos, bool overrideBadTagInfos, DicomMessageCollector &dcmMsgCollector) |
Extract as many PagedImage properties from the passed DICOM treePtr as possible. | |
MLDICOM_TO_ML_TOOLS_EXPORT std::string | determineBasicREGProperties (DCMTree::Const_TreePtr treePtr, size_t extent[3], double voxelSize[3], MLErrorCode &errCode, DicomMessageCollector &dcmMsgCollector) |
Extract basic image properties from a DICOM tree of REG modality and SOP Class UID "1.2.840.10008.5.1.4.1.1.66.3" (Deformable Registration Storage). | |
MLDICOM_TO_ML_TOOLS_EXPORT std::string | determineREGProperties (DCMTree::Const_TreePtr treePtr, ImageVector &extent, Vector3 &voxelSize, SubImage *subImage, MLErrorCode *errCode, DicomMessageCollector &dcmMsgCollector) |
Extract image properties and deformable vector field from a DICOM tree of REG modality and SOP Class UID "1.2.840.10008.5.1.4.1.1.66.3" (Deformable Registration Storage) Spatial registration storage with SOP Class UID "1.2.840.10008.5.1.4.1.1.66.1" will result to empty return string, ML_RESULT_OK (if errCode is provided), (0,...,0) extent, voxel size (1,1,1), subImage with empty box, nullptr data, and MLuint8Type. | |
MLDICOM_TO_ML_TOOLS_EXPORT bool | hasValidNonImageModality (DCMTree::Const_TreePtr treePtr) |
Returns true only if the passed string is a known, non-empty and valid modality string which is a non image modality (RTSTRUCT, RTPLAN, RTRECORD, AU, SR, HD, ECG, FID...) and the DCMTree is not a Secondary Capture IOD. | |
MLDICOM_TO_ML_TOOLS_EXPORT MLDataType | determineOutputVoxelType (DCMTree::StructuredMFPtr &srcVolumeSMFTree, const MLDataType inVoxDataType, const SubImageBox &volumeBox, const double inDataRangeMin, const double inDataRangeMax, const OutputDataTypeSelector voxelTypeSelector, const VoxelDoubleOperations operationMode, const PositionSpecificDoubleVector &posDbls, const VoxelDoubleOperations defaultOperationMode, const double defaultOperationDouble, double &resultRangeMin, double &resultRangeMax) |
Determines a voxel type for an ML output image from some properties of an input image and a set of double values applied to different slices of the input image. | |
MLDICOM_TO_ML_TOOLS_EXPORT void | determineDCMTreeInfo (DCMTree::Const_TreePtr dcmTree, DCMTreeInfo &dcmTreeInfo) |
Stores some statistical information from dcmTree in dcmTreeInfo. | |
MLDICOM_TO_ML_TOOLS_EXPORT DCMTree::Const_StructuredMFPtr | getSMFTreeFromPagedImage (const PagedImage &pImg) |
Tries to get the first DICOM image property extension and returns its DCMTree wrapped as Structured MF Tree if possible; otherwise nullptr is returned. | |
MLDICOM_TO_ML_TOOLS_EXPORT void | setUpMinMaxVoxelValues (std::string &errStr, DCMTree::Const_DictPtr dcmTreeDictPtr, double smallestPixelValue, double largestPixelValue, DCMTree::TreePtr dcmTree) |
Set up DCMTree_SmallestImagePixelValue and DCMTree_LargestImagePixelValue tags in dcmTree; requires that DCMTree_PixelRepresentation, DCMTree_SmallestImagePixelValue, or DCMTree_LargestImagePixelValue tags exist from which the value representation of the DCMTree_SmallestImagePixelValue and DCMTree_LargestImagePixelValue can be determined. | |
MLDICOM_TO_ML_TOOLS_EXPORT bool | guessMinMaxRangeFromDICOMTags (DCMTree::Const_TreePtr treePtr, MLdouble &minPixVal, MLdouble &maxPixVal, DicomMessageCollector &dcmMsgCollector) |
Try to guess a min/max range from DICOM tags for the case that they cannot be determined in another way. | |
MLDICOM_TO_ML_TOOLS_EXPORT void | calcImageDataMinMaxFromTag (DCMTree::Const_TreePtr &treePtr, MLint64 &minValInt64, MLint64 &maxValInt64, MLdouble &minValDbl, MLdouble &maxValDbl, DicomMessageCollector &dcmMsgCollector) |
Traverse all pixel values in the first found pixel data tag in the tree given by treePtr and returns their minimum and maximum values in minValDbl and maxValDbl as well as in minValInt64 and maxValint64. | |
MLDICOM_TO_ML_TOOLS_EXPORT void | determineMinMaxValues (DCMTree::Const_TreePtr treePtr, PagedImage &pagedImg) |
Update min/max voxel values of pagedImg from tags in treePtr if possible, otherwise these settings are left unchanged. | |
MLMULTI_FILE_VOLUME_EXPORT DCMTree::Const_TreePtr | getInputDCMTree (Module &moduleWithInFields, const std::string &inputSourceName, const std::string &fileName, Base *basePtr, const MLint volIdx, size_t *numVolumes, bool allowEmptyFileNames, DicomMessageCollector &dcmMsgCollector) |
Gets a DCMTree from an input which is selected via a string name. | |
MLMULTI_FILE_VOLUME_EXPORT void | getDCMTreeFromAnyFileType (const std::string &fileName, bool postError, DCMTree::Const_TreePtr &treePtr, size_t &numVols, DicomMessageCollector &dcmMsgCollector) |
Loads a Const_TreePtr from a file given by the absolute file path fileName if possible (currently .dcm and .mlimage files are supported); this function implements a subfunctionality of getInputDCMTree() and needs no Base or Module. | |
Variables | |
MLDICOM_TO_ML_TOOLS_EXPORT const char *const | VoxelDoubleOperationsStrings [NumberOfVoxelDoubleOperations] |
Strings according to VoxelDoubleOperations. | |
MLDICOM_TO_ML_TOOLS_EXPORT const char *const | OutputDataTypeSelectorsStrings [NumOutputDataTypeSelectors] |
Strings according to OutputDataTypeSelector. | |
MLDICOM_TO_ML_TOOLS_EXPORT const char *const | CalculateMinMaxFromDicomModesEnumStrings [NUM__CALC_MIN_MAX_FROM_DICOM_ENUMS] |
Strings names corresponding to the selectable DplMinMaxEnums. | |
Tool functions for the extraction and handling of information of specific DICOM frames.
A collection of DICOM tool functions.
Tool functions for the extraction and handling of information of specific single DICOM frames.
Tool function namespace with many tool functions for the conversion of DICOM information and tag values to comparable ML information objects.
typedef std::vector< FrameSpecificTags > ml::DicomToMLTools::FrameSpecificTagsVector |
Often used std::vector type of FrameSpecificTag elements.
Definition at line 67 of file mlDicomFrameSelectionTools.h.
Often used std::vector type of PositionSpecificDouble elements.
Definition at line 89 of file mlDicomFrameSelectionTools.h.
Number of available VoxelDoubleOperations.
Enumerator | |
---|---|
NumberOfVoxelDoubleOperations |
Definition at line 38 of file mlDicomFrameSelectionTools.h.
Number of available OutputDataTypeSelectors modes.
Enumerator | |
---|---|
NumOutputDataTypeSelectors |
Definition at line 458 of file mlDicomToMLTools.h.
Available selectable DPL configurations.
Definition at line 34 of file mlDicomTreeMinMaxTools.h.
Methods how to fill a page with data from the DICOM file or tree.
Definition at line 48 of file mlDicomToMLTools.h.
Specifies whether the output voxel type shall be adopted when the data is scaled.
Definition at line 444 of file mlDicomToMLTools.h.
Defines some modes how a (voxel) value can be manipulated with a double value.
Definition at line 31 of file mlDicomFrameSelectionTools.h.
MLDICOM_TO_ML_TOOLS_EXPORT bool ml::DicomToMLTools::applyFrameSpecificOperation | ( | const VoxelDoubleOperations & | operationMode, |
const SubImage & | srcSubImage, | ||
SubImage & | dstSubImage, | ||
const PositionSpecificDoubleVector & | positionDoubles, | ||
const VoxelDoubleOperations | dummyOperationMode = Copy, | ||
const MLdouble | dummyOperationValue = 0.0, | ||
PositionSpecificDoubleVector * | valueFreePositions = nullptr, | ||
bool | isOldMultiFrameDICOM = false ) |
Copy voxels from overlapping regions of srcSubImage to dstSubImage and apply
the operationMode if for the z, t, u position of the slice an entry can be found in positionDoubles whose double value can be used for modification.
The double operation is performed regardless of the voxel data type and whether it can store the result precision or not. If no such entry is found and the isOldMultiFrameDICOM mode is not executed as explained below then the dummyOperationMode and value are used.
operationMode | The operation to be applied as transfer operation from srcSubImage voxels to dstSubImage voxels on slices where an entry in positionDoubles could be found. |
srcSubImage | The source of the voxels to be processed and written into dstSubImage. |
dstSubImage | The target for the voxels to be read from dstSubImage and then processed. |
positionDoubles | A set of double values associated to frame positions in z,t, and u. |
dummyOperationMode | The operation to be applied as transfer operation from srcSubImage voxels to dstSubImage voxels on slices for which no entry in positionDoubles could be found. |
dummyOperationValue | The double to be used as value in conjunction with dummOperationMode. |
valueFreePositions | If non nullptr: An array of z, t, and u positions for which no entries in doublePositions exist and for which the copy operation was performed. Ignored if nullptr. |
isOldMultiFrameDICOM | In the case of old multi-frame files we have only one pixel buffer with multiple slices (appears e.g. in RTDose or US images). In these cases we typically also have only one positionDoubles at (0,0,0) which must be applied to the entire image. Will be ignored if positionDoubles contains more than one entry or the first entry is not of position 0,0,0. |
References applyFrameSpecificOperation().
Referenced by applyFrameSpecificOperation().
MLDICOM_TO_ML_TOOLS_EXPORT bool ml::DicomToMLTools::applyPaletteInfosToPagedImage | ( | const DICOMTagTools::DicomPaletteInfo & | paletteInfos, |
PagedImage & | pagedImage, | ||
const bool | adjustToLUTType = false ) |
If possible then this function modifies pagedImage according to the settings paletteInfos.
paletteInfos | The palette information is considered valid if paletteInfos.dataType is MLuint8Type or MLuint16Type. |
pagedImage | The PagedImage to be adopted according to the settings in paletteInfos if possible. Input extent in c dimension must be 1. Changed are CDimensionInfos, ImageExtent, and PageExtent. |
adjustToLUTType | If false, usually the function updates the dataType of PagedImage only if needed but usually remains in the incoming data type; if true, the data type of the palette is used instead to maximize the quality of the color. |
References applyPaletteInfosToPagedImage().
Referenced by applyPaletteInfosToPagedImage().
MLDICOM_TO_ML_TOOLS_EXPORT bool ml::DicomToMLTools::applyPhotometricInterpretationChangesToPagedImage | ( | const DCMTree::Const_TreePtr & | dcmTree, |
PagedImage & | pagedImage ) |
If possible then this function modifies pagedImage according to the photometric interpretation such that pixel values can be translated correctly.
This function should be used together with applyPhotometricInterpretationToSubImg. Currently only MONOCHROME1 and YBR_FULL conversions to RGB are implemented. Do not use this function for PALETTE COLOR conversion; see determinePaletteInformation, applyPaletteInfosToPagedImage, and applySubImageColorLookUp for that purpose.
dcmTree | The palette information is considered valid if paletteInfos.dataType is MLuint8Type or MLuint16Type. |
pagedImage | The PagedImage to be adopted according to the DICOM tag "Photometric Interpretation" if possible. Input extent in c dimension must be 1 for MONOCHROME1 and 3 for YBR_FULL. Changes CDimensionInfos, ImageExtent, and PageExtent. For YBR_FULL the voxel data type must be MLuint8Type and a one or two byte type for MONOCHROME1. |
References applyPhotometricInterpretationChangesToPagedImage().
Referenced by applyPhotometricInterpretationChangesToPagedImage().
MLDICOM_TO_ML_TOOLS_EXPORT bool ml::DicomToMLTools::applyPhotometricInterpretationToSubImg | ( | DCMTree::Const_TreePtr | dcmTree, |
const SubImage & | inSubImg, | ||
const double | minVoxelValue, | ||
const double | maxVoxelValue, | ||
SubImage & | outSubImg ) |
Applies a color format conversion from input subimage to output subimage according to the photometric interpretation tag in dcmTree.
This function shall be used in conjunction with applyPhotometricInterpretationChangesToPagedImage which should be used to set up the image configuration of the subimages. Currently only MONOCHROME1 and YBR_FULL conversions to RGB are implemented. Do not use this function for PALETTE COLOR conversion; see determinePaletteInformation, applyPaletteInfosToPagedImage, and applySubImageColorLookUp for that purpose.
dcmTree | The DICOM tree from which the information about the color format conversion is retrieved. |
inSubImg | The input subimage whose voxels must be of MLuint8Type, MLint8Type, MLuint16Type, or MLint16Type for MONOCHROME1 MLuint8Type for YBR_FULL. Must have same extent in x,y,z,t, and u dimension like outSubImg, and c-extent must be 1 for MONOCHROME1 and 3 for YBR_FULL conversion. |
minVoxelValue | The minimum voxel value of the input image; lower voxel values will be clamped against it. |
maxVoxelValue | The maximum voxel value of the input image; larger voxel values will be clamped against it. |
outSubImg | The output subimage to be filled with the converted color information from inSubImg. Must have same extent in x, y, z, t, and u dimension like inSubImg, and c must be 1 for MONOCHROME1 and 3 for YBR_FULL conversion. Voxel type must be the same as in inSubImg. |
References applyPhotometricInterpretationToSubImg().
Referenced by applyPhotometricInterpretationToSubImg().
MLDICOM_TO_ML_TOOLS_EXPORT bool ml::DicomToMLTools::applySubImageColorLookUp | ( | const SubImage & | inSubImg, |
const DICOMTagTools::DicomPaletteInfo & | paletteInfo, | ||
SubImage & | outSubImg ) |
Applies an intensity to color look up from valid region of inSubImg and paletteInfo to outSubImg.
inSubImg | The input subimage whose voxels must be of MLuint8Type, MLint8Type, MLuint16Type, or MLint16Type. Must have same extent in x,y,z,t, and u dimension like outSubImg, and c-extent must be 1. |
paletteInfo | Translation information from intensity values to color values; it is considered valid if dataType is MLuint8Type or MLint8Type and numEntries are > 0. |
outSubImg | The output subimage to be filled with color information looked up from inSubImag via paletteInfo. Must have same extent in x, y, z, t, and u dimension like inSubImg, and c must be 3. |
References applySubImageColorLookUp().
Referenced by applySubImageColorLookUp().
MLDICOM_TO_ML_TOOLS_EXPORT void ml::DicomToMLTools::calcImageDataMinMaxFromTag | ( | DCMTree::Const_TreePtr & | treePtr, |
MLint64 & | minValInt64, | ||
MLint64 & | maxValInt64, | ||
MLdouble & | minValDbl, | ||
MLdouble & | maxValDbl, | ||
DicomMessageCollector & | dcmMsgCollector ) |
Traverse all pixel values in the first found pixel data tag in the tree given by treePtr and returns their minimum and maximum values in minValDbl and maxValDbl as well as in minValInt64 and maxValint64.
In case of complex spectroscopy data the data is scanned after decomposing the complex values as twice as many float data. If
treePtr | The DICOM tree whose min/max values shall be determined. |
minValInt64 | Found minimum value cast to MLint64. |
maxValInt64 | Found maximum value cast to MLint64. |
minValDbl | Found minimum value cast to MLdouble. |
maxValDbl | Found maximum value cast to MLdouble. |
dcmMsgCollector | Collects error, info and issue messages (typically related to a handle). |
References calcImageDataMinMaxFromTag().
Referenced by calcImageDataMinMaxFromTag().
MLDICOM_TO_ML_TOOLS_EXPORT void ml::DicomToMLTools::checkAndCorrectImageExtentAccordingToPixelData | ( | DCMTree::Const_TreePtr | treePtr, |
size_t | pixelDataSizeInBytes, | ||
ImageVector & | imgExt, | ||
DicomMessageCollector & | dcmMsgCollector ) |
Check especially whether the extent of the image given in imgExt is larger by a multiple than the pixel data where the multiple is the same as imgExt.z, imgExt.t or imgExt.z*imgExt.t.
This sometimes happens on frame data exported from multi-frame as single frames where for example NumberOfSlices or NumberOfFrame tags are not correct reset/removed in the written single frame data. This routine can do these correction only if the pixel data tag stores its data in-memory and if it is still inside of the treePtr.
treePtr | The DICOM tree from which the image extent was calculated. |
imgExt | The extent of the image determined from treePtr and which |
pixelDataSizeInBytes | The give number of bytes pixel data used as the true size to compare against the other parameters. shall be checked for inconsistencies and/or corrected. |
dcmMsgCollector | Collects error, info and issue messages (typically related to a handle). |
References checkAndCorrectImageExtentAccordingToPixelData().
Referenced by checkAndCorrectImageExtentAccordingToPixelData().
MLDICOM_TO_ML_TOOLS_EXPORT MLErrorCode ml::DicomToMLTools::convertDCMTreeToSubImage | ( | const DICOMCachedIOFileHandle & | dcmFrameHandle, |
DCMTree::Const_TreePtr | alternativeDCMTree, | ||
SubImage & | subImage, | ||
DicomMessageCollector & | dcmMsgCollector ) |
Reads the DICOM file given by dcmFrameHandle via the MLDICOMCachedIOTreeCache (or uses alternativeDCMTree if dcmFrameHandle is empty), and updates subImage to its data content.
This is intended and works only for 2D DICOM frames which can be copied with DicomToMLTools::copyFromDcmFileToSubImg and whose image properties are detected correctly with DicomToMLTools::getAnyDICOMImageProperties.
dcmFrameHandle | File handle to the DICOM frame to be converted. |
alternativeDCMTree | If dcmFileHandle is empty then this tree is used as source to copy from instead. Ignored if dcmFileHandle is not empty. |
subImage | Filled with the data from subImage or reset to an empty SubImage. The subimage owns the data allocated in the memory manager and will be destroyed automatically with subImage. |
dcmMsgCollector | Collects error, info and issue messages (typically related to a handle). |
References convertDCMTreeToSubImage().
Referenced by convertDCMTreeToSubImage().
MLDICOM_TO_ML_TOOLS_EXPORT size_t ml::DicomToMLTools::convertToFrameSpecificDoubles | ( | const FrameSpecificTagsVector & | frameSpecificTags, |
PositionSpecificDoubleVector & | frameSpecificDoubles ) |
Converts first entries of each entries in FrameSpecificTagsVector to a PositionSpecificDoubleVector object.
The value of the first valid tag of each entry of frameSpecifcTags is converted to an entry of frameSpecificDoubles and its value is convertible to double, otherwise the corresponding entry in frameSpecifcDoubles is not created at all.
frameSpecificTags | The frame specific tag sets from which the first entries are converted to frameSpecificDoubles. |
frameSpecificDoubles | The container for converted entries from frameSpecificTags. |
References convertToFrameSpecificDoubles().
Referenced by convertToFrameSpecificDoubles().
MLDICOM_TO_ML_TOOLS_EXPORT void ml::DicomToMLTools::convertToImageProperties | ( | DCMTree::StructuredMFPtr & | baseSMFPtr, |
const std::string & | firstFileName, | ||
PagedImage & | resultImgProps, | ||
FillPageMethods * | fillPageMethod, | ||
const ZTUFileNameSet * | setOfFileHandles, | ||
double | defaultFillValue, | ||
CalculateMinMaxFromDicomModes | minMaxCalcMode, | ||
const std::string & | versionString, | ||
bool | anonymize, | ||
bool | removePrivateMultiFrameSQTag, | ||
bool | forceOrthogonalWorldMatrix, | ||
bool | copyPrivateTopLevelSrcTags, | ||
DicomMessageCollector & | dcmMsgCollector ) |
Determines as much PagedImage information from baseSMFPtr as possible and.
baseSMFPtr | The structured MF tree to be generated/composed and appended to resultImgProps as DICOMTreeImagePropertyExtension. |
firstFileName | The name of the file to be used as the source file the DICOM image properties come from. If multiple file names are available then that one corresponding to the first DICOM frame should be taken. |
resultImgProps | The properties to be set up with properties determined from from baseSMFPtr. |
fillPageMethod | If nullptr (the default) it is ignored, otherwise it returns the way how data from the files in the pageFileNames should be copied to ML pages. |
setOfFileHandles | If it is non nullptr then it is used to create a new structured multi-frame tree in baseSMFPtr. If nullptr is passed (the default) then all following arguments are not used and ignored. |
defaultFillValue | Fill value for image regions which cannot be read from DICOM. |
minMaxCalcMode | The way how min/max value are to be determined from DICOM tags, see CalculateMinMaxFromDicomModes for details. |
versionString | String to be added to the DICOM as private description about the used importer version. |
anonymize | If true then the created patientIdName and birth date will be anonymized. WARNING: This is only a partial and incomplete anonymization of the DICOM information. For a reliable anonymization other approaches are needed. |
removePrivateMultiFrameSQTag | If true then a private MeVis sequence tag with DICOM frame information will be removed (if it exists) before adding the tree to image properties, otherwise the tag is left unchanged. |
forceOrthogonalWorldMatrix | If enabled then the world matrix is always determined from the first ImageOrientationPatient of the first frame in frame set. use with care because gantry tilted data will be imported with incorrect world matrices then. |
copyPrivateTopLevelSrcTags | If true then private top level tags from source frames are copied to the baseSMFPtr, otherwise they are removed. |
dcmMsgCollector | Collects error, info and issue messages (typically related to a handle). |
References convertToImageProperties().
Referenced by convertToImageProperties().
MLDICOM_TO_ML_TOOLS_EXPORT MLErrorCode ml::DicomToMLTools::copyFromDCMTreeToSubImg | ( | const DICOMCachedIOFileHandle & | dcmFileHandle, |
DCMTree::Const_TreePtr | alternativeDCMTree, | ||
SubImage & | outSubImg, | ||
bool | force, | ||
DicomMessageCollector & | dcmMsgCollector ) |
Tries to fill the given output subimage outSubImg with pixel data from the DICOM tree given by either dcmFileHandle or alternativeDCMTree.
dcmFileHandle | If non empty then this handle is used as source to load the DICOM tree via the DICOM tree cache. |
alternativeDCMTree | If dcmFileHandle is empty then this tree is used as source to copy from instead. Ignored if dcmFileHandle is not empty. |
outSubImg | The data from the DIOCM tree will be copied into this SubImage. |
force | If true then images are also loaded with limited support, e.g. for unsupported color formats or so. They will be loaded incorrectly, however, they will be loaded if possible. |
dcmMsgCollector | Collects error, info and issue messages (typically related to a handle). |
References copyFromDCMTreeToSubImg().
Referenced by copyFromDCMTreeToSubImg().
MLDICOM_TO_ML_TOOLS_EXPORT bool ml::DicomToMLTools::copySpectData | ( | SubImage & | outSubImg, |
const ImageVector & | outImgExtent, | ||
const DICOMTagTools::SpectComplex * | mrsData, | ||
size_t | spectDataSizeInBytes ) |
Copies the complex spectroscopy data from mrsData to the output subimage assuming appropriate sizes of mrsData which must have been calculated successfully with getSpectDICOMImageProperties and which must match the PagedImage properties calculated in the same routine.
The call is ignored if mrsData is nullptr. If any voxel access was out of range then false is returned, otherwise true.
References copySpectData().
Referenced by copySpectData().
MLDICOM_TO_ML_TOOLS_EXPORT std::string ml::DicomToMLTools::createOverlayBitSubImages | ( | const FrameSpecificTagsVector & | tagSet, |
MLint | z, | ||
MLint | t, | ||
MLint | u, | ||
std::vector< BitImage > & | bitImages ) |
Create and return a BitImage in bitSubImages for each overlay for which all required type 1 tags are found in the first z,t,u frame occurrence.
All type 1 DICOM tags must be consistent according to the DICOM standard or the returned BitImage entries will be valid but empty. The OverlayOrigin tag is evaluated and transformed into ML voxel image coordinates such that the sourceBox member in each BitImage returns the subimage box of the overlay in directly usable voxel image space.
tagSet | All overlay tags for all frames in the z,t,u-space. |
z | z-position of the frame for which the BitImages shall be extracted. |
t | t-position of the frame for which the BitImages shall be extracted. |
u | u-position of the frame for which the BitImages shall be extracted. |
bitImages | A vector of BitImages which are set according to the overlays defined in the found overlay tags. |
References createOverlayBitSubImages().
Referenced by createOverlayBitSubImages().
MLDICOM_TO_ML_TOOLS_EXPORT std::string ml::DicomToMLTools::determineBasicREGProperties | ( | DCMTree::Const_TreePtr | treePtr, |
size_t | extent[3], | ||
double | voxelSize[3], | ||
MLErrorCode & | errCode, | ||
DicomMessageCollector & | dcmMsgCollector ) |
Extract basic image properties from a DICOM tree of REG modality and SOP Class UID "1.2.840.10008.5.1.4.1.1.66.3" (Deformable Registration Storage).
Spatial registration storage with SOP Class UID "1.2.840.10008.5.1.4.1.1.66.1" will result to empty return string, errCode = ML_RESULT_OK, (0,...,0) extent, and voxel size (1,1,1).
treePtr | The DICOM tree from which the properties shall be extracted. |
extent | The extent of the extracted grid from the tag (0064,0007) UL [GridDimensions] or (0,0,0) if not valid. |
voxelSize | Will be set with the value from the tag (0064,0008) FD [GridResolution] to be used as voxel size or (1,1,1) if not valid. |
errCode | An ML error code corresponding to the returned string is returned, ML_RESULT_OK on success. |
dcmMsgCollector | Collects error, info and issue messages (typically related to a handle). |
References determineBasicREGProperties().
Referenced by determineBasicREGProperties().
MLDICOM_TO_ML_TOOLS_EXPORT void ml::DicomToMLTools::determineDCMTreeInfo | ( | DCMTree::Const_TreePtr | dcmTree, |
DCMTreeInfo & | dcmTreeInfo ) |
Stores some statistical information from dcmTree in dcmTreeInfo.
References determineDCMTreeInfo().
Referenced by determineDCMTreeInfo().
MLDICOM_TO_ML_TOOLS_EXPORT bool ml::DicomToMLTools::determineImageExtentsFromDCMTree | ( | DCMTree::Const_TreePtr | treePtr, |
ImageVector & | imgExt, | ||
std::vector< std::string > * | cDimInfos, | ||
bool | overrideBadTagInfos, | ||
DicomMessageCollector & | dcmMsgCollector ) |
Update imgExt and - if non nullptr - cDimInfos from treePtr if possible, otherwise they are left unchanged.
Does not throw DCMTree::Exceptions.
treePtr | DCMTree in which the tags are searched and whose content is analyzed for image extent and color channel infos. |
imgExt | Image extent modified if appropriate information is found in treePtr. |
cDimInfos | Descriptive color channel information for PagedImage.cDimInfo to which ML constants like ML_RED, ML_HUE, ML_LUMINANCE etc. are appended if appropriate information is found in treePtr. Ignored if nullptr. |
overrideBadTagInfos | If true then inconsistencies found in the tagTree will corrected and errorInfos will be added if necessary; if false then the already known settings from imgExt will be considered with priority and won't be overwritten by heuristics correcting bad DICOM tags. |
dcmMsgCollector | Collects error, info and issue messages (typically related to a handle). |
References determineImageExtentsFromDCMTree().
Referenced by determineImageExtentsFromDCMTree().
MLDICOM_TO_ML_TOOLS_EXPORT void ml::DicomToMLTools::determineMinMaxValues | ( | DCMTree::Const_TreePtr | treePtr, |
PagedImage & | pagedImg ) |
Update min/max voxel values of pagedImg from tags in treePtr if possible, otherwise these settings are left unchanged.
Does not throw DCMTree::Exceptions.
treePtr | DCMTree in which the tags are searched and whose content is analyzed for color channel infos. |
pagedImg | The PagedImage whose min/max voxel values are updated if possible. |
References determineMinMaxValues().
Referenced by determineMinMaxValues().
MLDICOM_TO_ML_TOOLS_EXPORT MLDataType ml::DicomToMLTools::determineOutputVoxelType | ( | DCMTree::StructuredMFPtr & | srcVolumeSMFTree, |
const MLDataType | inVoxDataType, | ||
const SubImageBox & | volumeBox, | ||
const double | inDataRangeMin, | ||
const double | inDataRangeMax, | ||
const OutputDataTypeSelector | voxelTypeSelector, | ||
const VoxelDoubleOperations | operationMode, | ||
const PositionSpecificDoubleVector & | posDbls, | ||
const VoxelDoubleOperations | defaultOperationMode, | ||
const double | defaultOperationDouble, | ||
double & | resultRangeMin, | ||
double & | resultRangeMax ) |
Determines a voxel type for an ML output image from some properties of an input image and a set of double values applied to different slices of the input image.
srcVolumeSMFTree | The Structured multi-frame tree related to the input image. |
inVoxDataType | The voxel data type of the input image. |
volumeBox | The SubImageBox covering the extents of the input image. |
inDataRangeMin | The minimum voxel values of the input volume. |
inDataRangeMax | The maximum voxel values of the input volume. |
voxelTypeSelector | Selects the calculation mode for the output voxel type, see OutputDataTypeSelector for details. |
operationMode | The mode how double values of the output image are calculated from double values from posDbls and input image voxels. See VoxelDoubleOperations for details. |
posDbls | A vector of positions specifying slices of the input volume together with double values to be applied to those slices with operationMode. |
defaultOperationMode | The calculation which is applied to slices of the the volume where no corresponding entry in posDbls exist. |
defaultOperationDouble | The double value to be used to process volume slices for which no corresponding entry in posDbls exist. |
resultRangeMin | The minimum of the voxel value range for the output image which has been determined from the given parameters. Will be set to inDataRangeMin on error or if return type is ML_INVALID_DATA_TYPE. |
resultRangeMax | The maximum of the voxel value range for the output image which has been determined from the given parameters. Will be set to inDataRangeMax on error or if return type is ML_INVALID_DATA_TYPE. |
References determineOutputVoxelType().
Referenced by determineOutputVoxelType().
MLDICOM_TO_ML_TOOLS_EXPORT std::string ml::DicomToMLTools::determineREGProperties | ( | DCMTree::Const_TreePtr | treePtr, |
ImageVector & | extent, | ||
Vector3 & | voxelSize, | ||
SubImage * | subImage, | ||
MLErrorCode * | errCode, | ||
DicomMessageCollector & | dcmMsgCollector ) |
Extract image properties and deformable vector field from a DICOM tree of REG modality and SOP Class UID "1.2.840.10008.5.1.4.1.1.66.3" (Deformable Registration Storage) Spatial registration storage with SOP Class UID "1.2.840.10008.5.1.4.1.1.66.1" will result to empty return string, ML_RESULT_OK (if errCode is provided), (0,...,0) extent, voxel size (1,1,1), subImage with empty box, nullptr data, and MLuint8Type.
treePtr | The DICOM tree from which the properties shall be extracted. |
extent | The extent of the extracted grid from the tag (0064,0007) UL [GridDimensions] or (0,0,0,0,0,0) if not valid. |
voxelSize | Will be set with the value from the tag (0064,0008) FD [GridResolution] to be used as voxel size or (1,1,1) if not valid. |
subImage | If passed non nullptr then the subImage content will be freed its box.v1 will be set to (0,0,0,0,0,0), box.v2 to extent-Vector(1) and its data will be allocated and filled with a copy of the the VectorGridData from the tag (0064,0009) OF [VectorGridData]. The voxel type will be of Vector3f. On any failure the subImage box will be set empty, the data type to MLuint8Type, and the data to nullptr. |
errCode | If non nullptr an ML error code corresponding to the returned string is returned. If nullptr then it will be ignored. |
dcmMsgCollector | Collects error, info and issue messages (typically related to a handle). |
References determineREGProperties().
Referenced by determineREGProperties().
MLDICOM_TO_ML_TOOLS_EXPORT void ml::DicomToMLTools::getAnyDICOMImageProperties | ( | DCMTree::Const_TreePtr | treePtr, |
PagedImage & | outInfos, | ||
bool | overrideBadTagInfos, | ||
DicomMessageCollector & | dcmMsgCollector ) |
Extract as many PagedImage properties from the passed DICOM treePtr as possible.
Note that this function does not set or handle the DICOM tree or other image property extensions. If no useful properties can be found or the treePtr is invalid then properties are set invalid. Note that this function overwrites only found properties. Therefore image and page extents should be initialized with at least ImageVector(1) before calling this function.
treePtr | The DICOM tree from which the outInfos settings are derived. |
outInfos | The destination for the image information derived from treePtr tags. |
overrideBadTagInfos | If true then inconsistencies found in the tagTree will corrected and errorInfos will be added if necessary; if false then the already known settings from outInfos will be considered with priority and won't be overwritten by heuristics correcting bad DICOM tags. |
dcmMsgCollector | Collects error, info and issue messages (typically related to a handle). |
References getAnyDICOMImageProperties().
Referenced by getAnyDICOMImageProperties().
MLMULTI_FILE_VOLUME_EXPORT void ml::DicomToMLTools::getDCMTreeFromAnyFileType | ( | const std::string & | fileName, |
bool | postError, | ||
DCMTree::Const_TreePtr & | treePtr, | ||
size_t & | numVols, | ||
DicomMessageCollector & | dcmMsgCollector ) |
Loads a Const_TreePtr from a file given by the absolute file path fileName if possible (currently .dcm and .mlimage files are supported); this function implements a subfunctionality of getInputDCMTree() and needs no Base or Module.
fileName | The absolute file name path to the file from which the DCMTree shall be loaded. |
postError | If true then an error will be appended to dcmMsgCollector on any file IO error or if no DICOM tree could be found in any file, otherwise errors will silently be ignored. |
treePtr | Returns the loaded DCMTree on success, or nullptr on failure; if file can be loaded successfully but does not contain a DCMTree then no messages may be generated/logged/posted but treePtr may be returned as nullptr. |
numVols | Will return 1 on successful DCMTree load, otherwise 0. |
dcmMsgCollector | Collects error, info and issue messages (typically related to a handle). |
References getDCMTreeFromAnyFileType().
Referenced by getDCMTreeFromAnyFileType().
|
inline |
Retrieves a double tag value from a frame specific tag with id rawTagId at (z,t,u) from smfTree, and returns all result information in valTagInfos; if the value cannot be retrieved from the given frame then it is tried to get it from the tree root.
Definition at line 238 of file mlDicomSingleFrameSelectionTools.h.
References getFrameSpecificDoubleTag(), and mlrange_cast().
Referenced by getFrameSpecificDoubleTag().
|
inline |
Same as getFrameSpecificDoubleTag() but for std::string values.
Definition at line 248 of file mlDicomSingleFrameSelectionTools.h.
References getFrameSpecificStringTag(), and mlrange_cast().
Referenced by getFrameSpecificStringTag().
MLDICOM_TO_ML_TOOLS_EXPORT FrameSpecificTagsVector ml::DicomToMLTools::getFrameSpecificTags | ( | const DCMTree::Const_StructuredMFPtr & | smfTree, |
DCMTree::RawTagId | tagId ) |
Returns an entry for each frame in which a tag with id tagId can be found and store the corresponding z, t, and u location in the entry as well as the found pointer to the tag.
If a tag cannot be found in the specific frame but it exist on tree root as common tag then the common tag will be set for the specific frame.
smfTree | The structured multi-frame tree in whose frames the tags shall be searched. |
tagId | The DICOM tag id to search in the frames. |
References getFrameSpecificTags().
Referenced by getFrameSpecificTags().
MLDICOM_TO_ML_TOOLS_EXPORT FrameSpecificTagsVector ml::DicomToMLTools::getFrameSpecificTagSet | ( | const DCMTree::Const_StructuredMFPtr & | smfTree, |
const std::vector< DCMTree::RawTagId > & | tagIds ) |
Returns an entry for each frame and each tag id from tagIds in which any tagId can be found and store the corresponding z, t, and u location in the entry as well as the found pointer to the tag.
If a tag cannot be found in the specific frame but it exist on tree root as common tag then the common tag will be set for the specific frame.
smfTree | The structured multi-frame tree in whose frames the tags shall be searched. |
tagIds | The DICOM tag ids to search in the frames. |
References getFrameSpecificTagSet().
Referenced by getFrameSpecificTagSet().
MLDICOM_TO_ML_TOOLS_EXPORT const FrameSpecificTags * ml::DicomToMLTools::getFrameSpecificTagsSet | ( | const FrameSpecificTagsVector & | tagSet, |
MLint | z, | ||
MLint | t, | ||
MLint | u ) |
Returns pointer to the first occurrence of a FrameSpecificTags entry which has the given z, t, and u positions or nullptr if not found.
References getFrameSpecificTagsSet().
Referenced by getFrameSpecificTagsSet().
MLMULTI_FILE_VOLUME_EXPORT DCMTree::Const_TreePtr ml::DicomToMLTools::getInputDCMTree | ( | Module & | moduleWithInFields, |
const std::string & | inputSourceName, | ||
const std::string & | fileName, | ||
Base * | basePtr, | ||
const MLint | volIdx, | ||
size_t * | numVolumes, | ||
bool | allowEmptyFileNames, | ||
DicomMessageCollector & | dcmMsgCollector ) |
Gets a DCMTree from an input which is selected via a string name.
If any specified module input (field), base pointer, list, or entry in list does not exist or is empty then simply a nullptr tree is returned. If a file is specified as input and cannot be read then an ML_PRINT_ERROR is performed.
moduleWithInFields | The module from which the image connector fields can be used to retrieve the DCMTree. |
inputSourceName | A string specifier describing which input source shall be used to retrieve the DCMTree. Allowed strings are "ImageConnector" get the DCMTree from image input #0 "ImageConnector #0" get the DCMTree from image input #0 "ImageConnector #1" get the DCMTree from image input #1 "ImageConnector #2" get the DCMTree from image input #2 "File", get the DCMTree from a file named fileName "MultiFileVolumeCache", get the DCMTree from a stored MultFileVolume(List) given by fileName. The volIdx is used to select the entry of the MultiFileVolumeList which shall be used. "DirectDicomImport" or "BaseConnector" (BaseConnector might have suffixes " #0", " #1", " #2" for convenience, which does not change functionality) get DCMTree from Base connector expecting MultiFileVolumeListRefCounted or DCMTreeRefCounted. The volIdx is used to select the entry of the MultiFileVolumeList which shall be used. |
fileName | Path and name to the DICOM file if inputSourceName is "File", otherwise its value is ignored. |
basePtr | Pointer to a base object if inputSourceName is "DirectDicomImport" or "BaseConnector", otherwise its value is ignored. |
volIdx | Only used for case if inputSourceName is "DirectDicomImport", "BaseConnector", "BaseConnector #0", "BaseConnector #1", "BaseConnector #2", or "MultiFileVolumeList", otherwise ignored. |
numVolumes | If passed non nullptr then the number of volumes at the selected input is returned. This will be one for normal valid inputs or the number of list entries if a Base objects with a list of objects is connected. |
allowEmptyFileNames | If true then empty file names do not cause errors appended to dcmMsgCollector when calling this function; in this case only an nullptr tree is returned. |
dcmMsgCollector | Collects error, info and issue messages (typically related to a handle). |
References getInputDCMTree().
Referenced by getInputDCMTree().
MLDICOM_TO_ML_TOOLS_EXPORT MLDataType ml::DicomToMLTools::getMLDataTypeFromDCMTree | ( | DCMTree::Const_TreePtr | treePtr, |
DicomMessageCollector & | dcmMsgCollector ) |
Determines the ML data type of pixel data in the given DICOM tree treePtr.
On success the data type is returned, otherwise ML_INVALID_DATA_TYPE.
treePtr | The DICOM tree the data type is computed from. |
dcmMsgCollector | Collects error, info and issue messages (typically related to a handle). |
References getMLDataTypeFromDCMTree().
Referenced by getMLDataTypeFromDCMTree().
MLDICOM_TO_ML_TOOLS_EXPORT std::vector< DCMTree::RawTagId > ml::DicomToMLTools::getOverlayTagSet | ( | ) |
Create a vector with all possible ids of type 1 and important type 3 overlay tags.
References getOverlayTagSet().
Referenced by getOverlayTagSet().
MLDICOM_TO_ML_TOOLS_EXPORT bool ml::DicomToMLTools::getPositionSpecificDoubleProperties | ( | const PositionSpecificDoubleVector & | positions, |
double & | rangeMin, | ||
double & | rangeMax, | ||
bool & | hasFractionalParts ) |
Returns some properties of the double values in valuePositions, the minimum / maximum range, and whether any value is a non integer one.
If positions is empty then passed values are left unchanged and false is returned, otherwise the passed values are adjusted and true is returned.
References getPositionSpecificDoubleProperties().
Referenced by getPositionSpecificDoubleProperties().
MLDICOM_TO_ML_TOOLS_EXPORT DCMTree::Const_StructuredMFPtr ml::DicomToMLTools::getSMFTreeFromPagedImage | ( | const PagedImage & | pImg | ) |
Tries to get the first DICOM image property extension and returns its DCMTree wrapped as Structured MF Tree if possible; otherwise nullptr is returned.
References getSMFTreeFromPagedImage().
Referenced by getSMFTreeFromPagedImage().
MLDICOM_TO_ML_TOOLS_EXPORT void ml::DicomToMLTools::getSpectDICOMImageProperties | ( | DCMTree::Const_TreePtr | treePtr, |
const std::string & | fileNameUTF8, | ||
PagedImage & | outInfos, | ||
Vector4 & | rotAxisAndRadians, | ||
Vector3 & | ipp, | ||
Vector3 & | relMRSPositionVector, | ||
Vector3 & | mrsPositionVector, | ||
Vector3 & | voiVector, | ||
Vector3 & | fovVector, | ||
bool | useOldWorldMatrixCalculation, | ||
DicomMessageCollector & | dcmMsgCollector ) |
Extract spectroscopy image properties and some other infos from the passed DICOM tree.
Note that this function does not set or handle the DICOM tree or other image property extensions. They have to be added be the caller.
treePtr | The DICOM tree all tags are extracted from to set up the image properties. |
fileNameUTF8 | The name of the DICOM file given as treePtr. This is also stored in outInfos to be able to created related target file from it. Be aware that WIN has problems with UTF8-code. |
outInfos | The PagedImage properties to be set up from the treePtr tags. |
rotAxisAndRadians | If a Siemens CSA-Header is found then it set with values from sSliceArray.asSlice[0].[sNormal.dSag, sNormal.dCor, sNormal.dTra, dInPlaneRot]; otherwise it is set to vec4(0,0,1, 0). |
ipp | If a Siemens CSA-Header is found then it is set with scanned ASCII values after "ImagePositionPatient"; otherwise it is filled with values from normal DICOM tags via a getImagePositionPatient-call. |
relMRSPositionVector | If a Siemens CSA-Header is found then it is set to scanned ASCII values from ipp - mrsPositionVector; otherwise it is set to vec3(0,0,0). |
mrsPositionVector | If a Siemens CSA-Header is found then it is set to scanned ASCII values from sSliceArray.asSlice[0].sPosition.[dSag, dCor, dTra]; otherwise it is set to vec3(0,0,0). |
voiVector | If a Siemens CSA-Header is found then it is set to scanned ASCII values from sSpecPara.sVoI.[dReadoutFOV, dPhaseFOV, dThickness]; otherwise it is set to vec3(0,0,0). |
fovVector | If a Siemens CSA-Header is found then it is set to scanned ASCII values from sSliceArray.asSlice[0].[dReadoutFOV, dPhaseFOV, dThickness]; otherwise it is set to vec3(0,0,0). |
useOldWorldMatrixCalculation | If enabled then for standard DICOM files the original world matrix calculation is used as implemented in LoadRawSiemensSpectData. If disabled (the default) then the normal DICOM world matrix calculation is used. |
dcmMsgCollector | Collects error, info and issue messages (typically related to a handle). |
References getSpectDICOMImageProperties().
Referenced by getSpectDICOMImageProperties().
MLDICOM_TO_ML_TOOLS_EXPORT size_t ml::DicomToMLTools::getVoxelSize | ( | DCMTree::Const_TreePtr | treePtr, |
double & | voxSizeX, | ||
double & | voxSizeY, | ||
double & | voxSizeZ, | ||
bool | replaceOnlyIfFound, | ||
bool * | isPrecise, | ||
std::vector< DCMTree::RawTagId > * | usedTags, | ||
DicomMessageCollector & | dcmMsgCollector ) |
Determine the voxel size from the DICOM tags and returns the number of found extents.
All not found extents are filled with 1 if replaceOnlyIfFound==false, otherwise they are only set if they are found.
treePtr | The DICOM tree from which the voxel size shall be determined. |
isPrecise | If this is passed non nullptr then its return value is set to true if the standard DICOM tags could be retrieved which determine a precise voxel spacing. If tags were used which do not describe the physically exact spacing then false is returned.
|
voxSizeX | Update to the x-extent of voxels if it can be determined from treePtr. If it cannot be determined unchanged if replaceOnlyIfFound, or 1 otherwise. |
voxSizeY | Like voxSizeX for the y extent of the voxels. |
voxSizeZ | Like voxSizeX for the z extent of the voxels. |
replaceOnlyIfFound | If true then the arguments voxSizeX, voxSizeY, and voxSizeZ are only modified if valid values are found, otherwise they are left unchanged. If case of false these arguments are set to 1 if they cannot be determined. |
usedTags | If this is passed non nullptr then the DICOM tag ids used to determine the voxel size are returned in the vector. |
dcmMsgCollector | Collects error, info and issue messages (typically related to a handle). |
References getVoxelSize().
Referenced by getVoxelSize().
MLDICOM_TO_ML_TOOLS_EXPORT bool ml::DicomToMLTools::guessMinMaxRangeFromDICOMTags | ( | DCMTree::Const_TreePtr | treePtr, |
MLdouble & | minPixVal, | ||
MLdouble & | maxPixVal, | ||
DicomMessageCollector & | dcmMsgCollector ) |
Try to guess a min/max range from DICOM tags for the case that they cannot be determined in another way.
The pixel data type, the used bits, the highest bit and stored bit tags can at least limit the min/max range to a useful range if other approaches failed.
treePtr | The tree to be checked for min/max pixel tags. |
minPixVal | The found minimum value if return value is true, otherwise ML_DOUBLE_MAX. |
maxPixVal | The found maximum value if return value is true, otherwise -ML_DOUBLE_MAX. |
dcmMsgCollector | Collects error, info and issue messages (typically related to a handle). |
References guessMinMaxRangeFromDICOMTags().
Referenced by guessMinMaxRangeFromDICOMTags().
MLDICOM_TO_ML_TOOLS_EXPORT bool ml::DicomToMLTools::hasValidNonImageModality | ( | DCMTree::Const_TreePtr | treePtr | ) |
Returns true only if the passed string is a known, non-empty and valid modality string which is a non image modality (RTSTRUCT, RTPLAN, RTRECORD, AU, SR, HD, ECG, FID...) and the DCMTree is not a Secondary Capture IOD.
The treePtr will also be examined for modalities such as REG whether it is an image like REG deformation field or only Matrix storage and therefore no image. It also will be checked for the Secondary Capture IOD which always is an image modality and which will result to a false return even if the modality tag value indicates a non image one. nullptr treePtrs will be handled as ML error.
References hasValidNonImageModality().
Referenced by hasValidNonImageModality().
MLDICOM_TO_ML_TOOLS_EXPORT bool ml::DicomToMLTools::isImageFrameNotOfBits | ( | DCMTree::Const_TreePtr | treePtr | ) |
Returns true if the DICOM tree seems to describe a sensible image with column and row extents > 1 as well as pixels with more than one bit per pixel, otherwise false.
PixelData presence is not checked, thus it can be used to check frames without pixel data to be image frames.
References isImageFrameNotOfBits().
Referenced by isImageFrameNotOfBits().
MLDICOM_TO_ML_TOOLS_EXPORT bool ml::DicomToMLTools::isVolumeCovered | ( | const PositionSpecificDoubleVector & | positions, |
const SubImageBox & | volume ) |
Returns true if the (z,t,u) positions in positions cover all (z,t,u) slices in volume, otherwise false is returned.
References isVolumeCovered().
Referenced by isVolumeCovered().
MLDICOM_TO_ML_TOOLS_EXPORT std::string ml::DicomToMLTools::rasterOverlays | ( | DicomToMLTools::FrameSpecificTagsVector & | overlayTagSet, |
SubImage & | outSubImg ) |
Takes overlay DICOM tags from overlayTagSet matching the x/y plane of outSubImage.getBox().v1, create BitImages from them and copies them into outSubImage where the entire background it filled with 0, and valid overlay bits are set to 1.
The return value is empty on success or if no overlays to render are found, and a descriptive string if anything fails, for example if overlay tags contain inconsistent information.
References rasterOverlays().
Referenced by rasterOverlays().
MLDICOM_TO_ML_TOOLS_EXPORT void ml::DicomToMLTools::setUpMinMaxVoxelValues | ( | std::string & | errStr, |
DCMTree::Const_DictPtr | dcmTreeDictPtr, | ||
double | smallestPixelValue, | ||
double | largestPixelValue, | ||
DCMTree::TreePtr | dcmTree ) |
Set up DCMTree_SmallestImagePixelValue and DCMTree_LargestImagePixelValue tags in dcmTree; requires that DCMTree_PixelRepresentation, DCMTree_SmallestImagePixelValue, or DCMTree_LargestImagePixelValue tags exist from which the value representation of the DCMTree_SmallestImagePixelValue and DCMTree_LargestImagePixelValue can be determined.
errStr | On success errStr is left unchanged, on error the error description is appended. |
dcmTreeDictPtr | A required dictionary pointer to decode tag names and ids. |
smallestPixelValue | The tag value for DCMTree_SmallestImagePixelValue. |
largestPixelValue | The tag value for DCMTree_LargestImagePixelValue. |
dcmTree | Tree to which the tags are added. |
References setUpMinMaxVoxelValues().
Referenced by setUpMinMaxVoxelValues().
MLDICOM_TO_ML_TOOLS_EXPORT void ml::DicomToMLTools::setUpOverlayOutputProperties | ( | DCMTree::Const_TreePtr | dcmTree, |
PagedImage & | overlayPagedImg, | ||
DicomToMLTools::FrameSpecificTagsVector & | overlayTagSet ) |
Determine DICOM overlay information from dcmTree, configures (or if necessary invalidates) the passed overlayPagedImg such that it can display these overlays correctly, and sets up overlayTagSet such that it provides all required DICOM tags to display them properly in calculateOutputSubImage.
It is assumed that overlayPagedImg is configured in the same ways as the image on which the overlay lives. As an example: Output image 0 shows a DICOM image and output image 1 shall display its overlays. Then set overlayPagedImg the same properties as output image 0 and then call this function. Specified properties are:
References setUpOverlayOutputProperties().
Referenced by setUpOverlayOutputProperties().
MLDICOM_TO_ML_TOOLS_EXPORT void ml::DicomToMLTools::setWorldMatrixFromDcmTree | ( | DCMTree::Const_TreePtr | treePtr, |
PagedImage & | outInfos, | ||
DicomMessageCollector & | dcmMsgCollector ) |
If possible all image properties from the DcmTree needed to set up the world matrix are searched and converted to a world matrix and voxel size and set in outInfos.
If no or only partial values are found then default settings are used instead.
treePtr | The DICOM tree the matrix is computed from. |
outInfos | The PagedImage in which the worldMatrix is set up as good as possible. |
dcmMsgCollector | Collects error, info and issue messages (typically related to a handle). |
References setWorldMatrixFromDcmTree().
Referenced by setWorldMatrixFromDcmTree().
|
extern |
Strings names corresponding to the selectable DplMinMaxEnums.
|
extern |
Strings according to OutputDataTypeSelector.
|
extern |
Strings according to VoxelDoubleOperations.