Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add checks/warnings on ROI in STC #63

Merged
merged 2 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/petpvcSTCPVCImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ using namespace itk;

namespace petpvc
{

/*! Single Target Correction (STC)

An Implementation of the STC Method, see<br>
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
<br>
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 >
{
Expand Down
23 changes: 23 additions & 0 deletions lib/petpvcSTCPVCImageFilter.txx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "itkObjectFactory.h"
#include "itkImageRegionIterator.h"
#include "itkImageRegionConstIterator.h"
#include <stdexcept>

using namespace itk;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 );

Expand Down
23 changes: 20 additions & 3 deletions src/STC.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.

*/

Expand Down Expand Up @@ -125,6 +133,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) {
Expand Down Expand Up @@ -195,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;
}