Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hacky fix for waveforms_and_times rf append floating point issue. #114

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions pypulseq/Sequence/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,7 @@ def waveforms_and_times(
[curr_dur + t, block.rf.freq_offset, block.rf.phase_offset]
)
if append_RF:

rf_piece = np.array(
[
curr_dur + rf.delay + rf.t,
Expand All @@ -1460,12 +1461,12 @@ def waveforms_and_times(
out_len[-1] += len(rf.t)

if np.abs(rf.signal[0]) > 0:
pre = np.array([[curr_dur + rf.delay + rf.t[0] - eps], [0]])
pre = np.array([[rf_piece[0, 0] - 0.1*self.system.rf_raster_time], [0]])
rf_piece = np.hstack((pre, rf_piece))
out_len[-1] += pre.shape[1]

if np.abs(rf.signal[-1]) > 0:
post = np.array([[curr_dur + rf.delay + rf.t[-1] + eps], [0]])
post = np.array([[rf_piece[0, -1] + 0.1*self.system.rf_raster_time], [0]])
rf_piece = np.hstack((rf_piece, post))
out_len[-1] += post.shape[1]

Expand Down Expand Up @@ -1510,11 +1511,15 @@ def waveforms_and_times(
:, wave_cnt[j] + np.arange(length - 1)
] = wave_data_local[:, 1:]
wave_cnt[j] += length - 1
if wave_cnt[j] != len(np.unique(wave_data[j][0, : wave_cnt[j]])):

rftdiff = np.diff(wave_data[j][0, : wave_cnt[j]])
if np.any(rftdiff < eps):
raise Warning(
"Not all elements of the generated time vector are unique."
"Time vector elements are not monotonically increasing."
)



# Trim output data
for j in range(shape_channels):
if wave_cnt[j] < wave_data[j].shape[1]:
Expand Down