From 986b1b3dcaa48e7186e86c2c49af247a121ab03d Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Thu, 20 Aug 2020 17:17:40 +0100 Subject: [PATCH 1/2] add checks/warnings on ROI in STC STC binarises an ROI and can be left with no voxels. We now warn/check about this. Fixes #62 --- lib/petpvcSTCPVCImageFilter.txx | 23 +++++++++++++++++++++++ src/STC.cxx | 5 ++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/petpvcSTCPVCImageFilter.txx b/lib/petpvcSTCPVCImageFilter.txx index e9017ea..117765f 100644 --- a/lib/petpvcSTCPVCImageFilter.txx +++ b/lib/petpvcSTCPVCImageFilter.txx @@ -26,6 +26,7 @@ #include "itkObjectFactory.h" #include "itkImageRegionIterator.h" #include "itkImageRegionConstIterator.h" +#include using namespace itk; @@ -64,6 +65,7 @@ void STCPVCImageFilter< TInputImage, TMaskImage> if (imageSize.Dimension != 3) { std::cerr << "[Error]\tMask file must be 3-D!" << std::endl; + throw std::runtime_error("Mask file must be 3-D"); } MaskSizeType desiredStart; @@ -92,6 +94,11 @@ void STCPVCImageFilter< TInputImage, TMaskImage> int numOfLabels = labelStatsFilter->GetNumberOfLabels(); nClasses = numOfLabels; + if ( numOfLabels < 2 ) { + std::cerr << "[Error]\tMask file contains only 1 label, implying zero voxels in the ROI" + << std::endl; + throw std::runtime_error("Mask file should contain at least 2 labels"); + } if ( this->m_bVerbose ) std::cout << "Number of labels: " << nClasses << std::endl; @@ -230,6 +237,22 @@ void STCPVCImageFilter< TInputImage, TMaskImage> { LabelPixelType labelValue = *vIt; + + //checks on ROI size + if ( k == 1 ) { + const typename LabelStatisticsFilterType::MapSizeType numOfVoxels = labelStatsFilter->GetCount( labelValue ); + if ( numOfVoxels == 0) { + std::cerr << "[Error]\tMask file contains zero voxels in the ROI for label " << labelValue << "!" + << std::endl; + throw std::runtime_error("Mask file contains zero voxels in the ROI"); + + } else if ( numOfVoxels < 10 ) { + std::cerr << "[Warning]\nMask file contains less than 10 voxels in the ROI. That is unlikely to work well.\n"; + } + if ( this->m_bVerbose ) + std::cout << "Number of voxels in the ROI of label " << labelValue << ": " << numOfVoxels << std::endl; + } + binThreshFilter->SetLowerThreshold( labelValue ); binThreshFilter->SetUpperThreshold( labelValue ); diff --git a/src/STC.cxx b/src/STC.cxx index 81d4ecf..7341604 100644 --- a/src/STC.cxx +++ b/src/STC.cxx @@ -3,7 +3,7 @@ Author: Benjamin A. Thomas - Copyright 2017 Institute of Nuclear Medicine, University College London. + Copyright 2017, 2020 Institute of Nuclear Medicine, University College London. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -125,6 +125,9 @@ int main(int argc, char *argv[]) maskReader->SetFileName(sMaskFileName); //Try to read mask. + if ( bDebug ) + std::cout << "Reading mask (making it binary by thresholding if it isn't yet)\n"; + try { maskReader->Update(); } catch (itk::ExceptionObject & err) { From 1360698e851e6701cd00140cc6e8abebfba55384 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Thu, 20 Aug 2020 17:39:29 +0100 Subject: [PATCH 2/2] added STC papers in comments/acknowledgment --- lib/petpvcSTCPVCImageFilter.h | 12 ++++++++++++ src/STC.cxx | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/petpvcSTCPVCImageFilter.h b/lib/petpvcSTCPVCImageFilter.h index d152b61..a9c4b13 100644 --- a/lib/petpvcSTCPVCImageFilter.h +++ b/lib/petpvcSTCPVCImageFilter.h @@ -44,6 +44,18 @@ using namespace itk; namespace petpvc { + + /*! Single Target Correction (STC) + + An Implementation of the STC Method, see
+ Sari H, Erlandsson K, Law I, Larsson HB, Ourselin S, Arridge S, Atkinson D, Hutton BF. + Estimation of an image derived input function with MR-defined carotid arteries in FDG-PET human studies using a novel partial volume correction method. + J Cereb Blood Flow Metab. 2017;37(4): 1398--409 +
+ Erlanddsson K and Hutton BF. + A novel voxel-based partial volume correction method for single regions of interest. + J Nucl Med Meeting Abstr 2014; 55: 2023. + */ template< class TInputImage, typename TMaskImage> class STCPVCImageFilter:public ImageToImageFilter< TInputImage, TInputImage > { diff --git a/src/STC.cxx b/src/STC.cxx index 7341604..27ed568 100644 --- a/src/STC.cxx +++ b/src/STC.cxx @@ -18,7 +18,15 @@ limitations under the License. This program implements the Single Target Correction (STC) partial volume correction - (PVC) technique. Please cite the following paper: + (PVC) technique. Please cite the following: + + Sari H, Erlandsson K, Law I, Larsson HB, Ourselin S, Arridge S, Atkinson D, Hutton BF. + Estimation of an image derived input function with MR-defined carotid arteries in FDG-PET human studies using a novel partial volume correction method. + J Cereb Blood Flow Metab. 2017;37(4): 1398--409 + + Erlanddsson K and Hutton BF. + A novel voxel-based partial volume correction method for single regions of interest. + J Nucl Med Meeting Abstr 2014; 55: 2023. */ @@ -198,7 +206,13 @@ int main(int argc, char *argv[]) std::string getAcknowledgments(void) { //Produces acknowledgments string for 3DSlicer. - std::string sAck = "This program implements the Single Target Correction (STC) partial volume correction (PVC) technique. Please cite the following paper:\n"; + std::string sAck = "This program implements the Single Target Correction (STC) partial volume correction (PVC) technique. Please cite the following:\n" + "Sari H, Erlandsson K, Law I, Larsson HB, Ourselin S, Arridge S, Atkinson D, Hutton BF.\n" + "Estimation of an image derived input function with MR-defined carotid arteries in FDG-PET human studies using a novel partial volume correction method.\n" + "J Cereb Blood Flow Metab. 2017;37(4): 1398--409\n\n" + "Erlanddsson K and Hutton BF.\n" + "A novel voxel-based partial volume correction method for single regions of interest.\n" + "J Nucl Med Meeting Abstr 2014; 55: 2023.\n"; return sAck; }