Pressure, flow, and dynamic thoraco-abdominal circumferences data for adults breathing under CPAP therapy 1.0.0

File: <base>/code/FigureGenerationCode.m (3,106 bytes)
%% CPAP Dataset - Figure Generation 
% Ella Guy
% Last Updated: 06/10/2022

clc, clear all, close all
%% Load Data ==============================================================

% Select File -------------------------------------------------------------
SubjectNumber = 3;   % de-identifyed subject number (1:30)
setPEEP = 0;         % PEEP setting(0:4:8)
for type = 1:3       % cued breath rate reference
% -------------------------------------------------------------------------
    Types = {'norm', 'pant', 'deep'};
    BreathRate = Types{type};
    
    RecordLength = [65, 35, 65];
    RecordTime = RecordLength(type);

    % Loads selected processed data infile
    filenameFormat = ...
        'DataProcessed/%dcmH2O_%s/CPAP2022_ProcessedData_Subjecct%d_%dcmH2O_%s.mat';
    infile = sprintf(filenameFormat, setPEEP, BreathRate, ...
        SubjectNumber, setPEEP, BreathRate);
    load(infile);
    
    % Infile:
    % 'Time' - Time [s]
    % 'Pressure' - Gauge pressure at venturi throat [cmH2O]
    % 'Flow' - Flow (Inspiratory positive and expiratory negative) [L/s] 
    % 'V_tidal' - Tidal Volume [L]
    % 'Chest' - Chest circumference [mm] 
    % 'Abd' - Abdominal circumference [mm]
    % 'InspInd' - Start of inspiration reference indicies 
    
    % Subject Graph Tag generation 
    GraphnameFormat_a = 'DataFigure_Subject%d_%dcmH20_%s.png';
    Graphname_a = sprintf(GraphnameFormat_a, SubjectNumber, setPEEP, ...
        BreathRate);
    
% =========================================================================
    %% Plotting

    InsptimeMarkers = Time(InspInd);
    
    figure(1)
    subplot(4, 1, 1)
    plot(Time, Pressure, 'LineWidth',1.5)
    for i = 1:length(InsptimeMarkers)
        xline(InsptimeMarkers(i), '--k')
    end
    axis([0, RecordTime, min(Pressure), max(Pressure)])
    yline(0)
    grid on
    grid minor
    title("Pressure at venturi throat [cmH_2O]", 'Fontsize', 12)
    
    subplot(4, 1, 2)
    plot(Time, Flow, 'LineWidth',1.5) 
    for i = 1:length(InsptimeMarkers)
        xline(InsptimeMarkers(i), '--k')
    end
    yline(0)
    axis([0, RecordTime, -2, 2])
    grid on
    grid minor
    title("Flow [L/s]", 'Fontsize', 12)
    
    subplot(4, 1, 3)
    plot(Time, V_tidal, '.','MarkerSize',3)
    for i = 1:length(InsptimeMarkers)
        xline(InsptimeMarkers(i), '--k')
    end
    yline(0)
    axis([0, RecordTime, min(V_tidal), max(V_tidal)])
    grid on
    grid minor
    title("Tidal Volume [L]", 'Fontsize', 12)
    
    subplot(4, 1, 4)
    hold on
    plot(Time, Chest,'LineWidth',1.5)
    plot(Time, Abd,'LineWidth',1.5)
    hold off
    for i = 1:length(InsptimeMarkers)
        xline(InsptimeMarkers(i), '--k')
    end
    axis([0, RecordTime, min([Chest; Abd]), max([Chest; Abd])])
    grid on
    grid minor
    title("Circumference of Chest and Abdomen [mm]", 'Fontsize', 12)
    
    set(gcf, 'Units', 'normalized', 'OuterPosition', [0,0.04,1,0.96])

    saveas(figure(1), Graphname_a) % saves plot 
    close(figure(1))

end