This file is indexed.

/usr/include/ITK-4.5/itkLabeledPointSetToPointSetMetricv4.hxx is in libinsighttoolkit4-dev 4.5.0-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 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
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
/*=========================================================================
 *
 *  Copyright Insight Software Consortium
 *
 *  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.txt
 *
 *  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 __itkLabeledPointSetToPointSetMetricv4_hxx
#define __itkLabeledPointSetToPointSetMetricv4_hxx

#include "itkLabeledPointSetToPointSetMetricv4.h"

#include "itkEuclideanDistancePointSetToPointSetMetricv4.h"

#include <algorithm>

namespace itk
{

/** Constructor */
template<typename TFixedPointSet, typename TMovingPointSet>
LabeledPointSetToPointSetMetricv4<TFixedPointSet, TMovingPointSet>
::LabeledPointSetToPointSetMetricv4()
{
  typedef EuclideanDistancePointSetToPointSetMetricv4<FixedPointSetType, MovingPointSetType> DefaultMetricType;
  typename DefaultMetricType::Pointer euclideanMetric = DefaultMetricType::New();
  this->m_PointSetMetric = euclideanMetric;

  this->m_UsePointSetData = true;
}

/** Destructor */
template<typename TFixedPointSet, typename TMovingPointSet>
LabeledPointSetToPointSetMetricv4<TFixedPointSet, TMovingPointSet>
::~LabeledPointSetToPointSetMetricv4()
{
}

template<typename TFixedPointSet, typename TMovingPointSet>
void
LabeledPointSetToPointSetMetricv4<TFixedPointSet, TMovingPointSet>
::Initialize( void ) throw ( ExceptionObject )
{
  Superclass::Initialize();

  if( !this->m_FixedPointSet->GetPointData() || this->m_FixedPointSet->GetPoints()->Size() != this->m_FixedPointSet->GetPointData()->Size() ||
    !this->m_MovingPointSet->GetPointData() || this->m_MovingPointSet->GetPoints()->Size() != this->m_MovingPointSet->GetPointData()->Size() )
    {
    itkExceptionMacro( "Each point of the point set must be associated with a label." );
    }

  this->DetermineCommonPointSetLabels();

  // Create point set metric instantiations for each label

  typename LabelSetType::const_iterator it;
  for( it = this->m_CommonPointSetLabels.begin(); it != this->m_CommonPointSetLabels.end(); ++it )
    {
    typename PointSetMetricType::Pointer metricPtr = dynamic_cast<PointSetMetricType *>( this->m_PointSetMetric->Clone().GetPointer() );

    FixedPointSetPointer fixedPointSet = this->GetLabeledFixedPointSet( *it );
    MovingPointSetPointer movingPointSet = this->GetLabeledMovingPointSet( *it );

    metricPtr->SetFixedPointSet( fixedPointSet );
    metricPtr->SetMovingPointSet( movingPointSet );
    metricPtr->Initialize();

    this->m_PointSetMetricClones.push_back( metricPtr );
    }
}

template<typename TFixedPointSet, typename TMovingPointSet>
typename LabeledPointSetToPointSetMetricv4<TFixedPointSet, TMovingPointSet>
::MeasureType
LabeledPointSetToPointSetMetricv4<TFixedPointSet, TMovingPointSet>
::GetLocalNeighborhoodValue( const PointType & point, const LabelType & label ) const
{
  typename LabelSetType::const_iterator labelIt = std::find( this->m_CommonPointSetLabels.begin(), this->m_CommonPointSetLabels.end(), label );
  if( labelIt == this->m_CommonPointSetLabels.end() )
    {
    itkExceptionMacro( "Label not found in common label set" );
    }
  else
    {
    unsigned int labelIndex = labelIt - this->m_CommonPointSetLabels.begin();
    MeasureType value = this->m_PointSetMetricClones[labelIndex]->GetLocalNeighborhoodValue( point, label );
    return value;
    }
}

template<typename TFixedPointSet, typename TMovingPointSet>
void
LabeledPointSetToPointSetMetricv4<TFixedPointSet, TMovingPointSet>
::GetLocalNeighborhoodValueAndDerivative( const PointType & point,
  MeasureType &measure, LocalDerivativeType & localDerivative, const LabelType & label ) const
{
  typename LabelSetType::const_iterator labelIt = std::find( this->m_CommonPointSetLabels.begin(), this->m_CommonPointSetLabels.end(), label );
  if( labelIt == this->m_CommonPointSetLabels.end() )
    {
    itkExceptionMacro( "Label not found in common label set" );
    }
  else
    {
    unsigned int labelIndex = labelIt - this->m_CommonPointSetLabels.begin();
    this->m_PointSetMetricClones[labelIndex]->GetLocalNeighborhoodValueAndDerivative( point, measure, localDerivative, label );
    }
}

template<typename TFixedPointSet, typename TMovingPointSet>
typename LabeledPointSetToPointSetMetricv4<TFixedPointSet, TMovingPointSet>::FixedPointSetPointer
LabeledPointSetToPointSetMetricv4<TFixedPointSet, TMovingPointSet>
::GetLabeledFixedPointSet( const LabelType label ) const
{
  typename FixedPointSetType::Pointer fixedPointSet = FixedPointSetType::New();
  fixedPointSet->Initialize();

  typename FixedPointSetType::PointIdentifier count = NumericTraits<PointIdentifier>::Zero;

  typename FixedPointSetType::PointsContainerConstIterator It = this->m_FixedPointSet->GetPoints()->Begin();
  typename FixedPointSetType::PointDataContainerIterator ItD = this->m_FixedPointSet->GetPointData()->Begin();
  while( It != this->m_FixedPointSet->GetPoints()->End() )
    {
    if( label == ItD.Value() )
      {
      fixedPointSet->SetPoint( count++, It.Value() );
      }
    ++It;
    ++ItD;
    }

  return fixedPointSet;
}

template<typename TFixedPointSet, typename TMovingPointSet>
typename LabeledPointSetToPointSetMetricv4<TFixedPointSet, TMovingPointSet>::MovingPointSetPointer
LabeledPointSetToPointSetMetricv4<TFixedPointSet, TMovingPointSet>
::GetLabeledMovingPointSet( const LabelType label ) const
{
  typename MovingPointSetType::Pointer movingPointSet = MovingPointSetType::New();
  movingPointSet->Initialize();

  typename MovingPointSetType::PointIdentifier count = NumericTraits<PointIdentifier>::Zero;

  typename MovingPointSetType::PointsContainerConstIterator It = this->m_MovingPointSet->GetPoints()->Begin();
  typename MovingPointSetType::PointDataContainerIterator ItD = this->m_MovingPointSet->GetPointData()->Begin();
  while( It != this->m_MovingPointSet->GetPoints()->End() )
    {
    if( label == ItD.Value() )
      {
      movingPointSet->SetPoint( count++, It.Value() );
      }
    ++It;
    ++ItD;
    }

  return movingPointSet;
}

template<typename TFixedPointSet, typename TMovingPointSet>
void
LabeledPointSetToPointSetMetricv4<TFixedPointSet, TMovingPointSet>
::DetermineCommonPointSetLabels()
{
  this->m_FixedPointSetLabels.clear();
  this->m_MovingPointSetLabels.clear();
  this->m_CommonPointSetLabels.clear();

  if( this->m_FixedPointSet->GetNumberOfPoints() > 0 )
    {
    typename FixedPointSetType::PointDataContainerIterator It = this->m_FixedPointSet->GetPointData()->Begin();
    while( It != this->m_FixedPointSet->GetPointData()->End() )
      {
      if( std::find( this->m_FixedPointSetLabels.begin(), this->m_FixedPointSetLabels.end(), It.Value() ) == this->m_FixedPointSetLabels.end() )
        {
        this->m_FixedPointSetLabels.push_back( It.Value() );
        }
      ++It;
      }
    }
  std::sort( this->m_FixedPointSetLabels.begin(), this->m_FixedPointSetLabels.end() );

  if( this->m_MovingPointSet->GetNumberOfPoints() > 0 )
    {
    typename MovingPointSetType::PointDataContainerIterator It = this->m_MovingPointSet->GetPointData()->Begin();
    while( It != this->m_MovingPointSet->GetPointData()->End() )
      {
      if( std::find( this->m_MovingPointSetLabels.begin(), this->m_MovingPointSetLabels.end(), It.Value() ) == this->m_MovingPointSetLabels.end() )
        {
        this->m_MovingPointSetLabels.push_back( It.Value() );
        }
      ++It;
      }
    }
  std::sort( this->m_MovingPointSetLabels.begin(), this->m_MovingPointSetLabels.end() );

  LabelSetType uncommonLabelSet;

  typename LabelSetType::const_iterator itF;
  for( itF = this->m_FixedPointSetLabels.begin(); itF != this->m_FixedPointSetLabels.end(); ++itF )
    {
    if( std::find( this->m_MovingPointSetLabels.begin(), this->m_MovingPointSetLabels.end(), *itF ) != this->m_MovingPointSetLabels.end() )
      {
      this->m_CommonPointSetLabels.push_back( *itF );
      }
    else
      {
      uncommonLabelSet.push_back( *itF );
      }
    }

  if( uncommonLabelSet.size() > 0 )
    {
    itkWarningMacro( "The label sets are not bijective." );
    }
}

/** PrintSelf method */
template<typename TFixedPointSet, typename TMovingPointSet>
void
LabeledPointSetToPointSetMetricv4<TFixedPointSet, TMovingPointSet>
::PrintSelf( std::ostream & os, Indent indent ) const
{
  Superclass::PrintSelf( os, indent );

  os << "Fixed label set: ";
  typename LabelSetType::const_iterator itF;
  for( itF = this->m_FixedPointSetLabels.begin(); itF != this->m_FixedPointSetLabels.end(); ++itF )
    {
    os << *itF << " ";
    }
  os << std::endl;

  os << "Moving label set: ";
  typename LabelSetType::const_iterator itM;
  for( itM = this->m_MovingPointSetLabels.begin(); itM != this->m_MovingPointSetLabels.end(); ++itM )
    {
    os << *itM << " ";
    }
  os << std::endl;
}

} // end namespace itk

#endif