[英]How can I save an image (nii.gz) after reshaping it?
我正在嘗試在重塑圖像后對其進行重塑,但在保存方法方面我遇到了問題。 這是我要運行的代碼:
import nibabel as nib
import numpy as np
from nibabel.testing import data_path
import os
example_filename = os.path.join("D:/Volumes convertidos LIDC", 'teste001converted.nii.gz')
img = nib.load('teste001converted.nii.gz')
print (img.shape)
newimg = img.get_fdata().reshape(332,360*360)
print (newimg.shape)
nib.save(newimg, os.path.join("D:/Volumes convertidos LIDC", 'test4d.nii.gz'))
我收到一個錯誤:
AttributeError: 'numpy.ndarray' object has no attribute 'to_filename'
有什么辦法可以解決
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.