-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added siemens data reader and phase shifter (#89)
* Added siemens and add_raw shifts * Update src/mrinufft/io/siemens.py Co-authored-by: Pierre-Antoine Comby <[email protected]> * Update * Fixed some more * Moved codes around * Added np.ndarray * Fix movement * Fix movement * Fix flake * ruff fix * Fix * Remove bymistake add * style: ruff * feat(io.utils): add basic test. --------- Co-authored-by: Pierre-Antoine Comby <[email protected]>
- Loading branch information
1 parent
37c6921
commit 8e15f05
Showing
4 changed files
with
145 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"""Module containing utility functions for IO in MRI NUFFT.""" | ||
|
||
import numpy as np | ||
|
||
|
||
def add_phase_to_kspace_with_shifts(kspace_data, kspace_loc, normalized_shifts): | ||
""" | ||
Add phase shifts to k-space data. | ||
Parameters | ||
---------- | ||
kspace_data : np.ndarray | ||
The k-space data. | ||
kspace_loc : np.ndarray | ||
The k-space locations. | ||
normalized_shifts : tuple | ||
The normalized shifts to apply to each dimension of k-space. | ||
Returns | ||
------- | ||
ndarray | ||
The k-space data with phase shifts applied. | ||
Raises | ||
------ | ||
ValueError | ||
If the dimension of normalized_shifts does not match the number of | ||
dimensions in kspace_loc. | ||
""" | ||
if len(normalized_shifts) != kspace_loc.shape[1]: | ||
raise ValueError( | ||
"Dimension mismatch between shift and kspace locations! " | ||
"Ensure that shifts are right" | ||
) | ||
phi = np.sum(kspace_loc * normalized_shifts, axis=-1) | ||
phase = np.exp(-2 * np.pi * 1j * phi) | ||
return kspace_data * phase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters