SIVIC API  0.9.26
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
svkMRSFirstOrderPhaseCostFunction.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2009-2014 The Regents of the University of California.
3  * All Rights Reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * • Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * • Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  * • None of the names of any campus of the University of California, the name
13  * "The Regents of the University of California," or the names of any of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
26  * OF SUCH DAMAGE.
27  */
28 
29 
30 
31 /*
32  * $URL$
33  * $Rev$
34  * $Author$
35  * $Date$
36  *
37  * Authors:
38  * Jason C. Crane, Ph.D.
39  * Beck Olson,
40  */
41 
42 #ifndef SVK_MRS_FIRST_ORDER_PHASE_COST_FUNCTION_H
43 #define SVK_MRS_FIRST_ORDER_PHASE_COST_FUNCTION_H
44 
45 
46 #include <vtkMath.h>
47 
48 #include <svkMRSAutoPhase.h>
49 #include <svkPhaseSpec.h>
50 
51 #include <math.h>
52 
53 
54 using namespace svk;
55 
56 
57 /*
58  * Cost function for ITK optimizer:
59  */
60 class svkMRSFirstOrderPhaseCostFunction : public itk::SingleValuedCostFunction
61 {
62 
63  public:
64 
66  itkTypeMacro( svkMRSFirstOrderPhaseCostFunction, SingleValuedCostFunction );
67 
68  itkNewMacro( Self );
69 
70 
72  {
73  }
74 
75 
79  MeasureType GetFirstOrderPhaseValue0( const ParametersType& parameters) const
80  {
81 
82  //++POWELL_CALLS_TO_GET_VALUE;
83 
84  double phi0 = parameters[0];
85  double phi1 = parameters[1];
86 
87  double intensity = FLT_MIN;
88  float cmplxPt[2];
89  double tmp;
90 
91  // apply first order phase to data:
92  this->copySpectrum->GetTupleValue(0, cmplxPt);
93  //svk::svkPhaseSpec::ZeroOrderPhase(phi0, cmplxPt);
94 
95  // maximize positive peak height (minimize negative peak ht)
96  tmp = -1*cmplxPt[0];
97  intensity= tmp;
98 
99  MeasureType measure = intensity;
100  return measure;
101  }
102 
103 
104  /*
105  * returns the cost function for the current param values:
106  * typedef double MeasureType
107  */
108  virtual MeasureType GetValue( const ParametersType & parameters ) const
109  {
110 
111  double cost;
112 
113  // make a member variable (copy)
114  //cout << "copy spectrum" << endl;
115  this->copySpectrum->DeepCopy(this->spectrum);
116  cost = GetFirstOrderPhaseValue( parameters );
117 
118  MeasureType measure = cost;
119  //cout << " cost: " << measure << endl;
120  return measure;
121  }
122 
123 
127  virtual unsigned int GetNumberOfParameters(void) const
128  {
129  return 3;
130  }
131 
132 
133  /*
134  *
135  */
136  void SetLinearPhaseArrays( vtkImageComplex** linearPhaseArrays)
137  {
138  this->linearPhaseArrays = linearPhaseArrays;
139  }
140 
141 
142  /*
143  *
144  */
145  void SetNumFirstOrderPhaseValues( int numPhaseValues )
146  {
147  this->numFirstOrderPhaseValues = numPhaseValues;
148  }
149 
150 
151 
152  protected:
153 
154  vtkImageComplex** linearPhaseArrays;
156 
157 
158 };
159 
160 
161 
162 #endif// SVK_MRS_FIRST_ORDER_PHASE_COST_FUNCTION_H
void SetNumFirstOrderPhaseValues(int numPhaseValues)
Definition: svkMRSFirstOrderPhaseCostFunction.h:145
svkMRSFirstOrderPhaseCostFunction()
Definition: svkMRSFirstOrderPhaseCostFunction.h:71
virtual MeasureType GetValue(const ParametersType &parameters) const
Definition: svkMRSFirstOrderPhaseCostFunction.h:108
int numFirstOrderPhaseValues
Definition: svkMRSFirstOrderPhaseCostFunction.h:155
vtkImageComplex ** linearPhaseArrays
Definition: svkMRSFirstOrderPhaseCostFunction.h:154
svkMRSFirstOrderPhaseCostFunction Self
Definition: svkMRSFirstOrderPhaseCostFunction.h:65
virtual unsigned int GetNumberOfParameters(void) const
Definition: svkMRSFirstOrderPhaseCostFunction.h:127
Definition: svkMRSFirstOrderPhaseCostFunction.h:60
MeasureType GetFirstOrderPhaseValue0(const ParametersType &parameters) const
Definition: svkMRSFirstOrderPhaseCostFunction.h:79
void SetLinearPhaseArrays(vtkImageComplex **linearPhaseArrays)
Definition: svkMRSFirstOrderPhaseCostFunction.h:136