Add rotate3D implementation#378
Conversation
|
This PR adds the rotate3D function to PyPulseq which enables rotation of gradient waveforms in 3D space. |
| [2 * (x * z - y * w), 2 * (y * z + x * w), 1 - 2 * (x * x + y * y)], | ||
| ], | ||
| dtype=float, | ||
| ) |
There was a problem hiding this comment.
I would use scipy's Rotation from_quat() method instead of a custom function - scipy is already a pypulseq dependency - see e.g., @fzimmermann89 gist for the import syntax.
| def rotate3D( | ||
| *args: SimpleNamespace, | ||
| rotation: Optional[Any] = None, | ||
| rotation_matrix: Optional[np.ndarray] = None, |
There was a problem hiding this comment.
Currently, pypyulseq styling for optional args is Union[actual-data-type, None].
|
|
||
| Also accepts list inputs: | ||
| ms_rotate3D([gx, gy, gz], rf, adc, rotation_matrix=R, system=sys) | ||
| """ |
There was a problem hiding this comment.
I would add a Numpy styled docstring:
Parameters
------------
arg1 : type
Description.
optional_arg2 : type, default=default_value.
Description.
Return
-------
output : type
Description.
Notes
-------
Optional notes section if required.
Example
---------
Optional usage example as
>>> import mypackage
>>> out = mypackage.func(inputs)
|
why do the gradients need to be realigned after scaling? also there are some strange (llm?) comments left in... |
|
Thanks for the comments. I updated it accordingly and resolved the issues. |
|
|
||
| Non-gradient events (e.g. RF, ADC, delay) are passed through unchanged. | ||
|
|
||
| Parameters |
There was a problem hiding this comment.
There are missing dashes for correct rendering:
Parameters
------------
same for the other sections of the docstring
| # grad_out_curr = align_gradient_to_raster(grad_out_curr, system.grad_raster_time) | ||
| # scaled = align_gradient_to_raster(scaled, system.grad_raster_time) | ||
| grad_out_curr = add_gradients([grad_out_curr, scaled], system=system) | ||
| grad_out_curr = align_gradient_to_raster(grad_out_curr, system.grad_raster_time) |
There was a problem hiding this comment.
@Moji3h, do you have any comment regarding @fzimmermann89 concern?
|
@Moji3h thank you for the review! I still see some issues with the docstring, as well as the remaining issue of post rotation gradient alignment. In addition, I would strongly advise to add some unit tests, it is important not to decrease the coverage. Thanks again for your support! |
No description provided.