20 #include <boost/lexical_cast.hpp>
23 #include <itksys/SystemTools.hxx>
36 int main(
int argc,
char* argv[])
50 parser.
setTitle(
"Qball Reconstruction");
54 map<string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
55 if (parsedArgs.size()==0)
58 std::string inFileName =
us::any_cast<
string>(parsedArgs[
"input"]);
59 std::string outfilename =
us::any_cast<
string>(parsedArgs[
"outFile"]);
60 outfilename = itksys::SystemTools::GetFilenamePath(outfilename)+
"/"+itksys::SystemTools::GetFilenameWithoutExtension(outfilename);
63 if (parsedArgs.count(
"b0Threshold"))
64 threshold = us::any_cast<int>(parsedArgs[
"b0Threshold"]);
67 if (parsedArgs.count(
"shOrder"))
68 shOrder = us::any_cast<int>(parsedArgs[
"shOrder"]);
71 if (parsedArgs.count(
"lambda"))
72 lambda = us::any_cast<float>(parsedArgs[
"lambda"]);
74 int normalization = 0;
75 if (parsedArgs.count(
"csa") &&
us::any_cast<
bool>(parsedArgs[
"csa"]))
78 bool outCoeffs =
false;
79 if (parsedArgs.count(
"outputCoeffs"))
80 outCoeffs = us::any_cast<bool>(parsedArgs[
"outputCoeffs"]);
83 if (parsedArgs.count(
"mrtrix"))
84 mrTrix = us::any_cast<bool>(parsedArgs[
"mrtrix"]);
97 std::cout <<
"SH order: " << shOrder;
98 std::cout <<
"lambda: " << lambda;
99 std::cout <<
"B0 threshold: " << threshold;
111 filter->SetThreshold( threshold );
112 filter->SetLambda(lambda);
113 filter->SetUseMrtrixBasis(mrTrix);
114 if (normalization==0)
115 filter->SetNormalizationMethod(FilterType::QBAR_STANDARD);
117 filter->SetNormalizationMethod(FilterType::QBAR_SOLID_ANGLE);
119 image->InitializeByItk( filter->GetOutput() );
120 image->SetVolume( filter->GetOutput()->GetBufferPointer() );
121 coeffsImage->InitializeByItk( filter->GetCoefficientImage().GetPointer() );
122 coeffsImage->SetVolume( filter->GetCoefficientImage()->GetBufferPointer() );
134 filter->SetThreshold( threshold );
135 filter->SetLambda(lambda);
136 filter->SetUseMrtrixBasis(mrTrix);
137 if (normalization==0)
138 filter->SetNormalizationMethod(FilterType::QBAR_STANDARD);
140 filter->SetNormalizationMethod(FilterType::QBAR_SOLID_ANGLE);
142 image->InitializeByItk( filter->GetOutput() );
143 image->SetVolume( filter->GetOutput()->GetBufferPointer() );
144 coeffsImage->InitializeByItk( filter->GetCoefficientImage().GetPointer() );
145 coeffsImage->SetVolume( filter->GetCoefficientImage()->GetBufferPointer() );
157 filter->SetThreshold( threshold );
158 filter->SetLambda(lambda);
159 filter->SetUseMrtrixBasis(mrTrix);
160 if (normalization==0)
161 filter->SetNormalizationMethod(FilterType::QBAR_STANDARD);
163 filter->SetNormalizationMethod(FilterType::QBAR_SOLID_ANGLE);
165 image->InitializeByItk( filter->GetOutput() );
166 image->SetVolume( filter->GetOutput()->GetBufferPointer() );
167 coeffsImage->InitializeByItk( filter->GetCoefficientImage().GetPointer() );
168 coeffsImage->SetVolume( filter->GetCoefficientImage()->GetBufferPointer() );
180 filter->SetThreshold( threshold );
181 filter->SetLambda(lambda);
182 filter->SetUseMrtrixBasis(mrTrix);
183 if (normalization==0)
184 filter->SetNormalizationMethod(FilterType::QBAR_STANDARD);
186 filter->SetNormalizationMethod(FilterType::QBAR_SOLID_ANGLE);
188 image->InitializeByItk( filter->GetOutput() );
189 image->SetVolume( filter->GetOutput()->GetBufferPointer() );
190 coeffsImage->InitializeByItk( filter->GetCoefficientImage().GetPointer() );
191 coeffsImage->SetVolume( filter->GetCoefficientImage()->GetBufferPointer() );
203 filter->SetThreshold( threshold );
204 filter->SetLambda(lambda);
205 if (normalization==0)
206 filter->SetNormalizationMethod(FilterType::QBAR_STANDARD);
208 filter->SetNormalizationMethod(FilterType::QBAR_SOLID_ANGLE);
210 image->InitializeByItk( filter->GetOutput() );
211 image->SetVolume( filter->GetOutput()->GetBufferPointer() );
212 coeffsImage->InitializeByItk( filter->GetCoefficientImage().GetPointer() );
213 coeffsImage->SetVolume( filter->GetCoefficientImage()->GetBufferPointer() );
218 std::cout <<
"Supplied SH order not supported. Using default order of 4.";
226 filter->SetThreshold( threshold );
227 filter->SetLambda(lambda);
228 filter->SetUseMrtrixBasis(mrTrix);
229 if (normalization==0)
230 filter->SetNormalizationMethod(FilterType::QBAR_STANDARD);
232 filter->SetNormalizationMethod(FilterType::QBAR_SOLID_ANGLE);
234 image->InitializeByItk( filter->GetOutput() );
235 image->SetVolume( filter->GetOutput()->GetBufferPointer() );
236 coeffsImage->InitializeByItk( filter->GetCoefficientImage().GetPointer() );
237 coeffsImage->SetVolume( filter->GetCoefficientImage()->GetBufferPointer() );
241 std::string coeffout = outfilename;
242 coeffout +=
"_shcoeffs.nrrd";
244 outfilename +=
".qbi";
250 catch ( itk::ExceptionObject &err)
252 std::cout <<
"Exception: " << err;
254 catch ( std::exception err)
256 std::cout <<
"Exception: " << err.what();
260 std::cout <<
"Exception!";
void AverageRedundantGradients(double precision)
itk::SmartPointer< Self > Pointer
void setContributor(std::string contributor)
Helper class for mitk::Images containing diffusion weighted data.
DataCollection - Class to facilitate loading/accessing structured data.
ValueType * any_cast(Any *operand)
int main(int argc, char *argv[])
std::map< std::string, us::Any > parseArguments(const StringContainerType &arguments, bool *ok=nullptr)
void InitializeImage()
Make certain the owned image is up to date with all necessary properties.
static bool SaveImage(mitk::Image::Pointer image, const std::string &path)
SaveImage Convenience method to save an arbitrary mitkImage.
static bool SaveBaseData(mitk::BaseData *data, const std::string &path)
SaveBaseData Convenience method to save arbitrary baseData.
This class takes as input one or more reference image (acquired in the absence of diffusion sensitizi...
void addArgument(const std::string &longarg, const std::string &shortarg, Type type, const std::string &argLabel, const std::string &argHelp=std::string(), const us::Any &defaultValue=us::Any(), bool optional=true, bool ignoreRest=false, bool deprecated=false)
Image class for storing images.
void setCategory(std::string category)
void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix)
float GetReferenceBValue() const
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
GradientDirectionsContainerType::Pointer GetGradientContainer() const
static DataStorage::SetOfObjects::Pointer Load(const std::string &path, DataStorage &storage)
Load a file into the given DataStorage.
void setTitle(std::string title)
void setDescription(std::string description)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.