配准
Requirements
os
argparse
json
glob
re
pydicom == 2.3.0
numpy == 1.22.4
itk == 5.2.1.post1
itk—elastix == 0.13.0
torch == 1.13.0a0+d321be6
Overview
配准功能和其它深度学习模块并列,实现了对于数据集中同一病人的多个CT影像之间的配准功能,并且输出图像之间的检测框的匹配情况。
- 首先筛选出同一个病人的多个影像图片,并根据tag:
AcquisitionDateTime
排序。 - 配准功能只会在相邻的两个图像之间进行(将时间较早的影响作为
fixed_image
,时间较晚的图像作为moving_image
),相关配准结果保存在pid-{}_elastix_step-{}
文件夹下(pid-{}
为该病人的tag:PatientID
,step-1
表示该病人的第一组相邻的图像)。 -
pid-{}_elastix_step-{}/match_results.json
中保存了该病人的第{}
组相邻的图像之间的检测框的配对情况。
{
'matched': [[noudle1, matched_nodule1], [nodule2, matched_nodule2], ...],
'missing': [],
'new': []
}
-
'matched'
表示匹配上的检测框。 -
'missing'
表示出现在fixed_image
上,而moving_image
上没有出现的检测框。 -
'new'
表示在moving_image
上新出现的检测框。
- 在匹配结果中,每一个检测框被表示为一个八维数组,如下所示:
# center为中心点坐标,diameter为长径,label_1为肺结节分类结果,label_2为结节良恶性分类结果
[center_x, center_y, center_z, diameter_x, diameter_y, diameter_z, label_1, label_2]
Usage
- 在执行配准功能之前需要确保已经产生了所有影像的检测结果,并且存在
.json
文件。 - 执行配准功能:
python ./elastix_processing.py -- job_data_root /path/to/job_data_root
-- elastix_params_affine /path/to/affine_params
-- elastix_params_bspline /path/to/bspline_params
-
job_data_root
,该参数的含义与深度学习任务相同。 -
elastix_params_affine
,配准中Affine方法的参数。 -
elastix_params_bspline
,配准中Bspline方法的参数。
- 配准结果统一保存在
/path/to/job_data_root/output/elastix
中。