3 # File : itkSTMS_ArgumentsAnalysis.hxx
4 # ( C++ header file - STMS )
6 # Description : STMS lib that implements the STMS filter and clustering.
7 # This file is a part of the STMS Library project.
8 # ( https://www.creatis.insa-lyon.fr/site7/fr/realisations )
10 # [1] S. Mure, Grenier, T., Meier, S., Guttmann, R. G., et Benoit-Cattin, H.,
11 # « Unsupervised spatio-temporal filtering of image sequences. A mean-shift specification »,
12 # Pattern Recognition Letters, vol. 68, Part 1, p. 48 - 55, 2015.
14 # Copyright : Thomas GRENIER - Simon MURE
15 # ( https://www.creatis.insa-lyon.fr/~grenier/ )
18 # ( http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.txt )
20 # This software is governed by the CeCILL license under French law and
21 # abiding by the rules of distribution of free software. You can use,
22 # modify and/ or redistribute the software under the terms of the CeCILL
23 # license as circulated by CEA, CNRS and INRIA at the following URL
24 # "http://www.cecill.info".
26 # As a counterpart to the access to the source code and rights to copy,
27 # modify and redistribute granted by the license, users are provided only
28 # with a limited warranty and the software's author, the holder of the
29 # economic rights, and the successive licensors have only limited
32 # In this respect, the user's attention is drawn to the risks associated
33 # with loading, using, modifying and/or developing or reproducing the
34 # software by the user in light of its specific status of free software,
35 # that may mean that it is complicated to manipulate, and that also
36 # therefore means that it is reserved for developers and experienced
37 # professionals having in-depth computer knowledge. Users are therefore
38 # encouraged to load and test the software's suitability as regards their
39 # requirements in conditions enabling the security of their systems and/or
40 # data to be ensured and, more generally, to use and operate it in the
41 # same conditions as regards security.
43 # The fact that you are presently reading this means that you have had
44 # knowledge of the CeCILL license and that you accept its terms.
47 /* Please don't forget to cite our work :
49 title = {Unsupervised spatio-temporal filtering of image sequences. A mean-shift specification},
50 journal = {Pattern Recognition Letters},
51 volume = {68, Part 1},
55 doi = {http://dx.doi.org/10.1016/j.patrec.2015.07.021},
56 url = {http://www.sciencedirect.com/science/article/pii/S0167865515002305},
57 author = {S. Mure and T Grenier and Meier, S. and Guttmann, R.G. and H. Benoit-Cattin}
60 #ifndef itkSTMS_ArgumentsAnalysis_HXX
61 #define itkSTMS_ArgumentsAnalysis_HXX
65 #include "itkSTMS_ArgumentsAnalysis.h"
69 itkSTMS_ArgumentsAnalysis::itkSTMS_ArgumentsAnalysis(int argc, char **argv)
71 readParams.expDescription = "";
72 readParams.numTimePoints = 0;
73 readParams.startTimePoint = 1;
74 readParams.epsilon = 0.01;
75 readParams.maxIt = 100 ;
76 readParams.spScales[0] = 1.0;
77 readParams.spScales[1] = 1.0;
78 readParams.spScales[2] = 1.0;
79 readParams.rScale = 1.0;
81 readParams.merge = false;
83 readParams.isOk = false;
89 void itkSTMS_ArgumentsAnalysis::ParametersDisplay()
91 std::cout << std::endl <<
92 std::setw(29) << std::left << "Experiment description" << ": " << readParams.expDescription << std::endl;
93 std::cout << std::setw(29) << std::left << "Image dimension" << ": " << readParams.dim << std::endl;
94 std::cout << std::setw(29) << std::left << "Number of time-points" << ": " << readParams.numTimePoints << std::endl;
95 std::cout << std::setw(29) << std::left << "Staring time point" << ": " << readParams.startTimePoint << std::endl;
96 std::cout << std::setw(29) << std::left << "X scale" << ": " << readParams.spScales[0] << std::endl;
97 std::cout << std::setw(29) << std::left << "Y scale" << ": " << readParams.spScales[1] << std::endl;
98 std::cout << std::setw(29) << std::left << "Z scale" << ": " << readParams.spScales[2] << std::endl;
99 std::cout << std::setw(29) << std::left << "Range scale" << ": " << readParams.rScale << std::endl;
100 std::cout << std::setw(29) << std::left << "Epsilon" << ": " << readParams.epsilon << std::endl;
101 std::cout << std::setw(29) << std::left << "Maximum number of iterations" << ": " << readParams.maxIt << std::endl;
102 std::cout << std::setw(29) << std::left << "Samples merging" << ": " << readParams.merge << std::endl << std::endl;
105 void itkSTMS_ArgumentsAnalysis::ParametersAnalysisInfo()
107 std::cout << std::endl <<
108 std::setw(17) << std::left << "--expDescription" << ": Path to the XML file used to generate the image sequence." << std::endl;
109 std::cout << std::setw(17) << std::left << "--imageDimension" << ": Number of spatial components. (Default 3)" << std::endl;
110 std::cout << std::setw(17) << std::left << "--numTimePoints" << ": Number of time-points." << std::endl;
111 std::cout << std::setw(17) << std::left << "--startTimePoint" << ": Starting time point (default is 0)" << std::endl;
112 std::cout << std::setw(17) << std::left << "--xScale" << ": Spatial scale used for the x axis. (Default 1.0)" << std::endl;
113 std::cout << std::setw(17) << std::left << "--yScale" << ": Spatial scale used for the z axis. (Default 1.0)" << std::endl;
114 std::cout << std::setw(17) << std::left << "--zScale" << ": Spatial scale used for the z axis. Optional when using 2D images. (Default 1.0)" << std::endl;
115 std::cout << std::setw(17) << std::left << "--rScale" << ": Range scale used to set the tolerance on the infinity norm. (Default 1.0)" << std::endl;
116 std::cout << std::setw(17) << std::left << "--epsilon" << ": Stopping criteria of the STM-S procedure. Minimum global displacement of the samples. (Default 0.01)" << std::endl;
117 std::cout << std::setw(17) << std::left << "--maxIt" << ": Maximum number of iterations of the STM-S procedure. (Default 100)" << std::endl << std::endl;
118 std::cout << std::setw(17) << std::left << "--merge" << ": Specify if the samples are merged during the STMS procedure. No merging by default, no argument is needed after --merge." << std::endl << std::endl;
119 std::cout << std::setw(17) << std::left << "--help" << ": Usage help" << std::endl << std::endl;
123 void itkSTMS_ArgumentsAnalysis::CheckProvidedParameters(){
125 if( readParams.expDescription != "")
126 readParams.isOk = true;
129 void itkSTMS_ArgumentsAnalysis::Update()
132 bool first_it = true;
135 /* getopt_long stores the option index here. */
136 int option_index = 0;
138 c = getopt_long (argc, argv, "d:i::n:x::y::z::r::e::m::g::h::s::",
139 long_options, &option_index);
146 readParams.expDescription = std::string(optarg);
150 str = std::string(optarg);
151 readParams.dim = (unsigned int)std::stoi( str );
155 str = std::string(optarg);
156 readParams.numTimePoints = (unsigned int)std::stoi( str );
160 str = std::string(optarg);
161 readParams.startTimePoint = (unsigned int)std::stoi( str );
165 str = std::string(optarg);
166 readParams.spScales[0] = std::stof( str );
170 str = std::string(optarg);
171 readParams.spScales[1] = std::stof( str );
175 str = std::string(optarg);
176 readParams.spScales[2] = std::stof( str );
180 str = std::string(optarg);
181 readParams.rScale = std::stof( str );
185 str = std::string(optarg);
186 readParams.epsilon = std::stof( str );
190 str = std::string(optarg);
191 readParams.maxIt = (unsigned int)std::stoi( str );
195 readParams.merge = true;
199 std::cout << std::endl << "Usage help:";
200 ParametersAnalysisInfo();
201 std::exit( EXIT_SUCCESS );
205 std::cout << std::endl << "Usage help:";
206 ParametersAnalysisInfo();
207 std::exit( EXIT_FAILURE );
211 if( (c==-1) & first_it )
213 std::cout << std::endl << "Usage help:";
214 ParametersAnalysisInfo();
215 std::exit( EXIT_SUCCESS );
220 /* Detect the end of the options. */
221 if ( (c==-1) & !first_it )
227 CheckProvidedParameters();
228 if( readParams.isOk )
234 std::cout << std::endl << "All required parameters are not provided";
235 ParametersAnalysisInfo();
236 std::exit( EXIT_FAILURE );
240 } // end of namespace itkSTMS
241 #endif // itkSTMS_ArgumentsAnalysis_HXX