Some basic utility functions. More...
#include <algorithm>#include <functional>#include <cmath>#include "itkImage.h"#include "itkImageRegionConstIterator.h"#include "itkImageRegionConstIteratorWithIndex.h"#include "itkImageRegionIterator.h"#include "itkHistogramMatchingImageFilter.h"#include "itkAdaptiveHistogramEqualizationImageFilter.h"#include "itkConnectedThresholdImageFilter.h"#include "itkOrientImageFilter.h"#include "itkResampleImageFilter.h"#include "itkIdentityTransform.h"#include "itkLinearInterpolateImageFunction.h"#include "itkBSplineInterpolateImageFunction.h"#include "itkNearestNeighborInterpolateImageFunction.h"#include "itkTestingComparisonImageFilter.h"#include "itkStripTsImageFilter.h"#include "itkMaskImageFilter.h"#include "cbicaUtilities.h"#include "cbicaITKImageInfo.h"#include "gdcmMD5.h"#include "gdcmReader.h"#include "DicomIOManager.h"

Go to the source code of this file.
Typedefs | |
| using | ImageTypeFloat3D = itk::Image< float, 3 > |
Enumerations | |
| enum | DeformRegType { Demons, DiffeomorphicDemons, SymmetricForcesDemons, FastSymmetricForcesDemons } |
| enum | InterpolatorType { Linear, NearestNeighbor, BSpline } |
Functions | |
| template<class TImageType = ImageTypeFloat3D> | |
| TImageType::Pointer | ChangeImageValues (const typename TImageType::Pointer inputImage, const std::string &oldValues, const std::string &newValues) |
| Create an empty (optionally pass a value) ITK image based on an input image with same properties. More... | |
| template<class TImageType = ImageTypeFloat3D> | |
| TImageType::Pointer | CreateImage (const typename TImageType::Pointer inputImage, const typename TImageType::PixelType value=0) |
| Create an empty (optionally pass a value) ITK image based on an input image with same properties. More... | |
| template<class TImageType = ImageTypeFloat3D> | |
| std::vector< std::vector< typename TImageType::IndexType > > | CreateMaskIndeces (const std::vector< std::vector< typename TImageType::Pointer > > &inputModalitiesAndImages) |
| Calculate and preserve the mask indeces. More... | |
| template<typename TImageType = ImageTypeFloat3D> | |
| std::vector< typename TImageType::PixelType > | ExtractPixelValuesFromIndeces (const typename TImageType::Pointer inputImage, const std::vector< typename TImageType::IndexType > &indeces) |
| Wrap of GetPixelValues. | |
| template<typename TImageType = ImageTypeFloat3D> | |
| TImageType::Pointer | GetAdaptiveHistogramEqualizedImage (const typename TImageType::Pointer inputImage, const typename TImageType::Pointer referenceImage, const float alpha=0.3, const float beta=0.3, const float radius=1, const int numberOfHistogramLevels=100) |
| Get the indeces of the image which are not zero. More... | |
| template<class TImageType = ImageTypeFloat3D> | |
| float | GetDistanceBetweenIndeces (const typename TImageType::IndexType point1, const typename TImageType::IndexType point2) |
| Get the distance between 2 indeces of an itk::Image. | |
| float | GetDistanceBetweenIndeces (const float *point1, const float *point2) |
| Get the distance between 2 itk::P of an itk::Image. | |
| template<typename TImageType = ImageTypeFloat3D> | |
| itk::Vector< float, TImageType::ImageDimension > | GetDistances (const typename TImageType::Pointer inputImage) |
| Get distances in world coordinates across axes for an image. More... | |
| template<typename TImageType = ImageTypeFloat3D> | |
| TImageType::Pointer | GetHistogramMatchedImage (const typename TImageType::Pointer inputImage, const typename TImageType::Pointer referenceImage, const int numberOfMatchPoints=40, const int numberOfHistogramLevels=100) |
| Get the indeces of the image which are not zero. More... | |
| template<class TImageType = ImageTypeFloat3D> | |
| std::pair< std::string, typename TImageType::Pointer > | GetImageOrientation (const typename TImageType::Pointer inputImage) |
| Perform the deformable registration. More... | |
| template<typename TImageType = ImageTypeFloat3D> | |
| std::vector< typename TImageType::IndexType > | GetIndexFromNonZeroPixels (const typename TImageType::Pointer inputImage, const std::string valuesToExclude="0") |
| Get MD5 sum of a supplied file. More... | |
| template<class TImageType = ImageTypeFloat3D> | |
| std::pair< float, typename TImageType::IndexType > | GetMaxDistanceInLabelMap (const typename TImageType::Pointer inputLabelMap, const typename TImageType::IndexType indexForComputation, bool realCoordinateInput=false, bool realCoordinateOutput=false) |
| Get the maximum distance and corresponding coordinate from a seed point in a label map. More... | |
| template<class TImageType = ImageTypeFloat3D> | |
| std::vector< typename TImageType::IndexType > | GetNonZeroIndeces (typename TImageType::Pointer inputImage) |
| Get Non-zero indeces of image. | |
| template<typename TImageType = ImageTypeFloat3D> | |
| std::vector< typename TImageType::PixelType > | GetPixelValuesFromIndeces (const typename TImageType::Pointer inputImage, const std::vector< typename TImageType::IndexType > &indeces) |
| Get Pixel Values of specified indeces of input Image. More... | |
| template<class TImageType = ImageTypeFloat3D> | |
| bool | GetResultOfImageComparasion (const typename TImageType::Pointer referenceImage, const typename TImageType::Pointer checkImage, const typename TImageType::PixelType differenceThreshold=0, const unsigned int toleranceRadius=0, const unsigned long long numberOfPixelsTolerance=10, const typename TImageType::PixelType averageIntensityDifference=0) |
| Get result of Image comparison between 2 images. More... | |
| template<class TImageType = ImageTypeFloat3D, class TAtlasImageType = TImageType, class TAtlasLabelType = TImageType> | |
| TImageType::Pointer | GetSkullStrippedImage (const typename TImageType::Pointer inputImage, const typename TAtlasImageType::Pointer atlasImage, const typename TAtlasLabelType::Pointer atlasLabelImage) |
| Get skull stripped image. More... | |
| template<class TImageType = ImageTypeFloat3D> | |
| std::vector< typename TImageType::PixelType > | GetUniqueValuesInImage (typename TImageType::Pointer inputImage, bool sortResult=true) |
| Get the unique values in an image. More... | |
| template<typename TImageType > | |
| bool | ImageSanityCheck (const typename TImageType::Pointer image1, const typename TImageType::Pointer image2) |
| Check properties of 2 images to see if they are defined in the same space. | |
| bool | ImageSanityCheck (const std::string &image1, const std::string &image2) |
| Check properties of 2 images to see if they are defined in the same space. More... | |
| template<class TImageType = ImageTypeFloat3D> | |
| TImageType::Pointer | ResampleImage (const typename TImageType::Pointer inputImage, const itk::Vector< double, TImageType::ImageDimension > &outputSpacing, const std::string interpolator="Linear") |
| Resample an image to an isotropic resolution using the specified output spacing vector. More... | |
| template<class TImageType = ImageTypeFloat3D> | |
| TImageType::Pointer | ResampleImage (const typename TImageType::Pointer inputImage, const typename TImageType::SpacingType outputSpacing, typename TImageType::SizeType outputSize, const std::string interpolator="Linear") |
| Resample an image to an isotropic resolution using the specified output spacing vector. More... | |
| template<class TImageType = ImageTypeFloat3D> | |
| TImageType::Pointer | ResampleImage (const typename TImageType::Pointer inputImage, const float outputSpacing=1.0, const std::string interpolator="Linear") |
| Resample an image to an isotropic resolution using the specified output spacing. More... | |
| template<class TImageType = ImageTypeFloat3D> | |
| TImageType::Pointer | ResizeImage (const typename TImageType::Pointer inputImage, const size_t resizeFactor, const std::string &interpolator="Linear") |
| Resize an input image by a factor (expressed as a percentage) More... | |
Some basic utility functions.
Dependecies: ITK (module_review, module_skullstrip enabled), OpenMP
https://www.cbica.upenn.edu/sbia/software/
software@cbica.upenn.edu
Copyright (c) 2015 University of Pennsylvania. All rights reserved.
See COPYING file or https://www.cbica.upenn.edu/sbia/software/license.html
| TImageType::Pointer cbica::ChangeImageValues | ( | const typename TImageType::Pointer | inputImage, |
| const std::string & | oldValues, | ||
| const std::string & | newValues | ||
| ) |
Create an empty (optionally pass a value) ITK image based on an input image with same properties.
| inputImage | The image to base the output on |
| oldValues | Values separated by 'x' |
| newValues | Values separated by 'x' |
References cbica::ChangeImageValues(), and cbica::stringSplit().
Referenced by cbica::ChangeImageValues().
| TImageType::Pointer cbica::CreateImage | ( | const typename TImageType::Pointer | inputImage, |
| const typename TImageType::PixelType | value = 0 |
||
| ) |
Create an empty (optionally pass a value) ITK image based on an input image with same properties.
| inputImage | The image to base the output on |
| value | The value to populate the new image with; defaults to '0' |
References cbica::CreateImage().
Referenced by cbica::CreateImage().
| std::vector< std::vector< typename TImageType::IndexType > > cbica::CreateMaskIndeces | ( | const std::vector< std::vector< typename TImageType::Pointer > > & | inputModalitiesAndImages | ) |
Calculate and preserve the mask indeces.
| inputModalitiesAndImages | A collection of images which are stored in a per-modality basis (each entry corresponds to a subject, whose entries contain different modalities) |
References cbica::CreateMaskIndeces().
Referenced by cbica::CreateMaskIndeces().
| TImageType::Pointer cbica::GetAdaptiveHistogramEqualizedImage | ( | const typename TImageType::Pointer | inputImage, |
| const typename TImageType::Pointer | referenceImage, | ||
| const float | alpha = 0.3, |
||
| const float | beta = 0.3, |
||
| const float | radius = 1, |
||
| const int | numberOfHistogramLevels = 100 |
||
| ) |
Get the indeces of the image which are not zero.
| inputImage | The input image on which the matching needs to be done |
| referenceImage | The reference image based on which the |
| alpha | Ranges between 0-1; with 1 giving result same as input image and lower values behaving as unsharp filters; default = 0.3 |
| beta | Ranges between 0-1; with 1 giving result same as input image and lower values behaving as unsharp filters; default = 0.3 |
| radius | Ranges between 1-10 with default = 1 |
References cbica::GetAdaptiveHistogramEqualizedImage().
Referenced by cbica::GetAdaptiveHistogramEqualizedImage().
| itk::Vector< float, TImageType::ImageDimension > cbica::GetDistances | ( | const typename TImageType::Pointer | inputImage | ) |
Get distances in world coordinates across axes for an image.
| inputImage |
References cbica::GetDistances().
Referenced by cbica::GetDistances().
| TImageType::Pointer cbica::GetHistogramMatchedImage | ( | const typename TImageType::Pointer | inputImage, |
| const typename TImageType::Pointer | referenceImage, | ||
| const int | numberOfMatchPoints = 40, |
||
| const int | numberOfHistogramLevels = 100 |
||
| ) |
Get the indeces of the image which are not zero.
| inputImage | The input image on which the matching needs to be done |
| referenceImage | The reference image based on which the |
| numberOfMatchPoints | Governs the number of quantile values to be matched |
| numberOfHistogramLevels | Sets the number of bins used when creating histograms of the source and reference images |
References cbica::GetHistogramMatchedImage().
Referenced by cbica::GetHistogramMatchedImage().
| std::pair< std::string, typename TImageType::Pointer > cbica::GetImageOrientation | ( | const typename TImageType::Pointer | inputImage | ) |
Perform the deformable registration.
| movingImage | The moving image for registration |
| referenceImage | The reference image for registration |
| multiResLevels | Number of multi-resolution levels for registration, defaults to 5 |
| iterationStart | Start size of iteration for first multiResLevel, defaults to 10 |
| iterationStep | Step size of the iterations increasing over each MultiResLevel, defaults to 10 |
| iterationEnd | End size of iteration for first multiResLevel, defaults to 50 |
| regType | The type of registration to perform, defaults to 'Demons' |
| interpolatorType | The type of interpolator to use, defaults to 'Linear'Get the image orientation |
| inputImage | The input image |
References cbica::GetImageOrientation().
Referenced by cbica::GetImageOrientation().
| std::vector< typename TImageType::IndexType > cbica::GetIndexFromNonZeroPixels | ( | const typename TImageType::Pointer | inputImage, |
| const std::string | valuesToExclude = "0" |
||
| ) |
Get MD5 sum of a supplied file.
| fileName | The input file |
References cbica::GetIndexFromNonZeroPixels().
Referenced by cbica::GetIndexFromNonZeroPixels().
| std::pair< float, typename TImageType::IndexType > cbica::GetMaxDistanceInLabelMap | ( | const typename TImageType::Pointer | inputLabelMap, |
| const typename TImageType::IndexType | indexForComputation, | ||
| bool | realCoordinateInput = false, |
||
| bool | realCoordinateOutput = false |
||
| ) |
Get the maximum distance and corresponding coordinate from a seed point in a label map.
| inputLabelMap | The label map on which to do the calculation |
| indexForComputation | The index of the seed point from where to do the distance measurements |
| realCoordinatesPassed | Bool which denotes if indexForComputation is real (e.g. the tumorPoints used by GLISTR) or an image index |
References cbica::GetMaxDistanceInLabelMap().
Referenced by cbica::GetMaxDistanceInLabelMap().
| std::vector< typename TImageType::PixelType > cbica::GetPixelValuesFromIndeces | ( | const typename TImageType::Pointer | inputImage, |
| const std::vector< typename TImageType::IndexType > & | indeces | ||
| ) |
Get Pixel Values of specified indeces of input Image.
| inputImage | The input image in itk::Image format |
| indeced | The indeces from which pixel values need to be extracted |
References cbica::GetPixelValuesFromIndeces().
Referenced by cbica::GetPixelValuesFromIndeces().
| bool cbica::GetResultOfImageComparasion | ( | const typename TImageType::Pointer | referenceImage, |
| const typename TImageType::Pointer | checkImage, | ||
| const typename TImageType::PixelType | differenceThreshold = 0, |
||
| const unsigned int | toleranceRadius = 0, |
||
| const unsigned long long | numberOfPixelsTolerance = 10, |
||
| const typename TImageType::PixelType | averageIntensityDifference = 0 |
||
| ) |
Get result of Image comparison between 2 images.
This runs itk::Testing::ComparisonImageFilter inside so the inputs are identical. Always updates the largest possible region.
| referenceImage | The reference image for comparison |
| checkImage | The image to check |
| differenceThreshold | The minimum number of different pixels among both images; default is 0 |
| toleranceRadius | The maximum distance to look for a matching pixel; default is 0 |
| numberOfPixelsTolerance | The maximum maximum number of pixels that can be different; default is 10 |
| averageIntensityDifference | The maximum allowed average intensity difference between both images; default is 0 |
References cbica::GetResultOfImageComparasion().
Referenced by cbica::GetResultOfImageComparasion().
| TImageType::Pointer cbica::GetSkullStrippedImage | ( | const typename TImageType::Pointer | inputImage, |
| const typename TAtlasImageType::Pointer | atlasImage, | ||
| const typename TAtlasLabelType::Pointer | atlasLabelImage | ||
| ) |
Get skull stripped image.
Templated over InputImageType, AtlasImageType and AtlasLabelType
| inputImage | The input image on which to run the skull stripping |
| atlasImage | The atlas image |
| atlasLabelImage | The atlas label |
References cbica::GetSkullStrippedImage().
Referenced by cbica::GetSkullStrippedImage().
| std::vector< typename TImageType::PixelType > cbica::GetUniqueValuesInImage | ( | typename TImageType::Pointer | inputImage, |
| bool | sortResult = true |
||
| ) |
Get the unique values in an image.
| inputImage | The input image |
| sortResult | Whether the output should be sorted in ascending order or not, defaults to true |
References cbica::GetUniqueValuesInImage().
Referenced by cbica::GetUniqueValuesInImage().
|
inline |
Check properties of 2 images to see if they are defined in the same space.
Checks are done based on cbica::ImageInfo class
References cbica::ImageSanityCheck().
| TImageType::Pointer cbica::ResampleImage | ( | const typename TImageType::Pointer | inputImage, |
| const itk::Vector< double, TImageType::ImageDimension > & | outputSpacing, | ||
| const std::string | interpolator = "Linear" |
||
| ) |
Resample an image to an isotropic resolution using the specified output spacing vector.
This filter uses the example https://itk.org/Wiki/ITK/Examples/ImageProcessing/ResampleImageFilter as a base while processing time-stamped images as well
| inputImage | The input image to process |
| outputSpacing | The output spacing, always isotropic |
| interpolator | The type of interpolator to use; can be Linear, BSpline or NearestNeighbor |
References cbica::ResampleImage().
Referenced by cbica::ResampleImage().
| TImageType::Pointer cbica::ResampleImage | ( | const typename TImageType::Pointer | inputImage, |
| const typename TImageType::SpacingType | outputSpacing, | ||
| typename TImageType::SizeType | outputSize, | ||
| const std::string | interpolator = "Linear" |
||
| ) |
Resample an image to an isotropic resolution using the specified output spacing vector.
This filter uses the example https://itk.org/Wiki/ITK/Examples/ImageProcessing/ResampleImageFilter as a base while processing time-stamped images as well
| inputImage | The input image to process |
| outputSpacing | The output spacing, always isotropic |
| interpolator | The type of interpolator to use; can be Linear, BSpline or NearestNeighbor |
References cbica::ResampleImage().
| TImageType::Pointer cbica::ResampleImage | ( | const typename TImageType::Pointer | inputImage, |
| const float | outputSpacing = 1.0, |
||
| const std::string | interpolator = "Linear" |
||
| ) |
Resample an image to an isotropic resolution using the specified output spacing.
This filter uses the example https://itk.org/Wiki/ITK/Examples/ImageProcessing/ResampleImageFilter as a base while processing time-stamped images as well
| inputImage | The input image to process |
| outputSpacing | The output spacing, always isotropic |
| interpolator | The type of interpolator to use; can be Linear, BSpline or NearestNeighbor |
References cbica::ResampleImage().
| TImageType::Pointer cbica::ResizeImage | ( | const typename TImageType::Pointer | inputImage, |
| const size_t | resizeFactor, | ||
| const std::string & | interpolator = "Linear" |
||
| ) |
Resize an input image by a factor (expressed as a percentage)
This filter uses the example https://itk.org/Wiki/ITK/Examples/ImageProcessing/ResampleImageFilter as a base while processing time-stamped images as well
| inputImage | The input image to process |
| resizeFactor | The resize factor; can be greater than 100 (which causes an expanded image to be written) but can never be less than zero |
| interpolator | The type of interpolator to use; can be Linear, BSpline, BiCubic or NearestNeighbor |
References cbica::ResizeImage().
Referenced by cbica::ResizeImage().