本文整理汇总了Python中msct_image.Image.data[x,y,z]方法的典型用法代码示例。如果您正苦于以下问题:Python Image.data[x,y,z]方法的具体用法?Python Image.data[x,y,z]怎么用?Python Image.data[x,y,z]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msct_image.Image
的用法示例。
在下文中一共展示了Image.data[x,y,z]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_label_z
# 需要导入模块: from msct_image import Image [as 别名]
# 或者: from msct_image.Image import data[x,y,z] [as 别名]
def create_label_z(fname_seg, z, value):
"""
Create a label at coordinates x_center, y_center, z
:param fname_seg: segmentation
:param z: int
:return: fname_label
"""
fname_label = 'labelz.nii.gz'
nii = Image(fname_seg)
orientation_origin = nii.change_orientation('RPI') # change orientation to RPI
nx, ny, nz, nt, px, py, pz, pt = nii.dim # Get dimensions
# find x and y coordinates of the centerline at z using center of mass
from scipy.ndimage.measurements import center_of_mass
x, y = center_of_mass(nii.data[:, :, z])
x, y = int(round(x)), int(round(y))
nii.data[:, :, :] = 0
nii.data[x, y, z] = value
# dilate label to prevent it from disappearing due to nearestneighbor interpolation
from sct_maths import dilate
nii.data = dilate(nii.data, [3])
nii.setFileName(fname_label)
nii.change_orientation(orientation_origin) # put back in original orientation
nii.save()
return fname_label