![]() |
NFFT
3.3.1
|
00001 /* 00002 * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts 00003 * 00004 * This program is free software; you can redistribute it and/or modify it under 00005 * the terms of the GNU General Public License as published by the Free Software 00006 * Foundation; either version 2 of the License, or (at your option) any later 00007 * version. 00008 * 00009 * This program is distributed in the hope that it will be useful, but WITHOUT 00010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00011 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 00012 * details. 00013 * 00014 * You should have received a copy of the GNU General Public License along with 00015 * this program; if not, write to the Free Software Foundation, Inc., 51 00016 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 */ 00018 #include "config.h" 00019 00020 #include <stdlib.h> 00021 #include <math.h> 00022 #include <limits.h> 00023 #ifdef HAVE_COMPLEX_H 00024 #include <complex.h> 00025 #endif 00026 00027 #include "nfft3.h" 00028 00029 #ifndef MAX 00030 #define MAX(a,b) (((a)>(b))?(a):(b)) 00031 #endif 00032 00042 static void construct(char * file, int N, int M) 00043 { 00044 int j; /* some variables */ 00045 double real; 00046 double w; 00047 double time,min_time,max_time,min_inh,max_inh; 00048 mri_inh_2d1d_plan my_plan; 00049 FILE *fp,*fout,*fi,*finh,*ftime; 00050 int my_N[3],my_n[3]; 00051 int flags = PRE_PHI_HUT| PRE_PSI |MALLOC_X| MALLOC_F_HAT| 00052 MALLOC_F| FFTW_INIT| FFT_OUT_OF_PLACE| 00053 FFTW_MEASURE| FFTW_DESTROY_INPUT; 00054 00055 double Ts; 00056 double W,T; 00057 int N3; 00058 int m=2; 00059 double sigma = 1.25; 00060 00061 ftime=fopen("readout_time.dat","r"); 00062 finh=fopen("inh.dat","r"); 00063 00064 min_time=INT_MAX; max_time=INT_MIN; 00065 for(j=0;j<M;j++) 00066 { 00067 fscanf(ftime,"%le ",&time); 00068 if(time<min_time) 00069 min_time = time; 00070 if(time>max_time) 00071 max_time = time; 00072 } 00073 00074 fclose(ftime); 00075 00076 Ts=(min_time+max_time)/2.0; 00077 00078 min_inh=INT_MAX; max_inh=INT_MIN; 00079 for(j=0;j<N*N;j++) 00080 { 00081 fscanf(finh,"%le ",&w); 00082 if(w<min_inh) 00083 min_inh = w; 00084 if(w>max_inh) 00085 max_inh = w; 00086 } 00087 fclose(finh); 00088 00089 00090 N3=ceil((MAX(fabs(min_inh),fabs(max_inh))*(max_time-min_time)/2.0+m/(2*sigma))*4*sigma); 00091 T=((max_time-min_time)/2.0)/(0.5-((double) m)/N3); 00092 W=N3/T; 00093 00094 my_N[0]=N; my_n[0]=ceil(N*sigma); 00095 my_N[1]=N; my_n[1]=ceil(N*sigma); 00096 my_N[2]=N3; my_n[2]=N3; 00097 00098 /* initialise nfft */ 00099 mri_inh_2d1d_init_guru(&my_plan, my_N, M, my_n, m, sigma, flags, 00100 FFTW_MEASURE| FFTW_DESTROY_INPUT); 00101 00102 ftime=fopen("readout_time.dat","r"); 00103 fp=fopen("knots.dat","r"); 00104 00105 for(j=0;j<my_plan.M_total;j++) 00106 { 00107 fscanf(fp,"%le %le ",&my_plan.plan.x[2*j+0],&my_plan.plan.x[2*j+1]); 00108 fscanf(ftime,"%le ",&my_plan.t[j]); 00109 my_plan.t[j] = (my_plan.t[j]-Ts)/T; 00110 } 00111 fclose(fp); 00112 fclose(ftime); 00113 00114 finh=fopen("inh.dat","r"); 00115 for(j=0;j<N*N;j++) 00116 { 00117 fscanf(finh,"%le ",&my_plan.w[j]); 00118 my_plan.w[j]/=W; 00119 } 00120 fclose(finh); 00121 00122 00123 fi=fopen("input_f.dat","r"); 00124 for(j=0;j<N*N;j++) 00125 { 00126 fscanf(fi,"%le ",&real); 00127 my_plan.f_hat[j] = real*cexp(2.0*_Complex_I*M_PI*Ts*my_plan.w[j]*W); 00128 } 00129 00130 if(my_plan.plan.flags & PRE_PSI) 00131 nfft_precompute_psi(&my_plan.plan); 00132 00133 mri_inh_2d1d_trafo(&my_plan); 00134 00135 fout=fopen(file,"w"); 00136 00137 for(j=0;j<my_plan.M_total;j++) 00138 { 00139 fprintf(fout,"%le %le %le %le\n",my_plan.plan.x[2*j+0],my_plan.plan.x[2*j+1],creal(my_plan.f[j]),cimag(my_plan.f[j])); 00140 } 00141 00142 fclose(fout); 00143 00144 mri_inh_2d1d_finalize(&my_plan); 00145 } 00146 00147 int main(int argc, char **argv) 00148 { 00149 if (argc <= 3) { 00150 printf("usage: ./construct_data_inh_2d1d FILENAME N M\n"); 00151 return 1; 00152 } 00153 00154 construct(argv[1],atoi(argv[2]),atoi(argv[3])); 00155 00156 return 1; 00157 } 00158 /* \} */