imr-framework / pypulseq

Pulseq in Python
https://pypulseq.readthedocs.io
GNU Affero General Public License v3.0
115 stars 62 forks source link

Functions to make combining gradients easier #41

Closed tonggehua closed 2 years ago

tonggehua commented 3 years ago

Is your feature request related to a problem? Please describe. When I am coding oblique gradients, and with multiple types of gradients being played together, there is a need to add gradients together, scale gradients, or change the channels of an already made gradient object.

Describe the solution you'd like Include these utility functions:

  1. Gradient scaling / channel modification. Returns a changed copy of the input gradient. Detects violations of max gradient or max slew rate and raises corresponding errors.
  2. Combining any number of gradients with arbitrary channels into 3: gx,gy, and gz. Preserve trapezoidal gradients if timings match. Otherwise, return general gradients.
  3. Detect zero gradients during add_block: don't include them to reduce storage waste

Describe alternatives you've considered The alternative is for each user to perform these actions in their custom code, individually. I believe they are generally useful enough to be part of Pypulseq.

sravan953 commented 2 years ago

Hi @tonggehua ! Thanks for being (super) patient! Commit 505889cdacc030071a5b0325d50fa180ce83fc90 addresses this - add_gradients.py. Take a look - https://github.com/imr-framework/pypulseq/blob/505889cdacc030071a5b0325d50fa180ce83fc90/pypulseq/add_gradients.py