3 # File : itkSTMS_ArgumentsAnalysis_Spine.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_ArgumentsAnalysisSpine_HXX
61 #define itkSTMS_ArgumentsAnalysisSpine_HXX
66 #include "itkSTMS_ArgumentsAnalysis_Spine.h"
68 namespace itkSTMS_Spine
70 itkSTMS_ArgumentsAnalysis::itkSTMS_ArgumentsAnalysis(int argc, char **argv)
72 readParams.numTimePoints = 0;
73 readParams.epsilon = 0.01;
74 readParams.maxIt = 100 ;
75 readParams.spScales[0] = 1.0;
76 readParams.spScales[1] = 1.0;
77 readParams.spScales[2] = 1.0;
78 readParams.rScale = 1.0;
80 readParams.merge = false;
83 readParams.outFolder = "";
84 readParams.isOk = false;
85 readParams.imageExtension = ".nii.gz";
91 void itkSTMS_ArgumentsAnalysis::ParametersDisplay()
93 std::cout << std::endl <<
94 std::setw(29) << std::left << "Image dimension" << ": " << readParams.dim << std::endl;
95 std::cout << std::setw(29) << std::left << "Mask image" << ": " << readParams.mask << std::endl;
96 std::cout << std::setw(29) << std::left << "Output folder" << ": " << readParams.outFolder << std::endl;
97 std::cout << std::setw(29) << std::left << "Nb of time-points" << ": " << readParams.numTimePoints << std::endl;
98 std::cout << std::setw(29) << std::left << "X scale" << ": " << readParams.spScales[0] << std::endl;
99 std::cout << std::setw(29) << std::left << "Y scale" << ": " << readParams.spScales[1] << std::endl;
100 std::cout << std::setw(29) << std::left << "Z scale" << ": " << readParams.spScales[2] << std::endl;
101 std::cout << std::setw(29) << std::left << "Range scale" << ": " << readParams.rScale << std::endl;
102 std::cout << std::setw(29) << std::left << "Epsilon" << ": " << readParams.epsilon << std::endl;
103 std::cout << std::setw(29) << std::left << "Maximum number of iterations" << ": " << readParams.maxIt << std::endl;
104 std::cout << std::setw(29) << std::left << "Images extension" << ": " << readParams.imageExtension << std::endl;
105 std::cout << std::setw(29) << std::left << "Samples merging" << ": " << readParams.merge << std::endl << std::endl;
108 void itkSTMS_ArgumentsAnalysis::ParametersAnalysisInfo()
110 std::cout << std::endl <<
111 std::setw(17) << std::left << "--image " << ": Path to an image of the sequence." << std::endl;
112 std::cout << std::setw(17) << std::left << "--mask" << ": Binary mask image (optional)" << std::endl;
113 std::cout << std::setw(17) << std::left << "--outFolder" << ": Output images folder" << std::endl;
114 std::cout << std::setw(17) << std::left << "--imageDimension" << ": Number of spatial components. (Default 3)" << std::endl;
115 std::cout << std::setw(17) << std::left << "--imageExtension" << ": Extension of the images. (Default .nii.gz)" << std::endl;
116 std::cout << std::setw(17) << std::left << "--xScale" << ": Spatial scale used for the x axis. (Default 1.0)" << std::endl;
117 std::cout << std::setw(17) << std::left << "--yScale" << ": Spatial scale used for the z axis. (Default 1.0)" << std::endl;
118 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;
119 std::cout << std::setw(17) << std::left << "--rScale" << ": Range scale used to set the tolerance on the infinity norm. (Default 1.0)" << std::endl;
120 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;
121 std::cout << std::setw(17) << std::left << "--maxIt" << ": Maximum number of iterations of the STM-S procedure. (Default 100)" << std::endl << std::endl;
122 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;
123 std::cout << std::setw(17) << std::left << "--help" << ": Usage help" << std::endl << std::endl;
127 void itkSTMS_ArgumentsAnalysis::CheckProvidedParameters(){
129 if( !readParams.images.empty() & !readParams.outFolder.empty())
130 readParams.isOk = true;
133 void itkSTMS_ArgumentsAnalysis::Update()
136 bool first_it = true;
139 /* getopt_long stores the option index here. */
140 int option_index = 0;
142 c = getopt_long (argc, argv, "d:l::o:i::x::y::z::r::e::m::g::h::q::",
143 long_options, &option_index);
150 readParams.images.push_back( std::string(optarg) );
154 readParams.imageExtension = std::string(optarg);
158 readParams.mask = std::string(optarg);
162 readParams.outFolder = std::string(optarg);
166 str = std::string(optarg);
167 readParams.dim = (unsigned int)std::stoi( str );
171 str = std::string(optarg);
172 readParams.spScales[0] = std::stof( str );
176 str = std::string(optarg);
177 readParams.spScales[1] = std::stof( str );
181 str = std::string(optarg);
182 readParams.spScales[2] = std::stof( str );
186 str = std::string(optarg);
187 readParams.rScale = std::stof( str );
191 str = std::string(optarg);
192 readParams.epsilon = std::stof( str );
196 str = std::string(optarg);
197 readParams.maxIt = (unsigned int)std::stoi( str );
201 readParams.merge = true;
205 std::cout << std::endl << "Usage help:";
206 ParametersAnalysisInfo();
207 std::exit( EXIT_SUCCESS );
211 std::cout << std::endl << "Usage help:";
212 ParametersAnalysisInfo();
213 std::exit( EXIT_FAILURE );
217 if( (c==-1) & first_it )
219 std::cout << std::endl << "Usage help:";
220 ParametersAnalysisInfo();
221 std::exit( EXIT_SUCCESS );
226 /* Detect the end of the options. */
227 if ( (c==-1) & !first_it )
233 CheckProvidedParameters();
234 if( readParams.isOk )
236 readParams.numTimePoints = (unsigned int)readParams.images.size();
241 std::cout << std::endl << "All required parameters are not provided";
242 ParametersAnalysisInfo();
243 std::exit( EXIT_FAILURE );
247 } // end of namespace itkSTMS
248 #endif // itkSTMS_ArgumentsAnalysisSpine_HXX