7 #ifndef Tomato_OXSIGNCALCULATORSHMOLLI_H 8 #define Tomato_OXSIGNCALCULATORSHMOLLI_H 21 template<
typename MeasureType >
35 for (
int i = 0; i < this->getNSamples(); ++i) {
36 if (this->getSigns()[i] != 0) {
37 this->getSignal()[i] = this->getSigns()[i] * (this->getSigMag()[i]);
45 const MeasureType* invTimes,
46 const MeasureType* sigMag,
47 const MeasureType* sigPha,
54 virtual double getPhaMin() {
return _phaMin; }
55 virtual double getPhaMax() {
return _phaMax; }
57 virtual void setPhaMin(
int _phaMin) { SignCalculatorShmolli::_phaMin = _phaMin; }
58 virtual void setPhaMax(
int _phaMax) { SignCalculatorShmolli::_phaMax = _phaMax; }
66 this->_phaMin = -4096;
75 this->_nSamples = old._nSamples;
76 this->_phaMin = old._phaMin;
77 this->_phaMax = old._phaMax;
90 const static int MAX_MOLLI_TI_SAMPLES = 128;
91 const static int MAX_T1_TRESHOLD = 4000;
100 template<
typename MeasureType>
105 const MeasureType* invTimes,
106 const MeasureType* sigMag,
107 const MeasureType* sigPha,
111 MeasureType phaMax) {
116 KWUtil::copyArrayToArray(nSamples, signal, sigMag);
118 double MaxTIForSignInvert = (MAX_T1_TRESHOLD * 0.67);
122 double zeroRangeFraction = 0.3;
123 double PIrange = (phaMax - phaMin) / 2;
124 double PI05 = PIrange * 0.5;
125 double PIx2 = PIrange * 2;
126 int IsPhaseErrorFound = 0;
128 double upmap[MAX_MOLLI_TI_SAMPLES];
129 double PhaseAway[MAX_MOLLI_TI_SAMPLES];
131 int nsignspositive = 0;
132 int nsignsnegative = 0;
134 for (
int i = 0; i < nSamples; i++) {
135 upmap[i] = fmod(PIx2 + sigPha[i] - sigPha[0], PIx2);
136 PhaseAway[i] = fabs(upmap[i] - PIrange);
137 PhaseAway[i] = ((PI05 - PhaseAway[i]) /
138 (zeroRangeFraction * PI05));
139 if (PhaseAway[i] < -1) {
143 else if (PhaseAway[i] > 1) {
148 if ((signs[i] < 0) && (invTimes[i] > MaxTIForSignInvert))
150 IsPhaseErrorFound = 1;
154 if ((nsignspositive == 0) || (nsignsnegative == 0))
168 if (invTimes[nSamples - 1] > MaxTIForSignInvert) {
169 for (
int i = 0; i < nSamples; i++) signs[i] = 1;
174 double y1andlast4[MAX_MOLLI_TI_SAMPLES];
175 double x1andlast4[MAX_MOLLI_TI_SAMPLES];
176 double R1andlast4 = 0;
177 double dummySl, dummyOff;
178 y1andlast4[0] = sigMag[0];
179 x1andlast4[0] = invTimes[0];
180 for (
int i = 0; i < 4; i++)
181 y1andlast4[i + 1] = sigMag[nSamples - 1 - i];
182 for (
int i = 0; i < 4; i++)
183 x1andlast4[i + 1] = invTimes[nSamples - 1 - i];
185 R1andlast4 = KWUtil::SKPLinReg(x1andlast4, y1andlast4, 5, dummySl, dummyOff);
189 for (
int i = 0; i < nSamples; i++)signs[i] = -1;
193 double Rfirst4 = KWUtil::SKPLinReg(invTimes, sigMag, 4, dummySl, dummyOff);
194 double Rlast4 = KWUtil::SKPLinReg(invTimes + nSamples - 4,
195 sigMag + nSamples - 4, 4, dummySl, dummyOff);
196 if ((Rfirst4 > Rlast4) && (Rfirst4 > R1andlast4)) {
197 for (
int i = 0; i < nSamples; i++) signs[i] = 1;
202 for (
int i = 0; i < nSamples; i++) signs[i] = 1;
205 return (!IsPhaseErrorFound);
210 #endif //Tomato_OXSIGNCALCULATOR_H SignCalculatorShmolli(const SignCalculatorShmolli &old)
copy constructor
Definition: OxSignCalculatorShmolli.h:73
virtual int calculateSign()
Definition: OxSignCalculatorShmolli.h:25
virtual SignCalculator< MeasureType > * newByCloning()
Definition: OxSignCalculatorShmolli.h:84
static int SKPPhase2Signs(int nSamples, const MeasureType *invTimes, const MeasureType *sigMag, const MeasureType *sigPha, MeasureType *signal, MeasureType *signs, MeasureType phaMin, MeasureType phaMax)
Definition: OxSignCalculatorShmolli.h:103
void setAllPointersToNull()
set all the pointers to zero
Definition: OxSignCalculator.h:84
Definition: OxSignCalculator.h:21
Definition: OxCalculator.h:19
SignCalculatorShmolli()
constructor
Definition: OxSignCalculatorShmolli.h:63
Definition: OxSignCalculatorShmolli.h:22