【问题标题】:Reshape .nii images in such a way the depth must be first以深度必须优先的方式重塑 .nii 图像
【发布时间】:2021-09-25 15:18:26
【问题描述】:

我是医学图像的新手,遇到了一种名为 .nii/.nii.gz 的文件格式:(576, 576, 88) > 高宽576,深88。

但我想以这种方式重新定位 (88, 576, 576)。即深度必须是第一位的。在这种情况下,如何使用 python 实现这一点? 我做了如下;

import nibabel as nib
img1 = nib.load("path_to_the_file/segmentation.nii.gz")
img1.shape

(576, 576, 88)

我确实喜欢这个;

img1 = np.reshape(img1, (88, 576, 576))

但未能成功。

【问题讨论】:

标签: python python-3.x numpy numpy-slicing nifti


【解决方案1】:

如果您按原样可视化数据(使用此初始形状 (576, 576, 88)),您会在矢状平面(垂直于左右轴)上获得切片。

如果您想要横向平面上的图像(垂直于颅尾轴),您应该这样做:

img_transverse_plane = np.moveaxis(img1, -1, 0)

在日冕平面上:

img_coronal_plane = np.moveaxis(img1, 0, -1)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多