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

event-rfpulse.c

Go to the documentation of this file.
00001 /************************************************************************* 00002 * $Id: event-rfpulse.c,v 1.7 2005/09/22 11:42:36 yougz 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 "event-rfpulse.h" 00046 void DoPulseRect(EXPERIENCE3D * expr,EVENT * event, double angle, double duration) 00047 { 00048 double agz; 00049 00050 if (angle==90.) /* T2* weighting init */ 00051 ResetToExperience(expr); 00052 00053 agz = event->agz; // saving the gradient value because event->agz set to zero in init_evente3D 00054 InitEvent(event); 00055 event->agz = agz; 00056 event->ang = angle; 00057 event->pulse_duration = duration; 00058 Conversion(event); 00059 Kernel(expr, event); 00060 } 00061 00073 void DoPulseSinc(EXPERIENCE3D * expr,EVENT * event, double angle, double duration, int nb_points, int nb_lobs) 00074 { 00075 00076 double *fpul;//save the basic rectangular RF pulse used to define sinc shaped pulse 00077 int ip; 00078 double b1,fact,som,B,A,trp,b1v,angle_elementaire,agz; 00079 FILE *fic; 00080 00081 agz=event->agz;// saving the gradient value because event->agz set to zero in init_evente3D 00082 00083 // Computation of the table containing the set of nb_points rectangular RF pulse defining the sinc one 00084 // Of the rectangular pulse have the same duration (duration/nb_points) and their amplitude vary 00085 // The angle sum is equal to the global angle 00086 fpul=(double *)malloc(nb_points*sizeof(double)); 00087 som=0; 00088 A = duration/2.0; 00089 B=nb_lobs*M_PI/A; 00090 for(ip=0;ip<nb_points;ip++) 00091 { 00092 trp=ip*duration/nb_points; 00093 if(trp==A) fpul[ip]=1; 00094 else fpul[ip]=sin(B*(trp-A))/(B*(trp-A)); 00095 som=som+fpul[ip]; 00096 } 00097 fact=nb_points/som; 00098 00099 // Temporary saving 00100 fic=fopen("sinus.txt","w"); 00101 for(ip=0;ip<nb_points;ip++) fprintf(fic,"%f\n",fpul[ip]); 00102 fclose(fic); 00103 00104 // Applying the nb_points pulses 00105 agz=event->agz; 00106 b1=angle/(G*duration*1e-6)*fact; 00107 for(ip=0;ip<nb_points;ip=ip++) 00108 { 00109 b1v=b1*fpul[ip]; 00110 angle_elementaire=b1v*G*duration*1e-6/nb_points; 00111 event->agz=agz; 00112 DoPulseRect(expr,event, angle_elementaire, duration/nb_points); 00113 } 00114 free(fpul); 00115 } 00116 00117 00129 void DoPulseFile(EXPERIENCE3D * expr,EVENT * event, double angle, double duration, char *filename) 00130 { 00131 FILE *fic; 00132 int ip; 00133 double b1,fact,som,b1v,angle_elementaire,agz; 00134 double *fpul; 00135 int nb_points; 00136 00137 agz=event->agz; // saving the gradient value because event->agz set to zero in init_evente3D 00138 00139 fic=fopen(filename,"r"); 00140 if(fic==NULL) 00141 { 00142 printf("Unable to open the file %s containing the RF pulses! \n",filename); 00143 exit(-1); 00144 } 00145 00146 fscanf(fic,"%d ",&nb_points); 00147 fpul=(double *)malloc(nb_points*sizeof(double)); 00148 for(ip=0;ip<nb_points;ip++) fscanf(fic,"%lf ",&fpul[ip]); 00149 00150 fclose(fic); 00151 // Normalisation 00152 som=0; 00153 for(ip=0;ip<nb_points;ip++) som=som+fpul[ip]; 00154 fact=nb_points/som; 00155 00156 // Apply the pulses 00157 agz=event->agz; 00158 som=0; 00159 b1=angle/(G*duration*1e-6)*fact; 00160 for(ip=0;ip<nb_points;ip=ip++) 00161 { 00162 b1v=b1*fpul[ip]; 00163 angle_elementaire=b1v*G*duration*1e-6/nb_points; 00164 event->agz=agz; 00165 printf("ipnum=%d : %d \n",ip,nb_points); 00166 DoPulseRect(expr,event, angle_elementaire, duration/nb_points); 00167 som=som+angle_elementaire; 00168 } 00169 free(fpul); 00170 } 00171

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