简体   繁体   English

医学影像数据 - 如何将 .raw/mhd 转换为 Nifti/nii

[英]Medical Imaging Data - how to convert .raw/mhd to Nifti/nii

Is there a way in Python or any other language to convert .raw/mhd image data to Nifti/nii?有没有办法用 Python 或任何其他语言将 .raw/mhd 图像数据转换为 Nifti/nii?

I can load the .raw/mhd file in python via SimpleITK as in this post: Reading *.mhd/*.raw format in python我可以通过 SimpleITK 在 python 中加载 .raw/mhd 文件,如这篇文章所示: Reading *.mhd/*.raw format in python

import skimage.io as io
img = io.imread('file.mhd', plugin='simpleitk')

I am having a hard time exporting as nii with proper dimensions... would ideally use the header information in the original mhd file...我很难以适当的尺寸导出为 nii...理想情况下会使用原始 mhd 文件中的标题信息...

Thanks谢谢

You should be able to just do in with SimpleITK.您应该能够使用 SimpleITK。 You would do something like this:你会做这样的事情:

import SimpleITK as sitk

img = sitk.ReadImage("input.mhd")
sitk.WriteImage(img, "output.nii")

If you don't have SimpleITK in python, installing it as follows:如果python中没有SimpleITK,安装如下:

pip install SimpleITK pip 安装 SimpleITK

SimpleITK does its best effort of preserving all header information, although it's not perfect. SimpleITK 尽最大努力保留所有标头信息,尽管它并不完美。 Hopefully the voxel dimensions will be preserved.希望体素尺寸将被保留。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM