CustusX  2023.01.05-dev+develop.0da12
An IGT application
cxGenericScriptFilter.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #include "cxGenericScriptFilter.h"
13 #include <itkSmoothingRecursiveGaussianImageFilter.h>
14 #include <QTimer>
15 #include <QFileInfo>
16 #include <QDir>
17 #include <QDirIterator>
18 #include <QTextStream>
19 
20 #include "cxAlgorithmHelpers.h"
22 #include "cxPatientModelService.h"
23 #include "cxViewService.h"
24 
25 #include "cxUtilHelpers.h"
27 #include "cxStringProperty.h"
28 #include "cxDoubleProperty.h"
29 #include "cxBoolProperty.h"
30 #include "cxTypeConversions.h"
31 #include "cxImage.h"
32 #include "cxContourFilter.h"
33 #include "cxMesh.h"
34 
35 #include "cxPatientModelService.h"
36 #include "cxFileManagerService.h"
37 #include "cxVolumeHelpers.h"
38 #include "cxVisServices.h"
39 #include "cxFilePreviewProperty.h"
40 #include "cxFilePathProperty.h"
41 #include "cxProfile.h"
42 #include "cxLogger.h"
43 
44 namespace cx
45 {
46 
48 {
49  // Parse .ini file
50  QSettings settings(parameterFilePath, QSettings::IniFormat);
51  settings.beginGroup("environment");
52  envPath = settings.value("path").toString();
53  settings.endGroup();
54  settings.beginGroup("script");
55  scriptFilePath = settings.value("path").toString();
56  cArguments = settings.value("arguments").toString();
57  scriptEngine = settings.value("engine").toString();
58  model = settings.value("model").toString();
59  settings.endGroup();
60 }
61 
62 OutputVariables::OutputVariables(QString parameterFilePath)
63 {
64  // Parse .ini file
65  QSettings settings(parameterFilePath, QSettings::IniFormat);
66  settings.beginGroup("output");
67  mCreateOutputVolume = settings.value("volume").toBool();
68  mCreateOutputMesh = settings.value("mesh").toBool();
69  QString allColors = settings.value("color").toString();
70  mOutputColorList = allColors.split(";");
71  QString outputClass = settings.value("classes").toString();
72  mOutputClasses = outputClass.split(" ");
73  settings.endGroup();
74 }
75 
77  FilterImpl(services),
78  mOutputChannelName("ExternalScript"),
79  mScriptPathAddition("/filter_scripts"),
80  mCommandLine(NULL)
81 {
82 }
83 
85 {
86 }
87 
89 {
90  if(!mCommandLine || !mCommandLine->getProcess())
91  {
92  //Seems like this slot may get called after mCommandLine process is deleted
93  //CX_LOG_ERROR() << "GenericScriptFilter::processStateChanged: Process not existing!";
94  return;
95  }
96 
97  QProcess::ProcessState newState = mCommandLine->getProcess()->state();
98  if (newState == QProcess::Running)
99  {
100  CX_LOG_DEBUG() << "GenericScriptFilter process running";
101  //emit started(0);
102  }
103  if (newState == QProcess::NotRunning)
104  {
105  CX_LOG_DEBUG() << "GenericScriptFilter process finished running";
106  //emit finished();
107  }
108  if (newState == QProcess::Starting)
109  {
110  CX_LOG_DEBUG() << "GenericScriptFilter process starting";
111  }
112 }
113 
114 void GenericScriptFilter::processFinished(int code, QProcess::ExitStatus status)
115 {
116  if (status == QProcess::CrashExit)
117  reportError("GenericScriptFilter process crashed");
118 }
119 
120 void GenericScriptFilter::processError(QProcess::ProcessError error)
121 {
122  QString msg;
123  msg += "GenericScriptFilter process reported an error: ";
124 
125  switch (error)
126  {
127  case QProcess::FailedToStart:
128  msg += "Failed to start";
129  break;
130  case QProcess::Crashed:
131  msg += "Crashed";
132  break;
133  case QProcess::Timedout:
134  msg += "Timed out";
135  break;
136  case QProcess::WriteError:
137  msg += "Write Error";
138  break;
139  case QProcess::ReadError:
140  msg += "Read Error";
141  break;
142  case QProcess::UnknownError:
143  msg += "Unknown Error";
144  break;
145  default:
146  msg += "Invalid error";
147  }
148 
149  reportError(msg);
150 }
151 
153 {
154  if(!mCommandLine || !mCommandLine->getProcess())
155  return;
156 
157  QProcess* process = mCommandLine->getProcess();
158  CX_LOG_CHANNEL_INFO(mOutputChannelName) << QString(process->readAllStandardOutput());
159 }
160 
162 {
163  if(!mCommandLine || !mCommandLine->getProcess())
164  return;
165 
166  QProcess* process = mCommandLine->getProcess();
167  CX_LOG_CHANNEL_ERROR(mOutputChannelName) << QString(process->readAllStandardError());
168 }
169 
171 {
172  return "Script";
173 }
174 
176 {
177  return "generic_script_filter";
178 }
179 
181 {
182  return "<html>"
183  "<h3>Script.</h3>"
184  "<p>Support for calling external scripts from Custus"
185  "<p>Uses parameter file... "
186  "....</p>"
187  "</html>";
188 }
189 
191 {
192  QStringList paths;
193  paths << profile()->getPath()+mScriptPathAddition;
194 
195  mScriptFile = FilePathProperty::initialize("scriptSelector",
196  "Select configuration file",
197  "Select configuration file that specifies which script and parameters to use",
198  "",//FilePath
199  paths, //Catalog
200  root);
201  mScriptFile->setGroup("File");
203  return mScriptFile;
204 }
205 
207 {
208  mScriptFile->setValue(path);
209  this->scriptFileChanged();
210 }
211 
213 {
214  QStringList paths;
215  paths << profile()->getPath()+mScriptPathAddition;
216 
217  mScriptFilePreview = FilePreviewProperty::initialize("filename", "Filename",
218  "Select a ini file for running command line script",
219  mScriptFile->getValue(),
220  paths,
221  root);
222 
223  mScriptFilePreview->setGroup("File");
224  this->scriptFileChanged();//Initialize with data from mScriptFile variable
225  return mScriptFilePreview;
226 }
227 
229 {
230  mOptionsAdapters.push_back(this->getParameterFile(mOptions));
231  mOptionsAdapters.push_back(this->getIniFileOption(mOptions));
232 
233 }
234 
236 {
237  mScriptFilePreview->setValue(mScriptFile->getValue());
238 }
239 
241 {
243 
244  CX_LOG_DEBUG() << "deepSintefCommandString(variables): " << deepSintefCommandString(variables);
245 
246  if(isUsingDeepSintefEngine(variables))
247  return deepSintefCommandString(variables);
248 
249  return standardCommandString(variables);
250 }
251 
253 {
254  QString parameterFilePath = mScriptFile->getEmbeddedPath().getAbsoluteFilepath();
255  CX_LOG_DEBUG() << "parameterFilePath: " << parameterFilePath;
256 
257  CommandStringVariables variables = CommandStringVariables(parameterFilePath, input);
258 
259  // Get paths
260  variables.inputFilePath = getInputFilePath(input);
261  variables.outputFilePath = getOutputFilePath(input);
262 
263  return variables;
264 }
265 
267 {
268  QString commandString = variables.envPath;
269  commandString.append(" " + variables.scriptFilePath);
270  commandString.append(" " + variables.inputFilePath);
271  commandString.append(" " + variables.outputFilePath);
272  commandString.append(" " + variables.cArguments);
273 
274  return commandString;
275 }
276 
278 {
279  if(QString::compare(variables.scriptEngine, "DeepSintef", Qt::CaseInsensitive) == 0)
280  return true;
281  return false;
282 }
283 
285 {
286  QString commandString = variables.envPath;
287  commandString.append(" " + variables.scriptFilePath);
288  commandString.append(" --Task database --Arguments ");
289  commandString.append("\"");
290  commandString.append("InputVolume ");
291  commandString.append(variables.inputFilePath);
292  commandString.append(",OutputLabel ");
293  commandString.append(variables.outputFilePath);
294  commandString.append(",ModelsList ");
295  commandString.append(variables.model);
296  commandString.append("\"");
297  return commandString;
298 }
299 
301 {
302  return QFileInfo(path).exists();
303 }
304 
306 {
307  QString envPath = variables.envPath;
308  QString programPath = envPath.split(" ")[0];
309  //CX_LOG_DEBUG() << "programPath: " << programPath;
310  return programPath;
311 }
312 
313 QString GenericScriptFilter::getEnvironmentBasePath(QString environmentPath)
314 {
315  QString basePath = environmentPath.split(this->getFixedEnvironmentSubdir())[0];
316  //CX_LOG_DEBUG() << "basePath: " << basePath;
317 
318  if(!this->environmentExist(basePath))
319  basePath = this->findRequirementsFileLocation(basePath);
320 
321  return basePath;
322 }
323 
325 {
326  //CX_LOG_DEBUG() << "Search path: " << path;
327  QString cdDown = "..\\";
328  QStringList pathComponents = path.split(cdDown);
329  if(pathComponents.size() == 1)
330  {
331  cdDown = "../";
332  pathComponents = path.split(cdDown);
333  }
334  int numCdDown = 0;
335  for(int i = 0; i < pathComponents.size(); ++i)
336  if(pathComponents[i].isEmpty())
337  ++numCdDown;
338  QString strippedPath;
339  for(int i = 0; i < pathComponents.size(); ++i)
340  if(!pathComponents[i].isEmpty())
341  strippedPath = pathComponents[i] + "/";
342 
343  //Try both removing all "../", and adding some more
344  QString tempPath = strippedPath + "requirements.txt";
345  QString retval = path;
346  for(int i = 0; i < 10; ++i)
347  {
348  //CX_LOG_DEBUG() << "check if path exists: " << tempPath;
349  if(environmentExist(tempPath))
350  {
351  retval = tempPath;
352  break;
353  }
354  tempPath = cdDown + tempPath;
355  }
356  //CX_LOG_DEBUG() << "tempPath: " << tempPath;
357  //CX_LOG_DEBUG() << "retval: " << retval;
358 
359  return retval;
360 }
361 
362 bool GenericScriptFilter::createVirtualPythonEnvironment(QString environmentPath, QString requirementsPath)
363 {
364  if(!this->environmentExist(environmentPath) && this->isVirtualEnvironment(environmentPath))
365  {
366  if(!this->createProcess())
367  return false;
368  QString basePath = this->getEnvironmentBasePath(environmentPath);
369  QString scriptPath = getScriptPath();
370  bool retval = runCommandStringAndWait(scriptPath+"/cxCreateVenv.sh " + basePath + " " + requirementsPath);
371  return retval;
372  }
373  return false;
374 }
375 
377 {
378  if(path.contains(this->getFixedEnvironmentSubdir()))
379  return true;
380  return false;
381 }
382 
384 {
385  QString retval("venv/bin/python");
386  return retval;
387 }
388 
390 {
391  QString retval;
392 
393  QString parameterFilePath = mScriptFile->getEmbeddedPath().getAbsoluteFilepath();
394 
395  QSettings settings(parameterFilePath, QSettings::IniFormat);
396  settings.beginGroup("script");
397  QString scriptFilePath = settings.value("path").toString();//input instead?
398  settings.endGroup();
399 
400  scriptFilePath.replace("./","/");
401 
402  retval = QFileInfo(parameterFilePath).absoluteDir().absolutePath()+QFileInfo(scriptFilePath).dir().path();
403  CX_LOG_DEBUG() << "Pyton script file path: " << retval;
404 
405  retval = QFileInfo(parameterFilePath).absoluteDir().absolutePath();
406  CX_LOG_DEBUG() << "Using ini file path as script path: " << retval;
407 
408  return retval;
409 }
410 
412 {
413  QString inputFileName = input->getFilename();
414  QString inputFilePath = mServices->patient()->getActivePatientFolder();
415  inputFilePath.append("/" + inputFileName);
416  return inputFilePath;
417 }
418 
420 {
421  QFileInfo fi(input->getFilename());
422  QString outputFileName = fi.baseName();
423  QString outputFilePath = mServices->patient()->getActivePatientFolder();
424  CX_LOG_DEBUG() << "ActivePatientFolder (output): " << outputFilePath;
425  QString parameterFilePath = mScriptFile->getEmbeddedPath().getAbsoluteFilepath();
426 
427  // Parse .ini file, get file_append
428  QSettings settings(parameterFilePath, QSettings::IniFormat);
429  settings.beginGroup("output");
430  mResultFileEnding = settings.value("file_append","_copy.mhd").toString();
431  //mOutoutOrgans = settings.value("organs").toString().split(",");
432  settings.endGroup();
433 
434  outputFileName.append(mResultFileEnding);
435  outputFilePath.append("/" + fi.path());
436  outputFilePath.append("/" + outputFileName);
437  CX_LOG_DEBUG() << "outputFilePath: " << outputFilePath;
438 
439  return outputFilePath;
440 }
441 
443 {
444  CX_LOG_DEBUG() << "Command to run: " << command;
445 
446  QString parameterFilePath = mScriptFile->getEmbeddedPath().getAbsoluteFilepath();
447 
449  if(!mCommandLine)
450  return false;
451 
452  mCommandLine->getProcess()->setWorkingDirectory(getScriptPath()); //TODO: Use ini file path or python script file path?
453  bool success = mCommandLine->launch(command);
454  if(success)
455  return mCommandLine->waitForFinished(1000*60*30);//Wait at least 30 min
456  else
457  {
458  CX_LOG_WARNING() << "GenericScriptFilter::runCommandStringAndWait: Cannot start command!";
459  return false;
460  }
461 }
462 
464 {
466 
467  temp = StringPropertySelectImage::New(mServices->patient());
468  temp->setValueName("Input");
469  temp->setHelp("Select image input");
470  mInputTypes.push_back(temp);
471 }
472 
474 {
476  mOutputImageSelectDataPtr->setValueName("Output");
477  mOutputImageSelectDataPtr->setHelp("Output smoothed image");
479 
481  mOutputMeshSelectMeshPtr->setValueName("Output Mesh");
482  mOutputMeshSelectMeshPtr->setHelp("Output surface model");
484 
485 }
486 
488 {
489  if (!createProcess())
490  return false;
491 
492  ImagePtr input = this->getCopiedInputImage();
493  // get output also?
494  if (!input)
495  return false;
496 
497  // Parse .ini file, create command string to run
498  QString command = this->createCommandString(input);
499 
500  //command = QString("echo test");//Test simple command
501 
502  // Run command string on console
503  bool retval = this->runCommandStringAndWait(command);
504  if(!retval)
505  CX_LOG_WARNING() << "External process failed. QProcess::ProcessError: " << mCommandLine->getProcess()->error();
506  retval = retval & deleteProcess();
507 
508  return retval; // Check for error?
509 }
510 
511 
513 {
514  mCommandLine.reset();//delete
515  CX_LOG_DEBUG() << "createProcess";
516  mCommandLine = ProcessWrapperPtr(new cx::ProcessWrapper("ScriptFilter"));
517  mCommandLine->turnOffReporting();//Handle output in this class instead
518 
519  // Merge channels to get all output in same channel in CustusX console
520  mCommandLine->getProcess()->setProcessChannelMode(QProcess::MergedChannels);
521 
523  /**************************************************************************
524  * NB: For Python output to be written Python buffering must be turned off:
525  * E.g. Use python -u
526  **************************************************************************/
527  //Show output from process
528  connect(mCommandLine->getProcess(), &QProcess::readyRead, this, &GenericScriptFilter::processReadyRead);
529  return true;
530 }
531 
533 {
535  CX_LOG_DEBUG() << "deleteProcess";
536  if(mCommandLine)
537  {
538  CX_LOG_DEBUG() << "deleting";
539  mCommandLine.reset();
540  return true;
541  }
542  return false;
543 }
544 
546 {
547  CX_LOG_DEBUG() << "disconnectProcess";
548  if(mCommandLine)
549  {
550  CX_LOG_DEBUG() << "disconnecting";
552  disconnect(mCommandLine->getProcess(), &QProcess::readyRead, this, &GenericScriptFilter::processReadyRead);
553  return true;
554  }
555  return false;
556 }
557 
559 {
560  CX_LOG_DEBUG() << "postProcess";
561 
562  QString parameterFilePath = mScriptFile->getEmbeddedPath().getAbsoluteFilepath();
563  OutputVariables outputVariables = OutputVariables(parameterFilePath);
564 
565  bool createOutputVolume = outputVariables.mCreateOutputVolume;
566  bool createOutputMesh = outputVariables.mCreateOutputMesh;
567  QStringList colorList = outputVariables.mOutputColorList;
568  mOutputClasses = outputVariables.mOutputClasses;
569  this->setupOutputColors(colorList);
570 
571  return readGeneratedSegmentationFiles(createOutputVolume, createOutputMesh);
572 }
573 
574 void GenericScriptFilter::setupOutputColors(QStringList colorList)
575 {
576  mOutputColors.clear();
577  int i=0;
578  do
579  {
580  if (colorList.size() > i)
581  {
582  QStringList color = colorList[i].split(",");
583  QColor addColor = createColor(color);
584  mOutputColors.append(addColor);
585  }
586  else
587  {
588  QString outputClass("");
589  if(mOutputClasses.size() >= i)
590  outputClass = mOutputClasses[i];
591  CX_LOG_WARNING() << "In GenericScriptFilter::setupOutputColors(): No color set in ini for " << outputClass << " file. Setting mesh color to red.";
592  mOutputColors.append(getDefaultColor());
593  }
594  }
595  while (++i < mOutputClasses.size());
596 }
597 
598 QColor GenericScriptFilter::createColor(QStringList color)
599 {
600  QColor retval;
601  if (color.size() == 4)
602  retval.setRgb(color[0].toDouble(), color[1].toDouble(), color[2].toDouble(), color[3].toDouble());
603  if (!retval.isValid())
604  {
605  CX_LOG_WARNING() << "In GenericScriptFilter::createColor(): Invalid color set in ini file. Setting color to red.";
606  retval = getDefaultColor();
607  }
608  return retval;
609 }
610 
612 {
613  QColor retval;
614  retval.setNamedColor("red");
615  return retval;
616 }
617 
619 {
620 
621  // Make contour of segmented volume
622  double threshold = 1;
623 
625  mOutputImage->getBaseVtkImageData(),
626  threshold,
627  false, // reduce resolution
628  true, // smoothing
629  true, // keep topology
630  0 // target decimation
631  );
632 
633  QString uidOutputMesh = mOutputImage->getUid() + "_mesh";
634  QString nameOutputMesh = mOutputImage->getName() + "_mesh";
635  MeshPtr outputMesh = patientService()->createSpecificData<Mesh>(uidOutputMesh, nameOutputMesh);
636  outputMesh->setVtkPolyData(rawContour);
637  outputMesh->setColor(color);
638  patientService()->insertData(outputMesh);
639  outputMesh->get_rMd_History()->setRegistration(mOutputImage->get_rMd());
640  mServices->view()->autoShowData(outputMesh);
641 
642  mOutputMeshSelectMeshPtr->setValue(outputMesh->getUid());
643 }
644 
646 {
647  ImagePtr parentImage = this->getCopiedInputImage();
648  if(!parentImage)
649  {
650  CX_LOG_WARNING() << "GenericScriptFilter::readGeneratedSegmentationFiles: No input image";
651  return false;
652  }
653 
654  QFileInfo fileInfoInput(parentImage->getFilename());
655  QString outputFileName = fileInfoInput.baseName();
656  QFileInfo outputFileInfo(outputFileName.append(mResultFileEnding));
657  QString outputFilePath = mServices->patient()->getActivePatientFolder();
658  QString outputDir(outputFilePath.append("/" + fileInfoInput.path()));
659  QString outputFileNamesNoExtention = outputFileInfo.baseName();
660 
661  QDirIterator fileIterator(outputDir, QDir::Files);
662  while (fileIterator.hasNext())
663  {
664  QString filePath = fileIterator.next();
665  if(filePath.contains(outputFileNamesNoExtention) && filePath.contains(".mhd"))
666  {
667  QFileInfo fileInfoOutput(filePath);
668  QString uid = fileInfoOutput.fileName().replace(".mhd", "");
669  ImagePtr newImage = boost::dynamic_pointer_cast<Image>(mServices->file()->load(uid, filePath));
670  if(!newImage)
671  {
672  CX_LOG_WARNING() << "GenericScriptFilter::readGeneratedSegmentationFiles: No new image file created";
673  continue;
674  }
675 
677  uid, createImageName(parentImage->getName(), filePath),
678  newImage->getBaseVtkImageData(), parentImage);
679  if(!mOutputImage)
680  {
681  CX_LOG_WARNING() << "GenericScriptFilter::readGeneratedSegmentationFiles: Problem creating derived image";
682  continue;
683  }
684  if (createOutputVolume)
685  this->createOutputVolume();
686 
687  if(createOutputMesh && mOutputImage)
688  {
689  int colorNumber = 0;
690  for(int i=0; i<mOutputClasses.size(); i++)
691  {
692  if(filePath.contains(mOutputClasses[i], Qt::CaseSensitive))
693  {
694  colorNumber = i;
695  break;
696  }
697  }
698  QColor outputColor = getDefaultColor();
699  if(mOutputColors.size() > colorNumber)
700  outputColor = mOutputColors.at(colorNumber);
701  this->createOutputMesh(outputColor);
702  }
703  this->deleteNotUsedFiles(filePath, createOutputVolume);
704  }
705  else if(filePath.contains(outputFileNamesNoExtention) && filePath.contains(".vtk"))
706  {
707  QColor outputColor;
708  if(mOutputColors.size() > 0)
709  outputColor = mOutputColors[0];
710  else
711  outputColor = getDefaultColor();
712 
713  QString info;
714  MeshPtr outputMesh = boost::dynamic_pointer_cast<Mesh>(patientService()->importData(filePath, info));
715  outputMesh->setColor(outputColor);
716  mServices->view()->autoShowData(outputMesh);
717  ImagePtr inputImage = this->getCopiedInputImage();
718  if(inputImage)
719  outputMesh->get_rMd_History()->setRegistration(inputImage->get_rMd());
720  }
721  }
722 
723  return true;
724 }
725 
726 QString GenericScriptFilter::createImageName(QString parentName, QString filePath)
727 {
728  QString retval = parentName;
729  QString nameEnding = mResultFileEnding;
730  nameEnding.replace(".mhd", "");
731  for(int i=0; i<mOutputClasses.size(); i++)
732  {
733  if(filePath.contains(mOutputClasses[i], Qt::CaseSensitive))
734  retval = retval + QString("_") + mOutputClasses[i] + QString("_");
735  }
736  retval.append(nameEnding);
737  return retval;
738 }
739 
741 {
742  if(!mOutputImage)
743  return;
744 
745  mOutputImage->setImageType(istSEGMENTATION);//Mark with correct type
746  mOutputImage->resetTransferFunctions();//Reset transfer functions to get some useful values for visualization
747 
748  mServices->patient()->insertData(mOutputImage);
749  mServices->view()->autoShowData(mOutputImage);
750 
751  mOutputImageSelectDataPtr->setValue(mOutputImage->getUid());
752 }
753 
755 {
756  //delete files not used anymore
757  if (QFileInfo(fileNameMhd).exists() && !createOutputVolume)
758  QFile(fileNameMhd).remove();
759 
760  QString fileNameRaw = fileNameMhd.left(fileNameMhd.lastIndexOf("."))+".raw";
761  if (QFileInfo(fileNameRaw).exists() && !createOutputVolume)
762  QFile(fileNameRaw).remove();
763 
764  QString fileNameNii = fileNameMhd.left(fileNameMhd.lastIndexOf("."))+".nii";
765  if (QFileInfo(fileNameNii).exists())
766  QFile(fileNameNii).remove();
767 }
768 
769 } // namespace cx
770 
#define CX_LOG_CHANNEL_INFO(channel)
Definition: cxLogger.h:108
cxResource_EXPORT ProfilePtr profile()
Definition: cxProfile.cpp:160
QString standardCommandString(CommandStringVariables variables)
void setupOutputColors(QStringList colorList)
std::vector< SelectDataStringPropertyBasePtr > mInputTypes
Definition: cxFilterImpl.h:73
bool runCommandStringAndWait(QString command)
void reportError(QString msg)
Definition: cxLogger.cpp:71
bool readGeneratedSegmentationFiles(bool createOutputVolume, bool createOutputMesh)
bool createVirtualPythonEnvironment(QString environmentPath, QString requirementsPath)
A mesh data set.
Definition: cxMesh.h:45
virtual QString getName() const
void processError(QProcess::ProcessError error)
void deleteNotUsedFiles(QString fileNameMhd, bool createOutputVolume)
bool isVirtualEnvironment(QString path)
#define CX_ASSERT(statement)
Definition: cxLogger.h:116
bool isUsingDeepSintefEngine(CommandStringVariables variables)
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:40
QString createCommandString(ImagePtr input)
static StringPropertySelectDataPtr New(PatientModelServicePtr patientModelService, QString typeRegexp=".*")
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
boost::shared_ptr< class FilePreviewProperty > FilePreviewPropertyPtr
GenericScriptFilter(VisServicesPtr services)
QString getInputFilePath(ImagePtr input)
CommandStringVariables createCommandStringVariables(ImagePtr input)
FilePreviewPropertyPtr getIniFileOption(QDomElement root)
virtual QString getType() const
FilePathPropertyPtr getParameterFile(QDomElement root)
void processFinished(int code, QProcess::ExitStatus status)
SelectDataStringPropertyBasePtr mOutputImageSelectDataPtr
OutputVariables(QString parameterFilePath)
QString getEnvironmentBasePath(QString environmentPath)
virtual QString getHelp() const
std::vector< PropertyPtr > mOptionsAdapters
Definition: cxFilterImpl.h:75
FilePreviewPropertyPtr mScriptFilePreview
VisServicesPtr mServices
Definition: cxFilterImpl.h:82
ImagePtr createDerivedImage(PatientModelServicePtr dataManager, QString uid, QString name, vtkImageDataPtr raw, ImagePtr parent)
StringPropertySelectMeshPtr mOutputMeshSelectMeshPtr
boost::shared_ptr< class SelectDataStringPropertyBase > SelectDataStringPropertyBasePtr
QString deepSintefCommandString(CommandStringVariables variables)
PatientModelServicePtr patientService()
virtual bool execute()
void setVtkPolyData(const vtkPolyDataPtr &polyData)
Definition: cxMesh.cpp:92
CommandStringVariables(QString parameterFilePath, ImagePtr input)
A volumetric data set.
Definition: cxImage.h:45
void setParameterFilePath(QString path)
ImagePtr getCopiedInputImage(int index=0)
QDomElement mOptions
Definition: cxFilterImpl.h:76
Settings * settings()
Shortcut for accessing the settings instance.
Definition: cxSettings.cpp:21
QString createImageName(QString parentName, QString filePath)
istSEGMENTATION
FilePathPropertyPtr mScriptFile
void changed()
emit when the underlying data value is changed: The user interface will be updated.
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
static FilePathPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList paths, QDomNode root=QDomNode())
boost::shared_ptr< class ProcessWrapper > ProcessWrapperPtr
Definition: cxMainWindow.h:41
#define CX_LOG_DEBUG
Definition: cxLogger.h:95
QString getEnvironmentPath(CommandStringVariables variables)
std::vector< SelectDataStringPropertyBasePtr > mOutputTypes
Definition: cxFilterImpl.h:74
static FilePreviewPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList paths, QDomNode root=QDomNode())
#define CX_LOG_WARNING
Definition: cxLogger.h:98
bool environmentExist(QString path)
static StringPropertySelectMeshPtr New(PatientModelServicePtr patientModelService)
boost::shared_ptr< class FilePathProperty > FilePathPropertyPtr
static StringPropertySelectImagePtr New(PatientModelServicePtr patientModelService)
QString findRequirementsFileLocation(QString path)
boost::shared_ptr< class Mesh > MeshPtr
QColor createColor(QStringList color)
QString getOutputFilePath(ImagePtr input)
void createOutputMesh(QColor color)
#define CX_LOG_CHANNEL_ERROR(channel)
Definition: cxLogger.h:111
void setColor(const QColor &color)
Set the color of the mesh.
Definition: cxMesh.cpp:185
Namespace for all CustusX production code.