Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing 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

predicatedemocarotid2.cpp 9.2 KB
Newer Older
1
2
3
4
// ================================================================================================
// 
// This file is part of the CAMPVis Software Framework.
// 
5
// If not explicitly stated otherwise: Copyright (C) 2012-2015, all rights reserved,
6
7
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
//      Chair for Computer Aided Medical Procedures
8
9
10
//      Technische Universitaet Muenchen
//      Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
// 
11
12
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
// 
13
14
15
16
// 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
17
// 
18
19
20
21
// 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.
22
23
24
25
26
// 
// ================================================================================================

#include "predicatedemocarotid2.h"

27
#include "cgt/event/keyevent.h"
28
29
30
31
32
33
34
35
36
37
#include "core/datastructures/genericimagerepresentationlocal.h"
#include "core/datastructures/imagedata.h"

#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"

#include "modules/advancedusvis/processors/pointpredicateraycaster.h"

namespace campvis {

38
39
    PredicateDemoCarotid2::PredicateDemoCarotid2(DataContainer& dc)
        : AutoEvaluationPipeline(dc, getId())
40
        , _lsp()
41
42
43
44
45
46
47
48
49
        , _imageReader()
        , _labelReader()
        , _confidenceReader()
        , _gaussian(&_canvasSize)
        , _vesselnesFilter(&_canvasSize)
        , _morphology(&_canvasSize)
        , _snrFilter(&_canvasSize)
        , _ve(&_canvasSize)
    {
50
        addProcessor(&_lsp);
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
        addProcessor(&_imageReader);
        addProcessor(&_labelReader);
        addProcessor(&_confidenceReader);
        addProcessor(&_gaussian);
        addProcessor(&_vesselnesFilter);
        addProcessor(&_morphology);
        addProcessor(&_snrFilter);
        addProcessor(&_ve);

        addEventListenerToBack(&_ve);
    }

    PredicateDemoCarotid2::~PredicateDemoCarotid2() {
    }

    void PredicateDemoCarotid2::init() {
        AutoEvaluationPipeline::init();
        
        _imageReader.s_validated.connect(this, &PredicateDemoCarotid2::onProcessorValidated);

        _ve.p_outputImage.setValue("ve");
        _renderTargetID.setValue("ve");

        _imageReader.p_url.setValue(CAMPVIS_SOURCE_DIR "/modules/advancedusvis/sampledata/christian_bmode_2D_compounded_cropped.mhd");
        //_imageReader.p_url.setValue("D:/Medical Data/us_carotid_2014-02/christian/christian_bmode_2D_compounded_cropped.mhd");
        _imageReader.p_targetImageID.setValue("reader.output");
        _imageReader.p_targetImageID.addSharedProperty(&_gaussian.p_inputImage);
        _imageReader.p_targetImageID.addSharedProperty(&_snrFilter.p_inputImage);
        _imageReader.p_targetImageID.addSharedProperty(&_ve.p_inputVolume);

        _labelReader.p_url.setValue(CAMPVIS_SOURCE_DIR "/modules/advancedusvis/sampledata/christian_bmode_2D_compounded_cropped_layers.mhd");
        //_labelReader.p_url.setValue("D:/Medical Data/us_carotid_2014-02/christian/christian_bmode_2D_compounded_cropped_layers.mhd");
        _labelReader.p_targetImageID.setValue("labels");
        _labelReader.p_targetImageID.addSharedProperty(&_ve.p_inputLabels);

        _confidenceReader.p_url.setValue(CAMPVIS_SOURCE_DIR "/modules/advancedusvis/sampledata/christian_bmode_2D_compounded_cropped.mhd");
        _confidenceReader.p_targetImageID.setValue("confidence");
        _confidenceReader.p_targetImageID.addSharedProperty(&_ve.p_inputConfidence);

        _snrFilter.p_outputImage.setValue("snr");
        _snrFilter.p_outputImage.addSharedProperty(&_ve.p_inputSnr);

93
        _gaussian.p_sigma.setValue(6.2f);
94
95
96
        _gaussian.p_outputImage.addSharedProperty(&_vesselnesFilter.p_inputImage);

        _vesselnesFilter.p_outputImage.setValue("vesselness");
97
        _vesselnesFilter.p_lod.setValue(cgt::vec2(3.f, 4.f));
98
99
100
101
102
103
104
105
106
107
        _vesselnesFilter.p_alpha.setValue(0.2f);
        _vesselnesFilter.p_beta.setValue(0.8f);
        _vesselnesFilter.p_gamma.setValue(.0018f);
        _vesselnesFilter.p_theta.setValue(0.3f);
        _vesselnesFilter.p_outputImage.addSharedProperty(&_morphology.p_inputImage);

        _morphology.p_filterOperation.setValue("de");
        _morphology.p_structuringElement.setValue(1);
        _morphology.p_outputImage.addSharedProperty(&_ve.p_inputVesselness);

108
109
        Geometry1DTransferFunction* dvrTF = new Geometry1DTransferFunction(128, cgt::vec2(0.05f, .8f));
        dvrTF->addGeometry(TFGeometry1D::createQuad(cgt::vec2(0.f, 1.f), cgt::col4(0, 0, 0, 0), cgt::col4(255, 255, 255, 255)));
110
111
        static_cast<TransferFunctionProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::TransferFunction"))->setAutoFitWindowToData(false);
        static_cast<TransferFunctionProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::TransferFunction"))->replaceTF(dvrTF);
112
113
        static_cast<FloatProperty*>(_ve.getNestedProperty("VolumeRendererProperties::RaycasterProps::GradientLod"))->setValue(0.5f);

114
115
//         static_cast<Vec4Property*>(_ve.getNestedProperty("backgroundColor1"))->setValue(cgt::vec4(1.f));
//         static_cast<Vec4Property*>(_ve.getNestedProperty("backgroundColor2"))->setValue(cgt::vec4(1.f));
116
117
118
119
120
121
122
123
124
125
126
127

        _canvasSize.setVisible(false);
        _renderTargetID.setVisible(false);


        // initialize predicates with default config
        PointPredicateHistogramProperty* php = &_ve.p_histogram;
        if (php != nullptr) {
            PointPredicateHistogram* histogram = php->getPredicateHistogram();

            AbstractPointPredicate* vpToAdd = 0;
            vpToAdd = new RangePointPredicate("intensity", "Intensity", "Intensity Range");
128
            static_cast<RangePointPredicate*>(vpToAdd)->p_range.setValue(cgt::vec2(.05f, 1.f));
129
130
131
132
133
            histogram->addPredicate(vpToAdd);

            AbstractPointPredicate* a = new LabelBitPointPredicate("label", "Vessel2", "Vessel Layer");
            static_cast<LabelBitPointPredicate*>(a)->p_bit.setValue(2);
            AbstractPointPredicate* b = new RangePointPredicate("gradientMagnitude", "GradMag", "Gradient Magnitude Range");
134
            static_cast<RangePointPredicate*>(b)->p_range.setValue(cgt::vec2(.25f, 1.f));
135
136
137
138
139
140
141
142
143
            std::vector<AbstractPointPredicate*> v;
            v.push_back(a);
            v.push_back(b);
            vpToAdd = new AndCombinedPointPredicate("GradMagVessel", "Gradient Magnitude & Vessel Layer", v);
            histogram->addPredicate(vpToAdd);

            AbstractPointPredicate* foo = new LabelBitPointPredicate("label", "Carotid", "Carotid");
            static_cast<LabelBitPointPredicate*>(foo)->p_bit.setValue(4);
            AbstractPointPredicate* bar = new RangePointPredicate("vesselness", "Vesselness", "Vesselness Range");
144
            static_cast<RangePointPredicate*>(bar)->p_range.setValue(cgt::vec2(.22f, 1.f));
145
146
147
148
            v.clear();
            v.push_back(foo);
            v.push_back(bar);
            vpToAdd = new AndCombinedPointPredicate("CarotidVessel", "Vesselness & Carotid", v);
149
            vpToAdd->p_intensityHack.setValue(.15f);
150
151
152
153
154
155
156
157
158
159
            histogram->addPredicate(vpToAdd);

            vpToAdd = new LabelBitPointPredicate("label", "Skin", "Skin Layer");
            static_cast<LabelBitPointPredicate*>(vpToAdd)->p_bit.setValue(0);
            histogram->addPredicate(vpToAdd);

            vpToAdd = new LabelBitPointPredicate("label", "Muscle", "Muscle Layer");
            static_cast<LabelBitPointPredicate*>(vpToAdd)->p_bit.setValue(1);
            histogram->addPredicate(vpToAdd);

160
161
162
163
164
165
166
167
168
169
170
//             vpToAdd = new LabelBitPointPredicate("label", "Vessel", "Vessel Layer");
//             static_cast<LabelBitPointPredicate*>(vpToAdd)->p_bit.setValue(2);
//             histogram->addPredicate(vpToAdd);
            a = new LabelBitPointPredicate("label", "Vessel3", "Vessel Layer");
            static_cast<LabelBitPointPredicate*>(a)->p_bit.setValue(2);
            b = new LabelBitPointPredicate("label", "Vessel4", "Vessel Layer 2");
            static_cast<LabelBitPointPredicate*>(b)->p_bit.setValue(3);
            std::vector<AbstractPointPredicate*> v2;
            v2.push_back(a);
            v2.push_back(b);
            vpToAdd = new OrCombinedPointPredicate("VesselLayer", "Vessel Layer", v2);
171
172
173
            histogram->addPredicate(vpToAdd);

            histogram->resetPredicates();
174
            addProperty(*php);
175
176
177
178
179
180
181
182
183
184
185
186
187
        }
    }

    void PredicateDemoCarotid2::deinit() {
        AutoEvaluationPipeline::deinit();
    }

    void PredicateDemoCarotid2::onRenderTargetSizeChanged(const AbstractProperty* prop) {
    }

    void PredicateDemoCarotid2::onProcessorValidated(AbstractProcessor* processor) {
        if (processor == &_imageReader) {
            if (IVec2Property* tester = dynamic_cast<IVec2Property*>(_ve.getNestedProperty("VolumeRendererProperties::PGGProps::clipX"))) {
188
                tester->setValue(cgt::ivec2(42, 210));
189
190
191
192
            }
        }
    }
}