【医学影像数据处理】nii 数据格式文件操作汇总


大部分医学领域数据存储的都是 dicom格式,但是对于 CT等一类的序号图像,就需要多个 dicom文件独立存储,最终构成一个序列series,这样存储就太过于复杂了。

nifti(Neuroimaging Informatics Technology Initiative,神经影像信息技术倡议)格式,是一种用于神经影像学数据存储和交换的标准格式。它的设计旨在简化神经影像学数据的处理、分析和共享,并且广泛应用于医学影像、脑成像和神经科学研究领域。

NIfTI数据格式基于扩展名为“.nii”“.nii.gz”的文件。可以直接在itk-snap软件中打开,直接拖动就可以了。这块我也在我博客的其他文章进行了展示,感兴趣的可以直接去我的主页查看。

这里我们就简单介绍下,nii格式文件的读取和保存,目前发现有很多方法,反倒是有些乱了。整理汇总下,方便有这部分需求的伙伴。

注意:如果图像是用作AI训练,普通的png图像和原始的nii存储的3维转2维数据都是可以使用的。一般都会在前处理阶段对数据做归一化操作,所以&#x

### SPM Cluster Non-Maximum Suppression Implementation and Usage In the context of object detection algorithms, SPM (Spatial Pyramid Matching) cluster non-maximum suppression (NMS) plays a crucial role in refining detected objects by eliminating redundant bounding boxes. The process ensures that only the most accurate predictions are retained. #### Understanding NMS within Object Detection Algorithms Non-maximum suppression is an essential post-processing step used to filter out overlapping bounding boxes based on confidence scores. In traditional implementations, this involves comparing each box with others and suppressing those below a certain threshold or overlap ratio[^1]. For SPM-based methods: - **Input**: A set of candidate bounding boxes along with their associated class probabilities. - **Output**: Filtered list of high-confidence detections without significant overlaps. The specific implementation for SPM clusters can be described as follows: ```python def spm_cluster_nms(detections, iou_threshold=0.5): """ Apply spatial pyramid matching cluster non-maximum suppression Args: detections (list): List of tuples containing bbox coordinates and score Format: [(x_min, y_min, x_max, y_max, score), ...] iou_threshold (float): Intersection over Union threshold Returns: list: Indices of selected bboxes after applying nms """ if not detections: return [] # Convert input into numpy array for easier manipulation dets = np.array(detections) # Sort indices according to decreasing order of scores sorted_indices = np.argsort(-dets[:, 4]) keep = [] while len(sorted_indices) > 0: last = len(sorted_indices) - 1 i = sorted_indices[last] keep.append(i) # Compute IoU between current box and remaining ones xx1 = np.maximum(dets[i, 0], dets[sorted_indices[:last], 0]) yy1 = np.maximum(dets[i, 1], dets[sorted_indices[:last], 1]) xx2 = np.minimum(dets[i, 2], dets[sorted_indices[:last], 2]) yy2 = np.minimum(dets[i, 3], dets[sorted_indices[:last], 3]) w = np.maximum(0, xx2 - xx1 + 1) h = np.maximum(0, yy2 - yy1 + 1) intersection_area = w * h area_a = (dets[i, 2] - dets[i, 0] + 1) * (dets[i, 3] - dets[i, 1] + 1) area_b = (dets[sorted_indices[:last], 2] - dets[sorted_indices[:last], 0] + 1) * ( dets[sorted_indices[:last], 3] - dets[sorted_indices[:last], 1] + 1) union_areas = area_a + area_b - intersection_area ious = intersection_area / union_areas # Remove all elements whose IOUs exceed the provided threshold sorted_indices = sorted_indices[np.where( ious <= iou_threshold)[0]] return [int(idx) for idx in keep] ``` This code snippet demonstrates how one might implement SPM-cluster-specific NMS logic tailored towards enhancing performance when dealing with clustered features extracted through Spatial Pyramid Matching techniques.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

钱多多先森

你的鼓励,是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值