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

Test viz png #551

Merged
merged 7 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ jobs:
CIBW_ARCHS_MACOS: ${{ matrix.arch }}
CIBW_BEFORE_ALL_MACOS: |
python -m pip install cmake ninja setuptools
brew update
brew install libpng

CIBW_ENVIRONMENT_MACOS: |
CMAKE_OSX_ARCHITECTURES=${{ matrix.arch }}
CMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} CMAKE_PREFIX_PATH=/usr/local

run: python -m cibuildwheel --output-dir wheelhouse/cp${{ matrix.cibw_python }}-${{matrix.platform_id }}

Expand Down
4 changes: 2 additions & 2 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ $PYCMD test_segmentation.py $@
echo "Running utils tests"
$PYCMD test_utils.py $@

# echo "Running viz tests"
# $PYCMD test_viz.py $@
echo "Running viz tests"
$PYCMD test_viz.py $@

echo "Running bug tests"
$PYCMD test_bugs.py $@
Expand Down
78 changes: 2 additions & 76 deletions tests/test_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,59 +16,6 @@

import ants

class TestModule_surface(unittest.TestCase):

def setUp(self):
pass

def tearDown(self):
pass

def test_surf_example(self):
ch2i = ants.image_read( ants.get_ants_data("ch2") )
ch2seg = ants.threshold_image( ch2i, "Otsu", 3 )
wm = ants.threshold_image( ch2seg, 3, 3 )
wm2 = wm.smooth_image( 1 ).threshold_image( 0.5, 1e15 )
kimg = ants.weingarten_image_curvature( ch2i, 1.5 ).smooth_image( 1 )
wmz = wm2.iMath("MD",3)
rp = [(90,180,90), (90,180,270), (90,180,180)]
filename = mktemp(suffix='.png')
ants.surf( x=wm2, y=[kimg], z=[wmz],
inflation_factor=255, overlay_limits=(-0.3,0.3), verbose = True,
rotation_params = rp, filename=filename)

class TestModule_volume(unittest.TestCase):

def setUp(self):
pass

def tearDown(self):
pass

def test_vol_example(self):
ch2i = ants.image_read( ants.get_ants_data("mni") )
ch2seg = ants.threshold_image( ch2i, "Otsu", 3 )
wm = ants.threshold_image( ch2seg, 3, 3 )
kimg = ants.weingarten_image_curvature( ch2i, 1.5 ).smooth_image( 1 )
rp = [(90,180,90), (90,180,270), (90,180,180)]
filename = mktemp(suffix='.png')
result = ants.vol( wm, [kimg], quantlimits=(0.01,0.99), filename=filename)


class TestModule_render_surface_function(unittest.TestCase):

def setUp(self):
pass

def tearDown(self):
pass

def test_render_surface_function_example(self):
mni = ants.image_read(ants.get_ants_data('mni'))
mnia = ants.image_read(ants.get_ants_data('mnia'))
filename = mktemp(suffix='.html')
ants.render_surface_function(mni, mnia, alphasurf=0.1, auto_open=False, filename=filename)


class TestModule_plot(unittest.TestCase):

Expand All @@ -81,31 +28,10 @@ def tearDown(self):
pass

def test_plot_example(self):
filename = mktemp(suffix='.png')
for img in self.imgs:
ants.plot(img)


class TestModule_create_tiled_mosaic(unittest.TestCase):

def setUp(self):
img2d = ants.image_read(ants.get_ants_data('r16'))
img3d = ants.image_read(ants.get_ants_data('mni'))
self.imgs = [img2d, img3d]

def tearDown(self):
pass

def test_example(self):
img = ants.image_read(ants.get_ants_data('ch2')).resample_image((3,3,3))
p = ants.create_tiled_mosaic(img)

# test with output
outfile = mktemp(suffix='.png')
p = ants.create_tiled_mosaic(img, output=outfile)
ants.plot(img, filename=filename)

# rgb is not none
rgb = img.clone()
p = ants.create_tiled_mosaic(img, rgb=rgb)

if __name__ == '__main__':
run_tests()
Loading