# Sensitivity Measurement

SNR is the ratio of the peak value of the A-scan with a reflector on the sample arm and rms of the noise floor with the sample arm blocked.

Note that in the OCT community, SNR and sensitivity are sometimes used interchangeably 可交换的 (although technically they should be different). In our group, we will agree that SNR refers to the base measurement and Sensitivity is determined by also considering what ND filters were used. We should also report what power was incident on the sample for the measurement that was made.

This measurement process assumes your system is well enough aligned to get an interferogram.

## To perform an SNR measurement:

1. Make sure that your ND filters have been calibrated for the wavelength / light source you are using. The specifications are wavelength-dependent. To calibrate the ND filter, measure the power of a light source without a filter and after you add the filter. The decrease should tell you the actual OD of the filter for the wavelength you are using.
校准NDF，测量放NDF前后的光强，记录衰减。必须记录实际OD值和对应波长。

2. Add a reflector (mirror) in the sample arm.样品臂放置反射镜

3. Align the sample arm with the calibrated ND filter in place (this ensures that your alignment is as good as possible when you make the measurement).样品臂放置NDF校准样品臂，同时确保数字转换器范围接近期待值来最小化数字噪声。(make sure you set your digitizer range to nearly what you expect to measure to minimize digitization noise)

4. Adjust the reference arm power so that you are near to saturation with the current ND filter in the sample arm (this may require also having some sort of filter in the reference arm).调节参考镜功率接近饱和，此时样品臂有NDF，可能也需要NDF在参考臂。

5. Take an A-scan and find the peak. The reflector should be placed close to the DC point to reduce errors from fall-off（脱落）.记录信号，参考镜必须放置接近DC的地方来降低fall-off

6. Block the sample arm and take a measurement of the noise floor. (where the peak would normally be; use many pixels about where the peak would be; you can also take pixels from the same location as a function of time)挡住样品臂测试噪声，在peak所在的地方取值，

7. Take the ratio of the A-scan peak (linear scale) to the noise rms（root mean square均方根）. This number is your SNR. When reported in dB you should multiply it by 20.SNR = 20*log10(peak / noise_rms).We use 20log10 instead of 10log10 because in the interferometric equation, the information that corresponds to the peak of the A-scan value is proportional to the electric field from the sample (i.e., proportional to sqrt(Rs)*Es), not the intensity.

8. To calculate the sensitivity, add to the SNR the deficit caused by use of the ND filters. As mentioned above, the filter must be counted twice for double-passed light.

Sensitivity = SNR + 20*OD

where OD = optical density. This is because OD is already expressed in log10 form.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 14 18:45:30 2016

@author: zhuyue
"""

import matplotlib.pyplot as plt
import numpy as np
from scipy import signal
from scipy.fftpack import fft, fftshift

# %% Calibrate NDF 这是　放置NDF后光强 文件 和 原始光强 文件%%
INDF = 0.243 #uw
I0 = 294 #uw
OD = (np.log10(I0 / INDF))/2
#OD = max(od)
INDF_R = 44.4 #uw
I0_R = 294 #uw
OD_R = (np.log10(I0 / INDF_R))/2
# %% PEAK 这是　参考臂饱和样品臂NDF的干涉信号 文件%%

#%%initialization%%
SelRan = np.arange(0,2048,1)
window = signal.hann(SelRan.size)
AveRef = ref + sam

#%% Reshape %%
I = I - AveRef
I = I * window
S = fft(I, I.size)
Signal = np.abs(S)
peak_range = np.arange(0,50,1)
peak = max(Signal[peak_range])

# %% NOISE 这是　noise floor 文件　%%
N = np.abs(fft(N, N.size))
noise_range = np.arange(500,1023,1)
Noise = N[noise_range]

# %% RMS %%
from math import sqrt
def qmean(num):
return sqrt(sum(n*n for n in num)/len(num))
noise_rms = qmean(Noise)

sensi = 20 * np.log10 (peak / noise_rms) + 20 * OD + 20 * OD_R


## What I learned from:

• Optical power meter 要确定波长范围再读数据
• Noise floor
• Turn off the laser and make a reading
• Turn on the laser and block the sample
• Use a section of the FFT where there’s no signal as noise floor.