60 connect(mParameters.get(), SIGNAL(elastixParametersChanged()),
this, SIGNAL(
elastixChanged()));
64 "Display messages from the running registration process in CustusX",
70 "Disable rendering while running process.\n" 71 "Can be used to avoid clash in GPU usage.",
76 connect(mExecuter.get(), SIGNAL(finished()),
this, SLOT(executionFinishedSlot()));
77 connect(mExecuter.get(), SIGNAL(aboutToStart()),
this, SLOT(preprocessExecuter()));
89 void ElastixManager::preprocessExecuter()
91 QStringList parameterFiles = mParameters->getActiveParameterFiles();
93 QDir outDir(mServices->patient()->getActivePatientFolder()+
"/"+mParameters->getConfigUid()+
"/"+timestamp);
95 mExecuter->setDisplayProcessMessages(mDisplayProcessMessages->getValue());
96 mExecuter->setInput(mParameters->getActiveExecutable()->getEmbeddedPath().getAbsoluteFilepath(),
97 mServices->registration()->getFixedData(),
98 mServices->registration()->getMovingData(),
99 outDir.absolutePath(),
102 if (mDisableRendering->getValue())
104 mServices->view()->enableRender(
false);
108 void ElastixManager::executionFinishedSlot()
110 if (mDisableRendering->getValue())
111 mServices->view()->enableRender(
true);
114 Transform3D mMf = mExecuter->getAffineResult_mMf(&ok);
121 QStringList parameterFiles = mParameters->getActiveParameterFiles();
122 QString desc = QString(
"Image2Image [exe=%1]").arg(QFileInfo(mParameters->getActiveExecutable()->getValue()).fileName());
123 for (
unsigned i=0; i<parameterFiles.size(); ++i)
124 desc += QString(
"[par=%1]").arg(QFileInfo(parameterFiles[i]).fileName());
134 mServices->registration()->getFixedData()->get_rMd()
136 * mServices->registration()->getMovingData()->get_rMd().inv();
142 mServices->registration()->addImage2ImageRegistration(delta_pre_rMd, desc);
145 this->addNonlinearData();
152 void ElastixManager::addNonlinearData()
155 QString nonlinearVolumeFilename = mExecuter->getNonlinearResultVolume(&ok);
160 ImagePtr movingImage = boost::dynamic_pointer_cast<
Image>(mServices->registration()->getMovingData());
165 report(QString(
"Failed to import nonlinear volume %1").arg(nonlinearVolumeFilename));
169 QString uid = movingImage->getUid() +
"_nl%1";
170 QString name = movingImage->getName()+
" nl%1";
174 raw->getBaseVtkImageData(), movingImage);
177 nlVolume->get_rMd_History()->setRegistration(mServices->registration()->getFixedData()->get_rMd());
179 mServices->patient()->insertData(nlVolume);
181 report(QString(
"Added volume %1, created by a nonlinear transform").arg(nlVolume->getName()));
cxResource_EXPORT ProfilePtr profile()
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
static QString getConfigUid()
ElastixManager(RegServicesPtr services)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class Image > ImagePtr
Parameter and preset handling for the ElastiX registration.
QString timestampSecondsFormat()
QDomElement getElement()
return the current element
ImagePtr createDerivedImage(PatientModelServicePtr dataManager, QString uid, QString name, vtkImageDataPtr raw, ImagePtr parent)
ElastiX command-line wrapper.
boost::shared_ptr< class RegServices > RegServicesPtr
virtual ~ElastixManager()
Namespace for all CustusX production code.