Difference between revisions of "ctfInfo(API)"

From EosPedia
Jump to: navigation, search
(API)
(API)
Line 312: Line 312:
 
<tr>  
 
<tr>  
 
<td>0</td>  
 
<td>0</td>  
<td>return 1(No correction)</td>  
+
<td>return 1(No Correction)</td>  
 
</tr>  
 
</tr>  
 
<tr>  
 
<tr>  
 
<td>1</td>  
 
<td>1</td>  
<td>ctf/|ctf| (逆位相)</td>  
+
<td>ctf/|ctf| (phase flipping)</td>  
 
</tr>  
 
</tr>  
 
<tr>  
 
<tr>  
 
<td>2</td>  
 
<td>2</td>  
<td>ctf (逆位相 x  CTF Correction)</td>  
+
<td>ctf (phase flipping and ctf-multiplying)</td>  
 
</tr>  
 
</tr>  
 
<tr>  
 
<tr>  
 
<td>3</td>  
 
<td>3</td>  
<td>1/ctf    (0.1<|ctf| ) ( CTF Correction / 逆位相)</td>  
+
<td>1/ctf    (0.1<|ctf| ) (phase flipping and ctf-divided)</td>  
 
</tr>  
 
</tr>  
 
<tr>  
 
<tr>  
Line 346: Line 346:
 
<br>
 
<br>
  
===== 2Dの場合 =====
+
===== Case 2D =====
X, YからRを求めて引数としてctfWeightForCorrectionを呼び出す
+
Calculate R by X and Y. Then call ctfWeightForCorrection with it as argument.
 
  extern float ctfWeightForCorrection2D(ctfInfo* info, float X, float Y, long mode);
 
  extern float ctfWeightForCorrection2D(ctfInfo* info, float X, float Y, long mode);
  
==== 分子のEnvelope ====
+
==== Molecular Envelope ====
fileRead
+
File Read
 
  extern void lmolecularEnvelopeFileRead(FILE* fpt, molecularEnvelope* mol, int mode);
 
  extern void lmolecularEnvelopeFileRead(FILE* fpt, molecularEnvelope* mol, int mode);
file書き出し
+
File Write
 
  extern void lmolecularEnvelopeFileWrite(FILE* fpt, molecularEnvelope* mol, int mode);
 
  extern void lmolecularEnvelopeFileWrite(FILE* fpt, molecularEnvelope* mol, int mode);
 
Resampling
 
Resampling
 
  extern void lmolecularEnvelopeResampling(molecularEnvelope* dst, molecularEnvelope* src, float dR, float RMax, int mode);
 
  extern void lmolecularEnvelopeResampling(molecularEnvelope* dst, molecularEnvelope* src, float dR, float RMax, int mode);
srcにおけるRのEnvelope値を取得
+
Get the Envelope of src at R.
 
  extern float lmolecularEnvelopeDataGet(molecularEnvelope* src, float R, int mode);
 
  extern float lmolecularEnvelopeDataGet(molecularEnvelope* src, float R, int mode);
  
 
==== CTFInformation ====
 
==== CTFInformation ====
fileRead
+
File Read
 
  extern void ctfInfoRead(FILE* fpt, ctfInfo* ctf, char* pre, int mode);
 
  extern void ctfInfoRead(FILE* fpt, ctfInfo* ctf, char* pre, int mode);
file書き出し
+
File Write
 
  extern void ctfInfoWrite(FILE* fpt, ctfInfo ctf, char* pre, int mode);
 
  extern void ctfInfoWrite(FILE* fpt, ctfInfo ctf, char* pre, int mode);
  

Revision as of 08:45, 25 September 2014

DataManip/ctfInfo is API fo CTF Correction.

constant

#define ctfInfoModeWithAmplitudeContrast    0x0f
#define ctfInfoModeWithMTF                  0x10
#define ctfInfoModeWithIlluminationAngle    0x20
#define ctfInfoModeWithEnergySpread         0x40
#define ctfInfoModeAbsoluteValue            0x100 
typedef enum ctfInfoMode {
	ctfInfoModePhaseCTFOnly   = 0,
	ctfInfoModePhaseAndAmpCTF = 1 
} ctfInfoMode;
typedef enum ctfInfoMTFMode {
	ctfInfoMTFModeSingleExp = 0,
	ctfInfoMTFModeSingleLorentzian = 1,
	ctfInfoMTFModeBoth      = 2,
	ctfInfoMTFModeLinear    = 3, 
	ctfInfoMTFModeBothSum   = 4,
	ctfInfoMTFModePolynomial = 5
} ctfInfoMTFMode;

struct

typedef struct moleculrEnvelope {
	char* filename; 
	int   nR;
	float* R;
	float* Envelope;
	int    mode;	
} molecularEnvelope;
typedef struct ctfInfo {
	float kV;      /* kV */
	float defocus; /* A : Underfocus is plus, while overfocus is minus*/
	float Cc;      /* mm */
	float dE; 
	float Cs;      /* mm */
	float Ain;     /* mrad : Illumination Angle */
	long  flagWin; /* Windowing */ 
	float CutLow;  /* Windowing: CutLow  A-1 */
	float CutHigh; /* Windowing: CutHigh A-1 */

	float I0;      /* Intensity */
	float Isignal; /* Intensity of signal */

	float ratioOfAmpToPhase; /* The ratio of amp to phase */

	float Inoise;  /* Intensity of noise : Isignal*/
	long  flagWhiteNoise;
	float WhiteNoise;  /* Affected by MTF(R) */

	long  flagWhiteNoiseRaising; 	
	float WhiteNoiseRaising; /* WhiteNoise Raising depending upon R */

	float Inoise2; /* Intensity of noise */
	long  flagWhiteNoise2;
	float WhiteNoise2; /* Not Affected by MTF(R)*/

	int   flagAstigmatism;
	float defocus2D[2];      /* A : Normally [0]: Max [1]: Min */
	float defocus0axis;      /* radian : angle of the defocus2D[0]-axis */

	long mode;
	
	long  flagMagnification;	
	float Magnification;

	/* MTF(R): Modulation Transfer Function */ 
	ctfInfoMTFMode MTFMode;
	float BofMTF;  /* Exponential: exp(-B R)   */
	float BofMTF2; /* Lorentzian : 1/(B*B+R*R) */	
	float WeightOfSecondTermForMTF; /* 0 <-> 1 */
	/*for PolynomialExpNoise*//*d = degree*/
	float BofMTFd2;
	float BofMTFd3;
	float BofMTFd4;
	float BofMTFd5;
	float BofMTFd6;

	/* Molecular Envelope: Scattering Factor */
	/* For Gaussian */
	float MolecEnv;                   /* A : */
	/* For Table */
	long  flagMolecEnvTable;
	molecularEnvelope MolecEnvTable;
	/* For Lorentzian */
	float flagElastic;
	float Elastic;
	float ElasticShift;
	float ElasticWidth;
	float ElasticRing;
	float ElasticRingPosition;
	float ElasticRingWidth;

	/* Stage Vibration */
	long  flagVibration;
	long  VibrationMode;
	float BofVibration;

	/* Aliasing and Sampling */
	long flagAliasing;
	float NyquistFrequency;
	long flagSampling; 

	/* Inelastic Signal */
	/* For Gaussian */
	long flagWithInElastic;
	float InElasticGaussian;
	/* For Table */
	long flagWithInElasticTable;
	molecularEnvelope InElasticEnvTable;	
	/* Lorentzian */	
	long flagInElastic;
	float InElastic;
	float InElasticShift;
	float InElasticWidth;
	float InElasticRing;
	float InElasticRingPosition;
	float InElasticRingWidth;
} ctfInfo;

API

Scattering

Return the value that is added Signal(by ctfSignalFunction) and Noise(by ctfNoiseFunction).

extern float ctfScatteringFunction(ctfInfo* info, float R, long mode);

Signal

Output the signal.
(use ctfFunction, ctfMolecularEnvelopeFunction, ctfMolecularEnvelopeInElasticFunction, ctfVibrationFunction, ctfMTFFunction)
if info->flagAliasing=true: add Aliasing. (use info->NyquistFrequency)

extern float ctfSignalFunction(ctfInfo* info, float R, long mode);

Output the signal power about above.

extern float ctfSignalPowerFunction(ctfInfo* info, float R, long mode);
Calculate Molecular Envelope

if info->flagMolecEnvTable=true: call lmolecularEnvelopeDataGet, use table data(by info->MolecEnvTable)

extern float ctfMolecularEnvelopeFunction(ctfInfo* info, float R, long mode);
extern float ctfMolecularEnvelopeInElasticFunction(ctfInfo* info, float R, long mode);

Noise

Output noise that is multiplied White noise(info->WhiteNoise) and MTF(by ctfMTFFunction).
if info->flagAliasing=true: add Aliasing.(use info->NyquistFrequency)

extern float ctfNoiseFunction(ctfInfo* info, float R, long mode);

Output the noise power about above.

extern float ctfNoisePowerFunction(ctfInfo* info, float R, long mode);

Output noise by using White noise of info->WhiteNoise2.

extern float ctfNoise2Function(ctfInfo* info, float R, long mode);

Output the noise power about above.

extern float ctfNoise2PowerFunction(ctfInfo* info, float R, long mode);

Calculate Vibration Function

Calculate Vibration Function at R.
info->Magnification: RのMagnification

extern float ctfVibrationFunction(ctfInfo* info, float R, long mode);

if info->flagVibration=true and info->VibrationMode=0: Output Vibration Function: Env = exp(-B*B*R*R/2.0)(Otherwise: output 1)

Calculate CTF

extern float ctfFunction(ctfInfo* info, float R, long mode);

Calculate CTF at R
Wavelength of the electron beam: by wavelengthOfElectron
Contrast: set the method by info->mode

info->mode(Mask at 0x0f) Description
0 only Phase contrast
1 + Intensity contrast


Case 2D

Calculate R by X and Y. Then call cfFunction with it as argument.

extern float ctfFunction2D(ctfInfo* info, float X, float Y, long mode);

Calculate Envelope

extern float ctfEnvelopFunction(ctfInfo* info, float R, long mode);

Calculate Envelope at R
Wavelength of the electron beam: by wavelengthOfElectron
if info->flagMagnification=1: multiply R and info->Magnification(without 0).

info->mode part of mask Description
ctfInfoModeWithMTF 0x10 multiply MTF(by calling ctfMTFFunction)
ctfInfoModeWithIlluminationAngle 0x20 multiply the value with Illumination Angle(info->Ain)
ctfInfoModeWithEnergySpread 0x40 multiply the value with Energy Spread


Calculate MTF

extern float ctfMTFFunction(ctfInfo* info, float R, long mode);

Calculate MTF at R
info->Magnification: Magnification of R
if info->flagSampling=1: multiply the sampling function (by calling ctfFunctionSampling: info->NyquistFrequency is 2nd argument as Nyquist)

Variable Value Description used info's member by MTF
ctfInfoMTFModeSingleExp 0 Exponential BofMTF
ctfInfoMTFModeSingleLorentzian 1 Lorenz Function BofMTF2
ctfInfoMTFModeBoth 2 Exponential x Lorenz Function BofMTF, BofMTF2
ctfInfoMTFModeLinear 3 Linear BofMTF
ctfInfoMTFModeBothSum 4 Exponential + Lorenz Function BofMTF, BofMTF2, WeightOfSecondTermForMTF(Ratio of addition)
ctfInfoMTFModePolynomial 5 Polynomial BofMTF, BofMTFd2, BofMTFd3, BofMTFd4, BofMTFd5


Calculate Sampling function

Calculate Sampling function at R.

extern float ctfFunctionSampling(float R, float Nyquist, long mode);

Get wavelength of the electron beam

extern float wavelengthOfElectron(float E);

Determination of defocus from Thon ring

extern float defocusDeterminationFromThonRing(ctfInfo* info, float R, long n, long mode);

Wavelength of the electron beam: by wavelengthOfElectron
Contrast: set the method by info->mode

info->mode(Mask at 0x0f) Description
0 only Phase contrast
1 + Intensity contrast


Calculate weight for CTF Correction

Output the weight for CTF Correction.
extern float ctfWeightForCorrection(ctfInfo* info, float R, long mode);
mode Description
0 return 1(No Correction)
1 ctf/|ctf| (phase flipping)
2 ctf (phase flipping and ctf-multiplying)
3 1/ctf (0.1<|ctf| ) (phase flipping and ctf-divided)
4 ctf/(SQR(ctf)+SQR(NS)) phase-flipping + Winner Filtering
5 SQR(ctf) x ctf/|ctf| phase-flipping + ctf-Weighted
6 1/|ctf| (0.1<|ctf|) No phase-flipping + ctf-divided
7 |ctf|/(SQR(ctf)+SQR(NS)) No phase flipping + Winner Filtering


Case 2D

Calculate R by X and Y. Then call ctfWeightForCorrection with it as argument.

extern float ctfWeightForCorrection2D(ctfInfo* info, float X, float Y, long mode);

Molecular Envelope

File Read

extern void lmolecularEnvelopeFileRead(FILE* fpt, molecularEnvelope* mol, int mode);

File Write

extern void lmolecularEnvelopeFileWrite(FILE* fpt, molecularEnvelope* mol, int mode);

Resampling

extern void lmolecularEnvelopeResampling(molecularEnvelope* dst, molecularEnvelope* src, float dR, float RMax, int mode);

Get the Envelope of src at R.

extern float lmolecularEnvelopeDataGet(molecularEnvelope* src, float R, int mode);

CTFInformation

File Read

extern void ctfInfoRead(FILE* fpt, ctfInfo* ctf, char* pre, int mode);

File Write

extern void ctfInfoWrite(FILE* fpt, ctfInfo ctf, char* pre, int mode);

Only when installed PVM

extern void ctfInfoSendByPVM(ctfInfo* info, int tid, long mode);
extern void ctfInfoRecieveByPVM(ctfInfo* info, int tid, long mode);
extern void  ctfFunctionPVMStart(ctfInfo* info, float R, int tid, long mode);
extern float ctfFunctionPVMEnd(ctfInfo* info, float R, int tid, long mode);
extern void  ctfFunctionPVMServer();

Help

extern void ctfWeightForCorrectionUsage(FILE* fpt);