Skip to content
Merged
Changes from 1 commit
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
127 changes: 112 additions & 15 deletions src/mrinufft/trajectories/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,23 +420,34 @@ def get_gradient_times_to_travel(

Returns
-------
n_ramp_down: The timing values for the ramp down phase.
n_ramp_up: The timing values for the ramp up phase.
n_plateau: The timing values for the plateau phase.
gi: The intermediate gradient values for trapezoidal or triangular waveforms.
The timing values for the ramp down phase.
The timing values for the ramp up phase.
The timing values for the plateau phase.
The intermediate gradient values for trapezoidal or triangular waveforms.
"""
area_needed = (kspace_end_loc - kspace_start_loc) / gamma / raster_time

# Number of steps for direct ramp.
# Direct ramp steps
n_direct = np.ceil((end_gradients - start_gradients) / smax / raster_time).astype(
int
n_direct = np.ceil(
2 * area_needed / (start_gradients + end_gradients + np.finfo(np.float32).eps)
).astype("int")
n_direct[n_direct > 0] -= 1
# Minimum number of steps + 2 (as buffer)
n_direct_min = (
np.ceil(abs(end_gradients - start_gradients) / smax / raster_time).astype(int)
+ 2
)
area_direct = 0.5 * n_direct * (end_gradients + start_gradients)
direct_possible_mask = n_direct > n_direct_min

area_direct = 0.5 * n_direct_min * (end_gradients + start_gradients)

i = np.sign(area_direct - area_needed)

n_ramp_down = np.ceil((gmax + i * start_gradients) / smax / raster_time).astype(int)
n_ramp_up = np.ceil((gmax + i * end_gradients) / smax / raster_time).astype(int)
n_ramp_down = np.ceil(abs(gmax * i - start_gradients) / smax / raster_time).astype(
int
)
n_ramp_up = np.ceil(abs(end_gradients - i * gmax) / smax / raster_time).astype(int)

area_lowest = n_ramp_down * 0.5 * (start_gradients - i * gmax) + n_ramp_up * 0.5 * (
end_gradients - i * gmax
Expand All @@ -447,6 +458,43 @@ def get_gradient_times_to_travel(

# Condition: ramp-only sufficient
ramp_only_mask = np.abs(area_lowest) >= np.abs(area_needed)
# Re-Calculate the n_ramp_up and n_ramp_down to make it time efficient.
gi[ramp_only_mask] = (
0.5
* raster_time
* smax
* (
2 * area_needed[ramp_only_mask]
+ end_gradients[ramp_only_mask]
- start_gradients[ramp_only_mask]
)
/ (
end_gradients[ramp_only_mask]
- start_gradients[ramp_only_mask]
+ np.finfo(gi.dtype).eps
)
)
n_ramp_down[ramp_only_mask] = np.min(
[
n_ramp_down[ramp_only_mask],
np.ceil(
np.abs(gi[ramp_only_mask] - start_gradients[ramp_only_mask])
/ (smax * raster_time)
).astype(int),
],
axis=0,
)
n_ramp_up[ramp_only_mask] = np.min(
[
n_ramp_up[ramp_only_mask],
np.ceil(
np.abs(end_gradients[ramp_only_mask] - gi[ramp_only_mask])
/ (smax * raster_time)
).astype(int),
],
axis=0,
)
# Re-Calculate the updated gi based on new ramp down and ramp up values
gi[ramp_only_mask] = (
2 * area_needed[ramp_only_mask]
- (n_ramp_down[ramp_only_mask] + 1) * start_gradients[ramp_only_mask]
Expand All @@ -458,7 +506,7 @@ def get_gradient_times_to_travel(
remaining_area = np.zeros_like(area_needed)
remaining_area[plateau_mask] = area_needed[plateau_mask] - area_lowest[plateau_mask]
n_plateau[plateau_mask] = np.ceil(
np.abs(remaining_area[plateau_mask]) / gmax / raster_time
np.abs(remaining_area[plateau_mask]) / gmax
).astype(int)

gi[plateau_mask] = (
Expand All @@ -470,7 +518,25 @@ def get_gradient_times_to_travel(
+ n_ramp_up[plateau_mask]
+ 2 * n_plateau[plateau_mask]
)

# Update n_ramp when direct is possible. We still need gi to ensure we satisfy area constraints.
n_ramps_total = n_ramp_down + n_ramp_up + n_plateau
direct_is_faster_mask = n_direct < n_ramps_total
direct_possible_mask = direct_possible_mask & direct_is_faster_mask
n_direct = n_direct[direct_possible_mask]
gi_view = gi[direct_possible_mask].copy()
direct_ramp_down = n_direct // 2
direct_ramp_up = n_direct - direct_ramp_down
gi_view = (
2 * area_needed[direct_possible_mask]
- (direct_ramp_down + 1) * start_gradients[direct_possible_mask]
- (direct_ramp_up - 1) * end_gradients[direct_possible_mask]
) / (direct_ramp_down + direct_ramp_up)
gi[direct_possible_mask] = gi_view
n_plateau[direct_possible_mask] = 0
n_ramp_down[direct_possible_mask] = direct_ramp_down
n_ramp_up[direct_possible_mask] = direct_ramp_up
# Replace NaNs in any calculation above
gi[np.isnan(gi)] = start_gradients[np.isnan(gi)]
return n_ramp_down, n_ramp_up, n_plateau, gi


Expand Down Expand Up @@ -564,19 +630,50 @@ def get_gradient_amplitudes_to_travel_for_set_time(
nb_raster_points = np.max(n_ramp_down + n_ramp_up + n_plateau) + 2

area_needed = (kspace_end_loc - kspace_start_loc) / gamma / raster_time

# Intermediate gradient values. This is value of plateau or triangle gradients
gi = np.zeros_like(kspace_start_loc, dtype=np.float32)

# Assume direct solution first
n_ramp_up = np.ones(start_gradients.shape, dtype=int) * nb_raster_points // 2
n_ramp_down = nb_raster_points - n_ramp_up
gi = (
2 * area_needed
- (n_ramp_down + 1) * start_gradients
- (n_ramp_up - 1) * end_gradients
) / (n_ramp_down + n_ramp_up)
max_slew_needed = raster_time * np.max(
[abs(gi - start_gradients) / n_ramp_down, abs(end_gradients - gi) / n_ramp_up],
axis=0,
)
# FIXME: Becareful of rotating FOV boxes.
gmax_not_met = np.abs(gi) > gmax
smax_not_met = max_slew_needed > smax
direct_not_possible = gmax_not_met | smax_not_met

# Get the area for direct and estimate n_ramps
area_direct = 0.5 * nb_raster_points * (end_gradients + start_gradients)
i = np.sign(area_direct - area_needed)

n_ramp_down = np.ceil((gmax + i * start_gradients) / smax / raster_time).astype(int)
n_ramp_up = np.ceil((gmax + i * end_gradients) / smax / raster_time).astype(int)
n_plateau = nb_raster_points - n_ramp_up - n_ramp_down
n_ramp_down[direct_not_possible] = np.ceil(
abs(gmax * i[direct_not_possible] - start_gradients[direct_not_possible])
/ smax
/ raster_time
).astype(int)
n_ramp_up[direct_not_possible] = np.ceil(
(end_gradients[direct_not_possible] - gmax * i[direct_not_possible])
/ smax
/ raster_time
).astype(int)
n_plateau = np.zeros_like(n_ramp_down)
n_plateau[direct_not_possible] = (
nb_raster_points
- n_ramp_up[direct_not_possible]
- n_ramp_down[direct_not_possible]
)

# Get intermediate gradients for triangle waveform, when n_plateau<0
no_trapazoid = n_plateau <= 0
no_trapazoid = (n_plateau <= 0) & direct_not_possible
n_plateau[no_trapazoid] = 0

# Initial approximate calculation of gi
Expand Down
Loading