NFFT Logo 3.0 API Reference
Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

construct_data_inh_3d.c

00001 #include <stdlib.h>
00002 #include <math.h>
00003 #include <limits.h>
00004 #include "nfft3.h"
00005 #include "util.h"
00006 
00016 void construct(char * file, int N, int M)
00017 {
00018   int j;                  /* some variables */
00019   double real;
00020   double w;
00021   double time,min_time,max_time,min_inh,max_inh;
00022   mri_inh_3d_plan my_plan;  
00023   FILE *fp,*fout,*fi,*finh,*ftime;
00024   int my_N[3],my_n[3];
00025   int flags = PRE_PHI_HUT| PRE_PSI |MALLOC_X| MALLOC_F_HAT|
00026                       MALLOC_F| FFTW_INIT| FFT_OUT_OF_PLACE|
00027                       FFTW_MEASURE| FFTW_DESTROY_INPUT;
00028 
00029   double Ts;
00030   double W;
00031   int N3;
00032   int m=2;
00033   double sigma = 1.25;
00034 
00035   ftime=fopen("readout_time.dat","r");
00036   finh=fopen("inh.dat","r");
00037 
00038   min_time=INT_MAX; max_time=INT_MIN;
00039   for(j=0;j<M;j++)
00040   {
00041     fscanf(ftime,"%le ",&time);
00042     if(time<min_time)
00043       min_time = time;
00044     if(time>max_time)
00045       max_time = time;
00046   }
00047 
00048   fclose(ftime);
00049   
00050   Ts=(min_time+max_time)/2.0;
00051 
00052   min_inh=INT_MAX; max_inh=INT_MIN;
00053   for(j=0;j<N*N;j++)
00054   {
00055     fscanf(finh,"%le ",&w);
00056     if(w<min_inh)
00057       min_inh = w;
00058     if(w>max_inh)
00059       max_inh = w;
00060   }
00061   fclose(finh);
00062 
00063   N3=ceil((NFFT_MAX(fabs(min_inh),fabs(max_inh))*(max_time-min_time)/2.0+m/(2*sigma))*4*sigma);
00064 
00065   W= NFFT_MAX(fabs(min_inh),fabs(max_inh))/(0.5-((double)m)/N3);
00066 
00067   my_N[0]=N; my_n[0]=ceil(N*sigma);
00068   my_N[1]=N; my_n[1]=ceil(N*sigma);
00069   my_N[2]=N3; my_n[2]=ceil(N3*sigma);
00070   
00071   /* initialise nfft */ 
00072   mri_inh_3d_init_guru(&my_plan, my_N, M, my_n, m, sigma, flags,
00073                       FFTW_MEASURE| FFTW_DESTROY_INPUT);
00074 
00075   ftime=fopen("readout_time.dat","r");
00076   fp=fopen("knots.dat","r");
00077   
00078   for(j=0;j<my_plan.M_total;j++)
00079   {
00080     fscanf(fp,"%le %le",&my_plan.plan.x[3*j+0],&my_plan.plan.x[3*j+1]);
00081     fscanf(ftime,"%le ",&my_plan.plan.x[3*j+2]);
00082     my_plan.plan.x[3*j+2] = (my_plan.plan.x[3*j+2]-Ts)*W/N3;
00083   }
00084   fclose(fp);
00085   fclose(ftime);
00086 
00087   finh=fopen("inh.dat","r");
00088   for(j=0;j<N*N;j++)
00089   {
00090     fscanf(finh,"%le ",&my_plan.w[j]);
00091     my_plan.w[j]/=W;
00092   }
00093   fclose(finh);
00094 
00095 
00096   fi=fopen("input_f.dat","r");
00097   for(j=0;j<N*N;j++)
00098   {
00099     fscanf(fi,"%le ",&real);
00100     my_plan.f_hat[j] = real*cexp(2.0*I*PI*Ts*my_plan.w[j]*W);
00101   }
00102   
00103   if(my_plan.plan.nfft_flags & PRE_PSI)
00104     nfft_precompute_psi(&my_plan.plan);
00105 
00106   mri_inh_3d_trafo(&my_plan);
00107 
00108   fout=fopen(file,"w");
00109   
00110   for(j=0;j<my_plan.M_total;j++)
00111   {
00112     fprintf(fout,"%le %le %le %le\n",my_plan.plan.x[3*j+0],my_plan.plan.x[3*j+1],creal(my_plan.f[j]),cimag(my_plan.f[j]));
00113   }
00114 
00115   fclose(fout);
00116 
00117   mri_inh_3d_finalize(&my_plan);
00118 }
00119 
00120 int main(int argc, char **argv)
00121 { 
00122   if (argc <= 3) {
00123     printf("usage: ./construct_data_inh_3d FILENAME N M\n");
00124     return 1;
00125   }
00126   
00127   construct(argv[1],atoi(argv[2]),atoi(argv[3]));
00128   
00129   return 1;
00130 }
00131 /* \} */

Generated on 1 Nov 2006 by Doxygen 1.4.4