Skip to content

Bug: shiftMe does not update minTime/maxTime #14

@iahncajigas

Description

@iahncajigas

Bug Description

In SignalObj.m, the shiftMe method updates sObj.data and sObj.time but does not update sObj.minTime or sObj.maxTime. After calling shiftMe, these properties are stale and any code that relies on them (e.g., alignTime, findPeaks's default minDistance, duration calculations) will use the pre-shift time bounds.

Location

SignalObj.m, lines 1496–1506:

function shiftMe(sObj,deltaT,updateLabels)
    if(nargin<3)
        updateLabels=0;
    end
    sTemp = sObj.shift(deltaT,updateLabels);
    sObj.data=sTemp.data;
    sObj.time=sTemp.time;
    % BUG: sObj.minTime and sObj.maxTime are never updated
end

Expected Behavior

After shifting, minTime and maxTime should reflect the new time vector:

function shiftMe(sObj,deltaT,updateLabels)
    if(nargin<3)
        updateLabels=0;
    end
    sTemp = sObj.shift(deltaT,updateLabels);
    sObj.data=sTemp.data;
    sObj.time=sTemp.time;
    sObj.minTime=min(sObj.time);
    sObj.maxTime=max(sObj.time);
end

Impact

  • alignTime calls shiftMe but then checks sObj.minTime / sObj.maxTime for subsequent operations — these remain at pre-shift values.
  • findPeaks' default minDistance is computed from sObj.maxTime - sObj.minTime, which would be incorrect after a shift.
  • Any user code reading .minTime / .maxTime after a shift gets wrong values.

Found During

Python port (cajigaslab/nSTAT-python) — fixed in the Python implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions