Skip to content

Change TWeights in MultiLabelSTAPLE to double - #1

Open
thomas-albrecht wants to merge 1 commit into
mainfrom
STAPLE-double-weights
Open

Change TWeights in MultiLabelSTAPLE to double#1
thomas-albrecht wants to merge 1 commit into
mainfrom
STAPLE-double-weights

Conversation

@thomas-albrecht

Copy link
Copy Markdown
Owner

The WeightsType TWeights of the itk::MultiLabelSTAPLEImageFilter is set to the default float.
There is one big problem with this.

In itkMultiLabelSTAPLEImageFilter.hxx
the frequency of the labels is computed like this:

      for (in.GoToBegin(); !in.IsAtEnd(); ++in)
      {
        ++(this->m_PriorProbabilities[in.Get()]);
      }

where this->m_PriorProbabilities is of course an Array<WeightsType>.
Ultimately, the code is doing this:

float frequency = 0;
for (int i = 0; i < num_voxels; i++) {
  frequency = frequency + 1
}

At some point, precisely at $frequency = 2^{24} = 16,777,216$, the float representation of frequency and frequency + 1 is the same and the counter stops increasing. This number easily reached in even a modest 3D images, and the whole m_PriorProbabilities will be completely wrong.

Short of changing the ITK code, a simple fix is to use double as the weights type, which raises this problematic threshold to $2^{53} = 9,007,199,254,740,992$ (over 9 quadrillion).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant