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

mri.c

00001 #include "string.h"
00002 
00003 #include "nfft3.h"
00004 #include "options.h"
00005 #include "util.h"
00006 #include "window_defines.h"
00007 #include "math.h"
00008 
00014 typedef struct window_funct_plan_ {
00015   int d;
00016   int m;
00017   int n[1];
00018   double sigma[1];
00019   double *b;
00020   double *spline_coeffs;                
00022 } window_funct_plan;
00023 
00024 
00028 void window_funct_init(window_funct_plan* ths, int m, int n, double sigma) {
00029   ths->d=1;
00030   ths->m=m;
00031   ths->n[0]=n;
00032   ths->sigma[0]=sigma;
00033   WINDOW_HELP_INIT
00034 }
00035 
00036 /*
00037  * mri_inh_2d1d
00038  */
00039                                                                        
00040 void mri_inh_2d1d_trafo(mri_inh_2d1d_plan *that) {
00041   int l,j;
00042   complex double *f = (complex double*) fftw_malloc(that->M_total*sizeof(complex double));
00043   complex double *f_hat = (complex double*) fftw_malloc(that->N_total*sizeof(complex double));
00044 
00045   window_funct_plan *ths = (window_funct_plan*) fftw_malloc(sizeof(window_funct_plan));
00046   window_funct_init(ths,that->plan.m,that->N3,that->sigma3);
00047   
00048   /* the pointers that->f and that->f_hat have been modified by the solver */
00049   that->plan.f = that->f;
00050   that->plan.f_hat = that->f_hat;
00051 
00052   
00053   memset(f,0,that->M_total*sizeof(complex double));
00054   for(j=0;j<that->N_total;j++)
00055   {
00056     f_hat[j]=that->f_hat[j];
00057   }
00058 
00059   for(l=-ths->n[0]/2;l<=ths->n[0]/2;l++) {
00060     for(j=0;j<that->N_total;j++)
00061       that->f_hat[j]*=cexp(-2*PI*I*that->w[j]*((double)l))/PHI_HUT(ths->n[0]*that->w[j],0);
00062     nfft_trafo(&that->plan);
00063     for(j=0;j<that->M_total;j++){
00064       /* PHI has compact support */
00065       if(fabs(that->t[j]-((double)l)/((double)ths->n[0]))<that->plan.m/((double)ths->n[0])) 
00066         f[j]+=that->f[j]*PHI(that->t[j]-((double)l)/((double)ths->n[0]),0);
00067     }
00068     for(j=0;j<that->N_total;j++)
00069       that->f_hat[j]=f_hat[j];
00070   }
00071 
00072   fftw_free(that->plan.f);
00073   that->f=f;
00074   that->plan.f = that->f;
00075   
00076   fftw_free(f_hat);
00077   
00078   WINDOW_HELP_FINALIZE
00079   fftw_free(ths);
00080 }
00081 
00082 void mri_inh_2d1d_adjoint(mri_inh_2d1d_plan *that) {
00083   int l,j;
00084   complex double *f = (complex double*) fftw_malloc(that->M_total*sizeof(complex double));
00085   complex double *f_hat = (complex double*) fftw_malloc(that->N_total*sizeof(complex double));
00086 
00087   window_funct_plan *ths = (window_funct_plan*) fftw_malloc(sizeof(window_funct_plan));
00088   window_funct_init(ths,that->plan.m,that->N3,that->sigma3);
00089   
00090   memset(f_hat,0,that->N_total*sizeof(complex double));
00091   
00092   /* the pointers that->f and that->f_hat have been modified by the solver */
00093   that->plan.f = that->f;
00094   that->plan.f_hat = that->f_hat;
00095   
00096   for(j=0;j<that->M_total;j++)
00097   {
00098     f[j]=that->f[j];
00099   }
00100 
00101 
00102   
00103   for(l=-ths->n[0]/2;l<=ths->n[0]/2;l++) {
00104     
00105     for(j=0;j<that->M_total;j++) {
00106       /* PHI has compact support */
00107       if(fabs(that->t[j]-((double)l)/((double)ths->n[0]))<that->plan.m/((double)ths->n[0])) 
00108         that->f[j]*=PHI(that->t[j]-((double)l)/((double)ths->n[0]),0);
00109       else
00110         that->f[j]=0.0;
00111     }
00112     nfft_adjoint(&that->plan);
00113     for(j=0;j<that->N_total;j++)
00114       f_hat[j]+=that->f_hat[j]*cexp(2*PI*I*that->w[j]*((double)l));
00115     for(j=0;j<that->M_total;j++)
00116       that->f[j]=f[j];
00117   }
00118 
00119   for(j=0;j<that->N_total;j++)
00120   {
00121     f_hat[j] /= PHI_HUT(ths->n[0]*that->w[j],0);
00122   }
00123 
00124   fftw_free(that->plan.f_hat);
00125   that->f_hat=f_hat;
00126   that->plan.f_hat = that->f_hat;
00127   
00128   fftw_free(f);
00129   
00130   WINDOW_HELP_FINALIZE
00131   fftw_free(ths);
00132 }
00133 
00134 void mri_inh_2d1d_init_guru(mri_inh_2d1d_plan *ths, int *N, int M, int *n,
00135                     int m, double sigma, unsigned nfft_flags, unsigned fftw_flags) {
00136 
00137   nfft_init_guru(&ths->plan,2,N,M,n,m,nfft_flags,fftw_flags);
00138   ths->N3=N[2];
00139   ths->sigma3=sigma;
00140   ths->N_total = ths->plan.N_total;
00141   ths->M_total = ths->plan.M_total;
00142   ths->f = ths->plan.f;
00143   ths->f_hat = ths->plan.f_hat;
00144   
00145   ths->t = (double*) fftw_malloc(ths->M_total*sizeof(double));
00146   ths->w = (double*) fftw_malloc(ths->N_total*sizeof(double));
00147 }
00148 
00149 void mri_inh_2d1d_finalize(mri_inh_2d1d_plan *ths) {
00150   fftw_free(ths->t);
00151   fftw_free(ths->w);
00152   
00153   /* the pointers ths->f and ths->f_hat have been modified by the solver */
00154   ths->plan.f = ths->f;
00155   ths->plan.f_hat = ths->f_hat;
00156   
00157   nfft_finalize(&ths->plan);
00158 }
00159 
00160 /*
00161  * mri_inh_3d
00162  */
00163 
00164 void mri_inh_3d_trafo(mri_inh_3d_plan *that) {
00165   int l,j;
00166   window_funct_plan *ths = (window_funct_plan*) fftw_malloc(sizeof(window_funct_plan));
00167   window_funct_init(ths,that->plan.m,that->N3,that->sigma3);
00168 
00169   /* the pointers that->f has been modified by the solver */
00170   that->plan.f =that->f ;
00171   
00172 
00173 
00174   for(j=0;j<that->N_total;j++) {
00175     for(l=-ths->n[0]/2;l<ths->n[0]/2;l++)
00176     {
00177       /* PHI has compact support */
00178       if(fabs(that->w[j]-((double)l)/((double)ths->n[0]))<ths->m/((double)ths->n[0])) 
00179         that->plan.f_hat[j*ths->n[0]+(l+ths->n[0]/2)]= that->f_hat[j]*PHI(that->w[j]-((double)l)/((double)ths->n[0]),0);
00180       else
00181         that->plan.f_hat[j*ths->n[0]+(l+ths->n[0]/2)]=0.0;
00182     }
00183   }
00184   
00185   nfft_trafo(&that->plan);
00186   
00187   for(j=0;j<that->M_total;j++)
00188   {
00189     that->f[j] /= PHI_HUT(ths->n[0]*that->plan.x[3*j+2],0);
00190   }
00191 
00192   WINDOW_HELP_FINALIZE
00193   fftw_free(ths);
00194 }
00195 
00196 void mri_inh_3d_adjoint(mri_inh_3d_plan *that) {
00197   int l,j;
00198   window_funct_plan *ths = (window_funct_plan*) fftw_malloc(sizeof(window_funct_plan));
00199   window_funct_init(ths,that->plan.m,that->N3,that->sigma3);
00200 
00201   /* the pointers that->f has been modified by the solver */
00202   that->plan.f =that->f ;
00203   
00204   for(j=0;j<that->M_total;j++)
00205   {
00206     that->f[j] /= PHI_HUT(ths->n[0]*that->plan.x[3*j+2],0);
00207   }
00208   
00209   nfft_adjoint(&that->plan);
00210 
00211   for(j=0;j<that->N_total;j++) {
00212     that->f_hat[j]=0.0;
00213     for(l=-ths->n[0]/2;l<ths->n[0]/2;l++)
00214     {
00215       /* PHI has compact support */
00216       if(fabs(that->w[j]-((double)l)/((double)ths->n[0]))<ths->m/((double)ths->n[0])) 
00217         that->f_hat[j]+= that->plan.f_hat[j*ths->n[0]+(l+ths->n[0]/2)]*PHI(that->w[j]-((double)l)/((double)ths->n[0]),0);
00218     }
00219   }
00220 
00221   
00222   WINDOW_HELP_FINALIZE
00223   fftw_free(ths);
00224 }
00225 
00226 void mri_inh_3d_init_guru(mri_inh_3d_plan *ths, int *N, int M, int *n,
00227                     int m, double sigma, unsigned nfft_flags, unsigned fftw_flags) {
00228   ths->N3=N[2];
00229   ths->sigma3=sigma;
00230   nfft_init_guru(&ths->plan,3,N,M,n,m,nfft_flags,fftw_flags);
00231   ths->N_total = N[0]*N[1];
00232   ths->M_total = ths->plan.M_total;
00233   ths->f = ths->plan.f;
00234   ths->f_hat = (complex double*) fftw_malloc(ths->N_total*sizeof(complex double));
00235   ths->w = (double*) fftw_malloc(ths->N_total*sizeof(double));
00236 }
00237 
00238 void mri_inh_3d_finalize(mri_inh_3d_plan *ths) {
00239   fftw_free(ths->w);
00240   fftw_free(ths->f_hat);
00241   nfft_finalize(&ths->plan);
00242 }

Generated on 1 Nov 2006 by Doxygen 1.4.4