NFFT Logo 3.1.1 API Reference

construct_data_inh_2d1d.c

00001 /*
00002  * Copyright (c) 2002, 2009 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 
00019 /* $Id: construct_data_inh_2d1d.c 3198 2009-05-27 14:16:50Z keiner $ */
00020 
00021 #include <stdlib.h>
00022 #include <math.h>
00023 #include <limits.h>
00024 #include <complex.h>
00025 
00026 #include "nfft3.h"
00027 #include "nfft3util.h"
00028 
00038 void construct(char * file, int N, int M)
00039 {
00040   int j;                  /* some variables */
00041   double real;
00042   double w;
00043   double time,min_time,max_time,min_inh,max_inh;
00044   mri_inh_2d1d_plan my_plan;
00045   FILE *fp,*fout,*fi,*finh,*ftime;
00046   int my_N[3],my_n[3];
00047   int flags = PRE_PHI_HUT| PRE_PSI |MALLOC_X| MALLOC_F_HAT|
00048                       MALLOC_F| FFTW_INIT| FFT_OUT_OF_PLACE|
00049                       FFTW_MEASURE| FFTW_DESTROY_INPUT;
00050 
00051   double Ts;
00052   double W,T;
00053   int N3;
00054   int m=2;
00055   double sigma = 1.25;
00056 
00057   ftime=fopen("readout_time.dat","r");
00058   finh=fopen("inh.dat","r");
00059 
00060   min_time=INT_MAX; max_time=INT_MIN;
00061   for(j=0;j<M;j++)
00062   {
00063     fscanf(ftime,"%le ",&time);
00064     if(time<min_time)
00065       min_time = time;
00066     if(time>max_time)
00067       max_time = time;
00068   }
00069 
00070   fclose(ftime);
00071 
00072   Ts=(min_time+max_time)/2.0;
00073 
00074   min_inh=INT_MAX; max_inh=INT_MIN;
00075   for(j=0;j<N*N;j++)
00076   {
00077     fscanf(finh,"%le ",&w);
00078     if(w<min_inh)
00079       min_inh = w;
00080     if(w>max_inh)
00081       max_inh = w;
00082   }
00083   fclose(finh);
00084 
00085 
00086   N3=ceil((NFFT_MAX(fabs(min_inh),fabs(max_inh))*(max_time-min_time)/2.0+m/(2*sigma))*4*sigma);
00087   T=((max_time-min_time)/2.0)/(0.5-((double) m)/N3);
00088   W=N3/T;
00089 
00090   my_N[0]=N; my_n[0]=ceil(N*sigma);
00091   my_N[1]=N; my_n[1]=ceil(N*sigma);
00092   my_N[2]=N3; my_n[2]=N3;
00093 
00094   /* initialise nfft */
00095   mri_inh_2d1d_init_guru(&my_plan, my_N, M, my_n, m, sigma, flags,
00096                       FFTW_MEASURE| FFTW_DESTROY_INPUT);
00097 
00098   ftime=fopen("readout_time.dat","r");
00099   fp=fopen("knots.dat","r");
00100 
00101   for(j=0;j<my_plan.M_total;j++)
00102   {
00103     fscanf(fp,"%le %le ",&my_plan.plan.x[2*j+0],&my_plan.plan.x[2*j+1]);
00104     fscanf(ftime,"%le ",&my_plan.t[j]);
00105     my_plan.t[j] = (my_plan.t[j]-Ts)/T;
00106   }
00107   fclose(fp);
00108   fclose(ftime);
00109 
00110   finh=fopen("inh.dat","r");
00111   for(j=0;j<N*N;j++)
00112   {
00113     fscanf(finh,"%le ",&my_plan.w[j]);
00114     my_plan.w[j]/=W;
00115   }
00116   fclose(finh);
00117 
00118 
00119   fi=fopen("input_f.dat","r");
00120   for(j=0;j<N*N;j++)
00121   {
00122     fscanf(fi,"%le ",&real);
00123     my_plan.f_hat[j] = real*cexp(2.0*_Complex_I*PI*Ts*my_plan.w[j]*W);
00124   }
00125 
00126   if(my_plan.plan.nfft_flags & PRE_PSI)
00127     nfft_precompute_psi(&my_plan.plan);
00128 
00129   mri_inh_2d1d_trafo(&my_plan);
00130 
00131   fout=fopen(file,"w");
00132 
00133   for(j=0;j<my_plan.M_total;j++)
00134   {
00135     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]));
00136   }
00137 
00138   fclose(fout);
00139 
00140   mri_inh_2d1d_finalize(&my_plan);
00141 }
00142 
00143 int main(int argc, char **argv)
00144 {
00145   if (argc <= 3) {
00146     printf("usage: ./construct_data_inh_2d1d FILENAME N M\n");
00147     return 1;
00148   }
00149 
00150   construct(argv[1],atoi(argv[2]),atoi(argv[3]));
00151 
00152   return 1;
00153 }
00154 /* \} */

Generated on 17 Aug 2009 by Doxygen 1.5.3