/ concept-collection / seqlab
Sign in
concept-collection / seqlab
seqlab / src / engine / pulseq / +mr / pts2waveform.m
27 lines · 1.1 KBBlameHistoryRaw
1function waveform = pts2waveform(times, amplitudes, gradRasterTime)
3grd = (round(min(times)/gradRasterTime):round(max(times)/gradRasterTime))*gradRasterTime; % the previous code was clipping the gradient now and then...
4grd = grd(1:end-1).';
5waveform = interp1(times, amplitudes, grd + gradRasterTime/2);
7% % times = ceil(times/gradRasterTime)*gradRasterTime; % round onto grid
8% times = ceil(times/gradRasterTime); % round onto grid. SK: Dont multiply by
9% % gradRasterTime here: This will
10% % introduce numerical inaccuracies.
11% times_diff = diff(times);
12% amplitudes_diff = diff(amplitudes);
13% waveform = [];
14% for ii = 1:length(times)-1
15% % SK: there are no new points after the end, therefore we dont need to
16% % handle the overlap situation.
17% if ii == length(times)-1
18% crop = 0;
19% else
20% crop = 1;
21% end
22% y = amplitudes_diff(ii)/times_diff(ii)*...
23% (0:1:(times(ii+1)-times(ii)-crop))...
24% + amplitudes(ii);
25% waveform = [waveform y(1:end)];
26% end
27end
moveopenescclose