Bug Description
In SignalObj.m, the findPeaks method's 'minima' branch (line 1630) is identical to the 'maxima' branch (line 1626). The minima case does not negate the data before calling findpeaks, so it returns maxima instead of minima.
Location
SignalObj.m, lines 1624–1631:
if(strcmp(type,'maxima'))
for i=1:sObj.dimension
[values{i},indices{i}] = findpeaks(sObj.data(:,i),'MINPEAKDISTANCE',minDistance);
end
elseif(strcmp(type,'minima'))
for i=1:sObj.dimension
[values{i},indices{i}] = findpeaks(sObj.data(:,i),'MINPEAKDISTANCE',minDistance); % BUG: same as maxima
end
Expected Behavior
The minima branch should negate the signal before calling findpeaks, then return the original (non-negated) values at those indices:
elseif(strcmp(type,'minima'))
for i=1:sObj.dimension
[~,indices{i}] = findpeaks(-sObj.data(:,i),'MINPEAKDISTANCE',minDistance);
values{i} = sObj.data(indices{i},i);
end
Found During
Python port (cajigaslab/nSTAT-python) — fixed in the Python implementation.
Bug Description
In
SignalObj.m, thefindPeaksmethod's'minima'branch (line 1630) is identical to the'maxima'branch (line 1626). The minima case does not negate the data before callingfindpeaks, so it returns maxima instead of minima.Location
SignalObj.m, lines 1624–1631:Expected Behavior
The minima branch should negate the signal before calling
findpeaks, then return the original (non-negated) values at those indices:Found During
Python port (cajigaslab/nSTAT-python) — fixed in the Python implementation.