39 static void reconstruct(
char* filename,
int N,
int M,
int iteration ,
int weight)
43 double time,min_time,max_time,min_inh,max_inh;
45 double w,epsilon=0.0000003;
49 FILE* fp,*fw,*fout_real,*fout_imag,*finh,*ftime;
51 int flags = PRE_PHI_HUT| PRE_PSI |MALLOC_X| MALLOC_F_HAT|
52 MALLOC_F| FFTW_INIT| FFT_OUT_OF_PLACE;
53 unsigned infft_flags = CGNR | PRECOMPUTE_DAMP;
61 ftime=fopen(
"readout_time.dat",
"r");
62 finh=fopen(
"inh.dat",
"r");
64 min_time=INT_MAX; max_time=INT_MIN;
67 fscanf(ftime,
"%le ",&time);
76 Ts=(min_time+max_time)/2.0;
79 min_inh=INT_MAX; max_inh=INT_MIN;
82 fscanf(finh,
"%le ",&w);
90 N3=ceil((
NFFT_MAX(fabs(min_inh),fabs(max_inh))*(max_time-min_time)/2.0+m/(2*sigma))*4*sigma);
95 W=
NFFT_MAX(fabs(min_inh),fabs(max_inh))/(0.5-((double) m)/N3);
97 my_N[0]=N;my_n[0]=ceil(N*sigma);
98 my_N[1]=N; my_n[1]=ceil(N*sigma);
99 my_N[2]=N3; my_n[2]=ceil(N3*sigma);
102 mri_inh_3d_init_guru(&my_plan, my_N, M, my_n, m, sigma, flags,
103 FFTW_MEASURE| FFTW_DESTROY_INPUT);
106 infft_flags = infft_flags | PRECOMPUTE_WEIGHT;
112 if(my_iplan.
flags & PRECOMPUTE_WEIGHT)
114 fw=fopen(
"weights.dat",
"r");
117 fscanf(fw,
"%le ",&my_iplan.
w[j]);
123 if(my_iplan.
flags & PRECOMPUTE_DAMP)
129 double r=sqrt(j2*j2+k2*k2);
131 my_iplan.
w_hat[j*N+k]=0.0;
133 my_iplan.
w_hat[j*N+k]=1.0;
138 fp=fopen(filename,
"r");
139 ftime=fopen(
"readout_time.dat",
"r");
143 fscanf(fp,
"%le %le %le %le",&my_plan.plan.
x[3*j+0],&my_plan.plan.
x[3*j+1],&real,&imag);
144 my_iplan.
y[j]=real+ _Complex_I*imag;
145 fscanf(ftime,
"%le ",&my_plan.plan.
x[3*j+2]);
147 my_plan.plan.
x[3*j+2] = (my_plan.plan.
x[3*j+2]-Ts)*W/N3;
153 finh=fopen(
"inh.dat",
"r");
156 fscanf(finh,
"%le ",&my_plan.w[j]);
163 nfft_precompute_psi(&my_plan.plan);
166 nfft_precompute_full_psi(&my_plan.plan);
178 solver_before_loop_complex(&my_iplan);
179 for(l=0;l<iteration;l++)
184 fprintf(stderr,
"%e, %i of %i\n",sqrt(my_iplan.
dot_r_iter),
190 t = nfft_elapsed_seconds(t1,t0);
192 fout_real=fopen(
"output_real.dat",
"w");
193 fout_imag=fopen(
"output_imag.dat",
"w");
195 for (j=0;j<N*N;j++) {
197 my_iplan.
f_hat_iter[j]*=cexp(-2.0*_Complex_I*
PI*Ts*my_plan.w[j]*W);
199 fprintf(fout_real,
"%le ",creal(my_iplan.
f_hat_iter[j]));
200 fprintf(fout_imag,
"%le ",cimag(my_iplan.
f_hat_iter[j]));
206 mri_inh_3d_finalize(&my_plan);
210 int main(
int argc,
char **argv)
214 printf(
"usage: ./reconstruct_data_inh_3d FILENAME N M ITER WEIGHTS\n");
218 reconstruct(argv[1],atoi(argv[2]),atoi(argv[3]),atoi(argv[4]),atoi(argv[5]));