Skip to content

Commit

Permalink
add 3d masking test
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Tooley committed Apr 29, 2019
1 parent 8bee15a commit 7aa6acb
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
42 changes: 42 additions & 0 deletions testdata/integration/regression/mask_test_3d/create_3d_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python3

import numpy as np

from flannel import io as fio

image_shape = (140, 100, 60)
block_shape = (50, 40, 40)
block1_fixed_offset = (10, 10, 10)
block2_fixed_offset = (80, 10, 10)
block1_moved_offset = (10, 50, 10)
block2_moved_offset = (80, 50, 10)
mask_shape = (70, 100, 60)
mask_offset = (0, 0, 0)

def slice_from_offsets(shape, offset):
return tuple(slice(x, x+y) for x, y in zip(offset, shape))


def main():
"""Create 3D masking test data
"""

print("Saving fixed.image")
fixed = np.zeros(image_shape)
fixed[slice_from_offsets(block_shape, block1_fixed_offset)] = 1
fixed[slice_from_offsets(block_shape, block2_fixed_offset)] = 1
fio.save_image(fixed, "fixed.image")

print("Saving moved.image")
moved = np.zeros(image_shape)
moved[slice_from_offsets(block_shape, block1_moved_offset)] = 1
moved[slice_from_offsets(block_shape, block2_moved_offset)] = 1
fio.save_image(moved, "moved.image")

print("Saving mask.mask")
mask = np.zeros(image_shape)
mask[slice_from_offsets(mask_shape, mask_offset)] = 1
fio.save_mask(mask, "mask.mask")

if __name__ == "__main__":
main()
6 changes: 6 additions & 0 deletions testdata/integration/regression/mask_test_3d/nomask.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fixed=fixed.image
moved=moved.image
nodespacing=10
registered=registered_nomask.xdmf
map=map_nomask.xdmf
save_intermediate_frames=true
7 changes: 7 additions & 0 deletions testdata/integration/regression/mask_test_3d/withmask.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fixed=fixed.image
moved=moved.image
mask=mask.mask
nodespacing=10
registered=registered_withmask.xdmf
map=map_withmask.xdmf
save_intermediate_frames=true

0 comments on commit 7aa6acb

Please sign in to comment.