40 connect(mParameters.get(), SIGNAL(elastixParametersChanged()),
this, SIGNAL(
elastixChanged()));
44 "Display messages from the running registration process in CustusX",
50 "Disable rendering while running process.\n"
51 "Can be used to avoid clash in GPU usage.",
56 connect(mExecuter.get(), SIGNAL(finished()),
this, SLOT(executionFinishedSlot()));
57 connect(mExecuter.get(), SIGNAL(aboutToStart()),
this, SLOT(preprocessExecuter()));
69 void ElastixManager::preprocessExecuter()
71 QStringList parameterFiles = mParameters->getActiveParameterFiles();
73 QDir outDir(mServices->patient()->getActivePatientFolder()+
"/"+mParameters->getConfigUid()+
"/"+timestamp);
75 mExecuter->setDisplayProcessMessages(mDisplayProcessMessages->getValue());
76 mExecuter->setInput(mParameters->getActiveExecutable()->getEmbeddedPath().getAbsoluteFilepath(),
77 mServices->registration()->getFixedData(),
78 mServices->registration()->getMovingData(),
79 outDir.absolutePath(),
82 if (mDisableRendering->getValue())
84 mServices->view()->enableRender(
false);
88 void ElastixManager::executionFinishedSlot()
90 if (mDisableRendering->getValue())
91 mServices->view()->enableRender(
true);
94 Transform3D mMf = mExecuter->getAffineResult_mMf(&ok);
101 QStringList parameterFiles = mParameters->getActiveParameterFiles();
102 QString desc = QString(
"Image2Image [exe=%1]").arg(QFileInfo(mParameters->getActiveExecutable()->getValue()).fileName());
103 for (
unsigned i=0; i<parameterFiles.size(); ++i)
104 desc += QString(
"[par=%1]").arg(QFileInfo(parameterFiles[i]).fileName());
114 mServices->registration()->getFixedData()->get_rMd()
116 * mServices->registration()->getMovingData()->get_rMd().inv();
122 mServices->registration()->addImage2ImageRegistration(delta_pre_rMd, desc);
125 this->addNonlinearData();
132 void ElastixManager::addNonlinearData()
135 QString nonlinearVolumeFilename = mExecuter->getNonlinearResultVolume(&ok);
140 ImagePtr movingImage = boost::dynamic_pointer_cast<Image>(mServices->registration()->getMovingData());
141 ImagePtr raw = boost::dynamic_pointer_cast<Image>(mServices->file()->load(nonlinearVolumeFilename, nonlinearVolumeFilename));
145 report(QString(
"Failed to import nonlinear volume %1").arg(nonlinearVolumeFilename));
149 QString uid = movingImage->getUid() +
"_nl%1";
150 QString name = movingImage->getName()+
" nl%1";
154 raw->getBaseVtkImageData(), movingImage);
157 nlVolume->get_rMd_History()->setRegistration(mServices->registration()->getFixedData()->get_rMd());
159 mServices->patient()->insertData(nlVolume);
161 report(QString(
"Added volume %1, created by a nonlinear transform").arg(nlVolume->getName()));