左图:PET图像 中图:CT图像 右图:两图融合之后的图像
Reference:
四川大学华西医院PET-CT中心petct数据采集和处理的过程是怎么样的?
PET-CT怎样进行图像融合?
图像融合实现CT与PET图像的融合 OpenCV实现(附实验结果)
医学成像技术简介(CT,MRI等)及相关论坛、技术应用链接
基于深度学习的CT图像肺结节自动检测技术一——数据预处理(归一化,数据增强,数据标记)
实现:
import nibabel as nib
import cv2
import SimpleITK as sitk
import numpy as np
# 归一化
def MaxMinNormalizer(data):
data_max = np.max(data)
data_min = np.min(data)
data_normalize = (data - data_min) / (data_max - data_min)
return data_normalize
# 融合CT数据与PET数据
def Fusion(path_CT, path_PET):
image_CT = nib.load(path_CT).get_data()
image_CT = image_CT.astype(float)
image_CT_size = np.shape(image_CT)
# 归一化 CT
image_CT = MaxMinNormalizer(image_CT)
# 重采样后的PET全身图像
image_PET = nib.load(path_PET).get_data()
image_PET = image_PET.astype(float)
# 归一化 PET
image_PET = MaxMinNormalizer(image_PET)
# 融合比例
percent_list = []
for i in range(1, 10):
percent_list.append(i / 10)
# fusion CT , PET,
# percent_list=[0.1] # best performance
for percent in percent_list:
ImageFusion = np.zeros(image_CT_size)
for num in range(image_CT_size[2]):
image_CT_slice = image_CT[:, :, num]
image_PET_slice = image_PET[:, :, num]
# 按照比例融合数据
img_mix = cv2.addWeighted(image_CT_slice, percent, image_PET_slice, 1 - percent, 0)
ImageFusion[:, :, num] = img_mix
ImageFusion = np.transpose(ImageFusion, (2, 1, 0))
ImageFusionISO = sitk.GetImageFromArray(ImageFusion, isVector=False)
# 获取图像扫描及空间信息
input_PET_property = sitk.ReadImage(path_PET)
spacing = np.array(input_PET_property.GetSpacing())
direction = np.array(input_PET_property.GetDirection())
Origin = np.array(input_PET_property.GetOrigin())
# 重新把融合后的数据设置图像信息
ImageFusionISO.SetSpacing(spacing)
ImageFusionISO.SetOrigin(Origin)
ImageFusionISO.SetDirection(direction)
# 保存重采样后的数据
soffix_name = path_PET[-7:]
file_name = path_PET[:-19]
# savepath_name = file_name + '_modified_fusioin_0.6' + soffix_name
# savepath_name = file_name + 'CTPETFusioin_LINEAR_'+ str(percent) + soffix_name
savepath_name = file_name + 'CTPETFusioin_' + str(percent) + soffix_name
sitk.WriteImage(ImageFusionISO, savepath_name)
pass
def main():
name_list = ['CT', 'PET_Resample']
root = '/data/'
# CT全身图像数据路径
input_CT = root + name_list[0] + '.nii.gz'
# PET全身图像数据路径
input_PET = root + name_list[1] + '.nii.gz'
# 融合CT与PET
Fusion(input_CT, input_PET)
if __name__ == '__main__':
main()
Game Over~~~