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

waveforms_and_times append RF fixes #93

Merged
merged 2 commits into from
Dec 16, 2022

Conversation

btasdelen
Copy link
Collaborator

Waveforms and times with append RF parameter is not functioning properly, due to improper casts and some missing logics. Also, it was omitting the phase and frequency offsets.

This is a hacky fix and open to discussion. Upstream MATLAB implementation uses cell arrays for storing the time/waveform pairs, which is more flexible than the numpy arrays and nested lists used here. As the RF waveform is complex, usage of np array forces the associated time points to be complex as well, which is a bit awkward and inefficient.

I have two proposals for a better solution:

  1. We can switch to dictionaries, and only the time points and waveform would be np arrays. Example usage:
waves['gx']['t'] # For time points
waves['gx']['s'] # For waveform
waves['rf']['s'] # For waveform (only this one is complex)

I think this will be a more flexible, verbose and Pythonic way of doing this, but it slightly deviates from upstream.

  1. We can split RF into phase and magnitude so that the RF list will be like:
waves[3][0] # RF time
waves[3][1] # RF magnitude
waves[3][2] # RF phase

This will deviate less from the upstream, but adds even more complication to the output of this function, which I think feels confusing and hard-coded right now.

@sravan953 sravan953 self-assigned this Dec 16, 2022
@sravan953 sravan953 added the bug-fix Fixes something label Dec 16, 2022
@sravan953 sravan953 merged commit 509369f into imr-framework:dev Dec 16, 2022
@sravan953
Copy link
Collaborator

Thank you! My work on PyPulseq 1.4.0 so far was referencing Pulseq 1.4.0 as per the commit on Dec 21, 2021. We are already 1y since that commit. So once again, there are lots of changes to catch up on. ;)

@sravan953
Copy link
Collaborator

Regarding your proposal, are you suggesting we migrate the wave_data variable from being an object np.array to a dict?

@btasdelen
Copy link
Collaborator Author

It is a list of np.array (2xN) now. What I suggest is, it can be a list of list (2 elements) of np.array (1xN), or a dict of dict (or list) of numpy array (1xN).

The reason I suggest dicts is more towards user-friendliness. Instead of assuming the order of gradients and rf, user can call by name. But I understand that it also makes pypulseq deviate more from the Pulseq's interface.

@sravan953
Copy link
Collaborator

I agree with you, and I favor dict, that's a good idea. To clarify, and for record keeping, as per your suggestion, we would migrate to wave_data being a dict of lists.

@btasdelen btasdelen deleted the waveforms_rf_fixes branch December 19, 2022 18:54
@btasdelen
Copy link
Collaborator Author

Great! I can implement and open a PR for it when I have the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-fix Fixes something
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants