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 3c15a583 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Introducing ivus_tc module for IVUS tissue classification:

* Introducing IvusBatchReader processor to read an IVUS volume from a batch of 2D images
* Introducing IvusTcDemo pipeline stub
parent 412f2e72
# CMake file for ivus_tc module
IF(${ModuleEnabled})
# Source files:
FILE(GLOB ThisModSources RELATIVE ${ModulesDir}
modules/ivus_tc/pipelines/*.cpp
modules/ivus_tc/processors/*.cpp
)
# Header files (including GLSL files so that they'll appear in VS projects)
FILE(GLOB ThisModHeaders RELATIVE ${ModulesDir}
modules/ivus_tc/glsl/*.frag
modules/ivus_tc/glsl/*.geom
modules/ivus_tc/glsl/*.vert
modules/ivus_tc/pipelines/*.h
modules/ivus_tc/processors/*.h
)
SET(ThisModShaderDirectories "modules/ivus_tc/glsl")
SET(ThisModDependencies base io devil vis)
ENDIF(${ModuleEnabled})
SET(ThisModStatus EXPERIMENTAL)
SET(ThisModExternalDependencies FALSE)
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#include "ivustcdemo.h"
#include "tgt/event/keyevent.h"
#include "core/datastructures/imagedata.h"
#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"
namespace campvis {
IvusTcDemo::IvusTcDemo(DataContainer* dc)
: AutoEvaluationPipeline(dc)
, _lsp()
, _imageReader(&_canvasSize)
, _ve(&_canvasSize)
{
addProcessor(&_lsp);
addProcessor(&_imageReader);
addProcessor(&_ve);
addEventListenerToBack(&_ve);
}
IvusTcDemo::~IvusTcDemo() {
}
void IvusTcDemo::init() {
AutoEvaluationPipeline::init();
_ve.p_outputImage.setValue("combine");
_renderTargetID.setValue("combine");
_imageReader.p_inputDirectory.setValue("D:/Medical Data/IVUS/H52 LAD1/IVUS");
_imageReader.p_fileExtension.setValue("bmp");
_imageReader.p_outputImage.setValue("reader.output");
_imageReader.p_outputImage.addSharedProperty(&_ve.p_inputVolume);
Geometry1DTransferFunction* dvrTF = new Geometry1DTransferFunction(128, tgt::vec2(0.f, .05f));
dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(.12f, .15f), tgt::col4(85, 0, 0, 128), tgt::col4(255, 0, 0, 128)));
dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(.19f, .28f), tgt::col4(89, 89, 89, 155), tgt::col4(89, 89, 89, 155)));
dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(.41f, .51f), tgt::col4(170, 170, 128, 64), tgt::col4(192, 192, 128, 64)));
static_cast<TransferFunctionProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::TransferFunction"))->replaceTF(dvrTF);
static_cast<FloatProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::SamplingRate"))->setValue(4.f);
}
void IvusTcDemo::deinit() {
AutoEvaluationPipeline::deinit();
}
}
\ No newline at end of file
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#ifndef IVUSTCDEMO_H__
#define IVUSTCDEMO_H__
#include "core/pipeline/autoevaluationpipeline.h"
#include "core/properties/cameraproperty.h"
#include "modules/base/processors/lightsourceprovider.h"
#include "modules/io/processors/mhdimagereader.h"
#include "modules/io/processors/genericimagereader.h"
#include "modules/ivus_tc/processors/ivusbatchreader.h"
#include "modules/vis/processors/volumeexplorer.h"
namespace campvis {
class IvusTcDemo : public AutoEvaluationPipeline {
public:
/**
* Creates a AutoEvaluationPipeline.
*/
IvusTcDemo(DataContainer* dc);
/**
* Virtual Destructor
**/
virtual ~IvusTcDemo();
/// \see AutoEvaluationPipeline::init()
virtual void init();
/// \see AutoEvaluationPipeline::deinit()
virtual void deinit();
/// \see AbstractPipeline::getName()
virtual const std::string getName() const { return getId(); };
/// \see AbstractPipeline::getId()
static const std::string getId() { return "IvusTcDemo"; };
protected:
LightSourceProvider _lsp;
IvusBatchReader _imageReader;
VolumeExplorer _ve;
};
}
#endif // IVUSTCDEMO_H__
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#include "ivusbatchreader.h"
#include <IL/il.h>
#include "tgt/logmanager.h"
#include "tgt/filesystem.h"
#include "core/datastructures/genericimagerepresentationlocal.h"
#include "core/tools/stringutils.h"
namespace campvis {
const std::string IvusBatchReader::loggerCat_ = "CAMPVis.modules.vis.IvusBatchReader";
IvusBatchReader::IvusBatchReader(IVec2Property* viewportSizeProp)
: VisualizationProcessor(viewportSizeProp)
, p_inputDirectory("InputDirectory", "Input Directory", "", StringProperty::DIRECTORY)
, p_fileExtension("FileExtension", "File Extension", "bmp", StringProperty::BASIC_STRING)
, p_imageSpacing("ImageSpacing", "Image Spacing", tgt::vec3(.1f, .1f, .5f), tgt::vec3(0.f), tgt::vec3(10.f), tgt::vec3(.1f), tgt::ivec3(2))
, p_outputImage("OutputImage", "Output Image", "dd.output", DataNameProperty::WRITE)
{
addProperty(p_inputDirectory);
addProperty(p_fileExtension);
addProperty(p_outputImage);
}
IvusBatchReader::~IvusBatchReader() {
}
void IvusBatchReader::init() {
VisualizationProcessor::init();
}
void IvusBatchReader::deinit() {
VisualizationProcessor::deinit();
}
void IvusBatchReader::updateResult(DataContainer& data) {
std::string ext = StringUtils::lowercase(p_fileExtension.getValue());
std::vector<std::string> files = tgt::FileSystem::listFiles(p_inputDirectory.getValue(), true);
files.erase(std::remove_if(files.begin(), files.end(), [&] (const std::string& s) -> bool { return tgt::FileSystem::fileExtension(s, true) != ext; } ), files.end());
tgt::ivec3 imageSize(0, 0, static_cast<int>(files.size()));
uint8_t* buffer = nullptr;
for (size_t i = 0; i < files.size(); ++i) {
std::string filename = p_inputDirectory.getValue() + "/" + files[i];
// prepare DevIL
ILuint img;
ilGenImages(1, &img);
ilBindImage(img);
// try load file
if (! ilLoadImage(filename.c_str())) {
LERROR("Could not load image: " << filename);
delete [] buffer;
return;
}
// prepare buffer and perform dimensions check
if (i == 0) {
imageSize.x = ilGetInteger(IL_IMAGE_WIDTH);
imageSize.y = ilGetInteger(IL_IMAGE_HEIGHT);
buffer = new uint8_t[tgt::hmul(imageSize)];
}
else {
if (imageSize.x != ilGetInteger(IL_IMAGE_WIDTH)) {
LERROR("Could not load images: widths do not match!");
delete [] buffer;
return;
}
if (imageSize.y != ilGetInteger(IL_IMAGE_HEIGHT)) {
LERROR("Could not load images: heights do not match!");
delete [] buffer;
return;
}
}
// get data from image and transform to single intensity image:
ILubyte *data = ilGetData();
ilCopyPixels(0, 0, 0, imageSize.x, imageSize.y, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, buffer + (sizeof(uint8_t) * i * imageSize.x * imageSize.y));
ILint err = ilGetError();
if (err != IL_NO_ERROR) {
LERROR("Error during conversion: " << iluErrorString(err));
delete [] buffer;
return;
}
ilDeleteImage(img);
}
ImageData* id = new ImageData(3, imageSize, 1);
GenericImageRepresentationLocal<uint8_t, 1>::create(id, buffer);
data.addData(p_outputImage.getValue(), id);
ImageMappingInformation imi(imageSize, tgt::vec3(0.f), p_imageSpacing.getValue());
id->setMappingInformation(imi);
validate(AbstractProcessor::INVALID_RESULT);
}
}
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#ifndef IVUSBATCHREADER_H__
#define IVUSBATCHREADER_H__
#include "core/pipeline/visualizationprocessor.h"
#include "core/properties/allproperties.h"
#include "modules/devil/processors/devilimagereader.h"
namespace campvis {
/**
* Reads a batch of IVUS images from a directory and stacks them into a 3D volume.
*/
class IvusBatchReader : public VisualizationProcessor {
public:
/**
* Constructs a new IvusBatchReader Processor
**/
IvusBatchReader(IVec2Property* viewportSizeProp);
/**
* Destructor
**/
virtual ~IvusBatchReader();
/// \see AbstractProcessor::init
virtual void init();
/// \see AbstractProcessor::deinit
virtual void deinit();
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "IvusBatchReader"; };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Reads a batch of IVUS images from a directory and stacks them into a 3D volume."; };
/// \see AbstractProcessor::getAuthor()
virtual const std::string getAuthor() const { return "Christian Schulte zu Berge <christian.szb@in.tum.de>"; };
/// \see AbstractProcessor::getProcessorState()
virtual ProcessorState getProcessorState() const { return AbstractProcessor::EXPERIMENTAL; };
StringProperty p_inputDirectory; ///< Input directory to read files from
StringProperty p_fileExtension; ///< File extension of images to read
Vec3Property p_imageSpacing; ///< Image spacing
DataNameProperty p_outputImage; ///< image ID for output image
protected:
/// \see AbstractProcessor::updateResult
virtual void updateResult(DataContainer& dataContainer);
static const std::string loggerCat_;
};
}
#endif // IVUSBATCHREADER_H__
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