Skip to content

Commit

Permalink
Merge pull request #42 from dave3d/UpdateSitkUtil
Browse files Browse the repository at this point in the history
update to use simpleitkutlities in pypi
  • Loading branch information
dave3d committed May 1, 2023
2 parents fe07dff + dde9eac commit 5123ea3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ dependencies:
- pip:
- pydicom
- vtk
- git+https://github.com/SimpleITK/SimpleITKUtilities.git@main
- simpleitkutilities
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ numpy>=1.24.0
SimpleITK>=2.2
vtk>=9.2.0
pydicom>=2.3
SimpleITKUtilities @ git+https://github.com/SimpleITK/SimpleITKUtilities.git@main
simpleitkutilities
33 changes: 33 additions & 0 deletions tests/test_sitkutils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#! /usr/bin/env python

import unittest
from SimpleITK.utilities.vtk import *
import vtk
import SimpleITK as sitk
import platform


class TestSitkUtils(unittest.TestCase):
def test_sitk2vtk(self):
print("Testing SimpleITK Utilities")
dims = [102, 102, 102]
img = sitk.GaussianSource(sitk.sitkUInt8, dims)
direction = [0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, -1.0]
img.SetDirection(direction)

vol = sitk2vtk(img)
self.assertTupleEqual(vol.GetDimensions(), tuple(dims))
print("\nAccessing VTK image")
val = vol.GetScalarComponentAsFloat(5, 5, 5, 0)
print(val)
self.assertAlmostEqual(val, 3.0)

if vtk.vtkVersion.GetVTKMajorVersion() >= 9:
print("\nDirection matrix")
print(vol.GetDirectionMatrix())
else:
print("VTK version < 9. No direction matrix")


if __name__ == "__main__":
unittest.main()

0 comments on commit 5123ea3

Please sign in to comment.