00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
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.)
00051
ResetToExperience(expr);
00052
00053 agz = event->
agz;
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;
00077
int ip;
00078
double b1,fact,som,B,A,trp,b1v,angle_elementaire,agz;
00079 FILE *fic;
00080
00081 agz=event->
agz;
00082
00083
00084
00085
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
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
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;
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
00152 som=0;
00153
for(ip=0;ip<nb_points;ip++) som=som+fpul[ip];
00154 fact=nb_points/som;
00155
00156
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