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

test-sequence.c

Go to the documentation of this file.
00001 /************************************************************************* 00002 * $Id: test-sequence.c,v 1.31 2005/09/22 11:42:37 yougz Exp $ 00003 ************************************************************************** 00004 * TestSequence function is an excellent example of how to run a simulation 00005 * with the object definition, the experience definition, the sequence call 00006 * and the reconstruction step. It gives also variation about adding noise 00007 * and filtering at several step 00008 * One should copy such function to make similar tests in 3D 00009 ************************************************************************** 00010 This software is governed by the CeCILL license under French law and 00011 abiding by the rules of distribution of free software. You can use, 00012 modify and/ or redistribute the software under the terms of the CeCILL 00013 license as circulated by CEA, CNRS and INRIA at the following URL 00014 "http://www.cecill.info". 00015 00016 As a counterpart to the access to the source code and rights to copy, 00017 modify and redistribute granted by the license, users are provided only 00018 with a limited warranty and the software's author, the holder of the 00019 economic rights, and the successive licensors have only limited 00020 liability. 00021 00022 In this respect, the user's attention is drawn to the risks associated 00023 with loading, using, modifying and/or developing or reproducing the 00024 software by the user in light of its specific status of free software, 00025 that may mean that it is complicated to manipulate, and that also 00026 therefore means that it is reserved for developers and experienced 00027 professionals having in-depth computer knowledge. Users are therefore 00028 encouraged to load and test the software's suitability as regards their 00029 requirements in conditions enabling the security of their systems and/or 00030 data to be ensured and, more generally, to use and operate it in the 00031 same conditions as regards security. 00032 00033 The fact that you are presently reading this means that you have had 00034 knowledge of the CeCILL license and that you accept its terms. 00035 00036 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de 00037 l'Image). All rights reserved. See License.txt for details. 00038 00039 Version 1.0 05/09/2005 00040 *************************************************************************/ 00041 #include "test-sequence.h" 00042 #include "idvol.h" 00043 #include "idacr.h" 00044 #include "simri3d.h" 00045 #include "experience.h" 00046 #include "object.h" 00047 #include "object-simple.h" 00048 #include "object-compound.h" 00049 #include "object-brain.h" 00050 #include "object-ki.h" 00051 #include "output.h" 00052 #include "display.h" 00053 #include "seq-se.h" 00054 #include "sequence.h" 00055 00056 #ifdef HAVE_MPI 00057 #include <mpi.h> 00058 #endif 00059 00082 void TestSequence2D(int obj,int objsize,int imasize, 00083 double tacq,double TE,double TR,double teta, 00084 double b0, double db0,double b0def,int flagres,int flagdech,int filter, 00085 char * fileout,char * seqname,int display) 00086 { 00087 char fic[80]; 00088 int ntx, nty, ntz; /* K space size */ 00089 double fovx,fovy,fovz; /* Fov size in meter */ 00090 OBJECT3D *object; 00091 EXPERIENCE3D *expr; 00092 SEQPARAM seqparam; 00093 PPPVOLUME_COMPLEX_DOUBLE volrf; 00094 PPPVOLUME_FLOAT volrecmod; 00095 #ifdef HAVE_MPI 00096 int rank; 00097 #endif 00098 fic[0]='\0'; 00099 00100 printf("TestSequence2D start\n"); 00101 00102 if (objsize<imasize) 00103 { 00104 printf("The object has more pixel than the image !! \n"); 00105 exit(0); 00106 } 00107 00108 /* Object */ 00109 object = GetTestObject2D(obj,objsize,objsize,db0); 00110 // AddNoiseToObject(object,5.0); 00111 // ApplyMeanToObject(object,3); 00112 00113 /* Experience */ 00114 expr=AllocExperience(); 00115 ntx=imasize; nty=ntx; ntz=1; 00116 fovx=0.20; fovy=0.20; fovz=0.0020; 00117 SetFovExperience(expr,fovx,fovy,fovz,0.0,0.0,0.0); 00118 SetAcqExperience(expr,ntx,nty,ntz,tacq*1e-3); 00119 SetResonanceExperience(expr,flagres); 00120 SetFlagdechExperience(expr,flagdech); 00121 SetB0Experience(expr,b0); 00122 SetB0DefExperience(expr,b0def); 00123 00124 /* Sequence */ 00125 SetSeqParamTE(&seqparam,TE); 00126 SetSeqParamTR(&seqparam,TR); 00127 SetSeqParamTeta(&seqparam,teta); /* pour test GE2D */ 00128 00129 /* Acquisition */ 00130 volrf = RunSequence(seqname,&seqparam,object,expr); 00131 // WriteVolRF(volrf); 00132 FreeObject(object); 00133 // AddGaussianNoiseToRFVolume(volrf,0.001); 00134 if (filter==1) VolRFFiltering(volrf,HANNING); 00135 00136 /* Reconstruction */ 00137 volrecmod = RecVolIFFTModuleFromVol(volrf); 00138 volrf=NULL; /* Devrait etre un IdVolFree, mais volrf est deja liberere par IdVolIFFT ! */ 00139 00140 /* Save & Display */ 00141 #ifdef HAVE_MPI 00142 MPI_Comm_rank(MPI_COMM_WORLD,&rank); 00143 if (rank==0) WriteVolRecUchar(volrecmod,fileout); 00144 #else 00145 if (display==1) DisplayVolXY((PPPVOLUME)volrecmod,0,"Recvol2D"); 00146 WriteVolRecUchar(volrecmod,fileout); 00147 #endif 00148 printf("min=%e max=%e \n",IdVolMinima(volrecmod),IdVolMaxima(volrecmod)); 00149 IdVolFree(volrecmod); 00150 00151 printf("TestSequence2D End\n"); 00152 } 00153 00176 void TestSequence3D(int obj,int objsize,int imasize,double tacq,double TE, double TR,double teta, 00177 double b0, double db0,double b0def,int flagres,int flagdech,int filter, 00178 char * fileout,char * seqname,int display) 00179 { 00180 char fic[80]; 00181 int ntx, nty, ntz; /* Taille du volume RF acquis */ 00182 double fovx,fovy,fovz; /* Taille du fov en cm */ 00183 OBJECT3D *object; 00184 EXPERIENCE3D *expr; 00185 SEQPARAM seqparam; 00186 PPPVOLUME_COMPLEX_DOUBLE volrf; 00187 PPPVOLUME_FLOAT volrecmod; 00188 #ifdef HAVE_MPI 00189 int rank; 00190 #endif 00191 fic[0]='\0'; 00192 00193 printf("TestSequence3D start\n"); 00194 00195 if (objsize<imasize) 00196 { 00197 printf("L'object est plus petit que l'image !! \n"); 00198 exit(0); 00199 } 00200 00201 /* Object */ 00202 object= GetTestObject3D(obj,objsize,objsize,objsize,db0); 00203 // AddNoiseToObject(object,5.0); 00204 // ApplyMeanToObject(object,3); 00205 00206 /* Experience */ 00207 expr=AllocExperience(); 00208 ntx=imasize; nty=ntx; ntz=ntx; 00209 fovx=0.20; fovy=0.20; fovz=0.20; 00210 SetFovExperience(expr,fovx,fovy,fovz,0.0,0.0,0.0); 00211 SetAcqExperience(expr,ntx,nty,ntz,tacq*1e-3); 00212 SetResonanceExperience(expr,flagres); 00213 SetFlagdechExperience(expr,flagdech); 00214 SetB0Experience(expr,b0); 00215 SetB0DefExperience(expr,b0def); 00216 00217 /* Sequence */ 00218 SetSeqParamTE(&seqparam,TE); 00219 SetSeqParamTR(&seqparam,TR); 00220 SetSeqParamTeta(&seqparam,teta); 00221 00222 /* Acquisition */ 00223 volrf = RunSequence(seqname,&seqparam,object,expr); 00224 FreeObject(object); 00225 // WriteVolRF(volrf); 00226 // AddGaussianNoiseToRFVolume(volrf,0.001); 00227 if (filter==1) VolRFFiltering(volrf,HANNING); 00228 00229 /* Reconstruction */ 00230 volrecmod = RecVolIFFTModuleFromVol(volrf); 00231 volrf=NULL; /* Should be an IdVolFree function call, but volrf pointer if already free within IdVolIFFT function ! */ 00232 00233 /* Save & Display */ 00234 #ifdef HAVE_MPI 00235 MPI_Comm_rank(MPI_COMM_WORLD,&rank); 00236 if (rank==0) 00237 WriteVolRecUchar(volrecmod,"volse3dsimri.acr"); 00238 #else 00239 if (display==1) DisplayVolXY((PPPVOLUME)volrecmod,0,"Recvol2D"); 00240 WriteVolRecUchar(volrecmod,"volse3dsimri.acr"); 00241 #endif 00242 IdVolFree(volrecmod); 00243 00244 printf("TestSequence3D End\n"); 00245 }

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