-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathCalcSpeckleSNR.m
More file actions
27 lines (23 loc) · 828 Bytes
/
Copy pathCalcSpeckleSNR.m
File metadata and controls
27 lines (23 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function [envSNR]=CalcSpeckleSNR(rfmat, axMinIndex, axMaxIndex)
% function [envSNR]=CalcSpeckleSNR
%
% Really crude script to calculate the SNR from rf001.mat at user-specific
% axial indices (around the focus), averaged over all lateral lines that exist.
% If you are expecting elegant code, then look elsewhere!
%
% INPUTS: rfmat (string) - RF data matlab file (e.g., 'rf001.mat')
% axMinIndex (int) - raw rf001.mat axial index (min)
% axMaxIndex (int)
%
% OUTPUTS: envSNR (int) - raw SNR of the envelope-detected data
%
% EXAMPLE: [speckle_snr] = CalcSpeckleSNR('rf001.mat', 2500, 2750);
%
load(rfmat);
env = abs(hilbert(rf(axMinIndex:axMaxIndex,:)));
for i = 1:size(rf,2),
envmean(i) = mean(env(:,i));
envstd(i) = std(env(:,i));
envSNRa(i) = envmean(i)/envstd(i);
end;
envSNR = mean(envSNRa);