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

test-rmn.c

Go to the documentation of this file.
00001 /************************************************************************* 00002 * $Id: test-rmn.c,v 1.27 2005/09/09 11:41:16 yougz Exp $ 00003 ************************************************************************** 00004 This file contains several functions that run 1D RMN experience like FID, 00005 Train of spin echoes, train of gradient echoes ... 00006 ************************************************************************** 00007 This software is governed by the CeCILL license under French law and 00008 abiding by the rules of distribution of free software. You can use, 00009 modify and/ or redistribute the software under the terms of the CeCILL 00010 license as circulated by CEA, CNRS and INRIA at the following URL 00011 "http://www.cecill.info". 00012 00013 As a counterpart to the access to the source code and rights to copy, 00014 modify and redistribute granted by the license, users are provided only 00015 with a limited warranty and the software's author, the holder of the 00016 economic rights, and the successive licensors have only limited 00017 liability. 00018 00019 In this respect, the user's attention is drawn to the risks associated 00020 with loading, using, modifying and/or developing or reproducing the 00021 software by the user in light of its specific status of free software, 00022 that may mean that it is complicated to manipulate, and that also 00023 therefore means that it is reserved for developers and experienced 00024 professionals having in-depth computer knowledge. Users are therefore 00025 encouraged to load and test the software's suitability as regards their 00026 requirements in conditions enabling the security of their systems and/or 00027 data to be ensured and, more generally, to use and operate it in the 00028 same conditions as regards security. 00029 00030 The fact that you are presently reading this means that you have had 00031 knowledge of the CeCILL license and that you accept its terms. 00032 00033 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de 00034 l'Image). All rights reserved. See License.txt for details. 00035 00036 Version 1.0 05/09/2005 00037 00038 *************************************************************************/ 00039 #include "test-rmn.h" 00040 #include <idvol.h> 00041 #include <idacr.h> 00042 #include "simri3d.h" 00043 #include "experience.h" 00044 #include "object.h" 00045 #include "object-simple.h" 00046 #include "output.h" 00047 #include "display.h" 00048 #include "event-rfpulse.h" 00049 #include "event-precession.h" 00050 #include "event-acquisition.h" 00051 00052 #ifdef HAVE_MPI 00053 #include <mpi.h> 00054 #endif 00055 00064 void TestFID1D(int objsize,int sigsize) 00065 { 00066 char fic[80]; 00067 int x,y,z; 00068 double fovx,fovy,fovz; 00069 double Tacq; /* in s */ 00070 int ro,t1,t2; 00071 double acq_delay; /* in ms */ 00072 int tacq; 00073 OBJECT3D *object; 00074 EXPERIENCE3D* expr; 00075 EVENT* event, event_r; 00076 PPPVOLUME_COMPLEX_DOUBLE volrf; 00077 PPPVOLUME_FLOAT volrecmod,volz,voly; 00078 #ifdef HAVE_MPI 00079 int rank; 00080 #endif 00081 fic[0]='\0'; 00082 printf("Start TestFID1D \n"); 00083 event = &event_r; 00084 expr = AllocExperience(); 00085 x=objsize; y=1; z=1; 00086 t1=150; t2=200; ro=10; 00087 object=CreateHomogeneousObject(x,y,z,t1,t2,ro); 00088 SetObjectSize(object,(float)0.2,(float)0.0002,(float)0.0002); 00089 fovx=0.20; fovy=0.00020; fovz=0.00020; 00090 00091 /* T2* weighting */ 00092 SetObjectDeltaB0(object,0.0000001); 00093 00094 SetB0Experience(expr,1.5); 00095 SetObjectExperienceComponent(expr,object,WATER,0); 00096 SetFovExperience(expr,fovx,1,1,0,0,0); 00097 tacq=800; /* in ms */ 00098 Tacq = tacq * 1.e-3; /* conversion in s */ 00099 SetAcqExperience(expr,sigsize,1,1,Tacq); 00100 acq_delay=0; 00101 00102 DoWaiting(expr,event,ATT_INIT); 00103 00104 DoPulseRect(expr,event, 90., 300.); 00105 DoAcqFrequenceX(expr,event,0,0,0,acq_delay,PLUS); 00106 00107 /* Vizualisation of the T2* decay */ 00108 voly=GetSignalRFComponentFromExperience(expr,1); 00109 DisplayVolX((PPPVOLUME)voly,0,0,"Antenne Y",0,""); 00110 IdVolFree(voly); 00111 /* Vizualisation of the T1 growing*/ 00112 volz=GetSignalRFComponentFromExperience(expr,2); 00113 00114 event = &event_r; 00115 expr=AllocExperience(); 00116 00117 DisplayVolX((PPPVOLUME)volz,0,0,"Antenne Z",0,""); 00118 IdVolFree(volz); 00119 00120 volrf = GetSignalRFComplexFromExperience(expr); 00121 FreeExperience(expr); 00122 00123 volrecmod = RecVolIFFTModuleFromVol(volrf); 00124 volrf=NULL; 00125 00126 #ifdef HAVE_MPI 00127 MPI_Comm_rank(MPI_COMM_WORLD,&rank); 00128 if (rank==0) 00129 WriteVolRecUchar(volrecmod,"imafid1dsimri.acr"); 00130 #else 00131 WriteVolRecUchar(volrecmod,"imafid1dsimri.acr"); 00132 #endif 00133 IdVolFree(volrecmod); 00134 00135 printf("End TestFID1D \n"); 00136 } 00137 00146 void TestEchoSpin1D(int objsize,int sigsize) 00147 { 00148 char fic[80]; 00149 int x,y,z; 00150 double fovx,fovy,fovz; 00151 int ro,t1,t2; 00152 double acq_delay; /* in ms */ 00153 double TE,t; 00154 double timp; /* in ms */ 00155 int tacq; /* in ms */ 00156 OBJECT3D *object; 00157 EXPERIENCE3D* expr; 00158 EVENT* event, event_r; 00159 PPPVOLUME_COMPLEX_DOUBLE volrf; 00160 PPPVOLUME_FLOAT volrecmod,voly; 00161 #ifdef HAVE_MPI 00162 int rank; 00163 #endif 00164 00165 event = &event_r; 00166 expr=AllocExperience(); 00167 00168 fic[0]='\0'; 00169 printf("Sart EchoSpin1D \n"); 00170 00171 x=objsize; y=1; z=1; 00172 t1=500; t2=300; ro=77; 00173 object=CreateHomogeneousObject(x,y,z,t1,t2,ro); 00174 SetObjectSize(object,(float)0.2,(float)0.0002,(float)0.0002); 00175 fovx=0.20; fovy=0.00020; fovz=0.00020; 00176 00177 SetObjectDeltaB0(object,1.e-5); 00178 SetB0Experience(expr,1.); 00179 SetObjectExperienceComponent(expr,object,WATER,0); 00180 SetFovExperience(expr,fovx,1,1,0,0,0); 00181 tacq=10; /* en ms */ 00182 SetAcqExperience(expr,sigsize,1,1,(tacq * 1.e-3)); 00183 acq_delay=0.; 00184 00185 timp=300.; 00186 TE=20.; 00187 t=TE/2; /* equals TE/2 in ms */ 00188 00189 DoWaiting(expr,event,ATT_INIT); 00190 printf("Mo=%lf \n",expr->magstate[2][objsize/2][0][0]*objsize); 00191 00192 DoPulseRect(expr,event, 90.,timp); 00193 DoWaiting(expr,event,t-timp*1.e-3); 00194 DoPulseRect(expr,event, 180.,timp); 00195 DoWaiting(expr,event,t+timp*1.e-3-(tacq/2.+tacq/2./sigsize)); 00196 00197 DoAcqFrequenceX(expr,event,0,0,0,acq_delay,MINUS); 00198 00199 voly=GetSignalRFComponentFromExperience(expr,1); 00200 DisplayVolX((PPPVOLUME)voly,0,0,"Antenne Y",0,""); 00201 IdVolFree(voly); 00202 00203 volrf = GetSignalRFComplexFromExperience(expr); 00204 FreeExperience(expr); 00205 00206 volrecmod = RecVolIFFTModuleFromVol(volrf); 00207 volrf=NULL; 00208 00209 #ifdef HAVE_MPI 00210 MPI_Comm_rank(MPI_COMM_WORLD,&rank); 00211 if (rank==0) 00212 WriteVolRecUchar(volrecmod,"imafid1dsimri.acr"); 00213 #else 00214 WriteVolRecUchar(volrecmod,"imafid1dsimri.acr"); 00215 #endif 00216 IdVolFree(volrecmod); 00217 00218 printf("End TestEchoSpin1D \n"); 00219 } 00220 00229 void TestEchoGradient1D(int objsize,int sigsize) 00230 { 00231 char fic[80]; 00232 int x,y,z; 00233 double fovx,fovy,fovz; 00234 int ro,t1,t2; 00235 double acq_delay; /* in ms */ 00236 double tgp,TE,teta,gx; 00237 double timp; /* in ms */ 00238 int tacq; /* in ms */ 00239 OBJECT3D *object; 00240 EXPERIENCE3D* expr; 00241 EVENT* event, event_r; 00242 PPPVOLUME_COMPLEX_DOUBLE volrf; 00243 PPPVOLUME_FLOAT volrecmod,voly; 00244 #ifdef HAVE_MPI 00245 int rank; 00246 #endif 00247 00248 event = &event_r; 00249 expr=AllocExperience(); 00250 00251 fic[0]='\0'; 00252 printf("Sart EchoGradient1D \n"); 00253 00254 x=objsize; y=1; z=1; 00255 t1=500; t2=300; ro=77; 00256 object=CreateHomogeneousObject(x,y,z,t1,t2,ro); 00257 SetObjectSize(object,(float)0.2,(float)0.0002,(float)0.0002); 00258 fovx=0.20; fovy=0.00020; fovz=0.00020; 00259 00260 SetObjectDeltaB0(object,1.e-6); 00261 SetB0Experience(expr,1.); 00262 SetObjectExperienceComponent(expr,object,WATER,0); 00263 SetFovExperience(expr,fovx,1,1,0,0,0); 00264 tacq=10; /* in ms */ 00265 SetAcqExperience(expr,sigsize,1,1,(tacq * 1.e-3)); 00266 acq_delay=0.; 00267 gx=(sigsize-2)/tacq/G_kHz_G/fovx; 00268 gx = gx * 1.0; /* Gradient effect weighting on the decay */ 00269 timp=300.; 00270 00271 TE=20.; 00272 tgp=TE-timp*1.e-3-tacq/2.0-tacq/2.0; 00273 teta=90.0; 00274 00275 DoWaiting(expr,event,ATT_INIT); 00276 printf("Mo=%lf \n",expr->magstate[2][objsize/2][0][0]*objsize); 00277 00278 DoPulseRect(expr,event,teta,timp); 00279 DoWaiting(expr,event,tgp); 00280 DoGradient(expr,event,tacq/2.0,-gx,0.0,0.0); 00281 DoAcqFrequenceX(expr,event,gx,0,0,acq_delay,PLUS); 00282 00283 voly=GetSignalRFComponentFromExperience(expr,1); 00284 DisplayVolX((PPPVOLUME)voly,0,0,"Antenne Y",0,""); 00285 IdVolFree(voly); 00286 00287 volrf = GetSignalRFComplexFromExperience(expr); 00288 FreeExperience(expr); 00289 00290 volrecmod = RecVolIFFTModuleFromVol(volrf); 00291 volrf=NULL; 00292 00293 #ifdef HAVE_MPI 00294 MPI_Comm_rank(MPI_COMM_WORLD,&rank); 00295 if (rank==0) 00296 WriteVolRecUchar(volrecmod,"imafid1dsimri.acr"); 00297 #else 00298 WriteVolRecUchar(volrecmod,"imafid1dsimri.acr"); 00299 #endif 00300 IdVolFree(volrecmod); 00301 00302 printf("End TestEchoGradient1D \n"); 00303 } 00304 00313 void TestTrainEchoSpin1D(int objsize,int sigsize,int nbecho) 00314 { 00315 char fic[80]; 00316 int x,y,z,i; 00317 double fovx,fovy,fovz; 00318 int ro,t1,t2; 00319 double acq_delay; /* in ms */ 00320 double TE,t; 00321 double timp; /* in ms */ 00322 int tacq; /* in ms */ 00323 OBJECT3D *object; 00324 EXPERIENCE3D* expr; 00325 EVENT* event, event_r; 00326 PPPVOLUME_FLOAT voly; 00327 #ifdef HAVE_MPI 00328 int rank; 00329 #endif 00330 00331 event = &event_r; 00332 expr=AllocExperience(); 00333 00334 fic[0]='\0'; 00335 printf("Start TrainEchoSpin1D \n"); 00336 00337 x=objsize; y=1; z=1; 00338 t1=250; t2=300; ro=10; 00339 object=CreateHomogeneousObject(x,y,z,t1,t2,ro); 00340 SetObjectSize(object,(float)0.2,(float)0.0002,(float)0.0002); 00341 fovx=0.20; fovy=0.00020; fovz=0.00020; 00342 00343 SetObjectDeltaB0(object,0.00001); 00344 SetB0Experience(expr,1.); 00345 SetObjectExperienceComponent(expr,object,WATER,0); 00346 SetFovExperience(expr,fovx,1,1,0,0,0); 00347 tacq=10; /* in ms */ 00348 SetAcqExperience(expr,sigsize,1,1,(tacq * 1.e-3)); 00349 acq_delay=0.; 00350 00351 timp=3.; 00352 TE=100.; 00353 t=TE/2; /* corresponds to TE/2 in ms */ 00354 00355 DoWaiting(expr,event,ATT_INIT); 00356 00357 DoPulseRect(expr,event, 90.,timp); 00358 DoWaiting(expr,event,t-timp*1.e-3); 00359 00360 for (i=1;i<=nbecho;i++) 00361 { 00362 DoPulseRect(expr,event, 180.,timp); 00363 DoWaiting(expr,event,t+timp*1.e-3-(tacq/2.+tacq/2./sigsize)); 00364 DoAcqFrequenceX(expr,event,0,0,0,acq_delay,MINUS); 00365 DoWaiting(expr,event,t+timp*1.e-3-(tacq/2.+tacq/2./sigsize)); 00366 00367 voly=GetSignalRFComponentFromExperience(expr,1); 00368 IdVolFree(voly); 00369 } 00370 printf("End TestTrainEchoSpin1D \n"); 00371 } 00372 00382 void TestTrainEchoGradient1D(int objsize,int sigsize,int nbecho) 00383 { 00384 char fic[80]; 00385 int x,y,z,i; 00386 double fovx,fovy,fovz; 00387 int ro,t1,t2,s; 00388 double acq_delay; /* in ms */ 00389 double TE; 00390 double timp,gx,teta,tgp; /* in ms */ 00391 int tacq; /* in ms */ 00392 OBJECT3D *object; 00393 EXPERIENCE3D* expr; 00394 EVENT* event, event_r; 00395 PPPVOLUME_FLOAT voly; 00396 #ifdef HAVE_MPI 00397 int rank; 00398 #endif 00399 00400 event = &event_r; 00401 expr=AllocExperience(); 00402 00403 fic[0]='\0'; 00404 printf("Start TrainEchoGradient1D \n"); 00405 00406 x=objsize; y=1; z=1; 00407 t1=500; t2=300; ro=77; 00408 object=CreateHomogeneousObject(x,y,z,t1,t2,ro); 00409 SetObjectSize(object,(float)0.2,(float)0.0002,(float)0.0002); 00410 fovx=0.20; fovy=0.00020; fovz=0.00020; 00411 00412 SetObjectDeltaB0(object,1.e-6); 00413 SetB0Experience(expr,1.); 00414 /* */ 00415 SetObjectExperienceComponent(expr,object,WATER,0); 00416 SetFovExperience(expr,fovx,1,1,0,0,0); 00417 tacq=10; /* en ms */ 00418 SetAcqExperience(expr,sigsize,1,1,(tacq * 1.e-3)); 00419 acq_delay=0.; 00420 gx=(sigsize-2)/tacq/G_kHz_G/fovx; 00421 timp=300.; 00422 00423 TE=20.; 00424 tgp=TE-timp*1.e-3-tacq/2.0-tacq/2.0; 00425 teta=90.0; 00426 00427 DoWaiting(expr,event,ATT_INIT); 00428 printf("Mo=%lf \n",expr->magstate[2][objsize/2][0][0]*objsize); 00429 00430 DoPulseRect(expr,event,teta,timp); 00431 DoWaiting(expr,event,tgp); 00432 DoGradient(expr,event,tacq/2.0,-gx,0.0,0.0); 00433 DoAcqFrequenceX(expr,event,gx,0,0,acq_delay,PLUS); 00434 voly=GetSignalRFComponentFromExperience(expr,1); 00435 IdVolFree(voly); 00436 s=1; 00437 for (i=1;i<=nbecho;i++) 00438 { 00439 s= s*(-1); 00440 DoAcqFrequenceX(expr,event,s*gx,0,0,acq_delay,PLUS); 00441 getchar(); 00442 voly=GetSignalRFComponentFromExperience(expr,1); 00443 IdVolFree(voly); 00444 } 00445 00446 printf("End TestTrainEchoGradient1D \n"); 00447 } 00448 00457 void TestSimulatedEcho(int objsize,int sigsize) 00458 { 00459 char fic[80]; 00460 int x,y,z; 00461 double fovx,fovy,fovz; 00462 int ro,t1,t2; 00463 double acq_delay; /* in ms */ 00464 double TE,t,TM; 00465 double timp; /* in ms */ 00466 double alpha1,alpha2,alpha3; 00467 int tacq; /* in ms */ 00468 OBJECT3D *object; 00469 EXPERIENCE3D* expr; 00470 EVENT* event, event_r; 00471 PPPVOLUME_FLOAT voly; 00472 #ifdef HAVE_MPI 00473 int rank; 00474 #endif 00475 00476 00477 event = &event_r; 00478 expr=AllocExperience(); 00479 00480 fic[0]='\0'; 00481 printf("Start TestSimulatedEcho \n"); 00482 00483 x=objsize; y=1; z=1; 00484 t1=250; t2=300; ro=10; 00485 object=CreateHomogeneousObject(x,y,z,t1,t2,ro); 00486 SetObjectSize(object,(float)0.2,(float)0.0002,(float)0.0002); 00487 fovx=0.20; fovy=0.00020; fovz=0.00020; 00488 00489 SetObjectDeltaB0(object,0.00001); 00490 SetB0Experience(expr,1.5); 00491 SetObjectExperienceComponent(expr,object,WATER,0); 00492 SetFovExperience(expr,fovx,1,1,0,0,0); 00493 tacq=10; /* in ms */ 00494 SetAcqExperience(expr,sigsize,1,1,(tacq * 1.e-3)); 00495 00496 acq_delay=0.; 00497 timp=3.; 00498 alpha1=90.; 00499 alpha2=180; 00500 alpha3=180; 00501 00502 TE=80.; 00503 TM=100.; /* Mixin gtime */ 00504 t=TE/2; /* corresponds to TE/2 in ms */ 00505 00506 DoWaiting(expr,event,ATT_INIT); 00507 00508 DoPulseRect(expr,event,alpha1,timp); 00509 DoWaiting(expr,event,t-timp*1.e-3); /* waiting of TE/2 */ 00510 DoPulseRect(expr,event,alpha2,timp); 00511 DoWaiting(expr,event,t+timp*1.e-3-(tacq/2.+tacq/2./sigsize)); 00512 DoAcqFrequenceX(expr,event,0,0,0,acq_delay,MINUS); 00513 voly=GetSignalRFComponentFromExperience(expr,1); 00514 //DisplayVolX((PPPVOLUME)voly,0,0,"Echo spin 1-2",0,""); 00515 IdVolFree(voly); 00516 00517 DoWaiting(expr,event,TM-(t+tacq/2.)); /* 55 */ 00518 DoPulseRect(expr,event,alpha3,timp); 00519 DoWaiting(expr,event,t+timp*1.e-3-(tacq/2.+tacq/2./sigsize)); /* 35 */ 00520 DoAcqFrequenceX(expr,event,0,0,0,acq_delay,MINUS); 00521 voly=GetSignalRFComponentFromExperience(expr,1); 00522 //DisplayVolX((PPPVOLUME)voly,0,0,"Echo stimule 1-2-3",0,""); 00523 IdVolFree(voly); 00524 00525 DoWaiting(expr,event,TM-t-(tacq/2.)-t-tacq/2.0); /*10*/ 00526 DoAcqFrequenceX(expr,event,0,0,0,acq_delay,MINUS); 00527 voly=GetSignalRFComponentFromExperience(expr,1); 00528 //DisplayVolX((PPPVOLUME)voly,0,0,"Echo spin 1-2-3",0,""); 00529 IdVolFree(voly); 00530 00531 DoWaiting(expr,event,t-tacq/2.0-(tacq/2.+tacq/2./sigsize)); /* 30 */ 00532 DoAcqFrequenceX(expr,event,0,0,0,acq_delay,MINUS); 00533 voly=GetSignalRFComponentFromExperience(expr,1); 00534 //DisplayVolX((PPPVOLUME)voly,0,0,"Echo spin 2-3",0,""); 00535 IdVolFree(voly); 00536 00537 DoWaiting(expr,event,t-tacq/2.0-(tacq/2.+tacq/2./sigsize)); /* 30 */ 00538 DoAcqFrequenceX(expr,event,0,0,0,acq_delay,MINUS); 00539 voly=GetSignalRFComponentFromExperience(expr,1); 00540 //DisplayVolX((PPPVOLUME)voly,0,0,"Echo spin 1-3",0,""); 00541 IdVolFree(voly); 00542 00543 printf("End TestSimulatedEcho \n"); 00544 }

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