28 #define MAX(a,b) (((a)>(b))?(a):(b))
37 static void reconstruct(
char* filename,
int N,
int M,
int iteration ,
int weight)
41 double time,min_time,max_time,min_inh,max_inh;
43 double w,epsilon=0.0000003;
47 FILE* fp,*fw,*fout_real,*fout_imag,*finh,*ftime;
49 int flags = PRE_PHI_HUT| PRE_PSI |MALLOC_X| MALLOC_F_HAT|
50 MALLOC_F| FFTW_INIT| FFT_OUT_OF_PLACE;
51 unsigned infft_flags = CGNR | PRECOMPUTE_DAMP;
59 ftime=fopen(
"readout_time.dat",
"r");
60 finh=fopen(
"inh.dat",
"r");
62 min_time=INT_MAX; max_time=INT_MIN;
65 fscanf(ftime,
"%le ",&time);
74 Ts=(min_time+max_time)/2.0;
77 min_inh=INT_MAX; max_inh=INT_MIN;
80 fscanf(finh,
"%le ",&w);
88 N3=ceil((MAX(fabs(min_inh),fabs(max_inh))*(max_time-min_time)/2.0+m/(2*sigma))*4*sigma);
93 W= MAX(fabs(min_inh),fabs(max_inh))/(0.5-((double) m)/N3);
95 my_N[0]=N;my_n[0]=ceil(N*sigma);
96 my_N[1]=N; my_n[1]=ceil(N*sigma);
97 my_N[2]=N3; my_n[2]=ceil(N3*sigma);
100 mri_inh_3d_init_guru(&my_plan, my_N, M, my_n, m, sigma, flags,
101 FFTW_MEASURE| FFTW_DESTROY_INPUT);
104 infft_flags = infft_flags | PRECOMPUTE_WEIGHT;
110 if(my_iplan.
flags & PRECOMPUTE_WEIGHT)
112 fw=fopen(
"weights.dat",
"r");
115 fscanf(fw,
"%le ",&my_iplan.
w[j]);
121 if(my_iplan.
flags & PRECOMPUTE_DAMP)
127 double r=sqrt(j2*j2+k2*k2);
129 my_iplan.
w_hat[j*N+k]=0.0;
131 my_iplan.
w_hat[j*N+k]=1.0;
136 fp=fopen(filename,
"r");
137 ftime=fopen(
"readout_time.dat",
"r");
141 fscanf(fp,
"%le %le %le %le",&my_plan.plan.
x[3*j+0],&my_plan.plan.
x[3*j+1],&real,&imag);
142 my_iplan.
y[j]=real+ _Complex_I*imag;
143 fscanf(ftime,
"%le ",&my_plan.plan.
x[3*j+2]);
145 my_plan.plan.
x[3*j+2] = (my_plan.plan.
x[3*j+2]-Ts)*W/N3;
151 finh=fopen(
"inh.dat",
"r");
154 fscanf(finh,
"%le ",&my_plan.w[j]);
160 if(my_plan.plan.
flags & PRE_PSI) {
161 nfft_precompute_psi(&my_plan.plan);
163 if(my_plan.plan.
flags & PRE_FULL_PSI) {
164 nfft_precompute_full_psi(&my_plan.plan);
173 t0 = nfft_clock_gettime_seconds();
176 solver_before_loop_complex(&my_iplan);
177 for(l=0;l<iteration;l++)
182 fprintf(stderr,
"%e, %i of %i\n",sqrt(my_iplan.
dot_r_iter),
184 solver_loop_one_step_complex(&my_iplan);
187 t1 = nfft_clock_gettime_seconds();
190 fout_real=fopen(
"output_real.dat",
"w");
191 fout_imag=fopen(
"output_imag.dat",
"w");
193 for (j=0;j<N*N;j++) {
195 my_iplan.
f_hat_iter[j]*=cexp(-2.0*_Complex_I*M_PI*Ts*my_plan.w[j]*W);
197 fprintf(fout_real,
"%le ",creal(my_iplan.
f_hat_iter[j]));
198 fprintf(fout_imag,
"%le ",cimag(my_iplan.
f_hat_iter[j]));
203 solver_finalize_complex(&my_iplan);
204 mri_inh_3d_finalize(&my_plan);
208 int main(
int argc,
char **argv)
212 printf(
"usage: ./reconstruct_data_inh_3d FILENAME N M ITER WEIGHTS\n");
216 reconstruct(argv[1],atoi(argv[2]),atoi(argv[3]),atoi(argv[4]),atoi(argv[5]));
double * w
weighting factors
unsigned flags
iteration type
double dot_r_iter
weighted dotproduct of r_iter
NFFT_INT N_total
Total number of Fourier coefficients.
NFFT_INT M_total
Total number of samples.
fftw_complex * y
right hand side, samples
double * x
Nodes in time/spatial domain, size is doubles.
unsigned flags
Flags for precomputation, (de)allocation, and FFTW usage, default setting is PRE_PHI_HUT | PRE_PSI | ...
data structure for an inverse NFFT plan with double precision
double * w_hat
damping factors
static void reconstruct(char *filename, int N, int M, int iteration, int weight)
reconstruct makes an inverse 2d nfft
fftw_complex * f_hat_iter
iterative solution