Patch for edge case: moving block can be outside moving image domain #69
+14
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If distributed_piecewise_alignment_pipeline is called with a non-empty static_transform_list, the fixed block coordinates have to be transformed through all transforms in static_transform_list to determine the corresponding moving image block coordinates. When static_transform_list contains a transform, or a combination of transforms, that moves the moving image substantially, it is possible that a fixed image block will have no corresponding region in the moving image, that is, the corresponding moving image block would be entirely outside the moving image domain. Basically, this means the fixed image contains a region of data that the moving image does not (assuming the transforms in static_transform_list are correct).
To fix this, I added a hidden default flag to align.alignment_pipeline. If either fix or mov is None then the alignment_pipeline returns the identity transform. I also modified piecewise_align.distributed_piecewise_alignment_pipeline to check if any of the moving block end coordinates are negative. This would indicate that the region of moving image that corresponds to the fixed block is outside the moving image domain. In this case, instead of attempting (and failing) to read from the moving image zarr, we set mov to None. Everything else works the same way, but when alignment_pipeline sees mov=None, it immediately returns an identity transform.