The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit d28eac80 authored by schultezub's avatar schultezub
Browse files

Further work on CMBatchGeneration pipeline, batch process runs smoothly

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@477 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 8a5ff843
......@@ -122,7 +122,7 @@ namespace campvis {
processor->unlockProcessor();
#ifdef CAMPVIS_DEBUG
//LDEBUG("Executed processor " << processor->getName() << " duration: " << (endTime - startTime));
LDEBUG("Executed processor " << processor->getName() << " duration: " << (endTime - startTime));
#endif
}
}
......
......@@ -144,7 +144,7 @@ namespace campvis {
/**
* Slot getting called when one of the observed processors got invalidated.
* The default behaviour is just to set the invalidation level to invalid.
* The default behaviour is to dispatch a job to execute the invalidated processor and emit the s_invalidated signal.
* \param processor The processor that emitted the signal
*/
virtual void onProcessorInvalidated(AbstractProcessor* processor);
......
......@@ -159,7 +159,7 @@ namespace campvis {
/**
* Slot getting called when one of the observed processors got invalidated.
* The default behaviour is just to set the invalidation level to invalid.
* The default behaviour is to dispatch a job to execute the invalidated processor and emit the s_invalidated signal.
* \param processor The processor that emitted the signal
*/
virtual void onProcessorInvalidated(AbstractProcessor* processor);
......
......@@ -33,9 +33,19 @@
#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"
#include "core/datastructures/imagerepresentationrendertarget.h"
#include "core/tools/opengljobprocessor.h"
#include "core/tools/simplejobprocessor.h"
#include "core/tools/job.h"
#ifdef CAMPVIS_HAS_MODULE_DEVIL
#include <IL/il.h>
#include <IL/ilu.h>
#endif
#include <sstream>
#include <iomanip>
namespace campvis {
CmBatchGeneration::CmBatchGeneration()
......@@ -44,11 +54,20 @@ namespace campvis {
, _confidenceGenerator()
, _usBlurFilter()
, _usFusion(_effectiveRenderTargetSize)
, p_sourcePath("SourcePath", "Source Files Path", "")
, p_targetPath("TargetPath", "Target Files Path", "")
, p_range("Range", "Files Range", tgt::ivec2(0, 1), tgt::ivec2(0, 0), tgt::ivec2(10000, 10000))
, p_execute("Execute", "Execute Batch Pipeline")
{
addProcessor(&_usReader);
addProcessor(&_confidenceGenerator);
addProcessor(&_usFusion);
addProcessor(&_usBlurFilter);
addProperty(&p_sourcePath);
addProperty(&p_targetPath);
addProperty(&p_range);
addProperty(&p_execute);
}
CmBatchGeneration::~CmBatchGeneration() {
......@@ -57,12 +76,11 @@ namespace campvis {
void CmBatchGeneration::init() {
VisualizationPipeline::init();
_usReader.s_validated.connect(this, &CmBatchGeneration::onProcessorValidated);
p_sourcePath.setValue("D:\\Medical Data\\US Confidence Vis\\transcranial\\bl01");
p_targetPath.setValue("D:\\Medical Data\\US Confidence Vis\\transcranial\\bl01cm");
p_range.setValue(tgt::ivec2(0, 1));
p_execute.s_clicked.connect(this, &CmBatchGeneration::execute);
//_usReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\CurefabCS\\Stent_Patient_ B-Mode_2013-02-11T14.56.46z\\01_us.mhd");
//_usReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\01\\BMode_01.mhd");
//_usReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\UltrasoundBoneData\\SynthesEvaluationUnterschenkel");
_usReader.p_url.setValue("D:\\Medical Data\\US Confidence Vis\\transcranial\\us.png");
_usReader.p_targetImageID.setValue("us.image");
_usReader.p_importType.selectById("localIntensity");
......@@ -73,10 +91,10 @@ namespace campvis {
_confidenceGenerator.p_targetImageID.setValue("confidence.image.generated");
_confidenceGenerator.p_targetImageID.connect(&_usFusion.p_confidenceImageID);
_confidenceGenerator.p_curvilinear.setValue(true);
//_confidenceGenerator.p_origin.setValue(tgt::vec2(320.f, 444s.f));
//_confidenceGenerator.p_angles.setValue(tgt::vec2(225.f / 180.f * tgt::PIf, 315.f / 180.f * tgt::PIf));
_confidenceGenerator.p_origin.setValue(tgt::vec2(320.f, 35.f));
_confidenceGenerator.p_angles.setValue(tgt::vec2(45.f / 180.f * tgt::PIf, 135.f / 180.f * tgt::PIf));
_confidenceGenerator.p_origin.setValue(tgt::vec2(320.f, 444.f));
_confidenceGenerator.p_angles.setValue(tgt::vec2(225.f / 180.f * tgt::PIf, 315.f / 180.f * tgt::PIf));
//_confidenceGenerator.p_origin.setValue(tgt::vec2(320.f, 35.f));
//_confidenceGenerator.p_angles.setValue(tgt::vec2(45.f / 180.f * tgt::PIf, 135.f / 180.f * tgt::PIf));
_confidenceGenerator.p_lengths.setValue(tgt::vec2(0.f, 410.f));
_usFusion.p_targetImageID.setValue("us.fused");
......@@ -102,35 +120,80 @@ namespace campvis {
}
void CmBatchGeneration::execute() {
/*
if (!_usReader.getInvalidationLevel().isValid()) {
SimpleJobProc.enqueueJob(makeJob(this, &CmBatchGeneration::foobar));
}
if (!_usDenoiseilter.getInvalidationLevel().isValid()) {
SimpleJobProc.enqueueJob(makeJob<CmBatchGeneration, AbstractProcessor*>(this, &CmBatchGeneration::executeProcessor, &_usDenoiseilter));
}
if (!_confidenceGenerator.getInvalidationLevel().isValid()) {
SimpleJobProc.enqueueJob(makeJob<CmBatchGeneration, AbstractProcessor*>(this, &CmBatchGeneration::executeProcessor, &_confidenceGenerator));
}
for (std::vector<AbstractProcessor*>::iterator it = _processors.begin(); it != _processors.end(); ++it) {
if (! (*it)->getInvalidationLevel().isValid())
lockGLContextAndExecuteProcessor(*it);
}*/
}
if (p_range.getValue().x > p_range.getValue().y)
return;
void CmBatchGeneration::keyEvent(tgt::KeyEvent* e) {
for (int i = p_range.getValue().x; i < p_range.getValue().y; ++i) {
GLJobProc.enqueueJob(_canvas, makeJobOnHeap(this, &CmBatchGeneration::executePass, i), OpenGLJobProcessor::SerialJob);
}
}
const std::string CmBatchGeneration::getName() const {
return "CmBatchGeneration";
}
void CmBatchGeneration::onProcessorValidated(AbstractProcessor* processor) {
if (processor = &_usReader) {
void CmBatchGeneration::onProcessorInvalidated(AbstractProcessor* processor) {
// do nothing here - we do our own evaluation
}
void CmBatchGeneration::executePass(int path) {
std::stringstream ss;
// set up processors:
ss << p_sourcePath.getValue() << "\\" << "export" << std::setfill('0') << std::setw(4) << path << ".tga";
_usReader.p_url.setValue(ss.str());
executeProcessor(&_usReader);
DataHandle dh = _data.getData(_usReader.p_targetImageID.getValue());
if (dh.getData() != 0) {
if (const ImageData* tester = dynamic_cast<const ImageData*>(dh.getData())) {
_canvasSize.setValue(tester->getSize().xy());
}
}
executeProcessor(&_confidenceGenerator);
executeProcessor(&_usBlurFilter);
executeProcessor(&_usFusion);
// get result
ImageRepresentationRenderTarget::ScopedRepresentation repRT(_data, _usFusion.p_targetImageID.getValue());
if (repRT != 0) {
#ifdef CAMPVIS_HAS_MODULE_DEVIL
std::stringstream sss;
sss << p_targetPath.getValue() << "\\" << "export" << std::setfill('0') << std::setw(4) << path << ".png";
std::string filename = sss.str();
if (tgt::FileSystem::fileExtension(filename).empty()) {
LERROR("Filename has no extension");
return;
}
// get color buffer content
GLubyte* colorBuffer = repRT->getColorTexture()->downloadTextureToBuffer(GL_RGBA, GL_UNSIGNED_SHORT);
tgt::ivec2 size = repRT->getSize().xy();
// create Devil image from image data and write it to file
ILuint img;
ilGenImages(1, &img);
ilBindImage(img);
// put pixels into IL-Image
ilTexImage(size.x, size.y, 1, 4, IL_RGBA, IL_UNSIGNED_SHORT, colorBuffer);
ilEnable(IL_FILE_OVERWRITE);
ilResetWrite();
ILboolean success = ilSaveImage(filename.c_str());
ilDeleteImages(1, &img);
delete[] colorBuffer;
if (!success) {
LERROR("Could not save image to file: " << ilGetError());
}
#else
return;
#endif
}
}
}
\ No newline at end of file
......@@ -31,9 +31,6 @@
#define CMBATCHGENERATION_H__
#include "core/datastructures/imagerepresentationlocal.h"
#include "core/eventhandlers/mwheeltonumericpropertyeventhandler.h"
#include "core/eventhandlers/transfuncwindowingeventhandler.h"
#include "core/eventhandlers/trackballnavigationeventhandler.h"
#include "core/pipeline/visualizationpipeline.h"
#include "modules/devil/processors/devilimagereader.h"
#include "modules/io/processors/mhdimagereader.h"
......@@ -48,6 +45,9 @@
#include "modules/vis/processors/quadview.h"
#include "modules/randomwalk/processors/confidencemapgenerator.h"
#include "core/properties/buttonproperty.h"
#include "core/properties/genericproperty.h"
namespace campvis {
class CmBatchGeneration : public VisualizationPipeline {
public:
......@@ -73,23 +73,27 @@ namespace campvis {
/**
* Execute this pipeline.
**/
virtual void execute();
virtual void keyEvent(tgt::KeyEvent* e);
void execute();
protected:
/**
* Slot getting called when one of the observed processors got validated.
* Updates the camera properties, when the input image has changed.
* \param processor The processor that emitted the signal
* Slot getting called when one of the observed processors got invalidated.
* Overwrites the default behaviour to do nothing.
*/
virtual void onProcessorValidated(AbstractProcessor* processor);
virtual void onProcessorInvalidated(AbstractProcessor* processor);
void executePass(int path);
DevilImageReader _usReader;
ConfidenceMapGenerator _confidenceGenerator;
ItkImageFilter _usBlurFilter;
AdvancedUsFusion _usFusion;
StringProperty p_sourcePath;
StringProperty p_targetPath;
IVec2Property p_range;
ButtonProperty p_execute;
};
}
......
......@@ -70,7 +70,7 @@ namespace campvis {
void operator() (const tbb::blocked_range<size_t>& range) const {
// Get each slice of the range through the confidence map generator
ConfidenceMaps2DFacade _cmGenerator;
_cmGenerator.setSolver(_processor->p_solver.getOptionValue());
_cmGenerator.setSolver(_processor->p_solver.getOptionValue(), _processor->p_numSteps.getValue());
std::vector<double> inputValues;
const tgt::svec3& imageSize = _input->getSize();
inputValues.resize(_numElementsPerSlice);
......@@ -145,8 +145,6 @@ namespace campvis {
}
}
//std::copy(inputValues.begin(), inputValues.end(), _output);
offset += _numElementsPerSlice;
}
}
......@@ -173,6 +171,7 @@ namespace campvis {
, p_gamma("Gamma", "Gamma Parameter", .06f, .01f, 1.f)
, p_normalizeValues("NormalizeValues", "Noramlize Values", false)
, p_solver("FilterMode", "Filter Mode", solvers, 4)
, p_numSteps("NumSteps", "Number of Solver Steps", 1000, 100, 5000)
, p_curvilinear("Curvilinear", "Curvilinear Transducer?", false)
, p_origin("PolarOrigin", "Polar Origin", tgt::vec2(0.f), tgt::vec2(-1000.f), tgt::vec2(1000.f))
, p_angles("PolarAngles", "Polar Angles", tgt::vec2(0.f, 1.f), tgt::vec2(0.f), tgt::vec2(1000.f))
......@@ -186,6 +185,7 @@ namespace campvis {
addProperty(&p_gamma);
addProperty(&p_normalizeValues);
addProperty(&p_solver);
addProperty(&p_numSteps);
addProperty(&p_curvilinear);
addProperty(&p_origin);
addProperty(&p_angles);
......@@ -212,12 +212,12 @@ namespace campvis {
GenericImageRepresentationLocal<float, 1>* confidenceMap = GenericImageRepresentationLocal<float, 1>::create(output, outputValues);
data.addData(p_targetImageID.getValue(), output);
p_targetImageID.issueWrite();
validate(INVALID_RESULT);
}
else {
LDEBUG("No suitable input image found.");
}
validate(INVALID_RESULT);
}
}
......@@ -67,6 +67,7 @@ namespace campvis {
FloatProperty p_gamma; ///< Gamma Parameter
BoolProperty p_normalizeValues; ///< Flag whether to normalize the values before computation
GenericOptionProperty<std::string> p_solver; ///< Solver to use
IntProperty p_numSteps;
BoolProperty p_curvilinear;
Vec2Property p_origin;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment