ass="comment">%%%%%%%%%% REALIGN FIDUCIALS</span>
0085 <span class="comment">% We line up the fiducials around the sample that requires the least shifting.</span>
0086 target = round(mean(fiducials));
0087 
0088 <span class="comment">% Determine shifted indices for each waveform</span>
0089 shifts = fiducials - target;
0090 shifts(abs(shifts) &gt; maxshift) = 0;   <span class="comment">% big shifts are outliers; don't alter these</span>
0091 resample_inds = repmat((1:numsamples), [numspikes, 1]) + repmat(sh