36 #include <boost/bind.hpp>
37 #include <ctkPluginContext.h>
55 #define M_PI 3.14159265358979323846
63 mPatientModelService(patientModelService),
64 mVisualizationService(visualizationService)
70 connect(mParams.get(), SIGNAL(changedInputSettings()),
this, SLOT(setSettings()));
75 boost::bind(&UsReconstructionImplService::onServiceAdded,
this, _1),
76 boost::bind(&UsReconstructionImplService::onServiceModified,
this, _1),
77 boost::bind(&UsReconstructionImplService::onServiceRemoved,
this, _1)
80 mServiceListener->open();
92 void UsReconstructionImplService::patientChangedSlot()
94 this->
selectData(mPatientModelService->getActivePatientFolder() +
"/US_Acq/");
100 QString name = mParams->getParameter(
"Algorithm")->getValueAsVariant().toString();
103 return mServiceListener->getService(name);
106 void UsReconstructionImplService::setSettings()
108 mAlgoOptions.clear();
109 this->updateFromOriginalFileData();
116 if(!mOutputVolumeParams.
isValid())
118 reportError(
"Cannot reconstruct from invalid ultrasound data");
130 connect(executer.get(), SIGNAL(
reconstructFinished()),
this, SLOT(reconstructFinishedSlot()));
131 mExecuters.push_back(executer);
133 executer->startReconstruction(algo, par, fileData, mParams->getCreateBModeWhenAngio()->getValue());
138 std::set<cx::TimedAlgorithmPtr> retval;
139 for (
unsigned i=0; i<mExecuters.size(); ++i)
140 retval.insert(mExecuters[i]->getThread());
144 void UsReconstructionImplService::reconstructFinishedSlot()
146 mOriginalFileData.
mUsRaw->purgeAll();
148 std::set<cx::TimedAlgorithmPtr> retval;
149 for (
unsigned i=0; i<mExecuters.size(); ++i)
151 if (mExecuters[i]->getThread()->isFinished())
157 disconnect(executer.get(), SIGNAL(
reconstructFinished()),
this, SLOT(reconstructFinishedSlot()));
159 mExecuters.erase(mExecuters.begin()+i);
165 void UsReconstructionImplService::clearAll()
167 mOriginalFileData = USReconstructInputData();
168 mOutputVolumeParams = OutputVolumeParams();
173 return mOutputVolumeParams;
178 mOutputVolumeParams = par;
184 if (mAlgoOptions.empty())
209 return mOriginalFileData;
214 return mParams->getParameter(uid);
219 if (filename.isEmpty())
234 mOriginalFileData = fileData;
235 this->updateFromOriginalFileData();
239 void UsReconstructionImplService::updateFromOriginalFileData()
241 if (!mOriginalFileData.
isValid())
247 if (preprocessor->getOutputVolumeParams().isValid())
248 mOutputVolumeParams = preprocessor->getOutputVolumeParams();
251 reportError(
"Input ultrasound data not valid for reconstruction");
261 par.
mAlgorithmUid = mParams->getAlgorithmAdapter()->getValue();
264 par.
mAngio = mParams->getAngioAdapter()->getValue();
269 par.
mMaskReduce = mParams->getMaskReduce()->getValue().toDouble();
270 par.
mOrientation = mParams->getOrientationAdapter()->getValue();
276 QStringList range = mParams->getAlgorithmAdapter()->getValueRange();
278 mParams->getAlgorithmAdapter()->setValueRange(range);
281 PropertyPtr algoName = mParams->getParameter(
"Algorithm");
282 if (algoName->getValueAsVariant().value<QString>().isEmpty())
283 algoName->setValueFromVariant(service->
getName());
286 void UsReconstructionImplService::onServiceModified(ReconstructionMethodService* service)
288 reportWarning(
"ReconstructionMethodService modified... Do not know what to do. Contact developer.");
291 void UsReconstructionImplService::onServiceRemoved(ReconstructionMethodService* service)
293 QStringList range = mParams->getAlgorithmAdapter()->getValueRange();
294 range.removeAll(service->getName());
295 mParams->getAlgorithmAdapter()->setValueRange(range);
297 QString algoname = mParams->getParameter(
"Algorithm")->getValueAsVariant().toString();
298 if (algoname==service->getName())
void newInputDataAvailable(QString mhdFileName)
Reader class for the US Acquisition files.
void inputDataSelected(QString mhdFileName)
boost::shared_ptr< class ReconstructionExecuter > ReconstructionExecuterPtr
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).
UsReconstructionImplService(ctkPluginContext *pluginContext, PatientModelServicePtr patientModelService, VisualizationServicePtr visualizationService, XmlOptionFile settings)
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.