From bad3a5992f9e4e78003bbeb976988865e0f1fb81 Mon Sep 17 00:00:00 2001 From: Daniel Mackner Date: Fri, 29 Nov 2024 00:54:32 +0100 Subject: [PATCH] traj/seq: use indices_from_position in traj-tool --- src/noncart/traj.c | 20 ++++++++++++++++++++ src/noncart/traj.h | 1 + src/traj.c | 5 ++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/noncart/traj.c b/src/noncart/traj.c index 0be0cd21a..0bf001293 100644 --- a/src/noncart/traj.c +++ b/src/noncart/traj.c @@ -251,6 +251,26 @@ void calc_base_angles(double base_angle[DIMS], int Y, int E, struct traj_conf co } + +void indices_from_position(long ind[DIMS], const long pos[DIMS], struct traj_conf conf, long start_pos_GA) +{ + ind[PHS2_DIM] = pos[PHS2_DIM]; + ind[SLICE_DIM] = pos[SLICE_DIM]; + ind[TE_DIM] = pos[TE_DIM]; + ind[TIME_DIM] = pos[TIME_DIM]; + + if (conf.rational) + return; + + if (conf.turns > 1) + ind[TIME_DIM] = pos[TIME_DIM] % conf.turns; + + if (conf.golden && conf.aligned) + ind[TIME_DIM] = start_pos_GA + pos[TIME_DIM]; +} + + + // z-Undersampling bool zpartition_skip(long partitions, long z_usamp[2], long partition, long frame) { diff --git a/src/noncart/traj.h b/src/noncart/traj.h index 576540e37..8f4ce740b 100644 --- a/src/noncart/traj.h +++ b/src/noncart/traj.h @@ -38,6 +38,7 @@ extern const struct traj_conf rmfreq_defaults; extern void euler(float dir[3], float phi, float psi); extern void gradient_delay(float d[3], float coeff[2][3], float phi, float psi); extern void calc_base_angles(double base_angle[DIMS], int Y, int E, struct traj_conf conf); +extern void indices_from_position(long ind[DIMS], const long pos[DIMS], struct traj_conf conf, long start_pos_GA); extern bool zpartition_skip(long partitions, long z_usamp[2], long partition, long frame); extern int gen_fibonacci(int n, int ind); extern int recover_gen_fib_ind(int Y, int inc); diff --git a/src/traj.c b/src/traj.c index 407611ad3..7f5ecc1f2 100644 --- a/src/traj.c +++ b/src/traj.c @@ -296,8 +296,11 @@ int main_traj(int argc, char* argv[argc]) double angle = 0.; + long ind[DIMS] = { 0L }; + indices_from_position(ind, pos, conf, 0); + for (int d = 1; d < DIMS; d++) - angle += (double)pos[d] * base_angle[d]; + angle += (double)ind[d] * base_angle[d]; if (conf.half_circle_gold)