26 #define MAX(a,b) (((a)>(b))?(a):(b))
35 static void reconstruct(
char* filename,
int N,
int M,
int iteration ,
int weight)
38 double time,min_time,max_time,min_inh,max_inh;
41 double w,epsilon=0.0000003;
44 solver_plan_complex my_iplan;
45 FILE* fp,*fw,*fout_real,*fout_imag,*finh,*ftime;
57 ftime=fopen(
"readout_time.dat",
"r");
58 finh=fopen(
"inh.dat",
"r");
60 min_time=INT_MAX; max_time=INT_MIN;
63 fscanf(ftime,
"%le ",&time);
72 Ts=(min_time+max_time)/2.0;
75 min_inh=INT_MAX; max_inh=INT_MIN;
78 fscanf(finh,
"%le ",&w);
86 N3=ceil((MAX(fabs(min_inh),fabs(max_inh))*(max_time-min_time)/2.0+(m)/(2*sigma))*4*sigma);
91 T=((max_time-min_time)/2.0)/(0.5-((double) (m))/N3);
94 my_N[0]=N; my_n[0]=ceil(N*sigma);
95 my_N[1]=N; my_n[1]=ceil(N*sigma);
96 my_N[2]=N3; my_n[2]=N3;
100 FFTW_MEASURE| FFTW_DESTROY_INPUT);
105 nfft_precompute_lin_psi(&my_plan.plan);
111 solver_init_advanced_complex(&my_iplan,(nfft_mv_plan_complex*)(&my_plan), infft_flags );
116 fw=fopen(
"weights.dat",
"r");
117 for(j=0;j<my_plan.M_total;j++)
119 fscanf(fw,
"%le ",&my_iplan.w[j]);
131 double r=sqrt(j2*j2+k2*k2);
133 my_iplan.w_hat[j*N+k]=0.0;
135 my_iplan.w_hat[j*N+k]=1.0;
140 fp=fopen(filename,
"r");
141 ftime=fopen(
"readout_time.dat",
"r");
143 for(j=0;j<my_plan.M_total;j++)
145 fscanf(fp,
"%le %le %le %le",&my_plan.plan.x[2*j+0],&my_plan.plan.x[2*j+1],&real,&imag);
146 my_iplan.y[j]=real+ _Complex_I*imag;
147 fscanf(ftime,
"%le ",&my_plan.t[j]);
149 my_plan.t[j] = (my_plan.t[j]-Ts)/T;
155 finh=fopen(
"inh.dat",
"r");
158 fscanf(finh,
"%le ",&my_plan.w[j]);
164 if(my_plan.plan.flags &
PRE_PSI) {
165 nfft_precompute_psi(&my_plan.plan);
168 nfft_precompute_full_psi(&my_plan.plan);
172 for(j=0;j<my_plan.N_total;j++)
174 my_iplan.f_hat_iter[j]=0.0;
177 t0 = nfft_clock_gettime_seconds();
180 solver_before_loop_complex(&my_iplan);
181 for(l=0;l<iteration;l++)
184 if(my_iplan.dot_r_iter<epsilon)
186 fprintf(stderr,
"%e, %i of %i\n",sqrt(my_iplan.dot_r_iter),
188 solver_loop_one_step_complex(&my_iplan);
191 t1 = nfft_clock_gettime_seconds();
194 fout_real=fopen(
"output_real.dat",
"w");
195 fout_imag=fopen(
"output_imag.dat",
"w");
197 for (j=0;j<N*N;j++) {
199 my_iplan.f_hat_iter[j]*=cexp(-2.0*_Complex_I*M_PI*Ts*my_plan.w[j]*W);
201 fprintf(fout_real,
"%le ",creal(my_iplan.f_hat_iter[j]));
202 fprintf(fout_imag,
"%le ",cimag(my_iplan.f_hat_iter[j]));
207 solver_finalize_complex(&my_iplan);
212 int main(
int argc,
char **argv)
216 printf(
"usage: ./reconstruct_data_inh_2d1d FILENAME N M ITER WEIGHTS\n");
220 reconstruct(argv[1],atoi(argv[2]),atoi(argv[3]),atoi(argv[4]),atoi(argv[5]));
void mri_inh_2d1d_init_guru(mri_inh_2d1d_plan *ths, int *N, int M, int *n, int m, double sigma, unsigned nfft_flags, unsigned fftw_flags)
void mri_inh_2d1d_finalize(mri_inh_2d1d_plan *ths)
#define PRECOMPUTE_WEIGHT
Header file for the nfft3 library.