Help with assigning values to a matrix (coursera course)
조회 수: 6 (최근 30일)
이전 댓글 표시
Hello all, this is from a coursera course on computational neuroscience. What I'm trying to do is gather all the indices for spikes (spike_times = indices of where 1 appears in the vector named rho) and use those indices in the vector stim to get the stimulus value. There are ~53,000 spikes so there will be ~53,000 vectors of these stimulus values and the length of each of these vectors should be 150 (called num_timesteps in this code). to fill in sta, these vectors will summed together and divided by the num_spikes to get the average. I would like to figure this out for the most part on my own so that I can learn, but I'm a beginner at matlab. Could someone just give me a few pointers on how this will be structured in code? You can see the few lines I've started so far under "your code goes here". Thank you.
if true
function [ sta ] = compute_sta( stim, rho, num_timesteps )
%COMPUTE_STA Calculates the spike-triggered average for a neuron that
% is driven by a stimulus defined in stim. The spike-
% triggered average is computed over num_timesteps timesteps.
sta = zeros(num_timesteps, 1);
% This command finds the indices of all of the spikes that occur
% after 300 ms into the recording.
spike_times = find(rho(num_timesteps+1:end)) + num_timesteps;
% Fill in this value. Note that you should not count spikes that occur
% before 300 ms into the recording.
num_spikes = sum(rho(151:size(rho)) == 1);
% Compute the spike-triggered average of the spikes found using the
% find command. To do this, compute the average of all of the vectors
% starting 300 ms (exclusive) before a spike and ending at the time of
% the event (inclusive). Each of these vectors defines a list of
% samples that is contained within a window of 300 ms before the each
% spike. The average of these vectors should be completed in an
% element-wise manner.
%
% Your code goes here.
for idx = 1:numel(spike_times)
stimulus = stim(idx)
end end
댓글 수: 1
Myriam Escobar-Khondiker
2022년 1월 6일
Hi,
I'm n the same boat as you... new to matlab and trying to wrap my head around this question...
Can anybody help out please??
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Electrophysiology에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!