function [cycle, numCycles] = getCyclesFromPressure(data, dataIndex)

clear cycleData
clear thisCycleData
pressure = data{dataIndex}.pressureDBar;

% derivFilter = designfilt('differentiator', FilterOrder=10, PassbandFrequency = 0.02, StopbandFrequency=0.025);
% pDeriv=filter(derivFilter, pressure);

cycleNum = 1;

lowPHold = true;
pIncreasing = false;
highPHold = false;
pDecreasing = false;

lowPThresh = 30;
pIncrThresh = 2000;
highPHoldThresh = 1950;
pDecrThresh = 30;

cycleIndex = 1;
cycleName = "lowPHold";

for i=1:length(pressure)
    if(lowPHold)
        if(pressure(i) > lowPThresh)
            cycleNum = cycleNum + 1;
            cycleIndex = 1;
            lowPHold = false;
            pIncreasing = true;
            cycleName = "pIncr";
        end
    elseif(pIncreasing)
        if(pressure(i) > pIncrThresh)
            cycleNum = cycleNum + 1;
            cycleIndex = 1;
            pIncreasing = false;
            highPHold = true;
            cycleName = "highPHold";
        end
    elseif(highPHold)
        if(pressure(i) < highPHoldThresh)
            cycleNum = cycleNum + 1;
            cycleIndex = 1;
            highPHold = false;
            pDecreasing = true;
            cycleName = "pDecr";
        end
    elseif(pDecreasing)
        if(pressure(i) < pDecrThresh)
            cycleNum = cycleNum + 1;
            cycleIndex = 1;
            pDecreasing = false;
            lowPHold = true;
            cycleName = "lowPHold";
        end
    end

    % cycle{cycleNum}.dt(cycleIndex) = data{dataIndex}.dtLV(i);data{1}
    % cycle{cycleNum}.pressureDBar(cycleIndex) = data{dataIndex}.pressureDBar(i);
    % cycle{cycleNum}.vrsVolts(cycleIndex) = data{dataIndex}.vrsVolts(i);
    % cycle{cycleNum}.vrsStdDev(cycleIndex) = data{dataIndex}.vrsStdDev(i);
    % cycle{cycleNum}.thermTemp(cycleIndex) = data{dataIndex}.thermTemp(i);
    % cycle{cycleNum}.vkVolts(cycleIndex) = data{dataIndex}.vkVolts(i);
    % cycle{cycleNum}.vkStdDev(cycleIndex) = data{dataIndex}.vkStdDev(i);
    % cycle{cycleNum}.ikAmps(cycleIndex) = data{dataIndex}.ikAmps(i);
    % cycle{cycleNum}.ibAmps(cycleIndex) = data{dataIndex}.ibAmps(i);
    % cycle{cycleNum}.cycleNum(cycleIndex) = cycleNum;
    % cycle{cycleNum}.cycleName(cycleIndex,:) = cycleName(:);
    % cycle{cycleNum}.dataIndex(cycleIndex) = i;

    cycle(cycleNum).dt(cycleIndex) = data{dataIndex}.dtLV(i);
    cycle(cycleNum).pressureDBar(cycleIndex) = data{dataIndex}.pressureDBar(i);
    cycle(cycleNum).vrsVolts(cycleIndex) = data{dataIndex}.vrsVolts(i);
    cycle(cycleNum).vrsStdDev(cycleIndex) = data{dataIndex}.vrsStdDev(i);
    cycle(cycleNum).thermTemp(cycleIndex) = data{dataIndex}.thermTemp(i);
    cycle(cycleNum).vkVolts(cycleIndex) = data{dataIndex}.vkVolts(i);
    cycle(cycleNum).vkStdDev(cycleIndex) = data{dataIndex}.vkStdDev(i);
    cycle(cycleNum).ikAmps(cycleIndex) = data{dataIndex}.ikAmps(i);
    cycle(cycleNum).ibAmps(cycleIndex) = data{dataIndex}.ibAmps(i);
    cycle(cycleNum).cycleNum(cycleIndex) = cycleNum;
    cycle(cycleNum).cycleName(cycleIndex,:) = cycleName(:);
    cycle(cycleNum).dataIndex(cycleIndex) = i;

    % thisCycleData(cycleIndex) = dataTable{1}.vrsVolts(i);
    cycleIndex = cycleIndex + 1;
end

numCycles = length(cycle);

end
