Skip to content

Walkthroughs_VerifyRereferencing

Page Hayley edited this page Jul 31, 2020 · 1 revision

Verify Re-Referencing

Check the re-reference process by plotting the data within the same time frame. Filtered data is shown on the top panel, re-referenced data in the middle, and the common reference on the bottom.

Store Data and Set Time Variables

dataCAR = cell(3, 4); % Creates a cell array to store values
fs = blockObj.SampleRate; % Returns sample rate
x = linspace(300, 301, fs); % Sets x-axis for plots
s = round(x .* fs); % Makes an array of select time frame
ttext = ["Filtered"; "Reference"; "Filtered - Reference"]; % Creates text string with plot labels

Access Data and Plot Multiple Axis in the Same Figure

for iCol = 1:size(dataCar, 2) % Sets loop to the number of columns in cell array
    ch = iCol * 12; % Randomly samples every 12th channel
    extFilt = blockObj{'filt', ch, s}; % Extracts filtered data
    dataCAR{1, iCol} = extFilt{1, 1}; % Assigns data to the first row of each column
    dataCAR{2,iCol} = blockObj.Channels(ch).refMean(s); % Extracts reference data associated with each channel and adds it to the second row of the cell array
    extCAR = blockObj{'car', ch, s}; % Extracts CAR data
    dataCAR{3, iCol} = extCAR{1, 1}; % Assigns it to the third row of each column
    figure('Name', sprintf('Debug CAR: Ch-%02d', ch)); % Creates a new figure with channel name
        for n = 1:3
            subplot(3, 1, n); % Creates a figure with three subplots
            plot(x, plCAR{n, iCol}); % Plots data from each column
            ylim([-1000,1000]); % Changes y-axis limits
       	    title(ttext(n),'FontName','Arial','Color','k'); % Titles each subplot
        end
end
Clone this wiki locally