15 #include <boost/bind.hpp> 16 #include <ctkPluginContext.h> 35 #define M_PI 3.14159265358979323846 43 mPatientModelService(patientModelService),
44 mViewService(viewService),
45 mFileManagerService(filemanagerservice)
51 connect(mParams.get(), SIGNAL(changedInputSettings()),
this, SLOT(setSettings()));
56 boost::bind(&UsReconstructionImplService::onServiceAdded,
this, _1),
57 boost::bind(&UsReconstructionImplService::onServiceModified,
this, _1),
58 boost::bind(&UsReconstructionImplService::onServiceRemoved,
this, _1)
61 mServiceListener->open();
73 void UsReconstructionImplService::patientChangedSlot()
75 this->
selectData(mPatientModelService->getActivePatientFolder() +
"/US_Acq/");
81 QString name = mParams->getParameter(
"Algorithm")->getValueAsVariant().toString();
84 return mServiceListener->getServiceFromName(name);
87 void UsReconstructionImplService::setSettings()
90 this->updateFromOriginalFileData();
97 if(!mOutputVolumeParams.
isValid())
99 reportError(
"Cannot reconstruct from invalid ultrasound data");
111 connect(executer.get(), SIGNAL(
reconstructFinished()),
this, SLOT(reconstructFinishedSlot()));
112 mExecuters.push_back(executer);
114 bool success = executer->startReconstruction(algo, par, fileData, mParams->getCreateBModeWhenAngio()->getValue());
116 CX_LOG_WARNING() <<
"US reconstruction failed. Probably an error with input data.";
121 std::set<cx::TimedAlgorithmPtr> retval;
122 for (
unsigned i=0; i<mExecuters.size(); ++i)
123 retval.insert(mExecuters[i]->getThread());
127 void UsReconstructionImplService::reconstructFinishedSlot()
129 mOriginalFileData.
mUsRaw->purgeAll();
131 for (
unsigned i=0; i<mExecuters.size(); ++i)
133 if (mExecuters[i]->getThread()->isFinished())
139 disconnect(executer.get(), SIGNAL(
reconstructFinished()),
this, SLOT(reconstructFinishedSlot()));
141 mExecuters.erase(mExecuters.begin()+i);
147 void UsReconstructionImplService::clearAll()
155 return mOutputVolumeParams;
160 mOutputVolumeParams = par;
166 if (mAlgoOptions.empty())
191 return mOriginalFileData;
196 return mParams->getParameter(uid);
201 if (filename.isEmpty())
212 CX_LOG_WARNING() <<
"UsReconstructionImplService::selectData: Invalid input data";
221 mOriginalFileData = fileData;
222 this->updateFromOriginalFileData();
226 void UsReconstructionImplService::updateFromOriginalFileData()
228 if (mFileManagerService->isNull() || !mOriginalFileData.
isValid())
234 if (preprocessor->getOutputVolumeParams().isValid())
235 mOutputVolumeParams = preprocessor->getOutputVolumeParams();
238 reportError(
"Input ultrasound data not valid for reconstruction");
248 par.
mAlgorithmUid = mParams->getAlgorithmAdapter()->getValue();
251 par.
mAngio = mParams->getAngioAdapter()->getValue();
258 par.
mMaskReduce = mParams->getMaskReduce()->getValue().toDouble();
259 par.
mOrientation = mParams->getOrientationAdapter()->getValue();
265 QStringList range = mParams->getAlgorithmAdapter()->getValueRange();
267 mParams->getAlgorithmAdapter()->setValueRange(range);
270 PropertyPtr algoName = mParams->getParameter(
"Algorithm");
271 if (algoName->getValueAsVariant().value<QString>().isEmpty())
272 algoName->setValueFromVariant(service->
getName());
277 reportWarning(
"ReconstructionMethodService modified... Do not know what to do. Contact developer.");
282 QStringList range = mParams->getAlgorithmAdapter()->getValueRange();
283 range.removeAll(service->
getName());
284 mParams->getAlgorithmAdapter()->setValueRange(range);
286 QString algoname = mParams->getParameter(
"Algorithm")->getValueAsVariant().toString();
287 if (algoname==service->
getName())
void newInputDataAvailable(QString mhdFileName)
boost::shared_ptr< class FileManagerService > FileManagerServicePtr
Reader class for the US Acquisition files.
void inputDataSelected(QString mhdFileName)
boost::shared_ptr< class ReconstructionExecuter > ReconstructionExecuterPtr
UsReconstructionImplService(ctkPluginContext *pluginContext, PatientModelServicePtr patientModelService, ViewServicePtr viewService, FileManagerServicePtr filemanagerservice, XmlOptionFile settings)
void reportError(QString msg)
virtual ~UsReconstructionImplService()
virtual PropertyPtr getParam(QString uid)
Return one of the standard parameters.
Abstract interface for reconstruction algorithm.
virtual QString getSelectedFilename() const
Get the currently selected filename.
virtual std::set< cx::TimedAlgorithmPtr > getThreadedReconstruction()
Return the currently reconstructing thread object(s).
void reconstructFinished()
virtual void selectData(QString filename, QString calFilesPath="")
Set input data for reconstruction.
virtual void newDataOnDisk(QString mhdFilename)
Helper struct for sending and controlling output volume properties.
QDomElement getElement()
return the current element
virtual std::vector< PropertyPtr > getSettings(QDomElement root)=0
virtual std::vector< PropertyPtr > getAlgoOptions()
Return control parameters for the currently selected algorithm, adjustable like getParams() ...
boost::shared_ptr< class UsReconstructionFileReader > UsReconstructionFileReaderPtr
boost::shared_ptr< class Property > PropertyPtr
void reportWarning(QString msg)
Collection of reconstruction parameters.
boost::shared_ptr< class ReconstructPreprocessor > ReconstructPreprocessorPtr
virtual QString getName() const =0
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
void reconstructStarted()
Settings * settings()
Shortcut for accessing the settings instance.
Algorithm part of reconstruction - no dependencies on parameter classes.
virtual void setOutputVolumeParams(const OutputVolumeParams &par)
Control the output volume.
void reconstructAboutToStart()
Helper class for listening to services being added, modified and removed.
virtual OutputVolumeParams getOutputVolumeParams() const
Return params controlling the output data. These are data-dependent.
virtual XmlOptionFile getSettings()
Return the settings xml file where parameters are stored.
virtual USReconstructInputData getSelectedFileData()
Return the currently selected input data.
void newInputDataPath(QString path)
virtual ReconstructionMethodService * createAlgorithm()
virtual void startReconstruction()
virtual ReconstructCore::InputParams createCoreParameters()
Helper class for xml files used to store ssc/cx data.
Namespace for all CustusX production code.