-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_OCT_convert.m
47 lines (41 loc) · 1.77 KB
/
test_OCT_convert.m
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function test_OCT_convert()
% This function demonstrates how to load the mat 'test.mat' file generated by the OCT_converter.py.
% See the code line load('test.mat');
%
% The mat file contains Spectral as 3D or 2D data matrix.
% All other data are left with the same name without '.data' attached, like 'Chirp', 'OffsetSpectrum', 'OffsetErrors', etc.
%
% This demonstration does not apply intensity scaling.
%
close('all');
load('test.mat')
% The 3D matrix Spectral is immediately after loading test.mat available
% Here the A-line at 1000 for B-frame (1) is obtained
pdata = (squeeze(Spectral(1,1000,:)));
figure('name','Raw spectrum');plot(pdata)
% Get the mean of the apodisation data if it was stored as a region in Spectral.
% The variable Spectral_apo will be available.
mdata = (squeeze(mean(Spectral_apo(1,:,:))))';
% Get B-frame (1)
spec = single(squeeze(Spectral(1,:,:)));
spec_size = size(spec);
spec_xs = spec_size(1);
spec_zs = spec_size(2);
% remove DC
spec = spec - mdata;
figure('name','DC removed spectrum');plot(spec(1000,:));hold('on')
% linearize k-space
spec_lin = interp1(Chirp,spec',(1:spec_zs-1))';
% ifft --> z-space
spec_fft = log10(abs(ifft(spec_lin,[],2)));
f=figure();
% The header.xml is converted and stored as Header.
% Besides Header the substructure Header.DataFileDict is available
% to access data for each Spectral data set.
rangeX = str2double(Header.DataFileDict.Spectral0.RangeX);
rangeZ = str2double(Header.DataFileDict.Spectral0.RangeZ);
imagesc(spec_fft(:,1:spec_zs/2)','XData',[0,rangeX],'YData',[0,rangeZ],[-1.5,0.5]);
f.Position = f.Position .* [1,1, rangeX*0.2, rangeZ*0.2]
colormap('gray');
colorbar();
end