Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull request 52 (ReducedFullSampler) updated #1064

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

N-Dekker
Copy link
Member

@N-Dekker N-Dekker commented Mar 1, 2024


Other pull requests from Mathias, currently at https://github.com/SuperElastix/elastix/pulls?q=is%3Apr+is%3Aclosed+author%3AMathiasPolfliet+:

The code of the original pull requests was locally retrieved by git fetch origin pull/ID/head:BRANCH_NAME, as described at GitHub Docs - Checking out pull requests locally. The other two new branches based on those old pull request are:

Mathias Polfliet and others added 4 commits February 29, 2024 22:14
This is necessary in order to make the CI at github.com/SuperElastix/elastix happy.
This work was originally "based" on commit 2ec22d0 "VER: increased to 4.900 in preparation of release", 2018-03-19. The code is adjusted to make it compile on the latest revision of the main branch:

- IsInside is replaced with IsInsideInWorldSpace
- Obsolete typedefs inherited from Superclass2 were removed
- An elxOverrideGetSelfMacro call is added
Fixed macos-12/clang warnings like:
> warning: 'SelectNewSamplesOnUpdate' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]

From https://my.cdash.org/viewBuildError.php?type=1&buildid=2507427
Comment on lines +48 to +55
InputImageIndexType index = this->GetCroppedInputImageRegion().GetIndex();
index[ReducedInputImageDimension] = 0;
InputImageSizeType size = this->GetCroppedInputImageRegion().GetSize();
size[ReducedInputImageDimension] = 1;
InputImageRegionType region;
region.SetIndex(index);
region.SetSize(size);
InputImageIterator iter(inputImage, region);
Copy link
Member Author

@N-Dekker N-Dekker Mar 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be the essential part, compared to the "non-reduced" FullSampler. Looks like seven lines of code could be simplified to the following three:

    InputImageRegionType region = this->GetCroppedInputImageRegion();
    region.SetIndex(ReducedInputImageDimension, 0);
    region.SetSize(ReducedInputImageDimension, 1);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MathiasPolfliet @mstaring @stefanklein Is it really necessary for the "reduced" sampler to do index[ReducedInputImageDimension] = 0? Or would it be sufficient to only adjust the size, and leave the index alone?

I'm asking, because ITK allows specifying start index of the buffered region of an image to be non-zero. So an index value of zero may be outside the buffered region. Trying to retrieve samples outside the buffered region might cause crashes. So if it is sufficient for the "reduced" sampler to only adjust the size, I would prefer to leave the index alone.

Another option might be something like:

// Instead of index[ReducedInputImageDimension] = 0
index[ReducedInputImageDimension] = bufferedRegion.GetIndex(ReducedInputImageDimension);

But I wonder if that's useful/necessary.

@N-Dekker
Copy link
Member Author

N-Dekker commented Mar 3, 2024

Comparing ReducedFullSampler and FullSampler, based on the original code at commit 2ec22d0 "VER: increased to 4.900 in preparation of release" (2018):

elxReducedFullSampler.h vs elxFullSampler.h

  • 124 vs 123 lines
  • Added ReducedInputImageDimension (unnecessary in this case, it seems)

elxReducedFullSampler.h vs elxFullSampler.h

  • 27 vs 32 lines
  • no relevant changes (just "nothing")

elxReducedFullSampler.cxx vs elxFullSampler.cxx

  • 18 vs 22 lines
  • no relevant changes (just elxInstallMacro)

itkReducedFullSampler.h vs itkFullSampler.h

  • 124 vs 126 lines
  • Added ReducedInputImageDimension and InputImageSizeType
  • No ThreadedGenerateData

itkReducedFullSampler.hxx vs itkFullSampler.hxx

  • 150 vs 246 lines
  • No ThreadedGenerateData
  • Essential added code at the begin of GenerateData:
  InputImageIndexType index = this->GetCroppedInputImageRegion().GetIndex();
  index[ ReducedInputImageDimension ] = 0;
  InputImageSizeType size = this->GetCroppedInputImageRegion().GetSize();
  size[ ReducedInputImageDimension ] = 1;
  InputImageRegionType region;
  region.SetIndex( index );
  region.SetSize( size );
  InputImageIterator iter( inputImage, region );

@N-Dekker
Copy link
Member Author

N-Dekker commented Mar 3, 2024

Some comments:

  • There appears a lot of code duplication between this component and FullSampler. Can't ReducedFullSampler be written in terms of FullSampler? The FullSampler has very much been improved recently (commit b7029ed, 4d028f7 etc.). It would have been a pity if those improvements won't be included with ReducedFullSampler.
  • I would rename it "ReducedDimensionFullSampler", on order to be consistent with the existing "ReducedDimensionBSplineInterpolator". OK?
  • Does this suggest a reduced-dimension version for Grid, Random, RandomCoordinate, and RandomSparseMask, as well?

@MathiasPolfliet @mstaring @stefanklein Instead of this proposed new component, "ReducedFullSampler" wouldn't it be better to just add support for a new parameter, (ReduceDimension "true"), to the existing FullSampler? And possibly also to other existing sampler components?

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