@@ -455,10 +455,12 @@ def get_gradient_times_to_travel(
455455 n_ramp_up: The timing values for the ramp up phase.
456456 n_plateau: The timing values for the plateau phase.
457457 gi: The intermediate gradient values for trapezoidal or triangular waveforms.
458+
458459 See Also
459460 --------
460461 get_gradient_amplitudes_to_travel_for_set_time :
461- To directly get the waveforms required. This is most-likely what you want to use.
462+ To directly get the waveforms required. This is most-likely what
463+ you want to use.
462464 """
463465 acq = acq or Acquisition .default
464466 area_needed = (kspace_end_loc - kspace_start_loc ) / acq .gamma / acq .raster_time
@@ -642,16 +644,18 @@ def _residual(gi):
642644 nb_shots , nb_dimension = kspace_end_loc .shape
643645 G = np .zeros ((nb_shots , nb_raster_points , nb_dimension ), dtype = np .float32 )
644646 for i in range (nb_shots ):
645- start = n_ramp_down [i , 0 ]
646- G [i , :start ] = np .linspace (
647- start_gradients [i ], gi [i ], n_ramp_down [i ], endpoint = False , axis = - 1
648- )
649- if n_plateau [i , d ] > 0 :
650- G [i , start : start + n_plateau [i , 0 ]] = gi [i ]
651- start += n_plateau [i , 0 ]
652- G [i , start : start + n_ramp_up [i , 0 ]] = np .linspace (
653- gi [i ], end_gradients [i ], n_ramp_up [i , 0 ], axis = - 1 , endpoint = False
654- )
647+ for d in range (nb_dimension ):
648+ start = 0
649+ G [i , : n_ramp_down [i , d ], d ] = np .linspace (
650+ start_gradients [i , d ], gi [i , d ], n_ramp_down [i , d ], endpoint = False
651+ )
652+ start += n_ramp_down [i , d ]
653+ if n_plateau [i , d ] > 0 :
654+ G [i , start : start + n_plateau [i , d ], d ] = gi [i , d ]
655+ start += n_plateau [i , d ]
656+ G [i , start : start + n_ramp_up [i , d ], d ] = np .linspace (
657+ gi [i , d ], end_gradients [i , d ], n_ramp_up [i , d ], endpoint = False
658+ )
655659 return G
656660
657661
0 commit comments