]> gitweb.michael.orlitzky.com - spline3.git/blobdiff - util/view-mri-data.py
spline3.cabal: bump version to 1.0.2
[spline3.git] / util / view-mri-data.py
index 96fbfa57b23b0d07333f541ded8832c16b947dff..01bddbdcfc8d91aa24f6ae3156a5d57ccb985a69 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/python3
 
 """
 Display volumetric data from the Stanford Volume Data Archive. The
@@ -11,7 +11,7 @@ import sys
 
 def usage():
     binary = sys.argv[0]
-    print "Usage:", binary, "<data file>"
+    print(f"Usage: {binary} <data file>")
 
 if len(sys.argv) < 2:
     usage()
@@ -33,18 +33,19 @@ def cube_root(n):
 import numpy as np
 data = np.fromfile(sys.argv[1], dtype='>u2')
 
-original_data_length = 7143424
-multiplier = cube_root(len(data) / original_data_length)
+original_data_length = 109*256*256
+multiplier = cube_root(len(data) // original_data_length)
 data.shape = (109*multiplier, 256*multiplier, 256*multiplier)
 data = data.T
 
 # Display the data
-mlab.figure(bgcolor=(0, 0, 0), size=(1000, 1000))
+mlab.figure( bgcolor=(0,0,0), size=(1000,1000) )
 
+# Our data is scalar (grayscale), but not equally spaced in all
+# directions.
 src = mlab.pipeline.scalar_field(data)
-
-# Our data is not equally spaced in all directions:
 src.spacing = [1, 1, 1.5]
 src.update_image_data = True
-v = mlab.pipeline.volume(src, vmax=2500, vmin=1400)
+
+mlab.pipeline.volume(src, vmin=1400, vmax=2500)
 mlab.show()