Switch to unified view

a b/script_load_data_from_dicom.m
1
% These commands are optimized for DICOM images saved from Philips EPIQ 7C
2
% We extract the B-mode images, ECG, Time Stamp;
3
% Resolution of B model images in the X and Y direction are also calculated 
4
5
% Local name the Data file
6
Data_file                   = 'input';
7
8
% Exact filename
9
file_name                   = varargin{1};
10
11
% if file does not exist, return
12
if ~isfile(file_name)
13
    fprintf('File does NOT exist in this location: %s\n', file_name)
14
    handles.file_exist = false;
15
    return; 
16
else
17
    handles.file_exist = true;
18
end
19
20
% copy the data from source to the this folder and saveas Data_file
21
copyfile(file_name, Data_file);
22
23
fprintf('Loading the DICOM IMAGES. It might take time!\n');
24
25
% Load the data into MATLAB via helper files from Philips
26
% This function was written by Jonathan (Philips)
27
[~, dataout, ~]             = DICOMReaderGeneral(Data_file);
28
29
if (size(dataout{1}.time{1}, 2) ~= 1)
30
    
31
    % This variable is set to true if the input os bmode.
32
    handles.Bmode           = true;
33
    
34
    % Title of the reults plots
35
    handles.Waveform_Title.String = "Diameter [mm] Vs Time [seconds]";
36
    
37
    % Update handles about the current position
38
    handles.Message_Bar.String = "Loaded BMode images";
39
    
40
    % Extract b mode images 
41
    script_extract_B_mode_images;
42
    
43
    handles.Play_Button.String = 'Process B-Mode Data';
44
    
45
else
46
    
47
    % This variable is set to true if the input os bmode.
48
    handles.Bmode           = false;
49
    
50
    % Title of the reults plots
51
    handles.Waveform_Title.String = "Velocity [m/s] Vs Time [seconds]";
52
    
53
    % Extract pulsed Doppler data
54
    script_extract_Pulse_Doppler_data;
55
    
56
    % Update handles about the current position
57
    handles.Message_Bar.String = "Loaded Pulsed Doppler Data";
58
    
59
    handles.Play_Button.String = 'Process Pulsed Doppler Data';
60
   
61
end
62
63
% Location of the path to save results
64
handles.save_path           = script_create_save_path_name(file_name, handles.Bmode);
65
66
% Load ECG from the file. ECG is normalized using maximum value
67
physio                      = DICOMPhysioReader(Data_file);
68
69
if ~(size(physio.time, 1) == 0)
70
    time_ecg                = (physio.time-physio.time(1))/1e6;
71
    ECG                     = double(physio.channels(:,1));
72
    % Subsample ECG to # frames of B mode image
73
    time_frame              = linspace(0, max(time_ecg), Num_Time_Stamps)';
74
    interpolate_ECG         = interp1(time_ecg, ECG, time_frame); 
75
    handles.time            = time_frame;
76
    handles.ECG             = interpolate_ECG/max(interpolate_ECG);
77
else
78
    fprintf('NO ECG Data\n');
79
    time_ecg                = [];
80
    handles.ECG             = [];
81
    Fs                      = 42;
82
    time_frame              = (0:1/Fs:(Num_Time_Stamps-1)/Fs)'; 
83
    handles.time            = time_frame;
84
end
85
86