22 #include "DWINoiseGeneratorCLP.h" 28 main (
int argc,
char const* argv[])
38 typedef itk::VectorImage<double, 3> ImageType;
40 typedef itk::Image<double, 3> MaskImageType;
41 typedef itk::Image<double, 3> B0ImageType;
43 ImageType::Pointer dwi;
44 ImageType::Pointer dwiNoise;
45 B0ImageType::Pointer b0;
46 MaskImageType::Pointer mask;
49 AddNoiseFilterType::Pointer addNoiseFilter = AddNoiseFilterType::New();
51 itk::ReadVectorImage<double>(_InputFile, dwi);
53 addNoiseFilter->SetInput(dwi);
54 if (_b0FileArg.isSet())
56 itk::ReadImage<B0ImageType>(_b0File, b0);
58 addNoiseFilter->SetB0Image(b0);
60 if (_maskFileArg.isSet())
62 itk::ReadImage<MaskImageType>(_maskFile, mask);
63 addNoiseFilter->SetMaskImage(mask);
66 utlException(_NoiseSigmaArg.isSet() && _SNRArg.isSet(),
"Only one of these is allowed: --noisesigma or --snr");
67 utlException(!_NoiseSigmaArg.isSet() && !_SNRArg.isSet(),
"Set --noisesigma or --snr");
68 if (_NoiseSigmaArg.isSet())
69 addNoiseFilter->SetSigma(_NoiseSigma);
71 addNoiseFilter->SetSigma(1.0/_SNR);
73 if (_Noisetype==
"GAUSSIAN")
74 addNoiseFilter->SetNoisetype(AddNoiseFilterType::GAUSSIAN);
75 if (_Noisetype==
"RICIAN")
76 addNoiseFilter->SetNoisetype(AddNoiseFilterType::RICIAN);
80 addNoiseFilter->Update();
82 dwiNoise = addNoiseFilter->GetOutput();
83 itk::SaveImage<ImageType>(dwiNoise,_OutputFile);
helper functions specifically used in dmritool
#define utlException(cond, expout)
int main(int argc, char const *argv[])
add Gaussian or Rician noise to DWI data