MATLAB Answers

Spline Error - The first input must contain unique values

109 ビュー (過去 30 日間)
Hi,
I am proccessing data from the physionet Staff III database. I take the data, apply a bandpass filter and then apply cubic spline interpolation with the 'Spline' function. For the vast majority of data (~80%) this works well (I will include a list of the troublesome data below).
The error is listed as:
Error using chckxy (line 50)
The first input must contain unique values.
Error in spline (line 72)
[x,y,sizey,endslopes] = chckxy(x,y);
Error in Final_Year_Project_0_1_2>cubicspline (line 491)
yy = spline(x,twelveLead_9(lowers-20,i),xx);
My code to preform the cubic spline interpolation:
x = lowers; % isoelectric point from ecg
xx = 0:1:length(twelveLead_9); % Generate x-axis for the length of the data
splineData =[]; % Empty array for storage of data
for i = 1:9 % For each of the individule leads/channels
yy = spline(x,twelveLead_9(lowers-20,i),xx); % Calcualte the spline
splineData = vertcat(splineData, yy); % Create an array of spline per lead
end
splineDataT = splineData.'; % Transpose array to match orignal data
ecgDataNoSpline = (twelveLead_9 - (splineDataT(1:length(twelveLead_9),:))); % Subtract the 9 splines from the 9 leads
Looking at the first 20 patients on the staff III database (001a-020f) the files that do not work are (002e, 009c, 010c, 011b, 011c, 011d, 013b, 013c, 013d, 013e, 013f, 014a, 014c, 014d, 014f, 015b, 016e, 018d, 019b, 020b, 020c) This accounts for about 20% of the data so I cannot just ignore it.
I do not understand the error code, I have looked at similar problems here, and here but they don't seem to help or I am missing soemthing.
Thanks in advance,
Christopher

採用された回答

Christopher McCausland
Christopher McCausland 2021 年 2 月 17 日
編集済み: Christopher McCausland 2021 年 2 月 17 日
For anyone that finds this, I was able to determine my own issue. In the array of 300000 data points two concurrent data points had the same value. The 'spline' function can't handle this as it's looking for a cubic response.
I set a breakpoint in my code at the point of 'x' and preformed => mode(x) to find the issue. It was rather annoying.
Christopher
  1 件のコメント
Jonathan Ellis
Jonathan Ellis 2021 年 4 月 20 日
I want to say thank you for pointing this out. It was helpful for me to triage an error I was getting. In the end, just removing the duplicate data was fine (I was oversampled) but finding the source of the error was non-intuitive.

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by