资源简介
这是一个python的肺结节分割代码,是我最近修改过的代码,希望给初学者提供参考,为大家提供思路。欢迎大家下载参考。希望可以给大家帮助
代码片段和文件信息
#-*-coding:utf-8-*-
import numpy as np
import os
import math
def padding_patch(nodule_arr label_arr cube_size_xy=64 cube_size_z=32):
nodule_64_arr = np.ones((cube_size_z cube_size_xy cube_size_xy) dtype=np.float32)
nodule_64_arr *= -1000.0
label_64_arr = np.zeros((cube_size_z cube_size_xy cube_size_xy) dtype=np.float32)
#nodule_arr = normalization(nodule_arr)
origin_shape = nodule_arr.shape
padding_z = (cube_size_z - origin_shape[0])/2
padding_y = (cube_size_xy - origin_shape[1])/2
padding_x = (cube_size_xy - origin_shape[2])/2
edge_z_min = math.floor(padding_z)
edge_z_max = edge_z_min + origin_shape[0]
edge_y_min = math.floor(padding_y)
edge_y_max = edge_y_min + origin_shape[1]
edge_x_min = math.floor(padding_x)
edge_x_max = edge_x_min + origin_shape[2]
print([edge_z_min edge_z_max edge_y_min edge_y_max edge_x_min edge_x_max])
nodule_64_arr[edge_z_min:edge_z_max edge_y_min:edge_y_max edge_x_min:edge_x_max] = nodule_arr
label_64_arr[edge_z_min:edge_z_max edge_y_min:edge_y_max edge_x_min:edge_x_max] = label_arr
return nodule_64_arr label_64_arr
def normalization(nodule_arr max_val = 600.0 min_val = -1000.0):
nodule_arr = nodule_arr.astype(“float32“)
nodule_arr = (nodule_arr - min_val) / (max_val - min_val)
nodule_arr = np.clip(nodule_arr 0 1)
return nodule_arr
if __name__ == ‘__main__‘:
lidc_path = “E:/LIDC-IDRI/“
origin_path = os.path.join(lidc_path “four_radiologist_samples/“)
padding_path = os.path.join(lidc_path “lidc_padding_samples/“)
origin_sample_path = os.path.join(origin_path “sample/“)
origin_label_path = os.path.join(origin_path “label/“)
padding_sample_path = os.path.join(padding_path “sample/“)
padding_label_path = os.path.join(padding_path “label/“)
nodule_list = os.listdir(origin_sample_path)
for nodule_file in nodule_list:
lidc_id = nodule_file.split(“_“)[0]
nodule_id = nodule_file.split(“_“)[2]
label_file = lidc_id + “_label_“ + nodule_id
nodule_arr = np.load(os.path.join(origin_sample_path nodule_file))
label_arr = np.load(os.path.join(origin_label_path label_file))
label_arr = label_arr.astype(“float32“)
if nodule_arr.shape[0] <=32 and max(nodule_arr.shape[1] nodule_arr.shape[2]) <= 64:
nodule_64_arr label_64_arr = padding_patch(nodule_arr label_arr)
assert nodule_64_arr.shape == label_64_arr.shape
#print(nodule_64_arr.shape)
np.save(os.path.join(padding_sample_path nodule_file) nodule_64_arr)
np.save(os.path.join(padding_label_path label_file) label_64_arr)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\
文件 31 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\README.md
目录 0 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\dataset\
目录 0 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\dataset\__pycache__\
文件 1872 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\dataset\__pycache__\data_padding.cpython-36.pyc
文件 7843 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\dataset\__pycache__\data_process.cpython-36.pyc
文件 729 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\dataset\__pycache__\find_scans.cpython-36.pyc
文件 1068 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\dataset\__pycache__\plot_nodule.cpython-36.pyc
文件 2776 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\dataset\data_padding.py
文件 11702 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\dataset\data_process.py
文件 958 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\dataset\find_max_size.py
文件 873 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\dataset\find_scans.py
文件 954 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\dataset\padding_test.py
文件 1160 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\dataset\plot_nodule.py
文件 1440 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\dataset\result_process.py
文件 1020 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\dataset\sample_3d_lidc.py
文件 1027 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\dataset\seg_train_val.py
目录 0 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\model\
文件 524368 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\model\LIDC-IDRI-0001_label_0.npy
文件 524368 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\model\LIDC-IDRI-0001_sample_0.npy
目录 0 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\model\__pycache__\
文件 10203 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\model\__pycache__\model.cpython-36.pyc
文件 1148 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\model\__pycache__\utils.cpython-36.pyc
目录 0 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\model\checkpoint\
目录 0 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\model\checkpoint\unet3d_la
目录 0 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\model\checkpoint\unet3d_la
文件 247 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\model\checkpoint\unet3d_la
文件 3063 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\model\checkpoint\unet3d_la
文件 2257298 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\model\checkpoint\unet3d_la
文件 3063 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\model\checkpoint\unet3d_la
文件 2257298 2018-03-27 02:48 LIDC-IDRI-nodule-segmentation-master\model\checkpoint\unet3d_la
............此处省略32个文件信息
相关资源
- wxPython实战(中文版).pdf244916
- Python opencv库 cv2.so (armhf版
- 基于Python网络爬虫毕业论文.doc
- 基于Python智联招聘牌爬虫+本科毕业论
- think python中文版
- python编程从入门到实践.zip237878
- Python思维导图.
- 用Python解决数据结构与算法问题
- 《Python地理空间分析指南》文字版P
- 深度学习入门:基于python的理论与实
- Python数据分析与机器学习-新闻分类任
-
廖雪峰教程合集ja
vasc ript+Python+g - FlaskWeb开发:Python基于Web应用开发实战
- python语言介绍与交流PPT
- 高德API + Python 解决租房问题_实验楼
- 流畅的Python (Fluent Python) Kindle英文
- Python 高性能编程
- Django for beginners 2.1
- python3.6 API
- addin_assistant
- 基于Python的深度学习
- 深入浅出Python机器学习-段小手
- Learn Python3 The Hard Way(英文版PDF)(无
- 结巴分词Python代码
- OpenCV-Python-Tutorial-中文版段立辉译
- Python爬虫开源项目代码
- [全套55讲]-鱼C论坛小甲鱼Python课后题
- python并行编程pdf
- Python 程序设计思想与方法 陆朝俊 电
- OpenCV Python 计算机视觉 官方教程中文
评论
共有 条评论