@@ -10,15 +10,12 @@ def load_nifty_volume_as_4d_array(filename):
1010 """
1111 Read a nifty image and return a dictionay storing data array, origin,
1212 spacing and direction.\n
13- output['data_array'] 4d array with shape [C, D, H, W];\n
14- output['spacing'] a list of spacing in z, y, x axis;\n
15- output['direction'] a 3x3 matrix for direction.
13+ output['data_array'] 4D array with shape [C, D, H, W];\n
14+ output['spacing'] A list of spacing in z, y, x axis;\n
15+ output['direction'] A 3x3 matrix for direction.
1616
17- Args:
18- filename (str): the input file name
19-
20- Returns:
21- dict: a dictionay storing data array, origin, spacing and direction.
17+ :param filename: (str) The input file name
18+ :return: A dictionay storing data array, origin, spacing and direction.
2219 """
2320 img_obj = sitk .ReadImage (filename )
2421 data_array = sitk .GetArrayFromImage (img_obj )
@@ -43,15 +40,12 @@ def load_rgb_image_as_3d_array(filename):
4340 """
4441 Read an RGB image and return a dictionay storing data array, origin,
4542 spacing and direction. \n
46- output['data_array'] 3d array with shape [D, H, W]; \n
43+ output['data_array'] 3D array with shape [D, H, W]; \n
4744 output['spacing'] a list of spacing in z, y, x axis; \n
4845 output['direction'] a 3x3 matrix for direction.
4946
50- Args:
51- filename (str): the input file name
52-
53- Returns:
54- dict: a dictionay storing data array, origin, spacing and direction.
47+ :param filename: (str) The input file name
48+ :return: A dictionay storing data array, origin, spacing and direction.
5549 """
5650 image = np .asarray (Image .open (filename ))
5751 image_shape = image .shape
@@ -74,14 +68,11 @@ def load_rgb_image_as_3d_array(filename):
7468
7569def load_image_as_nd_array (image_name ):
7670 """
77- load an image and return a 4D array with shape [C, D, H, W],
71+ Load an image and return a 4D array with shape [C, D, H, W],
7872 or 3D array with shape [C, H, W].
7973
80- Args:
81- image_name (str): the image name.
82-
83- Returns:
84- dict: a dictionay storing data array, origin, spacing and direction.
74+ :param filename: (str) The input file name
75+ :return: A dictionay storing data array, origin, spacing and direction.
8576 """
8677 if (image_name .endswith (".nii.gz" ) or image_name .endswith (".nii" ) or
8778 image_name .endswith (".mha" )):
@@ -97,10 +88,9 @@ def save_array_as_nifty_volume(data, image_name, reference_name = None):
9788 """
9889 Save a numpy array as nifty image
9990
100- Args:
101- data (numpy.ndarray): a numpy array with shape [Depth, Height, Width].\n
102- image_name (str): the ouput file name.\n
103- reference_name (str): file name of the reference image of which
91+ :param data: (numpy.ndarray) A numpy array with shape [Depth, Height, Width].
92+ :param image_name: (str) The ouput file name.
93+ :param reference_name: (str) File name of the reference image of which
10494 meta information is used.
10595 """
10696 img = sitk .GetImageFromArray (data )
@@ -114,12 +104,11 @@ def save_array_as_nifty_volume(data, image_name, reference_name = None):
114104
115105def save_array_as_rgb_image (data , image_name ):
116106 """
117- Save a numpy array as rgb image
107+ Save a numpy array as rgb image.
118108
119- Args:
120- data (numpy.ndarray): a numpy array with shape [3, H, W] or
121- [H, W, 3] or [H, W]. \n
122- image_name (str): the output file name.
109+ :param data: (numpy.ndarray) A numpy array with shape [3, H, W] or
110+ [H, W, 3] or [H, W].
111+ :param image_name: (str) The output file name.
123112 """
124113 data_dim = len (data .shape )
125114 if (data_dim == 3 ):
@@ -133,10 +122,9 @@ def save_nd_array_as_image(data, image_name, reference_name = None):
133122 """
134123 Save a 3D or 2D numpy array as medical image or RGB image
135124
136- Args:
137- data (numpy.ndarray): a numpy array with shape [D, H, W] or [C, H, W]. \n
138- image_name (str): the output file name. \n
139- reference_name (str): file name of the reference image of which
125+ :param data: (numpy.ndarray) A numpy array with shape [3, H, W] or
126+ [H, W, 3] or [H, W].
127+ :param reference_name: (str) File name of the reference image of which
140128 meta information is used.
141129 """
142130 data_dim = len (data .shape )
@@ -158,16 +146,14 @@ def rotate_nifty_volume_to_LPS(filename_or_image_dict, origin = None, direction
158146 '''
159147 Rotate the axis of a 3D volume to LPS
160148
161- Args:
162- filename_or_image_dict (str): filename of the nifty file (str) or image dictionary
149+ :param filename_or_image_dict: (str) Filename of the nifty file (str) or image dictionary
163150 returned by load_nifty_volume_as_4d_array. If supplied with the former,
164151 the flipped image data will be saved to override the original file.
165152 If supplied with the later, only flipped image data will be returned.\n
166- origin (list or tuple): the origin of the image.\n
167- direction (list or tuple): the direction of the image.
153+ :param origin: (list/ tuple) The origin of the image.
154+ :param direction: (list or tuple) The direction of the image.
168155
169- Returns:
170- dict: a dictionary for image data and meta info, with ``data_array``,
156+ :return: A dictionary for image data and meta info, with ``data_array``,
171157 ``origin``, ``direction`` and ``spacing``.
172158 '''
173159
0 commit comments