44 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
45 if (mpi_rank!=0)
return;
49 cout <<
"Usage: castor-recon.exe -df file.cdh -(f/d)out output -it iter [settings]" << endl;
51 cout <<
"[Main options]:" << endl;
53 cout <<
" -df file.cdh : Give an input CASTOR datafile (no default)." << endl;
54 cout <<
" -fout name : Give the root name for all output files (no default, alternative to -dout)" << endl;
55 cout <<
" -dout name : Give the name of the output directory where all output files will be written (no default, alternative to -fout)" << endl;
56 cout <<
" -it list : Give the sequence of iterations:subsets separated by commas (no default)." << endl;
57 cout <<
" -dim x,y,z : Give the number of voxels in each dimension (default: those of the scanner)." << endl;
58 cout <<
" -fov x,y,z : Give the size of the field-of-view in each dimension, in mm (default: those of the scanner, or calculated from" << endl;
59 cout <<
" the voxel sizes provided using '-vox')." << endl;
60 cout <<
" -vox x,y,z : Give the size of the voxels in each dimension, in mm (default: those of the scanner, or calculated from the fov" << endl;
61 cout <<
" if a fov value is provided using '-fov')." << endl;
62 cout <<
" -vb : Give the general verbosity level, from 0 (no verbose) to 5 and above (at the event level) (default: 1)." << endl;
64 cout <<
"[Specific options]:" << endl;
65 cout <<
" -help-dim : Print out specific help about dimensions settings." << endl;
66 cout <<
" -help-in : Print out specific help about input settings." << endl;
67 cout <<
" -help-out : Print out specific help about output settings." << endl;
68 cout <<
" -help-algo : Print out specific help about reconstruction optimizer algorithm settings." << endl;
69 cout <<
" -help-proj : Print out specific help about projection operators." << endl;
70 cout <<
" -help-dynamic : Print out specific help about dynamic methodologies settings." << endl;
71 cout <<
" -help-imgp : Print out specific help about image processing modules." << endl;
72 cout <<
" -help-comp : Print out specific help about computing settings." << endl;
73 cout <<
" -help-corr : Print out specific help about all corrections that can be disabled." << endl;
74 cout <<
" -help-misc : Print out specific help about miscellaneous and verbose settings." << endl;
76 cout <<
"[Implemented Modules]:" << endl;
77 cout <<
" -help-scan : Show the list of all scanners from the configuration directory." << endl;
78 cout <<
" -help-projm : Show the list and description of all implemented projectors." << endl;
79 cout <<
" -help-opti : Show the list and description of all implemented optimizer algorithms." << endl;
83 cout <<
" -help-conv : Show the list and description of all implemented image convolvers." << endl;
84 cout <<
" -help-proc : Show the list and description of all implemented image processing modules." << endl;
87 cout <<
" --help,-h,-help : Print out this help page." << endl;
90 cout <<
" Compiled with MPI" << endl;
93 cout <<
" Compiled with OpenMP" << endl;
96 cout <<
" Compiled for GPU" << endl;
98 #if defined(CASTOR_OMP) || defined(CASTOR_MPI) || defined(CASTOR_GPU)
102 cout <<
" Build date: " << BUILD_DATE << endl;
105 #ifdef CASTOR_VERSION
106 cout <<
" This program is part of the CASToR release version " <<
CASTOR_VERSION <<
"." << endl;
124 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
125 if (mpi_rank!=0)
return;
129 cout <<
"[Input settings]:" << endl;
134 cout <<
" -df file.Cdf : Give an input CASTOR datafile (no default)." << endl;
136 cout <<
" -img file.hdr : Give an input image as the initialization of the algorithm (default: uniform value)." << endl;
138 cout <<
" -sens file.hdr : Provide the sensitivity image (default: sensitivity image is computed before reconstruction)." << endl;
139 cout <<
" the image file should integrate all sensitivity images if more than one are required" << endl;
140 cout <<
" if dual-gating is enabled and if it required sensitivity images for each gate, the image should integrate nb_resp_gates * nb_card_gates sensitivity images" << endl;
141 cout <<
" (all cardiac-gated based sensitivity images for each one of the respiratory gates)." << endl;
143 cout <<
" -norm file.cdh : For list-mode data, provide a normalization data file for sensitivity computation (default: use the scanner LUT and" << endl;
144 cout <<
" assume all LORs with a weight of 1.). This restricts the computation of the sensitivity to the LORs provided in the" << endl;
145 cout <<
" normalization file and associated normalization factors and/or attenuation factors." << endl;
146 cout <<
" For dynamic reconstructions with multiple frames, as many normalization files as frames can be supplied, their names" << endl;
147 cout <<
" separated by commas. This is useful when dead-times correction is included in the normalization factors." << endl;
148 cout <<
" Can also use this option multiple times when multiple bed positions are reconstructed at once." << endl;
150 cout <<
" -atn file.hdr : Give an input attenuation image (unit has to be cm-1) for sensitivity image generation or SPECT attenuation correction." << endl;
152 cout <<
" -help-in : Print out this help." << endl;
169 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
170 if (mpi_rank!=0)
return;
174 cout <<
"[Output settings]:" << endl;
176 cout <<
" -fout name : Give the root name for all output files. All output files will be written as 'name_suffix.ext'." << endl;
177 cout <<
" So the provided name should not end with '.' or '/' character. (no default, alternative to -dout)" << endl;
178 cout <<
" -dout name : Give the name of the output directory where all output files will be written. All files will also" << endl;
179 cout <<
" be prefixed by the name of the directory. The provided name should not end with '.' or '/' character." << endl;
180 cout <<
" (no default, alternative to -fout)" << endl;
182 cout <<
" -oit list : Give the sequence of output iterations as a list of 'a:b' pairs separated by commas. This will output one" << endl;
183 cout <<
" iteration over 'a' until 'b' is reached, then it goes to the next pair of setting. (default: last iteration)" << endl;
185 cout <<
" -omd : (M)erge (D)ynamic images. Indicate if a dynamic serie of 3D images should be written on disk in one file" << endl;
186 cout <<
" instead of a serie of 3D images associated with an interfile metaheader" << endl;
192 cout <<
" -osens : Flag to say that we want to save the sensitivity image of each subset/iteration, when in histogram mode." << endl;
194 cout <<
" -osub : Flag to say that we want to save the image after each subset." << endl;
196 cout <<
" -olut : If a scanner LUT (geometry information) is computed from a .geom file, it will be save on disk in the scanner repository" << endl;
198 cout <<
" -sens-histo : If input file is a histogram, compute the global sensitivity from it (and still proceed to normal reconstruction after)" << endl;
200 cout <<
" -sens-only : For list-mode data, exit directly after computing and saving the sensitivity." << endl;
202 cout <<
" -help-out : Print out this help." << endl;
219 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
220 if (mpi_rank!=0)
return;
224 cout <<
"[Dimensions options]:" << endl;
226 cout <<
" -dim x,y,z : Give the number of voxels in each dimension (default: those of the scanner)." << endl;
228 cout <<
" -fov x,y,z : Give the size of the field-of-view in each dimension, in mm (default: those of the scanner)." << endl;
230 cout <<
" -vox x,y,z : Give the size of the voxels in each dimension, in mm (default: those of the scanner, or calculated from the fov if a fov value is provided using '-fov')." << endl;
232 cout <<
" -off x,y,z : Give the offset of the field-of-view in each dimension, in mm (default: 0.,0.,0.)." << endl;
233 cout <<
" (note this has no effect when using a pre-computed system matrix)" << endl;
235 cout <<
" -fov-out percent : Give the percentage of the eliptical transaxial FOV to be kept while saving the image (default: no making)" << endl;
237 cout <<
" -slice-out value : Give the number of axial slices to be masked at each border of the axial field-of-view (default: 0)" << endl;
239 cout <<
" -flip-out value : Flip the image before saving it (not done in the computation); specify the axis (e.g. 'X', 'XY', 'YZ') (default: no flip)" << endl;
241 cout <<
" -help-dim : Print out this help." << endl;
258 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
259 if (mpi_rank!=0)
return;
262 cout <<
"[Algorithm settings]:" << endl;
264 cout <<
" -opti param : Give the algorithm to be used, along with a configuration file (algo:file.conf) or the list of parameters" << endl;
265 cout <<
" associated to the algorithm (algo,param1,param2,...). If the algorithm only is specified, the default" << endl;
266 cout <<
" configuration file is used if any. By default, the MLEM algorithm is used. For specific help, use option -help-opti." << endl;
268 cout <<
" -opti-fom : Flag to say that we want to compute and print figures-of-merit (likelihood and RMSE) in the data-space." << endl;
270 cout <<
" -opti-stat : Flag to say that we want to compute and print basic statistics about the image update." << endl;
278 cout <<
" -help-opti : Print out specific help about algorithm settings." << endl;
299 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
300 if (mpi_rank!=0)
return;
303 cout <<
"[Projector settings]:" << endl;
305 cout <<
" -proj param : Give the projector to be used for both forward and backward projections, along with a configuration file (proj:file.conf)" << endl;
306 cout <<
" or the list of parameters associated to the projector (proj,param1,param2,...). If the projector only is specified, the" << endl;
307 cout <<
" default configuration file is used. By default, the Siddon projector is used. For specific help, use option -help-proj." << endl;
309 cout <<
" -projF param : Give the projector to be used for forward projections. See option -proj for details." << endl;
311 cout <<
" -projB param : Give the projector to be used for backward projections. See option -proj for details." << endl;
313 cout <<
" -proj-common : Give parameterization of different common projector-related options." << endl;
319 cout <<
" -ignore-TOF : Flag to say that we want to ignore any potential TOF information (default: use it if present in the datafile)." << endl;
321 cout <<
" -help-projm : Print out specific help about projector settings." << endl;
338 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
339 if (mpi_rank!=0)
return;
342 cout <<
"[Image processing settings]:" << endl;
344 cout <<
" -conv param;when : Give an image convolver model to be used within the algorithm, along with a configuration file (conv:file.conf::when) or the" << endl;
345 cout <<
" list of parameters associated to the convolver (conv,param1,param2,...::when). If the convolver only is specified, its default" << endl;
346 cout <<
" configuration file is used. By default, no convolver is applied. Multiple convolvers can be combined simply by repeating this" << endl;
347 cout <<
" this option. The mandatory 'when' parameter specifies when the convolver is applied (psf, sieve, forward, backward, post, intra)." << endl;
348 cout <<
" For more specific help, use option -help-conv." << endl;
350 cout <<
" -help-conv : Print out specific help about the image convolver settings." << endl;
352 cout <<
" -proc param;when : Give an image processing module to be used within the algorithm, along with a configuration file (proc:file.conf;when) or the" << endl;
353 cout <<
" list of parameters associated to the module (proc,param1,param2,...;when). If the module only is specified, its default" << endl;
354 cout <<
" configuration file is used. By default, no image processing module is applied. Multiple modules can be combined simply by" << endl;
355 cout <<
" repeating this this option. The mandatory 'when' parameter specifies when the module is applied (forward, backward, post, intra)." << endl;
356 cout <<
" For more specific help, use option -help-proc." << endl;
358 cout <<
" -help-proc : Print out specific help about the image processing module settings." << endl;
375 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
376 if (mpi_rank!=0)
return;
380 cout <<
"[Dynamic settings]:" << endl;
382 cout <<
" -frm list : Give the framing for the reconstruction where 'list' is a list of all frames durations in seconds separated" << endl;
383 cout <<
" by commas. To specify a dead frame, add ';0' concatenated to the frame duration. Milliseconds maximum precision." << endl;
384 cout <<
" (default: 1 frame of the whole input file duration)" << endl;
386 cout <<
" -g path_to_file : Provide text file for dynamic data splitting associated to respiratory/cardiac gating or involuntary patient motion correction" << endl;
421 cout <<
" -help-dynamic : Print out this help." << endl;
438 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
439 if (mpi_rank!=0)
return;
443 cout <<
"[Computation settings]:" << endl;
446 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;
447 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;
451 cout <<
" -gpu : Flag to say that we want to use the GPU device (default: use the CPU only)." << endl;
454 cout <<
" -load size : Give a number between 0 and 100 to specify the number of events which will be loaded in the RAM." << endl;
455 cout <<
" It will be interpreted as a percent ratio (default: 100 means all data buffered. 0 means no data buffered.)" << endl;
457 cout <<
" -proj-comp : Give the strategy for projection line computation. Here are the three different strategies that can be used:" << endl;
458 cout <<
" 1 : Image-based system matrix elements storage: The voxels weights are added in a matrix representing the whole image, so" << endl;
459 cout <<
" the addition of a new line to the previous ones is straightforward only by adding the weights to the corresponding voxels." << endl;
460 cout <<
" As it is insanely long, it can possibly be used for example with extremely complex projectors that makes use of huge number" << endl;
461 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;
462 cout <<
" This strategy is not compatible with SPECT reconstruction including attenuation correction." << endl;
463 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;
464 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;
465 cout <<
" has a fixed size which is provided by the EstimateMaxNumberOfVoxelsPerLine() function from the vProjector class. There are no" << endl;
466 cout <<
" ckecks at all for possible buffer overflows. This is the fastest strategy and default one." << endl;
467 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;
468 cout <<
" upgraded if the current number of contributing voxels exceed the list's size. The first allocated size corresponds to the diagonal" << endl;
469 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;
470 cout <<
" is a bit slower than the fixed-list strategy during the first iteration, but is optimal with respect to RAM usage." << endl;
472 cout <<
" -rng : Give a seed for the random number generator (should be >=0)" << endl;
474 cout <<
" -help-comp : Print out this help." << endl;
477 cout <<
" Compiled with MPI" << endl;
480 cout <<
" Compiled with OpenMP" << endl;
483 cout <<
" Compiled for GPU" << endl;
485 #if defined(CASTOR_OMP) || defined(CASTOR_MPI) || defined(CASTOR_GPU)
503 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
504 if (mpi_rank!=0)
return;
508 cout <<
"[Miscellaneous settings]:" << endl;
510 cout <<
" -vb : Give the general verbosity level, from 0 (no verbose) to 5 and above (at the event level) (default: 1)." << endl;
511 cout <<
" -vb-algo : Give the verbose level specific to the algorithm (default: same as general verbose level)." << endl;
512 cout <<
" -vb-opti : Give the verbose level specific to the optimizer (default: same as general verbose level)." << endl;
513 cout <<
" -vb-proj : Give the verbose level specific to the projector (default: same as general verbose level)." << endl;
514 cout <<
" -vb-conv : Give the verbose level specific to the image convolver (default: same as general verbose level)." << endl;
515 cout <<
" -vb-proc : Give the verbose level specific to the image processing (default: same as general verbose level)." << endl;
516 cout <<
" -vb-scan : Give the verbose level specific to the scanner (default: same as general verbose level)." << endl;
517 cout <<
" -vb-data : Give the verbose level specific to the data and image management (default: same as general verbose level)." << endl;
518 cout <<
" -vb-defo : Give the verbose level specific to the deformation (default: same as general verbose level)." << endl;
519 cout <<
" -vb-dyna : Give the verbose level specific to the dynamic model (default: same as general verbose level)." << endl;
520 cout <<
" -vb-sens : Give the verbose level specific to the sensitivity computation (default: same as general verbose level)." << endl;
522 cout <<
" -conf : Give the path to the CASToR config directory (default: located through the CASTOR_CONFIG environment variable)." << endl;
524 cout <<
" -help-misc : Print out this help." << endl;
541 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
542 if (mpi_rank!=0)
return;
546 cout <<
"[Correction settings]:" << endl;
548 cout <<
" -ignore-corr list : Give the list of corrections that should be ignored, separated by commas (default: all corrections applied if present)." << endl;
549 cout <<
" Here is a list of all corrections that can be ignored:" << endl;
550 cout <<
" - attn: to ignore the attenuation correction (emission only)" << endl;
551 cout <<
" - norm: to ignore the normalization correction (emission only)" << endl;
552 cout <<
" - rand: to ignore the random correction (PET only)" << endl;
553 cout <<
" - scat: to ignore the scatter correction" << endl;
554 cout <<
" - deca: to ignore the decay correction (emission only)" << endl;
555 cout <<
" - brat: to ignore the branching ratio correction (emission only)" << endl;
556 cout <<
" - fdur: to ignore the frame duration correction (emission only)" << endl;
557 cout <<
" - cali: to ignore the calibration correction (emission only)" << endl;
569 int main(
int argc,
char** argv)
577 MPI_Init(&argc, &argv);
578 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
579 MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
598 INTNB nb_voxX=-1, nb_voxY=-1, nb_voxZ=-1;
599 FLTNB fov_sizeX=-1., fov_sizeY=-1., fov_sizeZ=-1.;
600 FLTNB vox_sizeX=-1., vox_sizeY=-1., vox_sizeZ=-1.;
602 FLTNB offsetX = 0., offsetY = 0., offsetZ = 0.;
606 string flip_out =
"";
613 string frame_list =
"";
615 int nb_resp_gates = 1;
617 int nb_card_gates = 1;
619 string path_to_4D_data_splitting_file =
"";
621 string dynamic_model_options =
"";
623 string resp_motion_options =
"";
625 string card_motion_options =
"";
627 string double_motion_options =
"";
629 string ipat_motion_options =
"";
631 int nb_time_basis = 1;
632 string path_to_time_basis_coef =
"";
634 int nb_resp_basis = 1;
635 string path_to_resp_basis_coef =
"";
637 int nb_card_basis = 1;
638 string path_to_card_basis_coef =
"";
640 string path_to_dynamic_quantification_file=
"";
649 vector<string> path_to_data_filename;
651 bool invert_datafile_order_flag =
false;
653 string path_to_initial_img =
"";
655 string path_to_sensitivity_img;
657 vector<string> path_to_normalization_filename;
659 string path_to_attenuation_img;
661 int nb_atn_resp_imgs = 1;
662 int nb_atn_card_imgs = 1;
664 string ignored_corrections =
"";
671 string path_dout =
"";
673 string path_fout =
"";
675 string output_iterations =
"";
677 bool merge_dynamic_imgs_flag =
false;
679 bool save_LUT_flag =
false;
681 bool save_sens_histo =
false;
683 bool save_subset_image =
false;
687 bool exit_after_sensitivity =
false;
689 bool sensitivity_from_histogram =
false;
696 string options_projector =
"incrementalSiddon";
697 string options_projectorF =
"incrementalSiddon";
698 string options_projectorB =
"incrementalSiddon";
699 string options_projector_common =
"";
703 bool ignore_POI =
false;
704 bool ignore_TOF =
false;
711 string nb_iterations_subsets =
"";
713 string options_optimizer =
"MLEM";
715 bool optimizer_fom =
false;
717 bool optimizer_stat =
false;
719 string options_penalty =
"";
726 vector<string> options_image_convolver;
728 vector<string> options_image_processing;
735 bool gpu_flag =
false;
737 int data_file_percentage_load = 100;
739 string nb_threads =
"1";
746 int verbose_general = 1;
748 int verbose_algo = -1;
749 int verbose_opti = -1;
750 int verbose_proj = -1;
751 int verbose_conv = -1;
752 int verbose_proc = -1;
753 int verbose_scan = -1;
754 int verbose_data = -1;
755 int verbose_defo = -1;
756 int verbose_dyna = -1;
757 int verbose_sens = -1;
759 string path_to_config_dir =
"";
761 int64_t seed_RNG = -1;
770 for (
int i=1; i<argc; i++)
773 string option = (string)argv[i];
780 if (option==
"-h" || option==
"--help" || option==
"-help")
786 else if (option==
"-help-scan")
789 Cerr(
"***** castor-recon() -> An error occured when trying to output the available scanners from the scanner repository !'" << endl;);
793 else if (option==
"-help-opti")
799 else if (option==
"-help-pnlt")
805 else if (option==
"-help-projm")
814 else if (option==
"-help-conv")
823 else if (option==
"-help-proc")
832 else if (option==
"-help-dynm")
838 else if (option==
"-help-motion")
844 else if (option==
"-help-in")
850 else if (option==
"-help-out")
856 else if (option==
"-help-dim")
862 else if (option==
"-help-algo")
868 else if (option==
"-help-proj")
874 else if (option==
"-help-imgp")
880 else if (option==
"-help-comp")
886 else if (option==
"-help-misc")
892 else if (option==
"-help-dynamic")
898 else if (option==
"-help-corr")
904 else if (option==
"-vb")
908 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
913 Cerr(
"***** castor-recon() -> Exception when trying to read provided verbosity level '" << verbose_general <<
" for option: " << option << endl);
919 else if (option==
"-vb-algo")
923 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
928 Cerr(
"***** castor-recon() -> Exception when trying to read provided verbosity level '" << verbose_algo <<
" for option: " << option << endl);
934 else if (option==
"-vb-opti")
938 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
943 Cerr(
"***** castor-recon() -> Exception when trying to read provided verbosity level '" << verbose_opti <<
" for option: " << option << endl);
949 else if (option==
"-vb-proj")
953 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
958 Cerr(
"***** castor-recon() -> Exception when trying to read provided verbosity level '" << verbose_proj <<
" for option: " << option << endl);
964 else if (option==
"-vb-conv")
968 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
973 Cerr(
"***** castor-recon() -> Exception when trying to read provided verbosity level '" << verbose_conv <<
" for option: " << option << endl);
979 else if (option==
"-vb-proc")
983 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
988 Cerr(
"***** castor-recon() -> Exception when trying to read provided verbosity level '" << verbose_proc <<
" for option: " << option << endl);
994 else if (option==
"-vb-scan")
998 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1003 Cerr(
"***** castor-recon() -> Exception when trying to read provided verbosity level '" << verbose_scan <<
" for option: " << option << endl);
1009 else if (option==
"-vb-data")
1013 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1018 Cerr(
"***** castor-recon() -> Exception when trying to read provided verbosity level '" << verbose_data <<
" for option: " << option << endl);
1024 else if (option==
"-vb-defo")
1028 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1033 Cerr(
"***** castor-recon() -> Exception when trying to read provided verbosity level '" << verbose_defo <<
" for option: " << option << endl);
1039 else if (option==
"-vb-dyna")
1043 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1048 Cerr(
"***** castor-recon() -> Exception when trying to read provided verbosity level '" << verbose_dyna <<
" for option: " << option << endl);
1054 else if (option==
"-vb-sens")
1058 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1063 Cerr(
"***** castor-recon() -> Exception when trying to read provided verbosity level '" << verbose_sens <<
" for option: " << option << endl);
1069 else if (option==
"-rng")
1073 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1078 Cerr(
"***** castor-recon() -> Exception when trying to read provided number '" << seed_RNG <<
" for option: " << option << endl);
1084 else if (option==
"-conf")
1088 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1091 path_to_config_dir = (string)argv[i+1];
1100 else if (option==
"-dim")
1104 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1110 Cerr(
"***** castor-recon() -> Invalid argument " << argv[i+1] <<
" for option " << option <<
" !" << endl);
1119 else if (option==
"-fov")
1123 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1129 Cerr(
"***** castor-recon() -> Invalid argument " << argv[i+1] <<
" for option " << option <<
" !" << endl);
1132 fov_sizeX = input[0];
1133 fov_sizeY = input[1];
1134 fov_sizeZ = input[2];
1138 else if (option==
"-vox")
1142 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1148 Cerr(
"***** castor-recon() -> Invalid argument " << argv[i+1] <<
" for option " << option <<
" !" << endl);
1151 vox_sizeX = input[0];
1152 vox_sizeY = input[1];
1153 vox_sizeZ = input[2];
1157 else if (option==
"-off")
1161 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1167 Cerr(
"***** castor-recon() -> Invalid argument " << argv[i+1] <<
" for option " << option <<
" !" << endl);
1176 else if (option==
"-fov-out")
1180 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1183 fov_out = atof(argv[i+1]);
1187 else if (option==
"-slice-out")
1191 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1194 slice_out = ((
INTNB)(atoi(argv[i+1])));
1198 else if (option==
"-flip-out")
1202 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1205 flip_out = (string)(argv[i+1]);
1214 else if (option==
"-frm")
1218 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1221 frame_list = (string)argv[i+1];
1225 else if (option==
"-g")
1229 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1233 path_to_4D_data_splitting_file = ((string)argv[i+1]);
1237 Cerr(
"***** castor-recon() -> Couldn't read the number of respiratory gates in the file " << path_to_4D_data_splitting_file <<
" for option " << option << endl);
1243 Cerr(
"***** castor-recon() -> Couldn't read the number of cardiac gates in the file " << path_to_4D_data_splitting_file <<
" for option " << option << endl);
1247 if (nb_resp_gates<1 || nb_card_gates <1)
1249 Cerr(
"***** castor-recon() -> Incorrect initialization of the number of gates for the option: " << option <<
". This number should be >= 1" << endl);
1255 else if (option==
"-time-basis")
1259 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1262 string input = argv[i+1];
1263 size_t column_pos = input.find_first_of(
":");
1264 if (column_pos==string::npos)
1266 Cerr(
"***** castor-recon() -> Incorrect argument after option " << option <<
", ':' sign is missing !" << endl);
1269 string str = input.substr(0, column_pos);
1270 nb_time_basis = atoi(str.c_str());
1271 path_to_time_basis_coef = input.substr(column_pos+1);
1275 else if (option==
"-resp-basis")
1279 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1282 string input = argv[i+1];
1283 size_t column_pos = input.find_first_of(
":");
1284 if (column_pos==string::npos)
1286 Cerr(
"***** castor-recon() -> Incorrect argument after option " << option <<
", ':' sign is missing !" << endl);
1289 string str = input.substr(0, column_pos);
1290 nb_resp_basis = atoi(str.c_str());
1291 path_to_resp_basis_coef = input.substr(column_pos+1);
1295 else if (option==
"-card-basis")
1299 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1302 string input = argv[i+1];
1303 size_t column_pos = input.find_first_of(
":");
1304 if (column_pos==string::npos)
1306 Cerr(
"***** castor-recon() -> Incorrect argument after option " << option <<
", ':' sign is missing !" << endl);
1309 string str = input.substr(0, column_pos);
1310 nb_card_basis = atoi(str.c_str());
1311 path_to_card_basis_coef = input.substr(column_pos+1);
1315 else if (option==
"-dynamic-model")
1319 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1322 dynamic_model_options = (string)argv[i+1];
1326 else if (option==
"-rm")
1330 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1333 resp_motion_options = (string)argv[i+1];
1337 else if (option==
"-cm")
1341 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1344 card_motion_options = (string)argv[i+1];
1348 else if (option==
"-rcm")
1352 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1355 double_motion_options = (string)argv[i+1];
1359 else if (option==
"-im")
1363 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1366 ipat_motion_options = (string)argv[i+1];
1370 else if (option==
"-qdyn")
1374 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1377 path_to_dynamic_quantification_file = (string)argv[i+1];
1386 else if (option==
"-df")
1390 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1393 string file_name = (string)argv[i+1];
1394 path_to_data_filename.push_back(file_name);
1399 else if (option==
"-df-inv")
1401 invert_datafile_order_flag =
true;
1404 else if (option==
"-img")
1408 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1411 path_to_initial_img = argv[i+1];
1415 else if (option==
"-sens")
1419 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1423 path_to_sensitivity_img = argv[i+1];
1427 else if (option==
"-norm")
1431 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1434 string file_name = (string)argv[i+1];
1435 path_to_normalization_filename.push_back(file_name);
1440 else if (option==
"-atn")
1444 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1448 path_to_attenuation_img = (string)argv[i+1];
1450 if (path_to_attenuation_img !=
"")
1457 Cerr(
"***** castor-recon() -> An error occurred while trying to read the interfile header of attenuation file " << path_to_attenuation_img <<
" !" << endl);
1471 else if (option==
"-dout")
1475 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1478 path_dout = argv[i+1];
1482 else if (option==
"-fout")
1486 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1489 path_fout = argv[i+1];
1493 else if (option==
"-oit")
1497 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1500 output_iterations = (string)argv[i+1];
1504 else if (option==
"-omd")
1506 merge_dynamic_imgs_flag =
true;
1509 else if (option==
"-olut")
1511 save_LUT_flag =
true;
1514 else if (option==
"-osens")
1516 save_sens_histo =
true;
1519 else if (option==
"-osub")
1521 save_subset_image =
true;
1524 else if (option==
"-otb")
1526 Cerr(
"!!!!! castor-recon() -> Warning: option -otb not yet implemented !" << endl);
1529 else if (option==
"-sens-only")
1531 exit_after_sensitivity =
true;
1534 else if (option==
"-sens-histo")
1536 sensitivity_from_histogram =
true;
1544 else if (option==
"-it")
1548 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1551 nb_iterations_subsets = (string)argv[i+1];
1555 else if (option==
"-opti")
1559 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1562 options_optimizer = (string)argv[i+1];
1566 else if (option==
"-opti-fom")
1568 optimizer_fom =
true;
1571 else if (option==
"-opti-stat")
1573 optimizer_stat =
true;
1576 else if (option==
"-penalty")
1580 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1583 options_penalty = (string)argv[i+1];
1587 else if (option==
"-conv")
1591 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1594 string convolver = (string)argv[i+1];
1595 options_image_convolver.push_back(convolver);
1599 else if (option==
"-proc")
1603 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1606 string module = (string)argv[i+1];
1607 options_image_processing.push_back(module);
1616 else if (option==
"-proj")
1620 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1623 options_projectorF = (string)argv[i+1];
1624 options_projectorB = (string)argv[i+1];
1628 else if (option==
"-projF")
1632 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1635 options_projectorF = (string)argv[i+1];
1639 else if (option==
"-projB")
1643 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1646 options_projectorB = (string)argv[i+1];
1650 else if (option==
"-proj-common")
1654 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1657 options_projector_common = (string)argv[i+1];
1661 else if (option==
"-ignore-TOF")
1666 else if (option==
"-ignore-POI")
1671 else if (option==
"-proj-comp")
1675 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1678 projector_computation_strategy = atoi(argv[i+1]);
1687 else if (option==
"-ignore-corr")
1691 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1694 ignored_corrections = (string)argv[i+1];
1704 else if (option==
"-gpu")
1711 else if (option==
"-th")
1715 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1718 nb_threads = (string)argv[i+1];
1722 else if (option==
"-th")
1726 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1729 Cerr(
"!!!!! castor-recon() -> Option -th is available only if the code is compiled using the CASTOR_OMP environment variable set to 1 !" << endl);
1730 Cerr(
" Press enter to continue with the execution BUT with only one thread." << endl);
1731 Cerr(
" Or kill this and compile CASToR with OpenMP." << endl);
1737 else if (option==
"-load")
1741 Cerr(
"***** castor-recon() -> Argument missing for option: " << option << endl);
1746 Cerr(
"***** castor-recon() -> Error while trying to convert variable for option " << option << endl);
1749 if (data_file_percentage_load>100 || data_file_percentage_load<0)
1751 Cerr(
"***** castor-recon() -> Incorrect initialization of the size data buffer" << endl);
1752 Cerr(
" Number provided: " << argv[i+1] <<
" is not in the expected [0;100] interval" << endl);
1764 Cerr(
"***** castor-recon() -> Unknown option '" << option <<
"' !" << endl);
1771 MPI_Barrier(MPI_COMM_WORLD);
1775 if (verbose_algo==-1) verbose_algo = verbose_general;
1776 if (verbose_opti==-1) verbose_opti = verbose_general;
1777 if (verbose_proj==-1) verbose_proj = verbose_general;
1778 if (verbose_conv==-1) verbose_conv = verbose_general;
1779 if (verbose_proc==-1) verbose_proc = verbose_general;
1780 if (verbose_scan==-1) verbose_scan = verbose_general;
1781 if (verbose_data==-1) verbose_data = verbose_general;
1782 if (verbose_defo==-1) verbose_defo = verbose_general;
1783 if (verbose_dyna==-1) verbose_dyna = verbose_general;
1784 if (verbose_sens==-1) verbose_sens = verbose_general;
1793 Cerr(
"***** castor-recon() -> Please provide at least one data filename !" << endl);
1797 if (path_fout.empty() && path_dout.empty())
1799 Cerr(
"***** castor-recon() -> Please provide an output option for output files (-fout or -dout) !" << endl);
1803 if (!path_fout.empty() && !path_dout.empty())
1805 Cerr(
"***** castor-recon() -> Please provide either output option -fout or -dout but not both !" << endl);
1811 if ( (nb_resp_gates>1 || nb_card_gates>1) && path_to_4D_data_splitting_file.empty() )
1813 Cerr(
"***** castor-recon() -> gating is enabled, but no file describing the splitting of the data has been provided (-gating option) !" << endl);
1821 if (verbose_general>=5)
Cout(
"----- Singletons initializations ... -----" << endl);
1831 p_outputManager->
SetVerbose(verbose_general);
1840 Cerr(
"***** castor-recon() -> A problem occured while checking for the config directory path !" << endl);
1846 Cerr(
"***** castor-recon() -> A problem occured while initializing output directory !" << endl);
1852 Cerr(
"***** castor-recon() -> A problem occured while logging command line arguments !" << endl);
1863 if (verbose_general>=5)
Cout(
"----- Singletons initializations OK -----" << endl);
1869 if (verbose_general>=5)
Cout(
"----- Geometry Initialization ... -----" << endl);
1878 string scanner_name =
"";
1881 Cerr(
"***** castor-recon() -> A problem occured while trying to find the system name in the datafile header !" << endl);
1886 Cerr(
"***** castor-recon() -> A problem occurred while searching for scanner system !" << endl);
1891 Cerr(
"***** castor-recon() -> A problem occurred during scanner object construction ! !" << endl);
1896 Cerr(
"***** castor-recon() -> A problem occurred while creating Scanner object !" << endl);
1901 Cerr(
"***** castor-recon() -> A problem occurred while retrieving scanner fields from the datafile header !" << endl);
1906 Cerr(
"***** castor-recon() -> A problem occurred while generating/reading the LUT !" << endl);
1912 Cerr(
"***** castor-recon() -> A problem occured while checking scanner manager parameters !" << endl);
1917 Cerr(
"***** castor-recon() -> A problem occured while initializing scanner !" << endl);
1921 if (verbose_general>=5)
Cout(
"----- Geometry Initialization OK -----" << endl);
1924 if (nb_voxX<=0 || nb_voxY<=0 || nb_voxZ<=0)
1928 Cerr(
"***** castor-recon() -> A problem occured while reading for default number of transaxial voxels !" << endl);
1933 Cerr(
"***** castor-recon() -> A problem occured while reading for default number of transaxial voxels !" << endl);
1938 Cerr(
"***** castor-recon() -> A problem occured while reading for default number of axial voxels !" << endl);
1943 if ( (fov_sizeX<=0 || fov_sizeY<=0 || fov_sizeZ<=0) && (vox_sizeX<=0 || vox_sizeY<=0 || vox_sizeZ<=0) )
1947 Cerr(
"***** castor-recon() -> A problem occured while reading for default transaxial FOV size !" << endl);
1952 Cerr(
"***** castor-recon() -> A problem occured while reading for default transaxial FOV size !" << endl);
1957 Cerr(
"***** castor-recon() -> A problem occured while reading for default axial FOV size !" << endl);
1966 if (verbose_general>=5)
Cout(
"----- Image dimensions initialization ... -----" << endl);
1969 if (p_ImageDimensionsAndQuantification->
SetNbThreads(nb_threads))
1971 Cerr(
"***** castor-recon() -> A problem occured while setting the number of threads !" << endl);
1974 p_ImageDimensionsAndQuantification->
SetNbBeds(nb_beds);
1975 p_ImageDimensionsAndQuantification->
SetNbVoxX(nb_voxX);
1976 p_ImageDimensionsAndQuantification->
SetNbVoxY(nb_voxY);
1977 p_ImageDimensionsAndQuantification->
SetNbVoxZ(nb_voxZ);
1978 p_ImageDimensionsAndQuantification->
SetVoxSizeX(vox_sizeX);
1979 p_ImageDimensionsAndQuantification->
SetVoxSizeY(vox_sizeY);
1980 p_ImageDimensionsAndQuantification->
SetVoxSizeZ(vox_sizeZ);
1981 p_ImageDimensionsAndQuantification->
SetFOVSizeX(fov_sizeX);
1982 p_ImageDimensionsAndQuantification->
SetFOVSizeY(fov_sizeY);
1983 p_ImageDimensionsAndQuantification->
SetFOVSizeZ(fov_sizeZ);
1985 p_ImageDimensionsAndQuantification->
SetOffsetX(offsetX);
1986 p_ImageDimensionsAndQuantification->
SetOffsetY(offsetY);
1987 p_ImageDimensionsAndQuantification->
SetOffsetZ(offsetZ);
1989 p_ImageDimensionsAndQuantification->
SetVerbose(verbose_data);
1991 p_ImageDimensionsAndQuantification->
SetFrames(frame_list);
1994 if (p_ImageDimensionsAndQuantification->
SetFlipOut(flip_out))
1996 Cerr(
"***** castor-recon() -> A problem occured while setting the output flip option !" << endl);
1999 if (resp_motion_options==
"" && double_motion_options==
"")
2001 p_ImageDimensionsAndQuantification->
SetNbRespGates(nb_resp_gates);
2007 if (path_to_resp_basis_coef!=
"")
2009 Cerr(
"***** castor-recon() -> Cannot use both respiratory motion correction and respiratory basis functions, it has no sense !" << endl);
2015 if (card_motion_options==
"" && double_motion_options==
"")
2017 p_ImageDimensionsAndQuantification->
SetNbCardGates(nb_card_gates);
2023 if (path_to_card_basis_coef!=
"")
2025 Cerr(
"***** castor-recon() -> Cannot use both cardiac motion correction and cardiac basis functions, it has no sense !" << endl);
2033 Cerr(
"***** castor-recon() -> A problem occured while checking image dimensions parameters !" << endl);
2036 if (p_ImageDimensionsAndQuantification->
Initialize())
2038 Cerr(
"***** castor-recon() -> A problem occured while initializing image dimensions !" << endl);
2042 if (p_ImageDimensionsAndQuantification->
InitDynamicData(path_to_4D_data_splitting_file,
2043 !resp_motion_options.empty(),
2044 !card_motion_options.empty(),
2045 !double_motion_options.empty(),
2046 !ipat_motion_options.empty(),
2050 Cerr(
"***** castor-recon() -> A problem occured while initializing Dynamic data manager's class !" << endl);
2055 int64_t nb_events = 0;
2060 Cerr(
"***** castor-recon() -> A problem occured while checking Dynamic data manager's parameters !" << endl);
2066 Cerr(
"***** castor-recon() -> A problem occured while initializing specific dynamic quantification factors!" << endl);
2070 if (verbose_general>=5)
Cout(
"----- Image dimensions initialization OK -----" << endl);
2076 if (verbose_general>=5)
Cout(
"----- Random number generator initialization ... -----" << endl);
2084 if (verbose_general >=5)
Cout(
"----- Random number generator initialization OK -----" << endl);
2090 if (verbose_general>=5)
Cout(
"----- Datafile initialization ... -----" << endl);
2097 for (
int i=0 ; i<nb_beds ; i++)
2100 (
dynamic_cast<iDataFilePET*
>(p_DataFile[i]))->SetIgnoreTOFFlag(ignore_TOF);
2106 for (
int i=0 ; i<nb_beds ; i++)
2114 Cerr(
"***** castor-recon() -> Unknown scanner type (" << p_ScannerManager->
GetScannerType() <<
") detected by sScannerManager ! Abort." << endl);
2119 for (
int bed=0 ; bed<nb_beds ; bed++)
2122 if (invert_datafile_order_flag) p_DataFile[bed]->
SetHeaderDataFileName(path_to_data_filename.at(nb_beds-1-bed));
2129 if (p_DataFile[bed]->ReadInfoInHeader())
2131 Cerr(
"***** castor-recon() -> A problem occurred during datafile header reading ! Abort." << endl);
2134 if (p_DataFile[bed]->CheckParameters())
2136 Cerr(
"***** castor-recon() -> A problem occurred while checking datafile parameters ! Abort." << endl);
2139 if (p_DataFile[bed]->ComputeSizeEvent())
2141 Cerr(
"***** castor-recon() -> A problem occurred in datafile initialization ! Abort." << endl);
2144 if (p_DataFile[bed]->InitializeFile())
2146 Cerr(
"***** castor-recon() -> A problem occurred in datafile initialization ! Abort." << endl);
2149 if (p_DataFile[bed]->PrepareDataFile())
2151 Cerr(
"***** castor-recon() -> A problem occured in datafile preparation ! Abort." << endl);
2156 for (
int bed=1; bed<nb_beds; bed++)
2158 if (p_DataFile[0]->CheckConsistencyWithAnotherBedDatafile(p_DataFile[bed]))
2160 int bed_index_problem = bed + 1;
2161 if (invert_datafile_order_flag) bed_index_problem = nb_beds - bed;
2162 Cerr(
"***** castor-recon() -> A problem occured while checking consistency between first bed and bed " << bed_index_problem <<
" !" << endl);
2167 if (verbose_general>=5)
Cout(
"----- Datafile initialization OK -----" << endl);
2174 if (verbose_general>=5)
Cout(
"----- Projector initialization ... -----" << endl);
2185 p_ProjectorManager->
SetVerbose(verbose_proj);
2189 Cerr(
"***** castor-recon() -> A problem occured while checking projector manager's parameters !" << endl);
2195 Cerr(
"***** castor-recon() -> A problem occured while initializing projector manager !" << endl);
2201 Cerr(
"***** castor-recon() -> A problem occured while checking projector's compatibility with SPECT and attenuation correction !" << endl);
2205 if (verbose_general>=5)
Cout(
"----- Projector initialization OK -----" << endl);
2212 if (verbose_general>=5)
Cout(
"----- Optimizer initialization ... -----" << endl);
2217 p_OptimizerManager->
SetDataMode(p_DataFile[0]->GetDataMode());
2218 p_OptimizerManager->
SetDataType(p_DataFile[0]->GetDataType());
2224 p_OptimizerManager->
SetVerbose(verbose_opti);
2228 Cerr(
"***** castor-recon() -> A problem occured while checking optimizer manager's parameters !" << endl);
2234 Cerr(
"***** castor-recon() -> A problem occured while initializing optimizer manager !" << endl);
2238 if (verbose_general>=5)
Cout(
"----- Optimizer initialization OK -----" << endl);
2245 if (verbose_general>=5)
Cout(
"----- Image Convolver initialization (if any) ... -----" << endl);
2249 p_ImageConvolverManager->
SetVerbose(verbose_conv);
2251 p_ImageConvolverManager->
SetOptions(options_image_convolver);
2255 Cerr(
"***** castor-recon() -> A problem occured while checking image convolver manager's parameters !" << endl);
2261 Cerr(
"***** castor-recon() -> A problem occured while initializing image convolver manager !" << endl);
2265 if (verbose_general>=5)
Cout(
"----- Image Convolver initialization OK -----" << endl);
2272 if (verbose_general>=5)
Cout(
"----- Image Processing initialization (if any) ... -----" << endl);
2276 p_ImageProcessingManager->
SetVerbose(verbose_proc);
2278 p_ImageProcessingManager->
SetOptions(options_image_processing);
2282 Cerr(
"***** castor-recon() -> A problem occured while checking image processing manager's parameters !" << endl);
2288 Cerr(
"***** castor-recon() -> A problem occured while initializing image processing manager !" << endl);
2292 if (verbose_general>=5)
Cout(
"----- Image Processing initialization OK -----" << endl);
2299 if (verbose_general>=5)
Cout(
"----- Dynamic model initialization (if any) ... -----" << endl);
2304 p_DynamicModelManager->
SetOptions(dynamic_model_options);
2305 p_DynamicModelManager->
SetVerbose(verbose_dyna);
2309 Cerr(
"***** castor-recon() -> A problem occured while checking dynamic model manager's parameters !" << endl);
2315 Cerr(
"***** castor-recon() -> A problem occured while initializing dynamic model manager !" << endl);
2319 if (verbose_general>=5)
Cout(
"----- Dynamic model initialization OK -----" << endl);
2326 if (verbose_general>=5)
Cout(
"----- Image deformation initialization (if any) ... -----" << endl);
2331 p_DeformationManager->
SetDataMode(p_DataFile[0]->GetDataMode());
2333 if(resp_motion_options !=
"")
2335 p_DeformationManager->
SetOptions(resp_motion_options);
2339 else if (card_motion_options !=
"")
2341 p_DeformationManager->
SetOptions(card_motion_options);
2345 else if (double_motion_options !=
"")
2347 p_DeformationManager->
SetOptions(double_motion_options);
2351 else if (ipat_motion_options !=
"")
2353 p_DeformationManager->
SetOptions(ipat_motion_options);
2360 p_DeformationManager->
SetVerbose(verbose_defo);
2364 Cerr(
"***** castor-recon() -> A problem occured while checking image deformation manager's parameters !" << endl);
2370 Cerr(
"***** castor-recon() -> A problem occured while initializing image deformation manager !" << endl);
2374 if (verbose_general >=5)
Cout(
"----- Image deformation initialization OK -----" << endl);
2393 if ( path_to_sensitivity_img.empty() && (
2400 if (verbose_general>=5)
Cout(
"----- Image Sensitivity generation for list-mode initialization ... -----" << endl);
2420 Cerr(
"***** castor-recon() -> A problem occured while checking parameters of the sensitivity generator !" << endl);
2426 Cerr(
"***** castor-recon() -> A problem occured while initializing the sensitivity generator !" << endl);
2430 if (p_Sensitivity->
Launch())
2432 Cerr(
"***** castor-recon() -> A problem occured while computing the sensitivity !" << endl);
2437 else path_to_sensitivity_img =
"";
2439 delete p_Sensitivity;
2441 if (exit_after_sensitivity)
2444 delete p_ImageSpace;
2445 delete p_DeformationManager;
2446 delete p_DynamicModelManager;
2447 delete p_ImageProcessingManager;
2448 delete p_ImageConvolverManager;
2449 delete p_OptimizerManager;
2450 delete p_ProjectorManager;
2451 for (
int i=0 ; i<nb_beds ; i++)
delete p_DataFile[i];
2452 delete[] p_DataFile;
2453 delete p_ImageDimensionsAndQuantification;
2467 if (verbose_general>=5)
Cout(
"----- Iterative reconstruction algorithm initialization ... -----" << endl);
2490 Cerr(
"***** castor-recon() -> Error while setting the numbers of iterations and subsets !" << endl);
2495 Cerr(
"***** castor-recon() -> Error while setting the selected output iterations !" << endl);
2500 Cerr(
"***** castor-recon() -> Error while performing the reconstruction" << endl);
2509 if (verbose_general>=5)
Cout(
"----- Deleting CASToR objects ... -----" << endl);
2511 delete p_ImageSpace;
2512 delete p_DeformationManager;
2513 delete p_DynamicModelManager;
2514 delete p_ImageProcessingManager;
2515 delete p_ImageConvolverManager;
2516 delete p_OptimizerManager;
2517 delete p_ProjectorManager;
2518 for (
int i=0 ; i<nb_beds ; i++)
delete p_DataFile[i];
2519 delete[] p_DataFile;
2520 delete p_ImageDimensionsAndQuantification;
2521 if (verbose_general>=5)
Cout(
"----- CASToR objects successfully deleted -----" << endl);
2524 if (verbose_general>=1)
Cout(endl);
2528 return EXIT_SUCCESS;
void SetIgnorePOIFlag(bool a_ignorePOIFlag)
Set a boolean that that if we ignore POI information or not.
void SetRespBasisFunctionsFile(const string &a_respBasisFunctionsFile)
Set the file name containing the respiratory basis functions coefficients.
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.
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the Image Dimensions and Quantification Object.
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 SetPathToAttenuationImage(string a_pathToAttenuationImage)
This function is used to set the path to the attenuation image.
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 SetNumberOfAtnGateImages(int a_nbAtnRespGateImages, int a_nbAtnCardGateImages)
int Iterate()
Just call either the IterateCPU or the IterateGPU function as asked for.
int SetNbIterationsAndSubsets(const string &a_nbIterationsSubsets)
Set the number of iterations and subsets.
void SetVerbose(int a_verbose)
set verbosity
void SetGPUflag(bool a_flagGPU)
Set the GPU flag.
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...
void SetIgnoredCorrections(const string &a_ignoredCorrectionsList)
Set the string specifying the corrections that will be ignored.
void SetOptimizerImageStatFlag(bool a_optimizerImageStatFlag)
Set the optimizer image stat flag that specifies if some basic statistics about image update is compu...
void ShowHelpDynamicModel()
Show help about all implemented dynamic models.
void ShowHelpDeformation()
Show help about all implemented deformations.
void ShowHelp()
Display main command line options for castor-proj.
void SetComputationStrategy(int a_computationStrategy)
Set the computation strategy for the system matrix elements storage.
void SetProjectorManager(oProjectorManager *ap_ProjectorManager)
Set the Projector Manager Object.
int Initialize()
A function used to initialize the manager and the projectors or system matrices it manages...
static void ShowCommonHelp()
This function does not take any parameter and is used to display some help about the syntax of the op...
void SetSaveSensitivityHistoFlag(bool a_saveSensitivityHistoFlag)
Set the flag that specifies if the sensitivity image in histogram mode has to be saved for each subse...
int Initialize()
A public function used to initialize the sensitivity generator.
void SetVerbose(int a_verboseLevel)
Set the member m_verboseLevel to the provided value.
void ShowHelpImgp()
Display command line options related to the Image Processing module for castor-recon.
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 SetDeformationManager(oDeformationManager *ap_DeformationManager)
Set the Deformation Manager Object.
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 SetNbTimeBasisFunctions(int a_nbTimeBasisFunctions)
Set the number of time basis functions.
void SetOptions(const string &a_options)
Set the respiratory motion options contained in the provided string.
void SetVerbose(int a_verboseLevel)
Set the verbose level.
int BuildScannerObject()
Instantiate the specific scanner object related to the modality, and set verbosity of scanner object...
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the image dimensions in use.
string GetPathToSensitivityImage()
This function return the path to the sensitivity image.
void SetNbRespGates(int a_nbRespGates)
Set the number of respiratory gates.
int CheckParameters()
A function used to check the parameters settings.
void SetPathToSensitivityImage(string a_pathToSensitivityImage)
Set path to the sensitivity image.
This class is designed to manage the optimization part of an iterative reconstruction.
void SetOffsetY(FLTNB a_offsetY)
Set the image offset along the Y axis, in mm.
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 ShowHelpImageProcessingModule()
Show help about all implemented image processing modules.
void SetVerbose(int a_verboseLevel)
set verbosity
void SetDeformationManager(oDeformationManager *ap_DeformationManager)
This function is used to set the pointer to the oDeformationManager in use.
void SetOptionsForward(const string &a_optionsForward)
Set the forward projection options contained in the provided string.
int SetOutputIterations(const string &a_outputIterations)
Set the selected output iterations.
void SetVerbose(int a_verboseLevel)
Set Verbosity.
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the member mp_ImageDimensionsAndQuantification to the provided value.
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
Set the image dimensions in use.
This is the main class for iterative reconstructions, that manages the iteration loops. This class manages an iterative reconstruction of any kind, using a vDataFile, and through the use of an oProjector, an oOptimizer, a oConvolver, a oImageSpace.
int Launch()
A public function used to launch the sensitivity generator (compute the sensitivity image) ...
int Initialize()
A function used to initialize the manager and all image processing modules it manages.
string GetPathToScannerFile()
void SetVerbose(int a_verboseLevel)
Set verbosity level.
void ShowHelpPenalty()
Show help about all implemented penalties.
int Initialize()
Set the dynamic model flag and instanciate/initialize model objects through the ParseOptionsAndInitia...
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 SetVerbose(int a_verboseLevel)
void SetImageConvolverManager(oImageConvolverManager *ap_ImageConvolverManager)
This function is used to set the pointer to the oImageConvolverManager in use.
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 SetOptions(vector< string > a_options)
Set the member m_options to the provided value.
Declaration of class oIterativeAlgorithm.
void SetOptionsCommon(const string &a_optionsCommon)
Set the common projection options contained in the provided string.
int Initialize()
A function used to initialize the manager and the optimizer it manages.
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.
void SetPathToNormalizationFileName(vector< string > ap_pathToNormalizationFileName, bool a_inverseDataFileOrderFlag)
This function is used to set the path to the normalization file names, and the flag saying if their o...
static sAddonManager * GetInstance()
void SetSaveSubsetImageFlag(bool a_saveImageAfterSubsets)
Set the flag that specifies if the image has to be saved for each subset.
void SetComputeFromHistogramFlag(bool a_computeFromHistogramFlag)
This function is used to set the m_computeFromHistogramFlag.
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
void SetNbVoxY(INTNB a_nbVoxY)
Set the number of voxels along the Y axis.
void SetNbRespBasisFunctions(int a_nbRespBasisFunctions)
Set the number of respiratory basis functions.
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 SetVerbose(int a_verboseLevel)
Set the verbose level.
int CheckParameters()
A function used to check the parameters settings.
void SetNbCardGates(int a_nbCardGates)
Set the number of cardiac gates.
void SetDataMode(int a_dataMode)
Set the mode of the data (histogram, list-mode)
#define SCANNER_SPECT_CONVERGENT
int BuildLUT()
Call the eponym function of the scanner class.
void SetDataType(int a_dataType)
Set the type of the data (pet, spect, etc)
int GetNbIPatMotionSubsets()
call the eponym function from the oDynamicDataManager object
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 SetMPIRankAndSize(int a_mpiRank, int a_mpiSize)
Set the MPI rank of the MPI instance, and the MPI size (the number of instances)
void SetOptionsOptimizer(const string &a_optionsOptimizer)
Set the optimizer projection options contained in the provided string.
This class is designed to manage the use of dynamic model in the reconstruction.
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 SetNbBeds(int a_nbBeds)
Set number of beds (bed positions)
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...
int GetNbThreadsMax()
Get the maximum between the number of threads used for projections and image operations.
Singleton class that Instantiate and initialize the scanner object.
void SetImageProcessingManager(oImageProcessingManager *ap_ImageProcessingManager)
Set the Image Processing Manager Object.
void SetOptions(vector< string > a_options)
Set the member m_options to the provided value.
void SetOptionsPenalty(const string &a_optionsPenalty)
Set the penalty projection options contained in the provided string.
int CheckParameters()
A function used to check the parameters settings.
Declaration of class sScannerManager.
void SetPathInitImage(string a_pathToInitialImage)
Set path to an initial image.
void SetVoxSizeY(FLTNB a_voxSizeY)
Set the voxel's size along the Y axis, in mm.
Inherit from vDataFile. Class that manages the reading of a SPECT input file (header + data)...
This class is designed to manage the different image convolvers and to apply them.
void SetOffsetX(FLTNB a_offsetX)
Set the image offset along the X axis, in mm.
void SetHeaderDataFileName(const string &a_headerFileName)
set the data header file name
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.
void SetMergeDynImagesFlag(bool a_flag)
Set to on the flag indicating that a dynamic serie of 3D images should be written on disk in one file...
void SetPathToAttenuationImage(string a_pathToAttenuationImage)
This function is used to set the path to the attenuation image.
void SetMPIRank(int a_mpiRank)
Initialize the machine index for MPI.
void SetVerbose(int a_verboseLevel)
Set the verbose level.
void SetTimeBasisFunctionsFile(const string &a_timeBasisFunctionsFile)
Set the file name containing the time basis functions coefficients.
void SetDataFile(vDataFile **a2p_DataFile)
This function is used to set the pointer to the vDataFile array in use.
void SetDataFile(vDataFile *ap_DataFile)
Set a data file in use to later recover some information from it.
void ShowHelpMiscellaneous()
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
set the pointer to the oImageDimensionsAndQuantification object
int main(int argc, char **argv)
void ShowHelpProjector()
Show help about all implemented projectors.
#define KEYWORD_MANDATORY
int CheckParameters()
A function used to check the parameters settings.
static void ShowCommonHelp()
This function does not take any parameter and is used to display some help about the syntax of the op...
void SetImageSpace(oImageSpace *ap_ImageSpace)
This function is used to set the pointer to the oImageSpace in use.
void ShowHelpComputation()
int CheckParameters()
This function is used to check parameters after the latter have been all set using Set functions...
Singleton class that generate a thread-safe random generator number for openMP As singleton...
int Initialize()
Initialization : .
Declaration of class sRandomNumberGenerator.
void SetNbTOFBins(int a_nbTOFBins)
Set the number of TOF bins in use.
void SetScanner(vScanner *ap_Scanner)
This function is used to set the pointer to the vScanner in use.
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.
int CheckDynamicParameters(int64_t a_nbEvents)
Call the eponym function from the oDynamicDataManager object in order to check its parameters...
void SetVerbose(int a_verboseLevel)
set verbosity
Declaration of class oSensitivityGenerator.
This class is designed to manage the different image processing modules and to apply them...
This class is designed to manage the projection part of the reconstruction.
int GetNbTOFBins()
Get the number of TOF bins associated to the projector.
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...
void SetImageSpace(oImageSpace *ap_ImageSpace)
Set the Image Space Object.
void SetImageConvolverManager(oImageConvolverManager *ap_ImageConvolverManager)
Set the Image Convolver Manager Object.
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.
int CheckParameters()
A public function used to check the parameters settings.
This class is designed to manage all dimensions and quantification related stuff. ...
void SetNbBeds(int a_nbBeds)
Set the number of bed positions.
void SetNbCardBasisFunctions(int a_nbCardBasisFunctions)
Set the number of cardiac basis functions.
This file is used for all kind of different functions designed for options parsing and ASCII file rea...
void SetProjectorManager(oProjectorManager *ap_ProjectorManager)
This function is used to set the pointer to the oProjectorManager in use.
void SetImageDimensionsAndQuantification(oImageDimensionsAndQuantification *ap_ImageDimensionsAndQuantification)
This function is used to set the pointer to the oImageDimensionsAndQuantification in use...
void ShowHelpDimensions()
Display command line options related to image dimensions for castor-recon.
void SetGPUflag(bool a_flagGPU)
This function is used to set the GPU flag; do we use GPU or not.
int GetGeometricInfoFromDatafile(string a_pathToDataFilename)
Call the specialized function of the scanner object in order to get geometric informations from the d...
void SetVerbose(int a_verboseLevel)
Set the member m_verboseLevel to the provided value.
void SetVerbose(int a_verboseLevel)
set verbosity
int CheckSPECTAttenuationCompatibility(const string &a_pathToAttenuationImage)
A function used to check specific compatibility with SPECT and attenuation correction.
void SetCardBasisFunctionsFile(const string &a_cardBasisFunctionsFile)
Set the file name containing the cardiac basis functions coefficients.
void SetScanner(vScanner *ap_Scanner)
Set the scanner in use.
void ShowHelpAlgo()
Display command line options related to the Optimization algorithm module for castor-recon.
void ShowHelpOptimizer()
Show help about all implemented optimizers.
void SetOptimizerManager(oOptimizerManager *ap_OptimizerManager)
Set the Optimizer Manager Object.
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 SetDataFile(vDataFile **a2p_DataFile)
Set the list of DataFile.
void SetDynamicModelManager(oDynamicModelManager *ap_DynamicModelManager)
Set the Dynamic Model Manager Object.
This class is designed to manage the computation of the sensitivity image.
void CheckNumberOfProjectionThreadsConsistencyWithDatafileSize(vDataFile **a2p_Datafile)
Declaration of class sAddonManager.
void GetUserEndianness()
Check user/host computer endianness and write it to the global variable User_Endianness.
int SetFlipOut(const string &a_flipOut)
Set the output flip options, the parameter being a string potentially containing the letters x...
int Initialize()
A function used to initialize the manager and all image convolvers it manages.
int SetDynamicSpecificQuantificationFactors(const string &a_quantificationFile)
Apply specific quantification factors manually provided as an option.
void ShowHelpCorrection()
Display command line options related to correction settings for castor-recon.
void ShowHelpImageConvolver()
Show help about all implemented image convolvers.
void SetOptimizerFOMFlag(bool a_optimizerFOMFlag)
Set the optimizer FOM flag that specifies if some figures-of-merit (FOM) will be computed in the data...