Skip to content

Commit

Permalink
split definitions from general functions in mri.h
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Mackner authored and uecker committed Dec 7, 2024
1 parent ab1715f commit d482c73
Show file tree
Hide file tree
Showing 31 changed files with 123 additions and 99 deletions.
1 change: 1 addition & 0 deletions src/caldir.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "misc/mmio.h"
#include "misc/misc.h"
#include "misc/mri.h"
#include "misc/mri2.h"
#include "misc/opts.h"
#include "misc/debug.h"

Expand Down
1 change: 1 addition & 0 deletions src/calib/calmat.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "misc/misc.h"
#include "misc/mri.h"
#include "misc/mri2.h"
#include "misc/debug.h"

#include "calmat.h"
Expand Down
1 change: 1 addition & 0 deletions src/calib/estvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "misc/debug.h"
#include "misc/misc.h"
#include "misc/mri2.h"

#include "calib/calib.h"
#include "calib/calmat.h"
Expand Down
1 change: 1 addition & 0 deletions src/calmat.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "misc/mmio.h"
#include "misc/mri.h"
#include "misc/mri2.h"
#include "misc/misc.h"
#include "misc/debug.h"
#include "misc/opts.h"
Expand Down
1 change: 1 addition & 0 deletions src/cc.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "misc/mmio.h"
#include "misc/mri.h"
#include "misc/mri2.h"
#include "misc/misc.h"
#include "misc/debug.h"
#include "misc/opts.h"
Expand Down
1 change: 1 addition & 0 deletions src/ecalib.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "misc/mmio.h"
#include "misc/mri.h"
#include "misc/mri2.h"
#include "misc/misc.h"
#include "misc/debug.h"
#include "misc/opts.h"
Expand Down
71 changes: 71 additions & 0 deletions src/estdelay.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,77 @@
#endif


static void traj_radial_angles(int N, float angles[N], const long tdims[DIMS], const complex float* traj)
{
assert(N == tdims[2]);

long tdims1[DIMS];
md_select_dims(DIMS, ~MD_BIT(1), tdims1, tdims);

complex float* traj1 = md_alloc(DIMS, tdims1, CFL_SIZE);

md_slice(DIMS, MD_BIT(1), (long[DIMS]){ 0 }, tdims, traj1, traj, CFL_SIZE);

for (int i = 0; i < N; i++)
angles[i] = M_PI + atan2f(crealf(traj1[3 * i + 0]), crealf(traj1[3 * i + 1]));

md_free(traj1);
}



static float traj_radial_dcshift(const long tdims[DIMS], const complex float* traj)
{
long tdims1[DIMS];
md_select_dims(DIMS, ~MD_BIT(1), tdims1, tdims);

complex float* traj1 = md_alloc(DIMS, tdims1, CFL_SIZE);
// Extract what would be the DC component in Cartesian sampling

md_slice(DIMS, MD_BIT(1), (long[DIMS]){ [1] = tdims[1] / 2 }, tdims, traj1, traj, CFL_SIZE);

NESTED(float, dist, (int i))
{
return sqrtf(powf(crealf(traj1[3 * i + 0]), 2.) + powf(crealf(traj1[3 * i + 1]), 2.));
};

float dc_shift = dist(0);

for (int i = 0; i < tdims[2]; i++)
if (fabsf(dc_shift - dist(i)) > 0.0001)
debug_printf(DP_WARN, "Inconsistently shifted spoke: %d %f != %f\n", i, dist(i), dc_shift);

md_free(traj1);

return dc_shift;
}


static float traj_radial_dk(const long tdims[DIMS], const complex float* traj)
{
long tdims1[DIMS];
md_select_dims(DIMS, ~MD_BIT(1), tdims1, tdims);

complex float* traj1 = md_alloc(DIMS, tdims1, CFL_SIZE);
// Extract what would be the DC component in Cartesian sampling

md_slice(DIMS, MD_BIT(1), (long[DIMS]){ [1] = tdims[1] / 2 }, tdims, traj1, traj, CFL_SIZE);

NESTED(float, dist, (int i))
{
return sqrtf(powf(crealf(traj1[3 * i + 0]), 2.) + powf(crealf(traj1[3 * i + 1]), 2.));
};

float dc_shift = dist(0);

md_slice(DIMS, MD_BIT(1), (long[DIMS]){ [1] = tdims[1] / 2 + 1 }, tdims, traj1, traj, CFL_SIZE);

float shift1 = dist(0) - dc_shift;

md_free(traj1);

return shift1;
}



Expand Down
1 change: 1 addition & 0 deletions src/estdims.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "misc/misc.h"
#include "misc/opts.h"
#include "misc/mri.h"
#include "misc/mri2.h"



Expand Down
1 change: 1 addition & 0 deletions src/lrmatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include "misc/debug.h"
#include "misc/mri.h"
#include "misc/mri2.h"
#include "misc/mmio.h"
#include "misc/misc.h"
#include "misc/opts.h"
Expand Down
13 changes: 0 additions & 13 deletions src/misc/mri.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,6 @@ enum mri_dims {
#define MOTION_DIM ITER_DIM
#define MOTION_FLAG ITER_FLAG

extern void estimate_pattern(int D, const long dims[__VLA(D)], unsigned long flags, _Complex float* pattern, const _Complex float* kspace_data);
extern _Complex float* extract_calib(long caldims[DIMS], const long calsize[3], const long in_dims[DIMS], const _Complex float* in_data, _Bool fixed);
extern _Complex float* extract_calib2(long caldims[DIMS], const long calsize[3], const long in_dims[DIMS], const long in_strs[DIMS], const _Complex float* in_data, _Bool fixed);
extern void data_consistency(const long dims[DIMS], _Complex float* dst, const _Complex float* pattern, const _Complex float* kspace1, const _Complex float* kspace2);
extern void calib_geom(long caldims[DIMS], long calpos[DIMS], const long calsize[3], const long in_dims[DIMS], const _Complex float* in_data);

extern void estimate_im_dims(int N, unsigned long flags, long dims[__VLA(N)], const long tdims[__VLA(N)], const _Complex float* traj);
extern void estimate_fast_sq_im_dims(int N, long dims[3], const long tdims[__VLA(N)], const _Complex float* traj);

extern void traj_radial_angles(int N, float angles[__VLA(N)], const long tdims[DIMS], const _Complex float* traj);
extern float traj_radial_dcshift(const long tdims[DIMS], const _Complex float* traj);
extern float traj_radial_dk(const long tdims[DIMS], const _Complex float* traj);

#include "misc/cppwrap.h"

#endif // __MRI_H
Expand Down
87 changes: 1 addition & 86 deletions src/misc/mri.c → src/misc/mri2.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@

#include "sense/optcom.h"

#include "mri.h"




#include "mri2.h"



Expand All @@ -52,13 +48,6 @@ void data_consistency(const long dims[DIMS], complex float* dst, const complex f










void estimate_pattern(int D, const long dims[D], unsigned long flags, complex float* pattern, const complex float* kspace_data)
{
md_zrss(D, dims, flags, pattern, kspace_data);
Expand Down Expand Up @@ -308,77 +297,3 @@ void estimate_fast_sq_im_dims(int N, long dims[3], const long tdims[N], const co
dims[j] = (0. == max_dims[j]) ? 1 : fast_size;
}



void traj_radial_angles(int N, float angles[N], const long tdims[DIMS], const complex float* traj)
{
assert(N == tdims[2]);

long tdims1[DIMS];
md_select_dims(DIMS, ~MD_BIT(1), tdims1, tdims);

complex float* traj1 = md_alloc(DIMS, tdims1, CFL_SIZE);

md_slice(DIMS, MD_BIT(1), (long[DIMS]){ 0 }, tdims, traj1, traj, CFL_SIZE);

for (int i = 0; i < N; i++)
angles[i] = M_PI + atan2f(crealf(traj1[3 * i + 0]), crealf(traj1[3 * i + 1]));

md_free(traj1);
}


float traj_radial_dcshift(const long tdims[DIMS], const complex float* traj)
{
long tdims1[DIMS];
md_select_dims(DIMS, ~MD_BIT(1), tdims1, tdims);

complex float* traj1 = md_alloc(DIMS, tdims1, CFL_SIZE);
// Extract what would be the DC component in Cartesian sampling

md_slice(DIMS, MD_BIT(1), (long[DIMS]){ [1] = tdims[1] / 2 }, tdims, traj1, traj, CFL_SIZE);

NESTED(float, dist, (int i))
{
return sqrtf(powf(crealf(traj1[3 * i + 0]), 2.) + powf(crealf(traj1[3 * i + 1]), 2.));
};

float dc_shift = dist(0);

for (int i = 0; i < tdims[2]; i++)
if (fabsf(dc_shift - dist(i)) > 0.0001)
debug_printf(DP_WARN, "Inconsistently shifted spoke: %d %f != %f\n", i, dist(i), dc_shift);

md_free(traj1);

return dc_shift;
}


float traj_radial_dk(const long tdims[DIMS], const complex float* traj)
{
long tdims1[DIMS];
md_select_dims(DIMS, ~MD_BIT(1), tdims1, tdims);

complex float* traj1 = md_alloc(DIMS, tdims1, CFL_SIZE);
// Extract what would be the DC component in Cartesian sampling

md_slice(DIMS, MD_BIT(1), (long[DIMS]){ [1] = tdims[1] / 2 }, tdims, traj1, traj, CFL_SIZE);

NESTED(float, dist, (int i))
{
return sqrtf(powf(crealf(traj1[3 * i + 0]), 2.) + powf(crealf(traj1[3 * i + 1]), 2.));
};

float dc_shift = dist(0);

md_slice(DIMS, MD_BIT(1), (long[DIMS]){ [1] = tdims[1] / 2 + 1 }, tdims, traj1, traj, CFL_SIZE);

float shift1 = dist(0) - dc_shift;

md_free(traj1);

return shift1;
}


23 changes: 23 additions & 0 deletions src/misc/mri2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

#ifndef __MRI2_H
#define __MRI2_H

#include "misc/cppwrap.h"

#ifndef DIMS
#define DIMS 16
#endif

extern void estimate_pattern(int D, const long dims[__VLA(D)], unsigned long flags, _Complex float* pattern, const _Complex float* kspace_data);
extern _Complex float* extract_calib(long caldims[DIMS], const long calsize[3], const long in_dims[DIMS], const _Complex float* in_data, _Bool fixed);
extern _Complex float* extract_calib2(long caldims[DIMS], const long calsize[3], const long in_dims[DIMS], const long in_strs[DIMS], const _Complex float* in_data, _Bool fixed);
extern void data_consistency(const long dims[DIMS], _Complex float* dst, const _Complex float* pattern, const _Complex float* kspace1, const _Complex float* kspace2);
extern void calib_geom(long caldims[DIMS], long calpos[DIMS], const long calsize[3], const long in_dims[DIMS], const _Complex float* in_data);

extern void estimate_im_dims(int N, unsigned long flags, long dims[__VLA(N)], const long tdims[__VLA(N)], const _Complex float* traj);
extern void estimate_fast_sq_im_dims(int N, long dims[3], const long tdims[__VLA(N)], const _Complex float* traj);

#include "misc/cppwrap.h"

#endif // __MRI2_H

1 change: 1 addition & 0 deletions src/moba.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "num/filter.h"

#include "misc/mri.h"
#include "misc/mri2.h"
#include "misc/misc.h"
#include "misc/mmio.h"
#include "misc/utils.h"
Expand Down
1 change: 1 addition & 0 deletions src/ncalib.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "misc/mmio.h"
#include "misc/mri.h"
#include "misc/mri2.h"
#include "misc/misc.h"
#include "misc/debug.h"
#include "misc/opts.h"
Expand Down
1 change: 1 addition & 0 deletions src/networks/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "misc/misc.h"
#include "misc/mmio.h"
#include "misc/mri.h"
#include "misc/mri2.h"

#include "misc/version.h"
#include "num/multind.h"
Expand Down
1 change: 1 addition & 0 deletions src/nlinv.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "linops/linop.h"

#include "misc/mri.h"
#include "misc/mri2.h"
#include "misc/misc.h"
#include "misc/version.h"
#include "misc/mmio.h"
Expand Down
1 change: 1 addition & 0 deletions src/nlinvnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "nlops/nlop.h"

#include "misc/mri.h"
#include "misc/mri2.h"
#include "misc/misc.h"
#include "misc/mmio.h"
#include "misc/utils.h"
Expand Down
2 changes: 2 additions & 0 deletions src/nn/layers.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ extern const struct nlop_s* append_flatten_layer(const struct nlop_s* network, i

extern const struct nlop_s* append_batchnorm_layer(const struct nlop_s* network, int o, unsigned long norm_flags, enum NETWORK_STATUS status);

#include "misc/cppwrap.h"

#endif
1 change: 1 addition & 0 deletions src/nufft.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "misc/mmio.h"
#include "misc/misc.h"
#include "misc/mri.h"
#include "misc/mri2.h"
#include "misc/debug.h"
#include "misc/opts.h"

Expand Down
1 change: 1 addition & 0 deletions src/pattern.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "misc/mmio.h"
#include "misc/mri.h"
#include "misc/mri2.h"
#include "misc/misc.h"
#include "misc/opts.h"

Expand Down
1 change: 1 addition & 0 deletions src/pics.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

#include "misc/debug.h"
#include "misc/mri.h"
#include "misc/mri2.h"
#include "misc/utils.h"
#include "misc/mmio.h"
#include "misc/misc.h"
Expand Down
1 change: 1 addition & 0 deletions src/pocsense.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "sense/optcom.h"

#include "misc/mri.h"
#include "misc/mri2.h"
#include "misc/mmio.h"
#include "misc/misc.h"
#include "misc/debug.h"
Expand Down
1 change: 1 addition & 0 deletions src/rtnlinv.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "num/init.h"

#include "misc/mri.h"
#include "misc/mri2.h"
#include "misc/misc.h"
#include "misc/version.h"
#include "misc/mmio.h"
Expand Down
1 change: 1 addition & 0 deletions src/sake/sake.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "misc/misc.h"
#include "misc/debug.h"
#include "misc/mri.h"
#include "misc/mri2.h"

#include "sake.h"

Expand Down
1 change: 1 addition & 0 deletions src/sense/optcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "num/fltools.h"

#include "misc/mri.h"
#include "misc/mri2.h"
#include "misc/misc.h"
#include "misc/debug.h"

Expand Down
Loading

0 comments on commit d482c73

Please sign in to comment.