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

clear cycleData
clear thisCycleData
pressure = data.pressureDBar;

cycleNum = 1;

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

lowPThresh = 30;
pIncrThresh = 2050;
highPHoldThresh = 2000;
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

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

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

numCycles = length(cycles);

end