본문 바로가기
Medical Imaging/Preprocess

HD-CTBET 툴을 사용하여 CT에서 skull stripping하는 방법

by ngool 2025. 6. 4.

뇌 영상 처리에서 Skull Stripping(두개골 제거)은 정합, 분할, 분석의 첫 단계입니다.

 

이번 포스팅에서는 HD-BET을 기반으로 만들어진 CT 영상 특화 Skull Stripping 도구, HD-CTBET을 사용하여 뇌 CT 영상에서 skull stripping을 수행하는 방법을 소개하겠습니다.

 

자세한 내용은 아래 페이지를 참고하시기 바랍니다.

https://github.com/CAAI/HD-CTBET

 

GitHub - CAAI/HD-CTBET: MRI brain extraction tool

MRI brain extraction tool. Contribute to CAAI/HD-CTBET development by creating an account on GitHub.

github.com


HD-CTBET 사용 방법

1. GitHub에서 코드 클론

git clone https://github.com/CAAI/HD-CTBET
cd HD-CTBET

 

2. Python 패키지로 설치 (editable mode)

pip install -e .

 

3. hd-ctbet 명령어로 CLI 실행이 가능한지 확인

hd-ctbet --help

 

만약 hd-ctbet: command not found 오류가 날 경우, ~/.local/bin을 시스템 PATH에 등록하면 해결될 가능성이 높습니다.

export PATH=$HOME/.local/bin:$PATH

 

4. Skull stripping 수행 (CLI)

hd-ctbet -i INPUT_FOLDER -o OUTPUT_FOLDER -device 0 -mode fast -tta 0

 

5. [OPTIONAL] Skull stripping 수행 (Python)

좀 더 확장해서 파이프라인을 작성하고 싶다면 아래와 같이 파이썬에서 실행할 수도 있습니다.

import subprocess

hd_ctbet_path = "/home/ykseo/.local/bin/hd-ctbet"
subprocess.run([
    hd_ctbet_path,
    '-i', '/brain_extraction/ct/input',
    '-o', '/brain_extraction/ct/output',
    '-device', '0',
    '-mode', 'fast',    # fast/accurate
    '-tta', '0'         # Test-Time Augmentation (0=OFF, 1=ON, 정확도↑ 속도↓)
])

결과 예시


성능이 그닥 좋아 보이지 않네요..

Skull이 완전히 날아가지 않고 경계 부분이 어느 정도 남아있는 모습입니다.

아래쪽 방향으로 갈 수록 심하네요.

 

CT brain extraction 툴은 여러 개 있는 것 같으니 다른 것도 확인해봐야 할 것 같습니다.