在python中讀取* .mhd / *。raw格式
最簡單的方法是使用SimpleITK(MedPy也將ITK用于.mhd / .raw文件)。命令
pip install SimpleITK
適用于許多python版本。要讀取.mhd /.raw,可以從kaggle使用此代碼
import SimpleITK as sitkimport numpy as np’’’This funciton reads a ’.mhd’ file using SimpleITK and return the image array, origin and spacing of the image.’’’def load_itk(filename): # Reads the image using SimpleITK itkimage = sitk.ReadImage(filename) # Convert the image to a numpy array first and then shuffle the dimensions to get axis in the order z,y,x ct_scan = sitk.GetArrayFromImage(itkimage) # Read the origin of the ct_scan, will be used to convert the coordinates from world to voxel and vice versa. origin = np.array(list(reversed(itkimage.Getorigin()))) # Read the spacing along each dimension spacing = np.array(list(reversed(itkimage.GetSpacing()))) return ct_scan, origin, spacing解決方法
誰能告訴我如何讀取包含python中的 .mhd / .raw文件的數據集的方式?
相關文章:
1. 詳解Android studio 動態(tài)fragment的用法2. 基于android studio的layout的xml文件的創(chuàng)建方式3. 編程語言PHP在Web開發(fā)領域的優(yōu)勢在哪?4. 解決Android studio xml界面無法預覽問題5. 什么是python的自省6. Spring Boot和Thymeleaf整合結合JPA實現分頁效果(實例代碼)7. 圖文詳解vue中proto文件的函數調用8. Android如何加載Base64編碼格式圖片9. Springboot Druid 自定義加密數據庫密碼的幾種方案10. Vue封裝一個TodoList的案例與瀏覽器本地緩存的應用實現

網公網安備