ctfInfo(API)
DataManip/ctfInfo is API fo CTF Correction.
Contents
- 1 constant
- 2 struct
- 3 API
- 3.1 Scattering
- 3.2 Signal
- 3.3 Noise
- 3.4 Calculate Vibration Function
- 3.5 Calculate CTF
- 3.6 Calculate Envelope
- 3.7 Calculate MTF
- 3.8 Calculate Sampling function
- 3.9 Get wavelength of the electron beam
- 3.10 Determination of defocus from Thon ring
- 3.11 Calculate weight for CTF Correction
- 3.12 Molecular Envelope
- 3.13 CTFInformation
- 3.14 Only when installed PVM
- 3.15 Help
constant
Mode
Mask data
#define ctfInfoModeWithAmplitudeContrast 0x0f #define ctfInfoModeWithMTF 0x10 #define ctfInfoModeWithIlluminationAngle 0x20 #define ctfInfoModeWithEnergySpread 0x40 #define ctfInfoModeAbsoluteValue 0x100
Value | Part of Mask | Description |
---|---|---|
ctfInfoModeWithAmplitudeContrast | 0x0f | Correction Mode |
ctfInfoModeWithMTF | 0x10 | Multiply MTF flag |
ctfInfoModeWithIlluminationAngle | 0x20 | Illumination Angle flag |
ctfInfoModeWithEnergySpread | 0x40 | Energy Spread flag |
ctfInfoModeAbsoluteValue | 0x100 | Absolute Value flag |
Define mode value
Contrast mode
For ctfInfo->mode (It supports to the value that is masked at ctfInfoModeWithAmplitudeContrast.)
typedef enum ctfInfoMode { ctfInfoModePhaseCTFOnly = 0, ctfInfoModePhaseAndAmpCTF = 1 } ctfInfoMode;
Variable | Value | Description |
---|---|---|
ctfInfoModePhaseCTFOnly | 0 | only Phase contrast |
ctfInfoModePhaseAndAmpCTF | 1 | + Intensity contrast |
Envelope's Mode
For ctfInfo->MTFMode
typedef enum ctfInfoMTFMode { ctfInfoMTFModeSingleExp = 0, ctfInfoMTFModeSingleLorentzian = 1, ctfInfoMTFModeBoth = 2, ctfInfoMTFModeLinear = 3, ctfInfoMTFModeBothSum = 4, ctfInfoMTFModePolynomial = 5 } ctfInfoMTFMode;
Variable | Value | Description |
---|---|---|
ctfInfoMTFModeSingleExp | 0 | Exponential |
ctfInfoMTFModeSingleLorentzian | 1 | Lorenz Function |
ctfInfoMTFModeBoth | 2 | Exponential x Lorenz Function |
ctfInfoMTFModeLinear | 3 | Linear |
ctfInfoMTFModeBothSum | 4 | Exponential + Lorenz Function |
ctfInfoMTFModePolynomial | 5 | Polynomial |
struct
Use for molecular envelope.
typedef struct moleculrEnvelope { char* filename; int nR; float* R; float* Envelope; int mode; } molecularEnvelope;
Setting as argument for these API.
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);