Statismo  0.10.1
 All Classes Namespaces Functions Typedefs
itkConditionalModelBuilder.h
1 /*
2  * This file is part of the statismo library.
3  *
4  * Author: Marcel Luethi (marcel.luethi@unibas.ch)
5  *
6  * Copyright (c) 2011 University of Basel
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  *
16  * Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in the
18  * documentation and/or other materials provided with the distribution.
19  *
20  * Neither the name of the project's author nor the names of its
21  * contributors may be used to endorse or promote products derived from
22  * this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
30  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 
39 #ifndef ITKMODELBUILDER_H_
40 #define ITKMODELBUILDER_H_
41 
42 #include <itkObject.h>
43 #include <itkObjectFactory.h>
44 
45 #include "itkDataManager.h"
46 #include "itkStatisticalModel.h"
47 #include "ConditionalModelBuilder.h"
48 #include "statismoITKConfig.h"
49 
50 namespace itk {
51 
56 template <class Representer>
57 class ConditionalModelBuilder : public Object {
58  public:
59 
61  typedef Object Superclass;
62  typedef SmartPointer<Self> Pointer;
63  typedef SmartPointer<const Self> ConstPointer;
64 
65  itkNewMacro( Self );
66  itkTypeMacro( ConditionalModelBuilder, Object );
67 
68 
71  typedef typename DataManagerType::SampleDataStructureListType SampleDataStructureListType;
72 
74 
75  virtual ~ConditionalModelBuilder() {
76  if (m_impl) {
77  delete m_impl;
78  m_impl = 0;
79  }
80  }
81 
82  template <class F>
83  typename boost::result_of<F()>::type callstatismoImpl(F f) const {
84  try {
85  return f();
87  itkExceptionMacro(<< s.what());
88  }
89  }
90 
91 
92  typename StatisticalModel<Representer>::Pointer
93  BuildNewModel(SampleDataStructureListType SampleDataStructureList,
95  const typename statismo::ConditionalModelBuilder<Representer>::CondVariableValueVectorType& conditioningInfo,
96  float noiseVariance,
97  double modelVarianceRetained
98  ) {
99  statismo::StatisticalModel<Representer>* model_statismo = callstatismoImpl(boost::bind(&ImplType::BuildNewModel, this->m_impl, SampleDataStructureList, surrogateTypes, conditioningInfo, noiseVariance, modelVarianceRetained));
100  typename StatisticalModel<Representer>::Pointer model_itk = StatisticalModel<Representer>::New();
101  model_itk->SetstatismoImplObj(model_statismo);
102  return model_itk;
103  }
104 
105 
106  private:
108  ConditionalModelBuilder& operator=(const ConditionalModelBuilder& rhs);
109 
110  ImplType* m_impl;
111 };
112 
113 
114 }
115 
116 #endif /* ITKMODELBUILDER_H_ */
ITK Wrapper for the statismo::PCAModelBuilder class.
Definition: itkConditionalModelBuilder.h:57
StatisticalModelType * BuildNewModel(const DataItemListType &sampleSet, const SurrogateTypeInfoType &surrogateTypesInfo, const CondVariableValueVectorType &conditioningInfo, float noiseVariance, double modelVarianceRetained=1) const
Definition: ConditionalModelBuilder.hxx:126
Creates a StatisticalModel conditioned on some external data.
Definition: ConditionalModelBuilder.h:73
Generic Exception class for the statismo Library.
Definition: Exceptions.h:68
static ConditionalModelBuilder * Create()
Definition: ConditionalModelBuilder.h:91
A Point/Value pair that is used to specify a value at a given point.
Definition: StatisticalModel.h:100
ITK Wrapper for the statismo::StatisticalModel class.
Definition: itkStatisticalModel.h:62