Skip to content
Merged
Show file tree
Hide file tree
Changes from 144 commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
8ca012c
Added
Apr 26, 2024
3a980c2
Merge branch 'mind-inria:master' into master
chaithyagr Apr 26, 2024
093edfb
Fix
Apr 26, 2024
f8a6a4a
Merge branch 'master' of github.com:chaithyagr/mri-nufft
Apr 26, 2024
74c1ecd
Remove bymistake add
Apr 26, 2024
0250aa8
Fix
Apr 26, 2024
060a8bd
Fixed lint
Apr 26, 2024
aecb844
Lint
Apr 26, 2024
3130bc1
Added refbackend
Apr 26, 2024
bc014b8
Fix NDFT
Apr 26, 2024
0cc73c4
feat: use finufft as ref backend.
paquiteau Apr 29, 2024
21e090f
feat(tests): move ndft vs nufft tests to own file.
paquiteau Apr 29, 2024
6869a4a
Merge branch 'master' of github.com:mind-inria/mri-nufft
Apr 29, 2024
f8364d4
Merge branch 'master' of github.com:mind-inria/mri-nufft
Apr 30, 2024
23a63da
Merge branch 'master' of github.com:mind-inria/mri-nufft
Jun 17, 2024
3709e74
Merge branch 'master' of github.com:mind-inria/mri-nufft
Jul 1, 2024
8d6b9b4
Merge branch 'master' of github.com:chaithyagr/mri-nufft
chaithyagr Aug 1, 2024
398fb28
Merge branch 'master' of github.com:mind-inria/mri-nufft
chaithyagr Sep 5, 2024
bcf7ce3
git Merge branch 'master' of github.com:mind-inria/mri-nufft
chaithyagr Sep 19, 2024
3da762f
Add support for pipe
chaithyagr Sep 20, 2024
d644cf6
\!docs_build try to run cufinufft tests
chaithyagr Sep 20, 2024
0dca8f6
\!docs_build fix style
chaithyagr Sep 20, 2024
643e1e9
Added next235 for stability
chaithyagr Sep 23, 2024
af6bbfa
Fix lint
chaithyagr Sep 23, 2024
02c834f
Fix CUPY
chaithyagr Sep 23, 2024
d50f427
Merge branch 'master' into cufinufft
chaithyagr Oct 24, 2024
8cfd427
WIP
chaithyagr Oct 24, 2024
ab6eaa4
merge
chaithyagr Oct 24, 2024
3c3f1c8
Updates
chaithyagr Oct 24, 2024
bb28eb9
fix back learn examples
chaithyagr Oct 25, 2024
cdf75af
move tto flatiron
chaithyagr Oct 25, 2024
986fb96
fix black
chaithyagr Oct 25, 2024
d4edc58
Move to test on GPU
chaithyagr Nov 8, 2024
1d01484
Update pyproject toml and use it in test-ci, to prevent duplication o…
chaithyagr Nov 13, 2024
9714ca9
Make CI build shorter
chaithyagr Nov 13, 2024
aba2c8f
Merge branch 'master' into cufinufft
chaithyagr Nov 13, 2024
78c60f9
Test run to run
chaithyagr Nov 13, 2024
d5fc2f6
Merge branch 'cufinufft' of github.com:chaithyagr/mri-nufft into cufi…
chaithyagr Nov 13, 2024
d844816
\!docs_build Added
chaithyagr Nov 13, 2024
2d58e02
Merge branch 'master' into cufinufft
chaithyagr Nov 14, 2024
3059ed5
Merge branch 'master' of github.com:mind-inria/mri-nufft
chaithyagr Nov 14, 2024
7a6f4a0
adding density normalization
Dec 5, 2024
d7e7123
Start support for finufft spread and interpolate (pipe)
chaithyagr Dec 6, 2024
95ec156
Merge branch 'master' into finufft
chaithyagr Dec 6, 2024
db9290b
Add support for density comp
chaithyagr Dec 6, 2024
5dc9da9
Add support for normlize back
chaithyagr Dec 6, 2024
363774a
Merge branch 'master' of github.com:mind-inria/mri-nufft
Jan 9, 2025
0b8d97d
Merge branch 'master' of github.com:mind-inria/mri-nufft
Jan 23, 2025
df10d86
Added a bunch of extra codes
Feb 3, 2025
f280aae
PEP fixes
Feb 3, 2025
9e8010e
Update siemens.py
chaithyagr Feb 4, 2025
53cad71
Added fixes
Feb 5, 2025
12c2c6a
add [docs]
Feb 5, 2025
3f87e64
Fixes and updates on the locatuions
Feb 5, 2025
ab37e30
Update the codes to be in sync with cufinufft / finufft 2.4.0
Feb 10, 2025
7187491
Merge branch 'master' into finufft
chaithyagr Feb 10, 2025
d945183
Merge branch 'finufft' of github.com:chaithyagr/mri-nufft into finufft
Feb 13, 2025
f25799d
Merge branch 'master' of github.com:mind-inria/mri-nufft
Feb 13, 2025
32236b4
Merge branch 'master' of github.com:mind-inria/mri-nufft
chaithyagr Mar 6, 2025
5273918
Merge branch 'master' of github.com:mind-inria/mri-nufft
Mar 28, 2025
ea175f9
Merge branch 'master' of github.com:mind-inria/mri-nufft
chaithyagr May 21, 2025
1811135
Merged to master
chaithyagr May 27, 2025
6bb4058
Merged to master
chaithyagr May 27, 2025
8099f5d
[style]
chaithyagr May 27, 2025
4ede0e2
Fix toml ffile [docs]
chaithyagr May 27, 2025
7b6da14
Fix toml ffile [docs]
chaithyagr May 27, 2025
bc09146
Update testbatch stuff
chaithyagr Jun 3, 2025
c091f90
Update the tests
chaithyagr Jun 4, 2025
6fe4dae
Fixed tests againnnn
chaithyagr Jun 4, 2025
c63214a
All set
chaithyagr Jun 4, 2025
68c1e45
Add finufft
chaithyagr Jun 4, 2025
ca72ece
Updates
chaithyagr Jun 4, 2025
a2c82d9
Fixes
chaithyagr Jun 4, 2025
2263ecd
More fixes
chaithyagr Jun 5, 2025
5bd1494
make tests less strict again
chaithyagr Jun 5, 2025
61d803f
remove bymistake
chaithyagr Jun 5, 2025
e2c115a
Remove strictness, everything works, hopefully [docs]
chaithyagr Jun 6, 2025
0699ae3
Merge branch 'master' into finufft
chaithyagr Jun 6, 2025
843599f
[docs] setup cufinufft also
chaithyagr Jun 12, 2025
7804bdc
[docs] fix style
chaithyagr Jun 12, 2025
1793f76
[docs] more updates, fixes
chaithyagr Jun 12, 2025
4f6fef2
pywavelets
chaithyagr Jun 12, 2025
0ff6838
[docs] fixes further
chaithyagr Jun 12, 2025
c843435
[docs] try again
chaithyagr Jun 12, 2025
6a21f31
[docs] final comments
chaithyagr Jun 16, 2025
fceb8a3
[docs] method class use
chaithyagr Jun 16, 2025
ee7552d
WIP, updated codes to get itw orking
chaithyagr May 21, 2025
f6f12d6
trying to vectorize
chaithyagr May 21, 2025
5ed5d33
WIP
chaithyagr May 21, 2025
b9cdd4a
WIP
chaithyagr May 23, 2025
c5c5769
added direct change
chaithyagr May 23, 2025
ef4c7d2
More updates
chaithyagr May 23, 2025
d9cbaa8
Added timing and gradients
chaithyagr May 26, 2025
18ab02d
Update gradspec and codes
chaithyagr May 26, 2025
d094ecf
Update the error for slew
chaithyagr May 26, 2025
caf6401
Added tests
chaithyagr May 26, 2025
00f0c77
Setup PEP, ready for review
chaithyagr May 26, 2025
72a6a48
Minor update on spec
chaithyagr May 26, 2025
eb594f2
WIP
chaithyagr May 26, 2025
43f5ae4
Fixes for tests
chaithyagr May 27, 2025
ff04c73
fix docs
chaithyagr May 27, 2025
030ba89
Update src/mrinufft/io/nsp.py
chaithyagr May 27, 2025
4d7ef5a
remove unused stuff
chaithyagr May 27, 2025
669353d
Final fixes. [docs]
chaithyagr May 27, 2025
4c7fbcf
Haandleing comments
chaithyagr Jun 5, 2025
8535e49
Update src/mrinufft/trajectories/tools.py
chaithyagr Jun 5, 2025
d81e17d
[docs] update the docnames
chaithyagr Jun 5, 2025
82d6bfd
update TE_pos
chaithyagr Jun 12, 2025
1c8a1d7
style fixes
chaithyagr Jun 12, 2025
8c6dfd7
style fixes
chaithyagr Jun 12, 2025
f5984e2
Merge branch 'master' into update_traj_specs
chaithyagr Jun 17, 2025
5dba80c
Merge pull request #269 from chaithyagr/update_traj_specs
chaithyagr Jun 19, 2025
4475574
Merge branch 'master' into add_prephasors
chaithyagr Jul 2, 2025
99382ed
Fix for ramps
chaithyagr Jul 2, 2025
37e038c
Update src/mrinufft/trajectories/tools.py
chaithyagr Jul 3, 2025
f5160b0
Apply suggestions from code review
chaithyagr Jul 3, 2025
a48a6ad
Update src/mrinufft/io/nsp.py
chaithyagr Jul 3, 2025
e18dace
Update src/mrinufft/io/nsp.py
chaithyagr Jul 3, 2025
aaa3a16
Update src/mrinufft/io/nsp.py
chaithyagr Jul 3, 2025
c2e0cb0
Update src/mrinufft/io/nsp.py
chaithyagr Jul 3, 2025
2293e0c
Handle comments
chaithyagr Jul 3, 2025
1d0886e
Updated according to comments
chaithyagr Jul 3, 2025
20b4b1c
rename parameters and fix ordering
chaithyagr Jul 3, 2025
79dcf6c
Merge branch 'master' into add_prephasors
chaithyagr Jul 4, 2025
ce88302
Handle comments
chaithyagr Jul 7, 2025
06c70a7
Merge branch 'master' into add_prephasors
chaithyagr Jul 9, 2025
4cbf5ba
Update codes
chaithyagr Jul 9, 2025
83c56fb
Merge branch 'add_prephasors' of github.com:mind-inria/mri-nufft into…
chaithyagr Jul 9, 2025
5a3c7b2
More updates
chaithyagr Jul 10, 2025
c7b029b
Fixed some bugs
chaithyagr Jul 10, 2025
1a746d6
Update the tools
chaithyagr Jul 10, 2025
af94165
style fixes and [docs]
chaithyagr Jul 10, 2025
a53719f
More bugs! Fixes
chaithyagr Jul 11, 2025
7cf0890
[WIP]
chaithyagr Jul 11, 2025
4cea1ac
Updateds WIP
Jul 18, 2025
9db59e3
wip
Jul 24, 2025
13f3c13
WIP: moved to solvers
Jul 25, 2025
c182941
Fixed everything, ready for review
Jul 25, 2025
c18283a
Update src/mrinufft/trajectories/tools.py
chaithyagr Jul 25, 2025
7a447c5
style fixes
Jul 25, 2025
8f2fffd
Merge branch 'add_prephasors' of github.com:mind-inria/mri-nufft into…
Jul 25, 2025
12ce016
Update ruff
Jul 25, 2025
935b52b
Added joblib
Jul 25, 2025
1429f27
style changes [docs]
Jul 28, 2025
386097a
Apply suggestions from code review
chaithyagr Aug 19, 2025
5b9e621
Renaming
Aug 19, 2025
3450ede
Fix more comments
Aug 19, 2025
d131f47
Undo changes
Aug 19, 2025
b9b307f
fix undo
Aug 19, 2025
8e54c61
refactor: split test in two
paquiteau Aug 19, 2025
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
6 changes: 5 additions & 1 deletion docs/trajectory_gradspec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ The binary file format is specified as follows:
+----------------+-------+---------+---------+------------------------------------------------------------------------+
| timestamp | FLOAT | 1 | n.a. | Time stamp when the binary is created |
+----------------+-------+---------+---------+------------------------------------------------------------------------+
| Empty places | FLOAT | 9 | n.a. | Yet unused : Default initialized with 0 |
| ADC pre-skip | FLOAT | 1 | n.a. | Gradient samples to skip before starting ADC, for pre-phasors |
+----------------+-------+---------+---------+------------------------------------------------------------------------+
| ADC post-skip | FLOAT | 1 | n.a. | Gradient samples to skip at the end of trajectory by turning off ADC |
+----------------+-------+---------+---------+------------------------------------------------------------------------+
| Empty places | FLOAT | 7 | n.a. | Yet unused : Default initialized with 0 |
+----------------+-------+---------+---------+------------------------------------------------------------------------+
| kStarts | FLOAT | D*Nc | 1/m | K-space location start |
+----------------+-------+---------+---------+------------------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "MRI Non-Cartesian Fourier Operators with multiple computation bac
authors = [{name="Pierre-antoine Comby", email="[email protected]"}]

readme = "README.md"
dependencies = ["numpy", "scipy", "matplotlib", "tqdm"]
dependencies = ["numpy", "scipy", "matplotlib", "tqdm", "joblib"]
requires-python = ">=3.9"

dynamic = ["version"]
Expand Down
146 changes: 124 additions & 22 deletions src/mrinufft/io/nsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from datetime import datetime

import numpy as np
from typing import Optional

from mrinufft.trajectories.utils import (
DEFAULT_GMAX,
Expand All @@ -19,6 +20,7 @@
convert_gradients_to_slew_rates,
convert_trajectory_to_gradients,
)
from mrinufft.trajectories.tools import get_gradient_amplitudes_to_travel_for_set_time

from .siemens import read_siemens_rawdat

Expand All @@ -29,14 +31,16 @@ def write_gradients(
grad_filename: str,
img_size: tuple[int, ...],
FOV: tuple[float, ...],
in_out: bool = True,
TE_pos: float = 0.5,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous discussion: https://github.com/mind-inria/mri-nufft/pull/269/files#r2139372805

You mentioned it will be used in the future, I would prefer to keep MRs split as otherwise it's easy to get tons of dead features, and it's difficult to review efficiently.

Also again what about trajectories with multiple echoes in one readout ? We already have some

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am okay with changing it back, but I felt its smaller change to be added here. On the other hand, multi-echo sequence is not even supported at the moment by our sequence and hence adding its support in trajectory specification seems cumbersome and useless. The support for TE_pos has been exisiting for quite some time. Sorry for complication here, I just realized we had it wrong here and made the change

min_osf: int = 5,
gamma: float = Gammas.HYDROGEN,
version: float = 4.2,
recon_tag: float = 1.1,
timestamp: float | None = None,
keep_txt_file: bool = False,
final_positions: np.ndarray | None = None,
start_skip_samples: int = 0,
end_skip_samples: int = 0,
):
"""Create gradient file from gradients and initial positions.

Expand All @@ -52,8 +56,10 @@ def write_gradients(
Image size.
FOV : tuple[float, ...]
Field of view.
in_out : bool, optional
Whether it is In-Out trajectory?, by default True
TE_pos : float, optional
The ratio of trajectory when TE occurs, with 0 as start of
trajectory and 1 as end. By default 0.5, which is the
center of the trajectory (in-out trajectory).
min_osf : int, optional
Minimum oversampling factor needed at ADC, by default 5
gamma : float, optional
Expand All @@ -69,6 +75,12 @@ def write_gradients(
binary file, by default False
final_positions : np.ndarray, optional
Final positions. Shape (num_shots, dimension), by default None
start_skip_samples : int, optional
Number of samples to skip in ADC at start of each shot, by default 0
This works only for version >= 5.1.
end_skip_samples : int, optional
Number of samples to skip in ADC at end of each shot, by default 0
This works only for version >= 5.1.

"""
num_shots = gradients.shape[0]
Expand Down Expand Up @@ -100,14 +112,12 @@ def write_gradients(
file.write(str(num_shots) + "\n")
file.write(str(num_samples_per_shot) + "\n")
if version >= 4.1:
if not in_out:
if TE_pos == 0:
if np.sum(initial_positions) != 0:
warnings.warn(
"The initial positions are not all zero for center-out trajectory"
)
file.write("0\n")
else:
file.write("0.5\n")
file.write(str(TE_pos) + "\n")
# Write the maximum Gradient
file.write(str(max_grad) + "\n")
# Write recon Pipeline version tag
Expand All @@ -119,6 +129,10 @@ def write_gradients(
timestamp = float(datetime.now().timestamp())
file.write(str(timestamp) + "\n")
left_over -= 1
if version >= 5.1:
file.write(str(start_skip_samples) + "\n")
file.write(str(end_skip_samples) + "\n")
left_over -= 2
file.write(str("0\n" * left_over))
# Write all the k0 values
file.write(
Expand Down Expand Up @@ -165,7 +179,7 @@ def write_gradients(
os.remove(grad_filename + ".txt")


def _pop_elements(array, num_elements=1, type="float"):
def _pop_elements(array, num_elements=1, type=np.float32):
"""Pop elements from an array.

Parameters
Expand Down Expand Up @@ -200,8 +214,11 @@ def write_trajectory(
gamma: float = Gammas.HYDROGEN,
raster_time: float = DEFAULT_RASTER_TIME,
check_constraints: bool = True,
TE_pos: float = 0.5,
gmax: float = DEFAULT_GMAX,
smax: float = DEFAULT_SMAX,
pregrad: str | None = None,
postgrad: str | None = None,
version: float = 5,
**kwargs,
):
Expand All @@ -226,10 +243,26 @@ def write_trajectory(
Gradient raster time in ms, by default 0.01
check_constraints : bool, optional
Check scanner constraints, by default True
TE_pos : float, optional
The ratio of trajectory when TE occurs, with 0 as start of
trajectory and 1 as end. By default 0.5, which is the
center of the trajectory (in-out trajectory).
gmax : float, optional
Maximum gradient magnitude in T/m, by default 0.04
smax : float, optional
Maximum slew rate in T/m/ms, by default 0.1
pregrad : str, optional
Pregrad method, by default `prephase`
`prephase` will add a prephasing gradient to the start of the trajectory.
postgrad : str, optional
Postgrad method, by default 'slowdown_to_edge'
`slowdown_to_edge` will add a gradient to slow down to the edge of the k-space
along x-axis for all the shots i.e. go to (Kmax, 0, 0).
This is useful for sequences needing a spoiler at the end of the trajectory.
However, spoiler is still not added, it is expected that the sequence
handles the spoilers, which can be variable.
`slowdown_to_center` will add a gradient to slow down to the center
of the k-space.
version: float, optional
Trajectory versioning, by default 5
kwargs : dict, optional
Expand All @@ -245,7 +278,46 @@ def write_trajectory(
gamma=gamma,
get_final_positions=True,
)

Ns_to_skip_at_start = 0
Ns_to_skip_at_end = 0
scan_consts = {
"gamma": gamma,
"gmax": gmax,
"smax": smax,
"raster_time": raster_time,
}
if pregrad == "prephase":
if version < 5.1:
raise ValueError(
"pregrad is only supported for version >= 5.1, "
"please set version to 5.1 or higher."
)
start_gradients = get_gradient_amplitudes_to_travel_for_set_time(
kspace_end_loc=initial_positions,
end_gradients=gradients[:, 0],
**scan_consts,
)
initial_positions = np.zeros_like(initial_positions)
gradients = np.hstack([start_gradients, gradients])
Ns_to_skip_at_start = start_gradients.shape[1]
if postgrad:
if version < 5.1:
raise ValueError(
"postgrad is only supported for version >= 5.1, "
"please set version to 5.1 or higher."
)
edge_locations = np.zeros_like(final_positions)
if postgrad == "slowdown_to_edge":
# Always end at KMax, the spoilers can be handeled by the sequence.
edge_locations[..., 0] = img_size[0] / FOV[0] / 2
end_gradients = get_gradient_amplitudes_to_travel_for_set_time(
kspace_end_loc=edge_locations,
start_gradients=gradients[:, -1],
kspace_start_loc=final_positions,
**scan_consts,
)
gradients = np.hstack([gradients, end_gradients])
Ns_to_skip_at_end = end_gradients.shape[1]
# Check constraints if requested
if check_constraints:
slewrates, _ = convert_gradients_to_slew_rates(gradients, raster_time)
Expand All @@ -261,6 +333,15 @@ def write_trajectory(
f"Maximum gradient amplitude: {maxG:.3f} > {gmax:.3f}"
f"Maximum slew rate: {maxS:.3f} > {smax:.3f}"
)
if pregrad != "prephase":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be safer without the prephase check (we always want to raise warning if the slew-rate is not hardware compatible)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naahh, i disagree.. As @Daval-G mentioned, the sequence can handle pre-phasors right. This warning shouyld come up only in the case of UTE trajectories.. I think I am handeling that in #273

border_slew_rate = gradients[:, 0] / raster_time
if np.any(np.abs(border_slew_rate) > smax):
warnings.warn(
"Slew rate at start of trajectory exceeds maximum slew rate!"
f"Maximum slew rate: {np.max(np.abs(border_slew_rate)):.3f}"
f" > {smax:.3f}. Please use prephase gradient to avoid this "
" issue."
)

# Write gradients in file
write_gradients(
Expand All @@ -270,16 +351,19 @@ def write_trajectory(
grad_filename=grad_filename,
img_size=img_size,
FOV=FOV,
TE_pos=TE_pos,
gamma=gamma,
version=version,
start_skip_samples=Ns_to_skip_at_start,
end_skip_samples=Ns_to_skip_at_end,
**kwargs,
)


def read_trajectory(
grad_filename: str,
dwell_time: float | str = DEFAULT_RASTER_TIME,
num_adc_samples: int = None,
num_adc_samples: int | None = None,
gamma: Gammas | float = Gammas.HYDROGEN,
raster_time: float = DEFAULT_RASTER_TIME,
read_shots: bool = False,
Expand Down Expand Up @@ -336,25 +420,27 @@ def read_trajectory(
if dwell_time == "min_osf":
dwell_time = raster_time / min_osf
(num_shots, num_samples_per_shot), data = _pop_elements(data, 2, type="int")
if num_adc_samples is None:
if read_shots:
num_adc_samples = num_samples_per_shot + 1
else:
num_adc_samples = int(num_samples_per_shot * (raster_time / dwell_time))
if version >= 4.1:
if version > 4:
TE, data = _pop_elements(data)
grad_max, data = _pop_elements(data)
recon_tag, data = _pop_elements(data)
recon_tag = np.around(recon_tag, 2)
left_over = 10
if version >= 4.2:
if version > 4.1:
timestamp, data = _pop_elements(data)
timestamp = datetime.fromtimestamp(float(timestamp))
left_over -= 1
if version > 5:
packed_skips, data = _pop_elements(data, num_elements=2, type="int")
start_skip_samples, end_skip_samples = packed_skips
left_over -= 2
else:
start_skip_samples = 0
end_skip_samples = 0
_, data = _pop_elements(data, left_over)
initial_positions, data = _pop_elements(data, dimension * num_shots)
initial_positions = np.reshape(initial_positions, (num_shots, dimension))
if version >= 5:
if version > 4.5:
final_positions, data = _pop_elements(data, dimension * num_shots)
final_positions = np.reshape(final_positions, (num_shots, dimension))
dwell_time_ns = dwell_time * 1e6
Expand All @@ -365,12 +451,28 @@ def read_trajectory(
data,
dimension * num_samples_per_shot * num_shots,
)
# Convert gradients to T/m
gradients = np.reshape(
grad_max * gradients, (num_shots * num_samples_per_shot, dimension)
grad_max * gradients * 1e-3, (num_shots, num_samples_per_shot, dimension)
)
# Convert gradients from mT/m to T/m
gradients = np.reshape(gradients * 1e-3, (-1, num_samples_per_shot, dimension))
kspace_loc = np.zeros((num_shots, num_adc_samples, dimension))
# Handle skipped samples
if start_skip_samples > 0:
start_location_updates = (
np.sum(gradients[:, :start_skip_samples], axis=1) * raster_time * gamma
)
initial_positions += start_location_updates
gradients = gradients[:, start_skip_samples:, :]
num_samples_per_shot -= start_skip_samples
if end_skip_samples > 0:
gradients = gradients[:, :-end_skip_samples, :]
num_samples_per_shot -= end_skip_samples
if num_adc_samples is None:
if read_shots:
# Acquire one extra sample at the end of each shot in read_shots mode
num_adc_samples = num_samples_per_shot + 1
else:
num_adc_samples = int(num_samples_per_shot * (raster_time / dwell_time))
kspace_loc = np.zeros((num_shots, num_adc_samples, dimension), dtype=np.float32)
kspace_loc[:, 0, :] = initial_positions
adc_times = dwell_time_ns * np.arange(1, num_adc_samples)
Q, R = divmod(adc_times, gradient_raster_time_ns)
Expand Down
Loading
Loading