Computer Assisted Medical Intervention Tool Kit version 6.0
 
Loading...
Searching...
No Matches
SimpleElastixRegistrationAction.h
Go to the documentation of this file.
1/*****************************************************************************
2 * $CAMITK_LICENCE_BEGIN$
3 *
4 * CamiTK - Computer Assisted Medical Intervention ToolKit
5 * (c) 2001-2025 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
6 *
7 * Visit http://camitk.imag.fr for more information
8 *
9 * This file is part of CamiTK.
10 *
11 * CamiTK is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
14 *
15 * CamiTK is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22 *
23 * $CAMITK_LICENCE_END$
24 ****************************************************************************/
25#ifndef SIMPLEELASTIXREGISTRATIONACTION_H
26#define SIMPLEELASTIXREGISTRATIONACTION_H
27
28#include <Action.h>
29#include <ImageComponent.h>
30
32
33#include <QDir>
34#include <QFileInfo>
35
44 Q_OBJECT
45
46public:
49
52
54 virtual QWidget* getWidget() override;
55
57 enum TransformationType { TRANSLATION, AFFINE, B_SPLINE };
58 Q_ENUM(TransformationType)
59
60 enum MetricType { ADVANCED_MEAN_SQUARES, ADVANCED_NORMALIZED_CORRELATION, ADVANCED_MATTES_MUTUAL_INFORMATION, NORMALIZED_MUTUAL_INFORMATION };
61 Q_ENUM(MetricType)
62
63
64 virtual bool event(QEvent* e) override;
65
66public slots:
72 virtual camitk::Action::ApplyStatus apply() override;
73
74private:
76// virtual void process();
77
78private:
79 // last run results
80 int lastExitCode;
81 QString lastStdOutput;
82 QString lastProcessError;
83 bool inConstructor; // safeguard for dynamic property change event during construction
84
85 // used to map item id with component for the "Fixed Image" and "Moving Image" combo box properties
86 QList<camitk::ImageComponent*> imageComponentList;
87
88 // update the elastix version property
89 void updateElastixVersion();
90
91 // ask the elastix executable path to the user, return true if the path is correct
92 void defineElastixExecutable();
93
94 // return the current test name using images names and parameter values
95 QString defaultResultName() const;
96
97 // name of the transformation computed by elastix
98 // As the computed transformation deforms the moving image into the fixed image,
99 // the transformation is a transform from moving to fixed, i.e., {}^{fixed} T_{moving}.
100 // The name should therefore be "moving_to_fixed" where "moving" is the moving image
101 // component name and "fixed" is the fixed image component name
102 QString transformName() const;
103
104 // save the given image component to the given path (preserving the filename)
105 // returns the file name without the path if succeed, empty string otherwise
106 QString saveComponentAs(camitk::ImageComponent* comp, QString path) const;
107
108 // create the elastix parameter file from the current properties, return true if the parameter file was created without error
109 bool createParameterFile(QFileInfo parameterFileInfo, QString initialization, QString transformType, QString similarityMetric) const;
110
111 // run elastix with the given parameter in the given directory, return true if elastix exit with code 0
112 bool runElastix(QStringList arguments, QString workingDirectory = "");
113
114 // Copy the resulting image and logs to the moving image file directory
115 // if everything went well returns the new mhd file to open
116 QString copyResults(QString tempDir) const;
117
118 // copy the given oldName file (name without dir) from source directory
119 // to newName file in the destination directory
120 bool copyFile(QString oldName, QDir source, QString newName, QDir destination) const;
121
122 // replace searchString by replacementString in fileName (given as full absolute path)
123 bool replaceInFile(const QString& fileName, const QString& searchString, const QString& replacementString) const;
124};
125#endif // SIMPLEELASTIXREGISTRATIONACTION_H
#define ELASTIX_REGISTRATION_API
Definition ElastixRegistrationAPI.h:8
Definition PersistenceManager.h:30
Perform a registration.
Definition SimpleElastixRegistrationAction.h:43
TransformationType
Possible Transformation.
Definition SimpleElastixRegistrationAction.h:57
@ AFFINE
Definition SimpleElastixRegistrationAction.h:57
MetricType
Definition SimpleElastixRegistrationAction.h:60
@ ADVANCED_MATTES_MUTUAL_INFORMATION
Definition SimpleElastixRegistrationAction.h:60
This class describes what is a generic Action extension.
Definition ActionExtension.h:57
Action class is an abstract class that enables you to build a action (generally an algorithm that wor...
Definition Action.h:215
ApplyStatus
describes what happened during the application of an algorithm (i.e. results of the apply method)
Definition Action.h:231
virtual camitk::Action::ApplyStatus apply()=0
This method is called when the action has to be applied on the target list (get the target lists usin...
virtual QWidget * getWidget()
This method has to be redefined in your Action only if:
Definition Action.cpp:178
The manager of the Image Volume data.
Definition ImageComponent.h:76