-
Notifications
You must be signed in to change notification settings - Fork 3
Walkthroughs_PreviewChannels
Page Hayley edited this page Jul 17, 2020
·
1 revision
After running block files through the various steps of extraction and LFP filtering, it is helpful to load the various files into a cell array to access a subset of the data easily and then view it preliminarily.
blockObj = tankObj{animal#, block#} % Should return the block info to verify correct indexing
chNum = size(blockObj.Channels,2); % Creates a var with the number of channels in the block
lfpData = cell(1, chNum); % Creates an empty cell array to store LFP data
fs = blockObj.Pars.LFP.DownSampledRate; % Creates a var with the LFP sample rate
start = (start time * fs); % Sets var for sample start point
stop = (stop time * fs); % Sets var for sample stop point
totalSamp = stop - start; % Finds the total number of samples in time frame
selectSamp = linspace(start, stop, totalSamp); % Creates a vector of the samples in the time frame of interest
for i = 1:chNum % Iteratively fills the cell array with each individual channel's data
lfpExt = blockObj{'lfp', i, selectSamp}; % Extracts data from block
lfpData{i} = lfpExt{1,1}; % Assigns it to a cell in the array
end
x = linspace(start time, stop time, totalSamp); % Creates a var for the x-axis using the time frame
legendTitle = cell(1, chNum); % Creates a cell array to fill with channel names for each figure
for i=1:chNum
n=i/8; % Sets number of channels on each figure to 8
legendTitle{i} = (['Channel ', num2str(i)]); % Stores channel name in cell array
lfpCh=lfpData{i}; % Iteratively accesses channel data
plot(x,lfpCh) % Plots channel
hold on % Holds figure to plot next channels on the same figure
if rem(n,1) == 0 % Matches the interval of channels you set above
range = i - 7; % Determines beginning of channel range for title and legend
title (['Subset of LFP data on channels ', num2str(range), ' through ', num2str(i)]); % Sets title of previous figure
xlabel(['Time(s)']); % Labels x-axis
ylabel(['LFP(V)']); % Labels y-axis
legend(legendTitle{(range) : i}); % Adds a legend with the channels shown in each figure
hold off
figure % Creates a new figure
end
end
