Streaming for itkResampleImageFilter in case of linear transforms#469
Conversation
|
The individual commits are in https://github.com/romangrothausmann/ITK/commits/streaming4ResampleImageFilter_incr, in particular with romangrothausmann@2cdc0ee the streaming tests are now expected to pass, which they do not (https://circleci.com/gh/InsightSoftwareConsortium/ITK/3182?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link): In It is unclear to me where this problem comes from and would need some help on this. @thewtex @blowekamp any idea? |
dzenanz
left a comment
There was a problem hiding this comment.
Looks good after a glance. Someone else should look too!
|
Many thanks @dzenanz for taking a look. I would say this should not be merged until the extent problem is solved and the tests pass as expected. |
thewtex
left a comment
There was a problem hiding this comment.
@romangrothausmann a few comments inline.
fb647ca to
d4e1177
Compare
Squashed commit of the following: commit ae8eb62 Author: Roman Grothausmann <romangrothausmann@users.noreply.github.com> Date: Thu Feb 7 15:56:57 2019 +0100 BUG: corrections from @thewtex in PR InsightSoftwareConsortium#469 commit 2cdc0ee Author: Roman Grothausmann <romangrothausmann@users.noreply.github.com> Date: Tue Feb 5 12:56:06 2019 +0100 Revert "ENH: new test are expected to fail as long as:": This reverts commit e5d421f. because InsightSoftwareConsortium#392 (replaced InsightSoftwareConsortium#84) was merged in bc4e197 commit d62cbd4 Author: Roman Grothausmann <romangrothausmann@users.noreply.github.com> Date: Fri Sep 28 11:55:28 2018 +0200 BUG: use ITK_NULLPTR instead of identityTransform commit 9c0b04c Author: Roman Grothausmann <romangrothausmann@users.noreply.github.com> Date: Thu Sep 27 12:45:50 2018 +0200 ENH: add transform to ImageAlgorithm::EnlargeRegionOverBox commit 5b8eaf5 Author: Roman Grothausmann <romangrothausmann@users.noreply.github.com> Date: Tue Sep 25 14:07:50 2018 +0200 ENH: use ImageAlgorithm::EnlargeRegionOverBox instead commit d6c44ea Author: Roman Grothausmann <romangrothausmann@users.noreply.github.com> Date: Thu Aug 30 13:05:31 2018 +0200 ENH: Method to compute InputRequestedRegion in itkResampleImageFilter based on suggestions from: https://discourse.itk.org/t/why-resampleimagefilter-is-slow/1217/14 https://itk.org/pipermail/insight-users/2015-April/051877.html and code from itkImageAlgorithm of v4.13.1 (based on commit 8510db2)
|
Many thanks @thewtex for taking the close look. Applied your suggestions (which all make sense) but the tests still fail for me locally with the same errors. |
|
The test also fail on CI. @thewtex any ideas would could be wrong with the current SDI implementation? |
|
@romangrothausmann I'll dig in... 🏊♂️ |
|
Tests are passing now 🎉 :-) There were a few tricky items:
should be
|
d4e1177 to
b1ee7d7
Compare
b1ee7d7 to
edd815b
Compare
|
Wow, many thanks @thewtex. I'm trying to understand your changes. |
True, many thanks for catching that, otherwise romangrothausmann@29db4ad#diff-43a4309c31e92fe375554af9562c5a04R221 makes no sense. So
is covered by: Not sure about |
It is possible to pull and create a new branch, then do the diff.
I will add some comments to the code... |
You could try using git cherry-pick: git checkout 29db4ad
git cherry-pick edd815bThese should give you only the relevant changes from Matt's commit. |
|
How do you know "that last sampled chunk is completely outside the input"? Is that the reason to remove itkPipelineMonitorImageFilter in itkResampleImageTest7.cxx (https://github.com/InsightSoftwareConsortium/ITK/compare/d4e1177f61ba9414f1ae05852384e5ec4e725c31..b1ee7d74b5fc198ea61c4cd6d54d18a14ad58b4c#diff-dfa5983cf67253ce0e03aca56a207db2L23)? |
|
Thanks @thewtex, @dzenanz for your feedback. Have to check |
I spent a bit of time debugging the test :-).
It needed to be removed because the PipelineMonitorImageFilter did not behave correctly with a generated image as an input versus a reader or another filter as the input on multiple runs -- the buffered region was being reset to zeros. Since we already covered it in ResampleImageTest2Streaming, I removed it in ResampleImageTest7. |
Hm, I see, but shouldn't we include some means to check that the streaming actually happens? In a case where the streaming does not happen (though requested) the test would always succeed. |
Good point. I will add a check at the end of streaming to verify that we are setting the requested region to a smaller chunk when streaming. |
Method to compute InputRequestedRegion in itk::ResampleImageFilter based on suggestions from: https://discourse.itk.org/t/why-resampleimagefilter-is-slow/1217/14 https://itk.org/pipermail/insight-users/2015-April/051877.html and code from itkImageAlgorithm of v4.13.1 (based on commit 8510db2) Co-authored-by: Matt McCormick <matt.mccormick@kitware.com>
|
Next patch set adds the streaming verification to |
edd815b to
6093197
Compare
|
Way cool! Many, many thanks @thewtex for catching the problem with A comment of yours ITK/Modules/Filtering/ImageGrid/test/itkResampleImageTest2Streaming.cxx Lines 158 to 160 in 6093197 makes me wonder if I do not understand the pipeline execution correctly. Aren't we asking for 8 divisions in: which according the the docs (https://itk.org/Doxygen/html/classitk_1_1PipelineMonitorImageFilter.html#a1e98d85c0f5a7ca8814a9c0d9d0d59e4) would have to match those checked by VerifyInputFilterExecutedStreaming as long as the argument is not given as a negative number?Your comment however sounds like the monitor-filter is doing the requesting not the writer. Does monitor->VerifyInputFilterExecutedStreaming(4) override writer1->SetNumberOfStreamDivisions(8)?
How did you come up with the values in these checks: ITK/Modules/Filtering/ImageGrid/test/itkResampleImageTest7.cxx Lines 134 to 137 in 6093197 I assume they are dependent on the input image extents and the chosen splitter ( |
Yes, this was a bug -- fixed here :-): #654
This is the final request region chunk -- yes, indeed, this is determined by the logic in |
This PR corresponds to #82, rebased onto master, meant for inclusion into master (ITK-5 instead of ITK-4.13.1).
Inspired by the discussion of the discourse topic Why ResampleImageFilter is slow?, this PR is a try to realize streaming for at least some transforms for the
itkResampleImageFilter.It is one of the most general filters in ITK and much used and the essential one for isotropic down-sampling of large datasets. Especially for that case it would be very helpful to have streaming capabilities, in order to generate smaller datasets for filters that cannot stream. Apart from a reduced memory footprint, streaming can lead to a significant speed up because a chunk can be processed while the next is loaded from disc, drastically reducing loading latencies.
As the filter is of great importance, some new tests cases (failing with the current implementation) were created (#392, now merged) that are expected to succeed (partially) when streaming is realized. With these tests (and possibly #468) master is equipped for testing the new contributions to
itkResampleImageFilter, which enable streaming for linear transforms. Manual test showed that streaming already works but (even for an identity transform) the result's extent is larger than without streaming.Therefore,
itkResampleImageTest7is meant to compare the current results ofitkResampleImageFilterin various cases with those obtained when streaming is employed. There, a reader and a writer are avoided to rule out any interference concerning streaming limitations in respect to a chosen file format.itkResampleImageTest2sis based onitkResampleImageTest2adjusted to write MHAs, which support streaming.