SIVIC API  0.9.26
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
svkMRSFirstPointPhaseCostFunction.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_POINT_PHASE_COST_FUNCTION_H
43 #define SVK_MRS_FIRST_POINT_PHASE_COST_FUNCTION_H
44 
45 #include <svkPhaseCostFunction.h>
46 
47 
48 using namespace svk;
49 
50 /*
51  * Cost function for ITK optimizer:
52  */
54 {
55 
56  public:
57 
60  typedef itk::SmartPointer<Self> Pointer;
61  typedef itk::SmartPointer<const Self> ConstPointer;
62 
63  itkNewMacro( Self );
65  //itkTypeRevisionMacro( svkMRSFirstPointPhaseCostFunction, svkPhaseCostFunction);
66 
67 
69  }
70 
71 
76  {
77 
78  //++POWELL_CALLS_TO_GET_VALUE;
79 
80  double phi0 = parameters[0];
81 
82  double intensity = FLT_MIN;
83  float cmplxPt[2];
84  double tmp;
85 
86  // apply zero order phase to data:
87  this->copySpectrum->GetTupleValue(0, cmplxPt);
88  svk::svkPhaseSpec::ZeroOrderPhase(phi0, cmplxPt);
89 
90  // maximize positive peak height (minimize negative peak ht)
91  tmp = -1*cmplxPt[0];
92  //if ( tmp >= intensity) {
93  intensity= tmp;
94  //cout << "new phase: " << phi0 * 180. / vtkMath::Pi() << " " << intensity << endl;
95  //}
96 
97  MeasureType measure = intensity;
98  return measure;
99  }
100 
101 
102  /*
103  * returns the cost function for the current param values:
104  * typedef double MeasureType
105  */
106  virtual MeasureType GetValue( const ParametersType & parameters ) const
107  {
108 
109  double cost;
110 
111  // make a member variable (copy)
112  //cout << "copy spectrum" << endl;
113  this->copySpectrum->DeepCopy(this->spectrum);
114  cost = GetFirstPointPhaseValue0( parameters );
115 
116  MeasureType measure = cost;
117  //cout << " cost: " << measure << endl;
118  return measure;
119  }
120 
121 
122  /*
123  *
124  */
125  virtual unsigned int GetNumberOfParameters(void) const
126  {
127  return 1;
128  }
129 
130 
131 };
132 
133 
134 
135 #endif// SVK_MRS_FIRST_POINT_PHASE_COST_FUNCTION_H
svkPhaseCostFunction Superclass
Definition: svkMRSFirstPointPhaseCostFunction.h:59
itk::SmartPointer< const Self > ConstPointer
Definition: svkMRSFirstPointPhaseCostFunction.h:61
Definition: svkPhaseCostFunction.h:64
Superclass::MeasureType MeasureType
Definition: svkPhaseCostFunction.h:79
itk::SmartPointer< Self > Pointer
Definition: svkMRSFirstPointPhaseCostFunction.h:60
svkMRSFirstPointPhaseCostFunction()
Definition: svkMRSFirstPointPhaseCostFunction.h:68
virtual unsigned int GetNumberOfParameters(void) const
Definition: svkMRSFirstPointPhaseCostFunction.h:125
MeasureType GetFirstPointPhaseValue0(const ParametersType &parameters) const
Definition: svkMRSFirstPointPhaseCostFunction.h:75
Definition: svkMRSFirstPointPhaseCostFunction.h:53
static void ZeroOrderPhase(float phi0, float *cmplxPt)
Definition: svkPhaseSpec.cc:339
virtual MeasureType GetValue(const ParametersType &parameters) const
Definition: svkMRSFirstPointPhaseCostFunction.h:106
Superclass::ParametersType ParametersType
Definition: svkPhaseCostFunction.h:77
svkMRSFirstPointPhaseCostFunction Self
Definition: svkMRSFirstPointPhaseCostFunction.h:58