Permalink
Browse files

added documentation to imageservice

  • Loading branch information...
1 parent 59c9238 commit 2ece1d41e99f17479e47289711b5bb11456abd5d @nicholsn committed Jul 25, 2012
Showing with 19 additions and 15 deletions.
  1. +19 −15 niquery/imageservice.py
View
@@ -64,21 +64,25 @@ def get_data(self):
returns a numpy array of a loaded image
"""
data = self.image.get_data()
- return np.array(data)
-
- def get_slice(self,axis, slice):
- global slab
- data = np.array(self.image.get_data())
- slab = np.empty(data.shape,data.dtype)
- print axis
- if axis is axis:
- slab = np.squeeze(data[slice,:,:])
- print True
- elif axis is 'coronal':
- slab = np.squeeze(data[:,slice,:])
- elif axis is 'axial':
- slab = np.squeeze(data[:,:,slice])
- return slab
+ return np.asarray(data)
+
+ def get_slice(self,axis, slice, volume=1):
+ """
+ returns a 2D slice from a 3D volume
+ """
+ if len(self.image.get_shape()) > 3:
+ return "The loaded data has more than 3 dimensions. Please use the get_4d_slice method"
+ else:
+ data = np.asarray(self.image.get_data())
+ slab = np.empty(data.shape,data.dtype)
+ if axis == 'coronal':
+ slab = np.squeeze(data[slice,:,:])
+ elif axis == 'axial':
+ slab = np.squeeze(data[:,slice,:])
+ elif axis == 'sagital':
+ slab = np.squeeze(data[:,:,slice])
+ return slab
+
def main():
imageservice=ImageService()

0 comments on commit 2ece1d4

Please sign in to comment.