def read_images_info(path):
for subdir, dirs, files in os.walk(path):
dcms = glob.glob(os.path.join(subdir, '*.dcm'))
if len(dcms) > 1:
slices = [dicom.read_file(dcm) for dcm in dcms]
slices.sort(key = lambda x: float(x.ImagePositionPatient[2]))
images = np.stack([s.pixel_array for s in slices], axis=0).astype(np.float32)
images = images + slices[0].RescaleIntercept
orig_shape = images.shape
inplane_scale = slices[0].PixelSpacing[0] / PIXEL_SPACING
inplane_size = int(np.rint(inplane_scale * slices[0].Rows / 2) * 2)
return orig_shape, inplane_size
prepare_data_for_submission.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录