Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

kernel-frequency-acq.c

Go to the documentation of this file.
00001 /************************************************************************* 00002 * $Id: kernel-frequency-acq.c,v 1.5 2005/09/09 08:22:19 bellet Exp $ 00003 ************************************************************************** 00004 This software is governed by the CeCILL license under French law and 00005 abiding by the rules of distribution of free software. You can use, 00006 modify and/ or redistribute the software under the terms of the CeCILL 00007 license as circulated by CEA, CNRS and INRIA at the following URL 00008 "http://www.cecill.info". 00009 00010 As a counterpart to the access to the source code and rights to copy, 00011 modify and redistribute granted by the license, users are provided only 00012 with a limited warranty and the software's author, the holder of the 00013 economic rights, and the successive licensors have only limited 00014 liability. 00015 00016 In this respect, the user's attention is drawn to the risks associated 00017 with loading, using, modifying and/or developing or reproducing the 00018 software by the user in light of its specific status of free software, 00019 that may mean that it is complicated to manipulate, and that also 00020 therefore means that it is reserved for developers and experienced 00021 professionals having in-depth computer knowledge. Users are therefore 00022 encouraged to load and test the software's suitability as regards their 00023 requirements in conditions enabling the security of their systems and/or 00024 data to be ensured and, more generally, to use and operate it in the 00025 same conditions as regards security. 00026 00027 The fact that you are presently reading this means that you have had 00028 knowledge of the CeCILL license and that you accept its terms. 00029 00030 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de 00031 l'Image). All rights reserved. See License.txt for details. 00032 00033 Version 1.0 05/09/2005 00034 *************************************************************************/ 00035 00036 #include "kernel-frequency-acq.h" 00037 #include <math.h> 00038 #ifdef HAVE_MPI 00039 #include <mpi.h> 00040 #include "seq-mpi.h" /* for MPI TAGS definition */ 00041 #endif 00042 00052 void KernelFrequency1(EXPERIENCE3D * expr, EVENT * event) 00053 { 00054 int ix, iy, iz; 00055 float sgn[3]; 00056 double v; 00057 int xmin; 00058 int xmax; 00059 00060 #ifdef HAVE_MPI 00061 xmin= expr->mpi_slice_x0; 00062 xmax= xmin+mpi_get_slice_width(expr, xmin); 00063 #else 00064 xmin = 0; 00065 xmax = expr->nfovx; 00066 #endif 00067 00068 sgn[0] = 0.; 00069 sgn[1] = 0.; 00070 sgn[2] = 0.; 00071 00072 if (event->op_flag == PLUS) 00073 { 00074 for (ix=xmin;ix<xmax;ix++) 00075 for(iy=expr->nfovy -1;iy>=0;iy--) 00076 for(iz=expr->nfovz -1;iz>=0;iz--) 00077 { /* Spins summation */ 00078 /* T2* in the transverse plane xy */ 00079 v = exp(-fabs(expr->to*G_Hz_T*expr->deltaB0[ix][iy][iz])); 00080 sgn[0] += (float) expr->magstate[0][ix][iy][iz]* (float)v; 00081 sgn[1] += (float) expr->magstate[1][ix][iy][iz]* (float)v; 00082 sgn[2] += (float) expr->magstate[2][ix][iy][iz]; 00083 } 00084 } 00085 else if (event->op_flag == MINUS) 00086 { 00087 for (ix=xmin;ix<xmax;ix++) 00088 for(iy=expr->nfovy -1;iy>=0;iy--) 00089 for(iz=expr->nfovz -1;iz>=0;iz--) 00090 { /* Spins summation */ 00091 /* T2* in the transverse plane xy */ 00092 v = exp(-fabs(expr->to*G_Hz_T*expr->deltaB0[ix][iy][iz])); 00093 sgn[0] -= (float) expr->magstate[0][ix][iy][iz]* (float) v; 00094 sgn[1] -= (float) expr->magstate[1][ix][iy][iz]* (float) v; 00095 sgn[2] -= (float) expr->magstate[2][ix][iy][iz]; 00096 } 00097 } 00098 00099 /* First k space point saving */ 00100 #ifndef OSCILLO 00101 expr->sgn[0][0][event->nu_pointy][event->nu_pointz] += sgn[0]; 00102 expr->sgn[1][0][event->nu_pointy][event->nu_pointz] += sgn[1]; 00103 expr->sgn[2][0][event->nu_pointy][event->nu_pointz] += sgn[2]; 00104 #else 00105 expr->sgn[0][0][event->nu_pointy][event->nu_pointz] = sgn[0]; 00106 expr->sgn[1][0][event->nu_pointy][event->nu_pointz] = sgn[1]; 00107 expr->sgn[2][0][event->nu_pointy][event->nu_pointz] = sgn[2]; 00108 #endif 00109 } 00110 00119 void KernelFrequency2(EXPERIENCE3D * expr, EVENT * event) 00120 { 00121 double v; 00122 double x, y, z, dw,edw; 00123 double p6x, p6y, p6z, p9x, p9y, p9z; 00124 double e1, e2, teta, rmnx, r1, r2; 00125 double *e0xyz, *e1xyz, *e2xyz; 00126 int ix, iy, iz, it; 00127 float *sgn[3]; 00128 int xmin; 00129 int xmax; 00130 00131 #ifdef HAVE_MPI 00132 xmin=expr->mpi_slice_x0; 00133 xmax=xmin+mpi_get_slice_width(expr, xmin); 00134 #else 00135 xmin = 0; 00136 xmax = expr->nfovx; 00137 #endif 00138 00139 p6x = G * event->ax; 00140 p9x = expr->xf + expr->obx - event->axoff; 00141 p6y = G * event->ay; 00142 p9y = expr->yf + expr->oby - event->ayoff; 00143 p6z = G * event->az; 00144 p9z = expr->zf + expr->obz - event->azoff; 00145 00146 /* RF signal allocation */ 00147 sgn[0] = (float *)malloc (expr->ntx * sizeof(float)); 00148 sgn[1] = (float *)malloc (expr->ntx * sizeof(float)); 00149 sgn[2] = (float *)malloc (expr->ntx * sizeof(float)); 00150 00151 /* RF signal point acquisition */ 00152 for (it = 1; it < expr->ntx; it++) 00153 { 00154 sgn[0][it] = 0.; 00155 sgn[1][it] = 0.; 00156 sgn[2][it] = 0.; 00157 /* T2* account */ 00158 expr->to = expr->to + expr->pt; 00159 00160 for (ix = xmin; ix < xmax; ix++) { 00161 x = expr->px * ix - p9x; 00162 for (iy = expr->nfovy - 1; iy >= 0; iy--) { 00163 y = expr->py * iy - p9y; 00164 for (iz = expr->nfovz - 1; iz >= 0; iz--) 00165 { /* Update of the spin states (Bloch) before the it point acquisition */ 00166 z = expr->pz * iz - p9z; 00167 00168 e0xyz = &(expr->magstate[0][ix][iy][iz]); 00169 e1xyz = &(expr->magstate[1][ix][iy][iz]); 00170 e2xyz = &(expr->magstate[2][ix][iy][iz]); 00171 00172 /* dw is given in rad/s */ 00173 // dw =(p6x * x)+(p6y * y)+(p6z * z)-(expr->G_edw)+G_rad_T*expr->G_deche[ix][iy][iz]; 00174 edw = expr->G_edw *(expr->B0+1.*(event->ax*x + event->ay*y + event->az*z) + expr->G_deche[ix][iy][iz]); 00175 dw = G_rad_T*(event->ax*x + event->ay*y + event->az*z + expr->G_deche[ix][iy][iz]) - edw; 00176 teta = dw * expr->pt; 00177 00178 e1 = exp(-expr->pt / expr->t1[ix][iy][iz]); 00179 e2 = exp(-expr->pt / expr->t2[ix][iy][iz]); 00180 00181 r1 = e2 * cos(teta); 00182 r2 = e2 * sin(teta); 00183 00184 rmnx = r1 * e0xyz[0] + r2 * e1xyz[0]; 00185 e1xyz[0] = -r2 * e0xyz[0] + r1 * e1xyz[0]; 00186 e2xyz[0] = e1 * e2xyz[0] + expr->ro[ix][iy][iz] * (1 - e1); 00187 e0xyz[0] = rmnx; 00188 00189 v = exp(-fabs(expr->to*G_Hz_T*expr->deltaB0[ix][iy][iz])); 00190 if (event->op_flag == PLUS) 00191 { /* Spins summation */ 00192 /* T2* in the transverse plane xy */ 00193 sgn[0][it] += (float) e0xyz[0] * (float) v; 00194 sgn[1][it] += (float) e1xyz[0] * (float) v; 00195 sgn[2][it] += (float) e2xyz[0]; 00196 } 00197 else if (event->op_flag == MINUS) 00198 { /* Spins summation */ 00199 /* T2* in the transverse plane xy */ 00200 sgn[0][it] -= (float) e0xyz[0] * (float) v; 00201 sgn[1][it] -= (float) e1xyz[0] * (float) v; 00202 sgn[2][it] -= (float) e2xyz[0]; 00203 } 00204 00205 } 00206 } 00207 } 00208 } 00209 00210 #ifndef OSCILLO 00211 for (it = 1; it < expr->ntx; it++) { 00212 expr->sgn[0][it][event->nu_pointy][event->nu_pointz] += sgn[0][it]; 00213 expr->sgn[1][it][event->nu_pointy][event->nu_pointz] += sgn[1][it]; 00214 expr->sgn[2][it][event->nu_pointy][event->nu_pointz] += sgn[2][it]; 00215 } 00216 #else 00217 for (it = 1; it < expr->ntx; it++) { 00218 expr->sgn[0][it][event->nu_pointy][event->nu_pointz] = sgn[0][it]; 00219 expr->sgn[1][it][event->nu_pointy][event->nu_pointz] = sgn[1][it]; 00220 expr->sgn[2][it][event->nu_pointy][event->nu_pointz] = sgn[2][it]; 00221 } 00222 #endif 00223 00224 free(sgn[0]); 00225 free(sgn[1]); 00226 free(sgn[2]); 00227 00228 if (event->spoiling_flag==1) 00229 /* Numerical spoiling : Canceling the transverse magnetisation */ 00230 for (ix=xmin;ix<xmax;ix++) 00231 for(iy=expr->nfovy -1;iy>=0;iy--) 00232 for(iz=expr->nfovz -1;iz>=0;iz--) 00233 { 00234 expr->magstate[0][ix][iy][iz]=0.0; 00235 expr->magstate[1][ix][iy][iz]=0.0; 00236 } 00237 00238 }

Generated on Wed Oct 19 09:28:34 2005 for SIMRI3D by doxygen 1.3.7