3D array, remove columns where second array == -1
Show older comments
Hi,
I am curently processing 13 channels of PSG data. I take my data and create 10 second buffers with 5 second overlaps for the length of the data. This returns a 3D array "windows3D" which is 2000*5147*13 (buffer width * no. of buffers * channels)
I have a second array called "truthBuffer" which is 1*5147, this array tells me if the 2000 samples have been identified by a clinican as positive (1) negitive (0) or are not scored (-1). I wish to preform Machine learning on this so I wish to remove the array elements of truthBuffer which are -1 and then remove the corresponding colums from all channels of windows3D.
This should return scoredTurthBuffer as a 1*2538 array (as there are 2609 '-1' values - this part works) and assessedWindows3D as a 2000*2538*13 (where the same 2538 colums are retained for all 13 channels) this part doesn't work
This is what i,ve tried below, this works well for "scoredTruthBuffer" (1*5147 ==> 1*2538) but "assessedWindows3D" changes from 2000*5147*13 to 1*133819391 array which is not what I expect. I am expecing an array of 2000*2538*13 back.
scoredTruthBuffer = truthBuffer; % Create a mirrior of truthBuffer || creates sized array 1*5147 as expected
assessedWindows3D = windows3D; % Create a mirrior of windows3D || creates sized array 2000*5147*13 as expected
toRemove = truthBuffer == -1; % Find what elements to remove in turthBuffer || 2609 '-1' values (5147-2609 = 2538)
scoredTruthBuffer(toRemove) = []; % remove elements from truthBuffer || creates sized array 1*2538 as expected
assessedWindows3D(toRemove) = []; % remove elements from truthBuffer || creates sized array 1*133819391 UNEXPECTED, expecting 2000*2538*13
I have also tried to include a for loop to preform this task channel by channel but I get the following error;
% Sudo
% for i = 1:13
% for j = 1:length(truthBuffer)
% if truthBuffer == -1
% windows3D(:, j ,i) = [];
% else
%
% end
% end
% end
% Error given
=>> A null assignment can have only one non-colon index.
I know the error is generated by the inclusion of both 'j' and 'i' but I cannot come up with a easy way around this.
How can I return "assessedWindows3D" as a 2000*2538*13 to match the columns removed in scoredTruthBuffer?
Thanks in advance,
Christopher
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!