Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你好,如何使用ANTs得到下面的这样的分割图? #6

Closed
FreshmanMa opened this issue Jun 1, 2023 · 4 comments
Closed

Comments

@FreshmanMa
Copy link

image
@iwuqing
Copy link
Owner

iwuqing commented Jun 1, 2023

我们采用了ANTsPyNet (https://github.com/ANTsX/ANTsPyNet) 这个第三方库进行自动分割。具体我们调用了其antspynet.utilities.deep_atropos。关于这个function的说明可以在这里找:https://antsx.github.io/ANTsPyNet/docs/build/html/utilities.html#applications

@iwuqing iwuqing closed this as completed Jun 2, 2023
@FreshmanMa
Copy link
Author

FreshmanMa commented Jun 4, 2023

吴博士,你好,我尝试去用了antspynet,但是没弄出来,能否提供详细的脚本 和 以及这两个Dice and IoU指标该怎么整?刚读研不太懂,一直学习这篇文章。感谢谢!264x264x264目前我没跑动。我用的下面的代码,我不知道对不对。我用的下采样后的132x132x132的MRI.nii.gz,然后再3Dslicer上查看是这样,颜色跟你论文中的也不一样。
import ants import antspynet file_path = './671855.nii.gz'
image = ants.image_read(file_path)
segmentation_result = antspynet.utilities.deep_atropos(image, do_preprocessing=True)['segmentation_image']
ants.image_write(segmentation_result, "./segmentation_671855.nii.gz")

image

@iwuqing
Copy link
Owner

iwuqing commented Jun 7, 2023

我们论文里面的图像是采用itk-snap进行显示的。从你的结果来看,应该是对的。另外关于IOU和dice指标的计算网上有比较多的实现,以下是一个参考代码

import numpy as np

def iou(mask1, mask2):
    intersection = np.logical_and(mask1, mask2).sum()
    union = np.logical_or(mask1, mask2).sum()

    iou_score = intersection / union
    return iou_score

def dice_coefficient(mask1, mask2):
    intersection = np.logical_and(mask1, mask2).sum()
    total = mask1.sum() + mask2.sum()

    dice = (2.0 * intersection) / total
    return dice

@FreshmanMa
Copy link
Author

FreshmanMa commented Jun 8, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants