diff --git a/Modules/BasicImageProcessing/CMakeLists.txt b/Modules/BasicImageProcessing/CMakeLists.txt new file mode 100644 index 0000000000..6c5ce84cae --- /dev/null +++ b/Modules/BasicImageProcessing/CMakeLists.txt @@ -0,0 +1,9 @@ +MITK_CREATE_MODULE( + DEPENDS MitkCore + PACKAGE_DEPENDS + PUBLIC + PRIVATE ITK|ITKIOImageBase+ITKIOGDCM +) + +#add_subdirectory(autoload/IO) +#add_subdirectory(test) diff --git a/Modules/BasicImageProcessing/files.cmake b/Modules/BasicImageProcessing/files.cmake new file mode 100644 index 0000000000..b814f09774 --- /dev/null +++ b/Modules/BasicImageProcessing/files.cmake @@ -0,0 +1,10 @@ +file(GLOB_RECURSE H_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include/*") + +set(CPP_FILES + mitkCESTImageNormalizationFilter.cpp + mitkCustomTagParser.cpp +) + +set(RESOURCE_FILES + +) diff --git a/Modules/BasicImageProcessing/include/mitkCESTImageNormalizationFilter.h b/Modules/BasicImageProcessing/include/mitkCESTImageNormalizationFilter.h new file mode 100644 index 0000000000..563fa22545 --- /dev/null +++ b/Modules/BasicImageProcessing/include/mitkCESTImageNormalizationFilter.h @@ -0,0 +1,79 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ +#ifndef __mitkCESTImageNormalizationFilter_h +#define __mitkCESTImageNormalizationFilter_h + +#include + +// MITK +#include "mitkImageToImageFilter.h" + +namespace mitk +{ + /** \brief Normalization filter for CEST images. + * + * This filter can be used to normalize CEST images, it only works with 4D images and assumes that the input + * mitk::Image has a property called mitk::CustomTagParser::m_OffsetsPropertyName, whith offsets separated by + * spaces. The number of offsets has to match the number of timesteps. + * + * Each timestep with a corresponding offset greater than 299 or less than -299 will be interpreted as normalization (M0) image. + * If only one M0 image is present normalization will be done by dividing the voxel value by the corresponding + * M0 voxel value. If multiple M0 images are present normalization between any two M0 images will be done by + * dividing by a linear interpolation between the two. + * The M0 images themselves will be transferred to the result without any processing. + * + * The output image will have the same geometry as the input image and a double pixel type. + */ + class MITKCEST_EXPORT CESTImageNormalizationFilter : public ImageToImageFilter + { + public: + mitkClassMacro(CESTImageNormalizationFilter, ImageToImageFilter); + itkFactorylessNewMacro(Self) itkCloneMacro(Self) + + protected: + /*! + \brief standard constructor + */ + CESTImageNormalizationFilter(); + /*! + \brief standard destructor + */ + ~CESTImageNormalizationFilter() override; + /*! + \brief Method generating the output information of this filter (e.g. image dimension, image type, etc.). + The interface ImageToImageFilter requires this implementation. Everything is taken from the input image. + */ + void GenerateOutputInformation() override; + /*! + \brief Method generating the output of this filter. Called in the updated process of the pipeline. + This method generates the normalized output image. + */ + void GenerateData() override; + + /** Internal templated method that normalizes across timesteps + */ + template + void NormalizeTimeSteps(const itk::Image* image); + + /// Offsets without M0s + std::string m_RealOffsets; + + /// non M0 indices + std::vector< unsigned int > m_NonM0Indices; + + }; +} // END mitk namespace +#endif diff --git a/Modules/BasicImageProcessing/include/mitkCustomTagParser.h b/Modules/BasicImageProcessing/include/mitkCustomTagParser.h new file mode 100644 index 0000000000..7a53928ef1 --- /dev/null +++ b/Modules/BasicImageProcessing/include/mitkCustomTagParser.h @@ -0,0 +1,123 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef MITKCUSTOMTAGPARSER_H +#define MITKCUSTOMTAGPARSER_H + +#include +#include + +#include + +namespace mitk +{ + /** + The custom tag parser can be used to parse the custom dicom tag of the siemens private tag + (0x0029, 0x1020) to extract relevant CEST data. + + An initial parsing determines whether the provided string belongs to CEST data at all. + If the "tSequenceFileName" is of the format "{WHATEVER}CEST_Rev####" it is assumed that the + data is indeed CEST data and was taken with revision #### (not limited to four digits). + + Which custom parameters to save and to which property name can be controlled by a json file. + This file can be either provided as a resource for the MitkCEST module during compilation or + placed next to the MitkCEST library in your binary folder. + + The expected format for the file "REVISIONNUMBER.json":
+ {
+ "REVISIONNUMBER" : "revision_json",
+ "sWiPMemBlock.alFree[1]" : "AdvancedMode",
+ "sWiPMemBlock.alFree[2]" : "RetreatMode"
+ }
+ + where : +
    +
  • REVISIONNUMBER is the revision number of this json parameter mapping (files with non digit characters in their + name will be ignored) +
  • sWiPMemBlock.alFree[1] is the name of one parameter in the private dicom tag +
  • AdvancedMode is the name of the property the content of sWiPMemBlock.alFree[1] should be saved to +
+ + \note It is assumed that the entire content of tag (0x0029, 0x1020) is provided and that it es hex encoded + (12\23\04...). + + If the sampling type is list it will try to access LIST.txt at the location provided in the constructor to + read the offsets. + */ + class MITKCEST_EXPORT CustomTagParser + { + public: + /// the constructor expects a path to one of the files to be loaded or the directory of the dicom files + CustomTagParser(std::string relevantFile); + + /// parse the provided dicom property and return a property list based on the closest revision parameter mapping + mitk::PropertyList::Pointer ParseDicomProperty(mitk::TemporoSpatialStringProperty *dicomProperty); + /// parse the provided string and return a property list based on the closest revision parameter mapping + mitk::PropertyList::Pointer ParseDicomPropertyString(std::string dicomPropertyString); + + void SetParseStrategy(std::string parseStrategy); + void SetRevisionMappingStrategy(std::string revisionMappingStrategy); + + /// name of the property for the offsets, including normalization offsets + static const std::string m_OffsetsPropertyName; + + /// name of the property for the data acquisition revision + static const std::string m_RevisionPropertyName; + + /// name of the property for the json parameter mapping revision + static const std::string m_JSONRevisionPropertyName; + + /// prefix for all CEST related property names + static const std::string m_CESTPropertyPrefix; + + protected: + std::string GetRevisionAppropriateJSONString(std::string revisionString); + void GetClosestLowerRevision(std::string revisionString); + std::string GetClosestLowerRevision(std::string revisionString, std::vector availableRevisionsVector); + + /// Decides whether or not the image is likely to be a T1Map, if not it is assumed to be a CEST sequence + bool IsT1Sequence(std::string preparationType, std::string recoveryMode, std::string spoilingType, std::string revisionString); + + /// Get a string filled with the properly formated offsets based on the sampling type and offset + std::string GetOffsetString(std::string samplingType, std::string offset, std::string measurements); + + /// returns a vector revision numbers of all REVISIONNUMBER.json found beside the MitkCEST library + std::vector GetExternalRevisions(); + /// returns a vector revision numbers of all REVISIONNUMBER.json provided as resources during the compile + std::vector GetInternalRevisions(); + + /// returns the path where external jsons are expected to be located + std::string GetExternalJSONDirectory(); + + /// the closest lower revision provided as resource, empty if none found + std::string m_ClosestInternalRevision; + /// the closest lower revision provided as a json beside the library, empty if none found + std::string m_ClosestExternalRevision; + + /// revision independent mapping to inject into the revision dependent json string + static const std::string m_RevisionIndependentMapping; + /// default revision dependent json string if none is found + static const std::string m_DefaultJsonString; + /// path to the dicom data + std::string m_DicomDataPath; + /// Should the kind of data be automatically determined or should it be parsed as a specific one + std::string m_ParseStrategy; + /// How to handle parameter mapping based on absent revision jsons + std::string m_RevisionMappingStrategy; + }; +} + +#endif // MITKCUSTOMTAGPARSER_H diff --git a/Modules/ModuleList.cmake b/Modules/ModuleList.cmake index 8ac0be92e5..89c06dd6e0 100644 --- a/Modules/ModuleList.cmake +++ b/Modules/ModuleList.cmake @@ -1,77 +1,78 @@ # The entries in the mitk_modules list must be # ordered according to their dependencies. set(MITK_MODULES Core CommandLine AppUtil RDF LegacyIO DataTypesExt Annotation LegacyGL AlgorithmsExt MapperExt DICOMReader DICOMReaderServices DICOMTesting SceneSerializationBase PlanarFigure ImageDenoising ImageExtraction SceneSerialization Gizmo GraphAlgorithms Multilabel ImageStatistics ContourModel SurfaceInterpolation Segmentation PlanarFigureSegmentation QtWidgets QtWidgetsExt Chart SegmentationUI MatchPointRegistration MatchPointRegistrationUI Classification GPGPU OpenIGTLink IGTBase IGT CameraCalibration OpenCL OpenCVVideoSupport QtOverlays ToFHardware ToFProcessing ToFUI PhotoacousticsHardware PhotoacousticsAlgorithms PhotoacousticsLib US USUI DicomUI Remeshing Python QtPython Persistence OpenIGTLinkUI IGTUI DicomRT RTUI IOExt XNAT TubeGraph BiophotonicsHardware DiffusionImaging TumorInvasionAnalysis BoundingShape RenderWindowManager RenderWindowManagerUI CEST + BasicImageProcessing ) if(MITK_ENABLE_PIC_READER) list(APPEND MITK_MODULES IpPicSupportIO) endif()