36 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
37 if (mpi_rank!=0)
return;
42 cout <<
"Usage: castor-proj.exe -img path_to_file.hdr -sc name -(f/d)out output [settings]" << endl;
44 cout <<
"[Main options]:" << endl;
45 cout <<
" -img path_to_img.hdr : Give the interfile header of the image to project (no default)." << endl;
46 cout <<
" -sc scanner_alias : Give the scanner model. It must correspond to the name of one of the file in the scanner repository (w/o file extension)" << endl;
47 cout <<
" -fout name : Give the root name for all output files (no default, alternative to -dout)" << endl;
48 cout <<
" -dout name : Give the name of the output directory where all output files will be written (no default, alternative to -fout)" << endl;
49 cout <<
" -fileType type : Give the type of events that will be generated : ('TYPE_PET' ou '0' = PET, 'TYPE_SPECT' ou '1' = SPECT) (default : TYPE_PET)" << endl;
50 cout <<
" -vb : Give the verbosity level, from 0 (no verbose) to above 5 (at the event level) (default: 1)." << endl;
52 cout <<
"[Specific options]:" << endl;
53 cout <<
" -help-in : Print out specific help about input settings." << endl;
54 cout <<
" -help-out : Print out specific help about output settings." << endl;
55 cout <<
" -help-proj : Print out specific help about projector settings." << endl;
56 cout <<
" -help-comp : Print out specific help about computing settings." << endl;
57 cout <<
" -help-misc : Print out specific help about miscellaneous and verbose settings." << endl;
58 cout <<
" -help-dynamic : Print out specific help about dynamic options." << endl;
59 cout <<
" -help-pet : Print out specific help about PET settings for analytic projection." << endl;
60 cout <<
" -help-spect : Print out specific help about SPECT settings for analytic projection." << endl;
62 cout <<
"[Implemented Modules]:" << endl;
63 cout <<
" -help-scan : Show the list of all scanners from the configuration directory." << endl;
64 cout <<
" -help-projm : Show the list and description of all implemented projectors." << endl;
66 cout <<
" --help,-h,-help : Print out this help page." << endl;
69 cout <<
" Compiled with MPI" << endl;
72 cout <<
" Compiled with OpenMP" << endl;
75 cout <<
" Compiled for GPU" << endl;
77 #if defined(CASTOR_OMP) || defined(CASTOR_MPI) || defined(CASTOR_GPU)
81 cout <<
" Build date: " << BUILD_DATE << endl;
85 cout <<
" This program is part of the CASToR release version " <<
CASTOR_VERSION <<
"." << endl;
107 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
108 if (mpi_rank!=0)
return;
112 cout <<
"[Input settings]:" << endl;
114 cout <<
" -off x,y,z : Give the offset of the field-of-view in each dimension, in mm (default: 0.,0.,0.)." << endl;
116 cout <<
" -atn path_to_img.hdr : Give the interfile header of an input attenuation image (unit has to be cm-1) (default: uniform value)." << endl;
118 cout <<
" -help-in : Print out this help." << endl;
137 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
138 if (mpi_rank!=0)
return;
142 cout <<
"[Output settings]:" << endl;
144 cout <<
" -fout name : Give the root name for all output files. All output files will be written as 'name_suffix.ext'." << endl;
145 cout <<
" So the provided name should not end with '.' or '/' character. (no default, alternative to -dout)" << endl;
146 cout <<
" -dout name : Give the name of the output directory where all output files will be written. All files will also" << endl;
147 cout <<
" be prefixed by the name of the directory. The provided name should not end with '.' or '/' character." << endl;
148 cout <<
" (no default, alternative to -fout)" << endl;
150 cout <<
" -olut : If a scanner LUT (geometry information) is computed from a .geom file, it will be written on disk in the scanner repository" << endl;
152 cout <<
" -help-out : Print out this help." << endl;
171 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
172 if (mpi_rank!=0)
return;
175 cout <<
"[Projector settings]:" << endl;
177 cout <<
" -proj param : Give the projector to be used for both forward and backward projections, along with a configuration file (proj:file.conf)" << endl;
178 cout <<
" or the list of parameters associated to the projector (proj,param1,param2,...). If the projector only is specified, the" << endl;
179 cout <<
" default configuration file is used. By default, the Siddon projector is used." << endl;
181 cout <<
" -proj-comp : Give the strategy for projection line computation. Here are the three different strategies that can be used:" << endl;
182 cout <<
" 1 : Image-based system matrix elements storage: The voxels weights are added in a matrix representing the whole image, so" << endl;
183 cout <<
" the addition of a new line to the previous ones is straightforward only by adding the weights to the corresponding voxels." << endl;
184 cout <<
" As it is insanely long, it can possibly be used for example with extremely complex projectors that makes use of huge number" << endl;
185 cout <<
" of ray tracings for a single event, where the list of contributions can become longer than the number of voxels in the image." << endl;
186 cout <<
" 2 : Fixed-size list storage of system matrix elements: The voxels are added one by one in two separated lists, one containing voxel" << endl;
187 cout <<
" indices and the other voxel weights. When a voxel is added to the oProjectionLine, it is simply pilled-up to the list. The list" << endl;
188 cout <<
" has a fixed size which is provided by the EstimateMaxNumberOfVoxelsPerLine() function from the vProjector class. There are no" << endl;
189 cout <<
" ckecks at all for possible buffer overflows. This is the fastest strategy and default one." << endl;
190 cout <<
" 3 : Adaptative-size list storage of system matrix elements: This is the same as the fixed-size strategy except that the size can be" << endl;
191 cout <<
" upgraded if the current number of contributing voxels exceed the list's size. The first allocated size corresponds to the diagonal" << endl;
192 cout <<
" of the image. During the first iteration, this size will be upgraded until it will reach a size suitable for all events. Thus it" << endl;
193 cout <<
" is a bit slower than the fixed-list strategy during the first iteration, but is optimal with respect to RAM usage." << endl;
195 cout <<
" -help-projm : Print out specific help about projector settings." << endl;
197 cout <<
" -help-proj : Print out this help." << endl;
216 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
217 if (mpi_rank!=0)
return;
221 cout <<
"[Computation settings]:" << endl;
224 cout <<
" -th param : Set the number of threads for parallel computation (default: 1). If 0 is given, then the maximum number of available threads is automatically determined." << endl;
225 cout <<
" Can also give two parameters separated by a comma (e.g. 16,4), to distinguish between the number of threads for projection and image operations respectively." << endl;
229 cout <<
" -gpu : Flag to say that we want to use the GPU device (default: use the CPU only)." << endl;
232 cout <<
" -conv param : Give an image convolver model to be used within the algorithm, along with a configuration file (conv:file.conf) or the" << endl;
233 cout <<
" list of parameters associated to the convolver (conv,param1,param2,...). If the convolver only is specified, its default" << endl;
234 cout <<
" configuration file is used. By default, no convolver is applied" << endl;
236 cout <<
" -help-conv : Show the list and description of all implemented image convolvers." << endl;
238 cout <<
" -noise poisson : Give the noise model to be used. Only Poisson noise is implemented for the moment (default : no noise model)" << endl;
240 cout <<
" -rng : Give a seed for the random number generator (should be >=0)" << endl;
242 cout <<
" -help-comp : Print out this help." << endl;
245 cout <<
" Compiled with MPI" << endl;
248 cout <<
" Compiled with OpenMP" << endl;
251 cout <<
" Compiled for GPU" << endl;
253 #if defined(CASTOR_OMP) || defined(CASTOR_MPI) || defined(CASTOR_GPU)
273 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
274 if (mpi_rank!=0)
return;
278 cout <<
"[Dynamic settings]:" << endl;
280 cout <<
" -frm list : Give the framing for the reconstruction where 'list' is a list of all frames durations in seconds separated" << endl;
281 cout <<
" by commas. To specify a dead frame, add ';0' concatenated to the frame duration. Milliseconds maximum precision." << endl;
282 cout <<
" (default: read from the 'image duration (sec)' key in the interfile image header" << endl;
284 cout <<
" (about gated images) : An image contening several respiratory/cardiac 'gates' can be provided to generate one datafile containing histograms of these gated images." << endl;
285 cout <<
" The number of gates being directly read from the 'number of respiratory gates' and 'number of cardiac gates' keys in the interfile header" << endl;
287 cout <<
" -help-dynamic : Print out this help." << endl;
306 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
307 if (mpi_rank!=0)
return;
310 cout <<
"[SPECT settings]:" << endl;
312 cout <<
" -SPECT_bins par : Give two integer parameters corresponding to the transaxial number of bins, separated by a comma (nbBinsX, nbBinsY). " << endl;
313 cout <<
" Default = transaxial number of pixels in the SPECT scanner file " << endl;
315 cout <<
" -SPECT_ang par : Give the total number of projections, followed by the first angle and the angle step in float" << endl;
316 cout <<
" Format : nb_projs:first_angle,step_angle" << endl;
318 cout <<
" -SPECT_c_ang par : SPECT custom angles : give the total number of projections, followed by the projections angles in float" << endl;
319 cout <<
" Format : nb_projs:angle1,angle2,... " << endl;
321 cout <<
" -SPECT_radius par : Give a distance between center of rotation to detectors which will be used for all heads" << endl;
323 cout <<
" -SPECT_rot par : Give the heads rotation direction. Accept two parameters: CW (clockwise, default), CCW (counter-clockwise)" << endl;
325 cout <<
" -help-spect : Print out this specific help." << endl;
344 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
345 if (mpi_rank!=0)
return;
348 cout <<
"[PET settings]:" << endl;
350 cout <<
" -PET_maxRingDiff param : Set the maximum number of differences between the ring ID of the two crystals (1 = 2D mode) (default = total number of rings in the scanner)" << endl;
369 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
370 if (mpi_rank!=0)
return;
374 cout <<
"[Miscellaneous settings]:" << endl;
376 cout <<
" -vb : Give the general verbosity level, from 0 (no verbose) to 5 and above (at the event level) (default: 1)." << endl;
377 cout <<
" -vb-algo : Give the verbose level specific to the analytic projection algorithm (default: same as general verbose level)." << endl;
378 cout <<
" -vb-proj : Give the verbose level specific to the projector (default: same as general verbose level)." << endl;
379 cout <<
" -vb-conv : Give the verbose level specific to the image convolver (default: same as general verbose level)." << endl;
380 cout <<
" -vb-scan : Give the verbose level specific to the scanner (default: same as general verbose level)." << endl;
381 cout <<
" -vb-data : Give the verbose level specific to the data and image management (default: same as general verbose level)." << endl;
383 cout <<
" -conf : Give the path to the CASToR config directory (default: located through the CASTOR_CONFIG environment variable)." << endl;
385 cout <<
" -help-misc : Print out this help." << endl;
400 int main(
int argc,
char** argv)
409 MPI_Init(&argc, &argv );
410 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
411 MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
416 if (mpi_rank==0) cout << endl;
424 int nb_VoxX=-1, nb_VoxY=-1, nb_VoxZ=-1;
425 FLTNB fov_SizeX=-1, fov_SizeY=-1, fov_SizeZ=-1;
426 FLTNB vox_SizeX=-1, vox_SizeY=-1, vox_SizeZ=-1;
428 FLTNB offsetX = 0, offsetY = 0, offsetZ = 0;
431 string path_to_initial_img =
"";
433 string path_to_attenuation_img =
"";
435 string scanner_name =
"";
442 string frame_list =
"";
444 int nb_resp_gates = 1;
446 int nb_card_gates = 1;
452 int max_ring_diff = -1;
455 string path_dout =
"";
457 string path_fout =
"";
460 bool save_LUT_flag =
false;
463 string noise_model =
"";
466 string options_projector =
"incrementalSiddon";
472 vector<string> options_image_convolver;
475 bool gpu_flag =
false;
477 int data_file_percentage_load = 0;
480 int verbose_general = 1,
488 string path_to_config_dir =
"";
491 int64_t seed_RNG = -1;
493 string nb_threads =
"1";
498 uint16_t SPECT_nb_bins[2] = {0, 0};
500 uint32_t SPECT_nb_projection_angles = 0;
502 FLTNB* SPECT_projection_angles = NULL;
504 FLTNB SPECT_first_angle= -1., SPECT_step_angle=-1.;
506 FLTNB SPECT_radius = -1.;
508 string SPECT_rot =
"CW";
514 for (
int i=1; i<argc; i++)
516 string option = (string)argv[i];
518 if (option==
"-h" || option==
"--help" || option==
"-help")
ShowHelp(0,mpi_rank);
521 else if (option==
"-help-scan")
524 Cerr(
"***** castor-proj() -> An error occured when trying to output the available scanners from the scanner repository !'" << endl;);
530 else if (option==
"-help-projm")
540 else if (option==
"-help-conv")
551 else if (option==
"-help-in")
557 else if (option==
"-help-out")
563 else if (option==
"-help-proj")
569 else if (option==
"-help-comp")
575 else if (option==
"-help-dynamic")
581 else if (option==
"-help-pet")
587 else if (option==
"-help-spect")
593 else if (option==
"-help-misc")
599 else if (option==
"-off")
603 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
611 Cerr(
"***** castor-proj() -> Invalid argument " << argv[i+1] <<
" for option " << option <<
" !" << endl);
621 else if (option==
"-frm")
625 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
628 frame_list = (string)argv[i+1];
633 else if (option==
"-sc")
637 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
640 scanner_name = argv[i+1];
645 else if (option==
"-img")
649 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
652 path_to_initial_img = argv[i+1];
657 else if (option==
"-fileType")
661 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
665 string input_str = argv[i+1];
667 if(!input_str.compare(
"TYPE_PET") )
669 else if(!input_str.compare(
"TYPE_SPECT") )
671 else if(!input_str.compare(
"TYPE_TRANSMISSION") )
677 Cerr(
"***** castor-proj() -> Exception when trying to read provided entry '" << input_str <<
" for option: " << option << endl);
686 else if (option==
"-atn")
690 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
693 path_to_attenuation_img = argv[i+1];
698 else if (option==
"-bed")
702 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
705 nb_beds = atoi(argv[i+1]);
710 else if (option==
"-PET_maxRingDiff")
714 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
717 max_ring_diff = atoi(argv[i+1]);
722 else if (option==
"-dout")
726 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
729 path_dout = argv[i+1];
733 else if (option==
"-fout")
737 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
740 path_fout = argv[i+1];
744 else if (option==
"-olut")
746 save_LUT_flag =
true;
748 else if (option==
"-noise")
750 noise_model = argv[i+1];
754 else if (option==
"-proj")
758 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
761 options_projector = (string)argv[i+1];
766 else if (option==
"-proj-comp")
770 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
773 projector_computation_strategy = atoi(argv[i+1]);
778 else if (option==
"-conv")
782 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
785 string convolver = (string)argv[i+1];
786 convolver.append(
"::forward");
787 options_image_convolver.push_back(convolver);
795 else if (option==
"-vb")
799 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
804 Cerr(
"***** castor-proj() -> Exception when trying to read provided verbosity level '" << verbose_general <<
" for option: " << option << endl);
811 else if (option==
"-vb-algo")
815 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
820 Cerr(
"***** castor-proj() -> Exception when trying to read provided verbosity level '" << verbose_algo <<
" for option: " << option << endl);
827 else if (option==
"-vb-proj")
831 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
836 Cerr(
"***** castor-proj() -> Exception when trying to read provided verbosity level '" << verbose_proj <<
" for option: " << option << endl);
843 else if (option==
"-vb-conv")
847 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
852 Cerr(
"***** castor-proj() -> Exception when trying to read provided verbosity level '" << verbose_conv <<
" for option: " << option << endl);
859 else if (option==
"-vb-scan")
863 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
868 Cerr(
"***** castor-proj() -> Exception when trying to read provided verbosity level '" << verbose_scan <<
" for option: " << option << endl);
875 else if (option==
"-vb-data")
879 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
884 Cerr(
"***** castor-proj() -> Exception when trying to read provided verbosity level '" << verbose_data <<
" for option: " << option << endl);
892 else if (option==
"-rng")
896 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
901 Cerr(
"***** castor-proj() -> Exception when trying to read provided number '" << seed_RNG <<
" for option: " << option << endl);
908 else if (option==
"-conf")
912 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
915 path_to_config_dir = (string)argv[i+1];
920 else if (option==
"-gpu")
926 else if (option==
"-th")
930 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
933 nb_threads = (string)argv[i+1];
938 else if (option==
"-load")
942 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
945 data_file_percentage_load = atoi(argv[i+1]);
946 if (data_file_percentage_load>100 || data_file_percentage_load<0)
948 Cerr(
"***** castor-proj() -> Incorrect initialization of the size data buffer" << endl);
949 Cerr(
" Number provided: " << argv[i+1] <<
" is not in the expected [0;100] interval" << endl);
954 else if (option==
"-SPECT_bins")
958 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
964 Cerr(
"***** castor-proj() -> Invalid argument " << argv[i+1] <<
" for option " << option <<
" !" << endl);
965 Cerr(
"***** castor-proj() -> Expected two uint16 parameters separated by a comma" << endl);
973 else if (option==
"-SPECT_c_ang")
977 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
982 string input_str = argv[i+1];
983 size_t colon = input_str.find_first_of(
":");
985 if (colon==string::npos)
987 Cerr(
"***** castor-proj() -> Parsing error : colon missing in option: " << option << endl);
994 Cerr(
"***** castor-proj() -> An error occured while trying to read the number of SPECT projection values " << input_str.substr(0,colon) <<
" for option " << option <<
" !" << endl);
998 SPECT_projection_angles =
new FLTNB[SPECT_nb_projection_angles];
1000 if(
ReadStringOption(input_str.substr(colon+1), SPECT_projection_angles, SPECT_nb_projection_angles,
",", option))
1002 Cerr(
"***** castor-proj() -> Invalid argument " << argv[i+1] <<
" for option " << option <<
" !" << endl);
1010 else if (option==
"-SPECT_ang")
1014 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
1019 string input_str = argv[i+1];
1020 size_t colon = input_str.find_first_of(
":");
1022 if (colon==string::npos)
1024 Cerr(
"***** castor-proj() -> Parsing error : colon missing in option: " << option << endl);
1031 Cerr(
"***** castor-proj() -> An error occured while trying to read the number of SPECT projection values " << input_str.substr(0,colon) <<
" for option " << option <<
" !" << endl);
1038 Cerr(
"***** castor-proj() -> Invalid argument " << argv[i+1] <<
" for option " << option <<
" !" << endl);
1043 SPECT_first_angle = input[0];
1044 SPECT_step_angle = input[1];
1050 else if (option==
"-SPECT_radius")
1054 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
1062 Cerr(
"***** castor-proj() -> An error occured while trying to read the SPECT global radius " << argv[i+1] <<
" for option " << option <<
" !" << endl);
1069 else if (option==
"-SPECT_rot")
1073 Cerr(
"***** castor-proj() -> Argument missing for option: " << option << endl);
1079 SPECT_rot = argv[i+1];
1081 if(SPECT_rot !=
"CW" && SPECT_rot !=
"CCW")
1083 Cerr(
"***** castor-proj() -> '" << SPECT_rot <<
"' is unknown argument for option " << option <<
".");
1084 Cerr(
" SPECT rotation direction must be either 'CW' (clockwise) or 'CCW' (counter-clockwise) !" << endl);
1093 if (mpi_rank==0)
Cerr(
"***** castor-proj() -> Unknown option '" << option <<
"' !" << endl);
1100 MPI_Barrier(MPI_COMM_WORLD);
1105 if (verbose_algo==-1) verbose_algo = verbose_general;
1106 if (verbose_proj==-1) verbose_proj = verbose_general;
1107 if (verbose_conv==-1) verbose_conv = verbose_general;
1108 if (verbose_scan==-1) verbose_scan = verbose_general;
1109 if (verbose_data==-1) verbose_data = verbose_general;
1122 if (scanner_name.empty())
1124 Cerr(
"***** castor-proj() -> Please provide a scanner name (format: Modality_Constuctor_Model) :" << endl);
1125 Cerr(
" -sc scanner_alias: Give the scanner model." << endl);
1126 Cerr(
" It must correspond to the name of one of the file in the scanner repository (without file extension)" << endl);
1131 if (verbose_general>=2)
Cout(
" selected scanner name: " << scanner_name << endl);
1135 if (path_fout.empty() && path_dout.empty())
1137 Cerr(
"***** castor-proj() -> Please provide an output option for output files (-fout or -dout) !" << endl);
1141 if (!path_fout.empty() && !path_dout.empty())
1143 Cerr(
"***** castor-proj() -> Please provide either output option -fout or -dout but not both !" << endl);
1148 if (path_to_initial_img.empty())
1150 Cerr(
"***** castor-proj() -> -img path_to_img.hdr : Give an interfile header of the image to project" << endl);
1155 if (verbose_general>=2)
Cout(
" selected input image path: " << path_to_initial_img << endl);
1173 p_outputManager->
SetVerbose(verbose_general);
1178 Cerr(
"***** castor-proj() -> A problem occured while checking for the config directory path !" << endl);
1185 Cerr(
"***** castor-proj() -> A problem occured while initializing output directory !" << endl);
1191 Cerr(
"***** castor-proj() -> A problem occured while logging command line arguments !" << endl);
1212 scanner_name = (scanner_name.find(
OS_SEP)) ?
1213 scanner_name.substr(scanner_name.find_last_of(
OS_SEP)+1) :
1218 Cerr(
"***** castor-proj() -> A problem occurred while searching for scanner system !" << endl);
1224 Cerr(
"***** castor-proj() -> A problem occurred during scanner object construction !" << endl);
1230 Cerr(
"***** castor-proj() -> A problem occurred while creating Scanner object !" << endl);
1240 Cerr(
"***** castor-proj() -> A problem occurred while setting PET geometric parameters !" << endl);
1247 SPECT_nb_projection_angles,
1250 SPECT_projection_angles,
1254 Cerr(
"***** castor-proj() -> A problem occurred while setting SPECT geometric parameters !" << endl);
1262 Cerr(
"***** castor-proj() -> A problem occurred while generating/reading the LUT !" << endl);
1270 Cerr(
"***** castor-proj() -> A problem occured while checking scanner manager parameters !" << endl);
1275 Cerr(
"***** castor-proj() -> A problem occured while initializing scanner !" << endl);
1289 Cerr(
"***** castor-proj() -> An error occurred while trying to read the interfile header of file reading file " << path_to_initial_img <<
" !" << endl);
1295 nb_VoxX = nb_VoxX<0 ? IF.
mtx_size[0] : nb_VoxX ;
1296 nb_VoxY = nb_VoxY<0 ? IF.
mtx_size[1] : nb_VoxY ;
1297 nb_VoxZ = nb_VoxZ<0 ? IF.
mtx_size[2] : nb_VoxZ ;
1307 if (frame_list ==
"")
1309 vector <string> image_filenames;
1310 if (
IntfIsMHD(path_to_initial_img, image_filenames) )
1312 Cerr(
"***** castor-proj() -> Error : while trying to read the interfile header '"<< path_to_initial_img <<
"' !" << endl);
1318 if(image_filenames.size() > 1)
1329 Cerr(
"***** castor-proj() -> Interfile reading error of the input image :"<<endl);
1331 <<
"' does not match the actual number of time frames * respiratory gates * cardiac gates ) '"<< IF.
nb_time_frames *
1338 stringstream ss_id, ss_df;
1341 string frame_duration_str = ss_id.str();
1347 if(dead_frame_sec > 0.)
1349 ss_df << dead_frame_sec;
1350 frame_duration_str.append(
",").append(ss_df.str()).append(
";0");
1354 frame_list.append(frame_duration_str);
1358 frame_list.append(
",");
1366 Cerr(
"***** castor-proj() -> Interfile reading error of the input image :"<<endl);
1368 <<
"' does not match the actual number of time frames * respiratory gates * cardiac gates ) '"<< IF.
nb_time_frames <<
"' !" << endl);
1374 frame_list.append(ss.str());
1377 frame_list.append(
",");
1393 if(nb_VoxX<0 || nb_VoxY<0 || nb_VoxZ<0)
1400 if ( (fov_SizeX<0 || fov_SizeY<0 || fov_SizeZ<0) && (vox_SizeX<0 || vox_SizeY<0 || vox_SizeZ<0) )
1421 if (verbose_general>=2)
1423 Cout(
" Image dimensions for analytical projections: " << endl);
1424 Cout(
" voxels number (X,Y,Z): " << nb_VoxX <<
"," << nb_VoxY <<
"," << nb_VoxZ << endl);
1425 Cout(
" voxels size (X,Y,Z): " << vox_SizeX <<
"," << vox_SizeY <<
"," << vox_SizeZ << endl);
1426 Cout(
" FOV (X,Y,Z): " << fov_SizeX <<
"," << fov_SizeY <<
"," << fov_SizeZ << endl);
1435 p_ImageDimensionsAndQuantification->
SetNbVoxX(nb_VoxX);
1436 p_ImageDimensionsAndQuantification->
SetNbVoxY(nb_VoxY);
1437 p_ImageDimensionsAndQuantification->
SetNbVoxZ(nb_VoxZ);
1438 p_ImageDimensionsAndQuantification->
SetNbThreads(nb_threads);
1439 p_ImageDimensionsAndQuantification->
SetNbBeds(nb_beds);
1440 p_ImageDimensionsAndQuantification->
SetVoxSizeX(vox_SizeX);
1441 p_ImageDimensionsAndQuantification->
SetVoxSizeY(vox_SizeY);
1442 p_ImageDimensionsAndQuantification->
SetVoxSizeZ(vox_SizeZ);
1443 p_ImageDimensionsAndQuantification->
SetFOVSizeX(fov_SizeX);
1444 p_ImageDimensionsAndQuantification->
SetFOVSizeY(fov_SizeY);
1445 p_ImageDimensionsAndQuantification->
SetFOVSizeZ(fov_SizeZ);
1447 p_ImageDimensionsAndQuantification->
SetOffsetX(offsetX);
1448 p_ImageDimensionsAndQuantification->
SetOffsetY(offsetY);
1449 p_ImageDimensionsAndQuantification->
SetOffsetZ(offsetZ);
1450 p_ImageDimensionsAndQuantification->
SetVerbose(verbose_data);
1451 p_ImageDimensionsAndQuantification->
SetNbRespGates(nb_resp_gates);
1452 p_ImageDimensionsAndQuantification->
SetNbCardGates(nb_card_gates);
1453 p_ImageDimensionsAndQuantification->
SetFrames(frame_list);
1456 Cerr(
"***** castor-proj() -> A problem occured while checking image dimensions parameters !" << endl);
1459 if (p_ImageDimensionsAndQuantification->
Initialize())
1461 Cerr(
"***** castor-proj() -> A problem occured while initializing image dimensions !" << endl);
1466 if (p_ImageDimensionsAndQuantification->
InitDynamicData(
"", 0, 0, 0, 0, nb_resp_gates, nb_card_gates ) )
1468 Cerr(
"***** castor-proj() -> A problem occured while initializing Dynamic data manager's class !" << endl);
1493 Cerr(
"***** castor-proj() -> Unknown scanner type !" << endl);
1500 Cerr(
"***** castor-proj() -> Only PET type events are allowed while using a PET scanner !" << endl);
1501 Cerr(
"***** castor-proj() -> (use '-fileType' to define modality (0=PET, 1=SPECT, 2=CT) )" << endl);
1504 for (
int i=0 ; i<nb_beds ; i++)
1507 if(path_to_attenuation_img !=
"")
1508 (
dynamic_cast<iDataFilePET*
>(p_DataFile[i]))->SetAtnCorrectionFlagOn();
1515 Cerr(
"***** castor-proj() -> Only SPECT type events are allowed while using a SPECT scanner !" << endl);
1516 Cerr(
"***** castor-proj() -> (use '-fileType' to define modality (0=PET, 1=SPECT, 2=CT) )" << endl);
1519 for (
int i=0 ; i<nb_beds ; i++)
1526 Cerr(
"***** castor-proj() -> Unsupported scanner type !" << endl);
1534 for (
int bed=0 ; bed<nb_beds ; bed++)
1547 if(p_DataFile[bed]->CheckParameters())
1549 Cerr(
"***** castor-proj() -> A problem occurred while checking datafile parameters ! Abort." << endl);
1589 p_ProjectorManager->
SetVerbose(verbose_proj);
1594 Cerr(
"***** castor-proj() -> A problem occured while checking projector manager's parameters !" << endl);
1601 Cerr(
"***** castor-proj() -> A problem occured while initializing projector manager !" << endl);
1615 p_ImageConvolverManager->
SetVerbose(verbose_conv);
1617 p_ImageConvolverManager->
SetOptions(options_image_convolver);
1622 Cerr(
"***** castor-proj() -> A problem occured while checking optimizer manager's parameters !" << endl);
1628 Cerr(
"***** castor-proj() -> A problem occured while initializing optimizer manager !" << endl);
1649 p_Projection->
InitOptimizer(p_ImageDimensionsAndQuantification);
1652 Cerr(
"***** castor-proj() -> A problem occured while initializing noise model !" << endl);
1669 if (p_Projection->
Launch())
1671 Cerr(
"***** castor-proj() -> Error occured during Projections" << endl;);
1679 if(SPECT_projection_angles)
delete SPECT_projection_angles;
1681 if (verbose_general>=5)
Cout(
"----- Deleting CASToR objects ... -----" << endl);
1682 delete p_Projection;
1683 delete p_ImageSpace;
1684 delete p_ImageConvolverManager;
1685 delete p_ProjectorManager;
1689 for (
int i=0 ; i<nb_beds ; i++)
delete p_DataFile[i];
1690 delete[] p_DataFile;
1691 delete p_ImageDimensionsAndQuantification;
1694 if (verbose_general>=5)
Cout(
"----- CASToR objects successfully deleted -----" << endl);
1697 if (verbose_general>=1)
Cout(endl);
1701 return EXIT_SUCCESS;
void SetDataMode(int a_dataMode)
set the data mode
This class is designed to be a mother virtual class for Datafile.
This header file is mainly used to declare some macro definitions and all includes needed from the st...
static sScannerManager * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the member mp_ImageDimensionsAndQuantification to the provided value.
static sRandomNumberGenerator * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
Declaration of class oImageDimensionsAndQuantification.
void SetNbBeds(int a_nbBeds)
Set number of beds (bed positions)
int InitDynamicData(string a_pathTo4DDataSplittingFile, int a_respMotionCorrectionFlag, int a_cardMotionCorrectionFlag, int a_doubleMotionCorrectionFlag, int a_invMotionCorrectionFlag, int a_nbRespGates, int a_nbCardGates)
Call the eponym function from the oDynamicDataManager object in order to initialize its data...
void SetVerbose(int a_verbose)
set verbosity
void SetFOVSizeZ(FLTNB a_fovSizeZ)
Set the FOV's size along the Z axis, in mm.
static void ShowCommonHelp()
This function is used to print out some help about the use of options common to all projectors...
This class manages the analytic projection of an image and the computation of the associated datafile...
void SetComputationStrategy(int a_computationStrategy)
Set the computation strategy for the system matrix elements storage.
int Initialize()
A function used to initialize the manager and the projectors or system matrices it manages...
void SetVerbose(int a_verboseLevel)
Set the member m_verboseLevel to the provided value.
void SetImageConvolverManager(oImageConvolverManager *ap_ImageConvolverManager)
Set the Image Convolver Manager Object.
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the image dimensions in use.
int FindScannerSystem(string a_scannerName)
Look for a file matching with the scanner name in parameter inside the scanner repository.
void SetFOVSizeY(FLTNB a_fovSizeY)
Set the FOV's size along the Y axis, in mm.
void SetNbVoxZ(INTNB a_nbVoxZ)
Set the number of voxels along the Z axis.
void SetDataFile(vDataFile **a2p_DataFile)
Set the list of DataFile.
int BuildScannerObject()
Instantiate the specific scanner object related to the modality, and set verbosity of scanner object...
void IntfKeyPrintFields(Intf_fields a_IF)
Print all the keys of the Intf_fields structure passed in parameter, as well as their values for debu...
void SetNbRespGates(int a_nbRespGates)
Set the number of respiratory gates.
int CheckParameters()
A function used to check the parameters settings.
void SetPathAtnImage(string a_pathToAtnImg)
Set path to an attenuation image.
void SetOffsetY(FLTNB a_offsetY)
Set the image offset along the Y axis, in mm.
void ShowHelpDynamic()
Display command line options related to the dynamic features for castor-proj.
void SetFOVOutMasking(FLTNB a_fovOutPercent, INTNB a_nbSliceOutMask)
Set the output FOV masking settings: transaxial unmasked FOV percent and number of extrem slices to r...
void SetVerbose(int a_verboseLevel)
set verbosity
#define TYPE_TRANSMISSION
void SetOptionsForward(const string &a_optionsForward)
Set the forward projection options contained in the provided string.
void SetPathInitImage(string a_pathToInitialImage)
Set path to an initial image.
virtual int ComputeSizeEvent()=0
This function is implemented in child classes Computation of the size of each event according to th...
vector< FLTNB > frame_group_pause
string GetPathToScannerFile()
void SetVerbose(int a_verboseLevel)
Set verbosity level.
static sOutputManager * GetInstance()
Instanciate the singleton object and Initialize member variables if not already done, return a pointer to this object otherwise.
void SetOffsetZ(FLTNB a_offsetZ)
Set the image offset along the Z axis, in mm.
void ShowHelpProj()
Display command line options related to the Projector module for castor-proj.
void SetSaveLUTFlag(bool a_flag)
Set to on the flag indicating a LUT generated by a geom file should be written on disk or not...
Declaration of class iDataFilePET.
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the Image Dimensions and Quantification Object.
void SetOptions(vector< string > a_options)
Set the member m_options to the provided value.
void SetOptionsCommon(const string &a_optionsCommon)
Set the common projection options contained in the provided string.
int CheckParameters()
Check if all parameters have been correctly initialized, and call the CheckParameters function of the...
void SetNbVoxX(INTNB a_nbVoxX)
Set the number of voxels along the X axis.
int SetNbThreads(const string &a_nbThreads)
Set the number of threads.
Declaration of class iDataFileSPECT.
void SetOptionsBackward(const string &a_optionsBackward)
Set the backward projection options contained in the provided string.
Declaration of class iScannerPET.
int IntfReadHeader(const string &a_pathToHeaderFile, Intf_fields *ap_IntfFields, int vb)
Read an Interfile header.
int InstantiateScanner()
Instantiate scanner using the related function in the scanner classes.
int LogCommandLine(int argc, char **argv)
Write log file header with the provided command line options and different informations.
static sAddonManager * GetInstance()
int IntfIsMHD(string a_pathToFile, vector< string > &ap_lPathToImgs)
Check if the string in argument contains the path to a Interfile metaheader.
Declaration of class oImageConvolverManager.
int ConvertFromString(const string &a_str, string *a_result)
Copy the 'a_str' string in the position pointed by 'a_result'.
#define FIXED_LIST_COMPUTATION_STRATEGY
int InitNoiseModel(string aNoiseModel)
void SetNbVoxY(INTNB a_nbVoxY)
Set the number of voxels along the Y axis.
int CheckConfigDir(const string &a_path)
Set the path to the CASTOR config directory from the given path if not empty or through the existence...
void SetProjectorManager(oProjectorManager *ap_ProjectorManager)
Set the Projector Manager Object.
int CheckParameters()
A function used to check the parameters settings.
void SetNbCardGates(int a_nbCardGates)
Set the number of cardiac gates.
#define SCANNER_SPECT_CONVERGENT
int BuildLUT()
Call the eponym function of the scanner class.
int Initialize(int a_nbThreads)
Instanciate a number of RNG according to the number of threads used in openMP.
int Initialize()
A function used to initialize all that is needed.
Singleton class that manages output writing on disk (images, sinograms, etc). It also manages loggi...
void SetFrames(const string &a_frameList)
Set the frame list (a string that will be parsed by the InitializeFramingAndQuantification function) ...
void SetFOVSizeX(FLTNB a_fovSizeX)
Set the FOV's size along the X axis, in mm.
void SetDataType(int a_dataType)
set the data type
int ReadDataASCIIFile(const string &a_file, const string &a_keyword, T *ap_return, int a_nbElts, bool a_mandatoryFlag)
Look for "a_nbElts" elts in the "a_file" file matching the "a_keyword" string passed as parameter a...
Singleton class that Instantiate and initialize the scanner object.
Declaration of class sScannerManager.
void SetVoxSizeY(FLTNB a_voxSizeY)
Set the voxel's size along the Y axis, in mm.
void ShowHelpComputation()
Display command line options related to the computation settings for castor-proj. ...
virtual int PrepareDataFile()=0
This function is implemented in child classes Store different kind of information inside arrays (da...
int PROJ_SetPETSpecificParameters(int a_maxRingDiff)
Deliver to the PET scanner object all informations provided from the datafile header.
Inherit from vDataFile. Class that manages the reading of a SPECT input file (header + data)...
int main(int argc, char **argv)
This class is designed to manage the different image convolvers and to apply them.
void ShowHelpInput()
Display command line options related to input settings for castor-proj.
void SetOffsetX(FLTNB a_offsetX)
Set the image offset along the X axis, in mm.
int Launch()
Just call either the LaunchCPU or the LaunchGPU function as asked for.
vScanner * GetScannerObject()
void SetVoxSizeX(FLTNB a_voxSizeX)
Set the voxel's size along the X axis, in mm.
void IntfKeyInitFields(Intf_fields *ap_IF)
Init the file of an Interfile fields structure passed in parameter to their default values...
int CheckParameters()
A function used to check the parameters settings.
vector< FLTNB > image_duration
void SetVerbose(int a_verboseLevel)
Set Verbosity.
void SetVerbose(int a_verboseLevel)
Set the verbose level.
void SetDataFile(vDataFile *ap_DataFile)
Set a data file in use to later recover some information from it.
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
set the pointer to the oImageDimensionsAndQuantification object
void ShowHelpProjector()
Show help about all implemented projectors.
void ShowHelpOutput()
Display command line options related to output settings for castor-proj.
#define KEYWORD_MANDATORY
int PROJ_SetSPECTSpecificParameters(uint16_t *ap_nbOfBins, uint32_t a_nbOfProjections, FLTNB a_firstAngle, FLTNB a_stepAngle, FLTNB *ap_projectionAngles, FLTNB a_CORtoDetectorDistance, string a_rotDirection)
Deliver to the SPECT scanner object all informations provided from the acquisition parameters...
static void ShowCommonHelp()
This function does not take any parameter and is used to display some help about the syntax of the op...
Singleton class that generate a thread-safe random generator number for openMP As singleton...
void SetGPUflag(bool a_flagGPU)
Set the GPU flag.
void ShowHelp(int a_returnCode, int a_mpiRank)
int Initialize()
Initialization : .
Declaration of class sRandomNumberGenerator.
#define SCANNER_SPECT_PINHOLE
void SetVerbose(int a_verbose)
Set the member m_verboseLevel to the provided value.
void SetVoxSizeZ(FLTNB a_voxSizeZ)
Set the voxel's size along the Z axis, in mm.
void ShowHelpMiscellaneous()
Display command line settings related to SPECT modality for castor-proj.
void SetVerbose(int a_verboseLevel)
set verbosity
This class is designed to manage the projection part of the reconstruction.
Interfile fields. This structure contains all the Interfile keys currently managed by CASToR Decl...
void SetBedIndex(int a_bedIndex)
set the bed index corresponding to this data file
Declaration of class sOutputManager.
This class holds all the matrices in the image domain that can be used in the algorithm: image...
int InitOutputDirectory(const string &a_pathFout, const string &a_pathDout)
Create the output directory if any, extract the base name and create the log file.
This class is designed to manage all dimensions and quantification related stuff. ...
int GetNbThreadsForProjection()
Get the number of threads used for projections.
Declaration of class oAnalyticProjection.
int GetScannerLayerNbRings(int a_layer)
Ask the number of rings to the scanner object for a specific layer. Returns an error if this inform...
void SetNbBeds(int a_nbBeds)
Set the number of bed positions.
This file is used for all kind of different functions designed for options parsing and ASCII file rea...
void SetVerbose(int a_verboseLevel)
set verbosity
Declaration of class iDataFileTransmission.
void SetScanner(vScanner *ap_Scanner)
Set the scanner in use.
void SetImageSpace(oImageSpace *ap_ImageSpace)
Set the Image Space Object.
virtual int PROJ_GetScannerSpecificParameters()=0
This function is implemented in child classes It is used to set several variables of the datafile w...
void SetScanner(vScanner *ap_Scanner)
Set the scanner in use.
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
set the pointer to the oImageDimensionsAndQuantification object
Inherit from vDataFile. Class that manages the reading of a PET input file (header + data)...
void SetPercentageLoad(int a_percentageLoad)
Set the percentage of the data file that will be loaded in memory.
int ReadStringOption(const string &a_input, T *ap_return, int a_nbElts, const string &sep, const string &a_option)
Parse the 'a_input' string corresponding to the 'a_option' into 'a_nbElts' elements, using the 'sep' separator. The results are returned in the templated 'ap_return' dynamic templated array. Call "ConvertFromString()" to perform the correct conversion depending on the type of the data to convert.
void InitOptimizer(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
virtual int PROJ_InitFile()=0
This function is implemented in child classes Initialize the fstream objets for output writing as w...
void GetUserEndianness()
Check user/host computer endianness and write it to the global variable User_Endianness.
int Initialize()
A function used to initialize the manager and all image convolvers it manages.
void ShowHelpImageConvolver()
Show help about all implemented image convolvers.