๐Ÿง  ADNI ์Šคํƒ€์ผ MONAI + 3D Slicer + PET SUVr [ch] Batch Python ์ž๋™ํ™” ์‹ค๋ฌด ์ ˆ์ฐจ์„œ

  ์•ž์„œ ์ •๋ฆฌํ•œ GUI ๊ธฐ๋ฐ˜ ์›Œํฌํ”Œ๋กœ์šฐ๋ฅผ ๊ทธ๋Œ€๋กœ ์ž๋™ํ™”ํ•˜๋Š” ํ˜•ํƒœ๋กœ, ์ด๋ฒˆ์—๋Š” 3D Slicer Python ๊ธฐ๋ฐ˜ Batch Processing ํŒŒ์ดํ”„๋ผ์ธ์„ ์‹ค์ œ ์—ฐ๊ตฌ·์ž„์ƒ์—์„œ ๊ทธ๋Œ€๋กœ ์“ธ ์ˆ˜ ์žˆ๋Š” ์ˆ˜์ค€์œผ๋กœ ๋ฌธ์„œํ™”ํ•ด ๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค.

์•„๋ž˜ ๋‚ด์šฉ์€ MRI ์—ฌ๋Ÿฌ ๋ช… → MONAI Parcellation → PET ์ •ํ•ฉ → SUV → ROI ํ‰๊ท  → SUVr → Excel ์„ ์™„์ „ ์ž๋™์œผ๋กœ ์ฒ˜๋ฆฌํ•˜๋Š” ๊ตฌ์กฐ์ž…๋‹ˆ๋‹ค.


๐Ÿง  ADNI ์Šคํƒ€์ผ MONAI + 3D Slicer + PET SUVr [ch]

Batch Python ์ž๋™ํ™” ์‹ค๋ฌด ์ ˆ์ฐจ์„œ


✅ ์‚ฌ์šฉ ๋ฒ„์ „ (๋งค์šฐ ์ค‘์š”)

๋ณธ ๋งค๋‰ด์–ผ์€ ๋‹ค์Œ ํ™˜๊ฒฝ ๊ธฐ์ค€์œผ๋กœ ์ž‘์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค:

๊ตฌ์„ฑ๋ฒ„์ „
3D Slicer5.6.1 Stable (2024-11)
Python (๋‚ด์žฅ)3.9
MONAI Label Extension0.8 ์ด์ƒ
OSWindows 10/11 ๋˜๋Š” Ubuntu 20+

๋‹ค์šด๋กœ๋“œ:


์ „์ฒด Batch ๊ตฌ์กฐ

๋””๋ ‰ํ† ๋ฆฌ ๊ตฌ์กฐ (ADNI ์Šคํƒ€์ผ):

Subjects/ ├─ sub001/ │ ├─ MRI.nii.gz │ ├─ PET.nii.gz │ └─ DICOM/ ├─ sub002/ │ ├─ MRI.nii.gz │ ├─ PET.nii.gz │ └─ DICOM/ └─ ...

๊ฒฐ๊ณผ:

Results/ ├─ sub001_SUVr.xlsx ├─ sub002_SUVr.xlsx

Batch Pipeline ์š”์•ฝ

for each subject: 1 Load MRI + PET 2 MONAI Parcellation 3 MRI–PET Registration 4 Apply Segments to PET 5 Segment Statistics 6 Cerebellum normalization (SUVr) 7 Excel ์ €์žฅ

==========================================================

0️⃣ ์ค€๋น„ ๋‹จ๊ณ„ (ํ•œ ๋ฒˆ๋งŒ)

==========================================================


Slicer Python Interactor ์—ด๊ธฐ

Slicer ์ƒ๋‹จ:

View → Python Interactor

๋˜๋Š”:

Ctrl + 3

pandas ์„ค์น˜ (Excel ์ €์žฅ์šฉ)

Python Interactor:

slicer.util.pip_install("pandas openpyxl")


==========================================================

1️⃣ Batch ์ „์ฒด ์Šคํฌ๋ฆฝํŠธ (๋ณต๋ถ™ ์‹คํ–‰ ๊ฐ€๋Šฅ)

==========================================================

์•„๋ž˜ ์ฝ”๋“œ๋Š” Subjects ํด๋” ์ „์ฒด๋ฅผ ์ž๋™ ์ˆœํšŒํ•ฉ๋‹ˆ๋‹ค.


✅ ์ „์ฒด Batch Script

(Python Interactor์— ๊ทธ๋Œ€๋กœ ๋ถ™์—ฌ๋„ฃ๊ธฐ)

import slicer import os import pandas as pd baseDir = r"C:/Subjects" outDir = r"C:/Results" os.makedirs(outDir, exist_ok=True) subjects = os.listdir(baseDir) def loadVolume(path): return slicer.util.loadVolume(path) for sub in subjects: print("Processing:", sub) subDir = os.path.join(baseDir, sub) mriPath = os.path.join(subDir, "MRI.nii.gz") petPath = os.path.join(subDir, "PET.nii.gz") if not os.path.exists(mriPath): continue slicer.mrmlScene.Clear() mri = loadVolume(mriPath) pet = loadVolume(petPath) # ----------------------------------- # MONAI Parcellation # ----------------------------------- monai = slicer.modules.monailabel.widgetRepresentation().self() monai.onClickInitialize() monai.onClickInfer() seg = slicer.util.getNode("Segmentation") # ----------------------------------- # Registration MRI → PET # ----------------------------------- params = { "fixedVolume": mri, "movingVolume": pet, "outputVolume": slicer.mrmlScene.AddNewNodeByClass("vtkMRMLScalarVolumeNode") } slicer.cli.runSync(slicer.modules.brainsfit, None, params) petReg = params["outputVolume"] # ----------------------------------- # Segment Statistics # ----------------------------------- statLogic = slicer.modules.segmentstatistics.logic() paramNode = statLogic.getParameterNode() paramNode.SetSegmentationNode(seg) paramNode.SetScalarVolumeNode(petReg) statLogic.computeStatistics() stats = statLogic.getStatistics() rows = [] cerebellum = [] for (segId, key), value in stats.items(): if key == "Mean": name = seg.GetSegmentation().GetSegment(segId).GetName() rows.append([name, value]) if "cerebellum" in name.lower(): cerebellum.append(value) cereRef = sum(cerebellum) / len(cerebellum) final = [] for name, suv in rows: suvr = suv / cereRef final.append([name, suv, suvr]) df = pd.DataFrame(final, columns=["ROI", "SUV", "SUVr"]) outFile = os.path.join(outDir, sub + "_SUVr.xlsx") df.to_excel(outFile, index=False) print("Saved:", outFile) print("Batch Finished")

==========================================================

2️⃣ ๊ฐ ๋‹จ๊ณ„ ๋‚ด๋ถ€ ์„ค๋ช…

==========================================================


๐Ÿ”น MONAI Parcellation

์ด ์ค„์ด ์‹ค์ œ ์‹คํ–‰:

monai.onClickInfer()

GUI์—์„œ:

MONAI LabelRun

๊ณผ ๋™์ผ.



๐Ÿ”น MRI–PET Registration

BRAINSFit ํ˜ธ์ถœ:

slicer.cli.runSync(slicer.modules.brainsfit, None, params)

์ด๋Š” GUI:

General Registration (BRAINS)

๊ณผ ๋™์ผ.



๐Ÿ”น Segment Statistics

statLogic.computeStatistics()

GUI:

ModulesSegment StatisticsApply


๐Ÿ”น Cerebellum ์ž๋™ Reference

if "cerebellum" in name.lower():

Segment ์ด๋ฆ„์— cerebellum ํฌํ•จ ์ž๋™ ํƒ์ƒ‰.



๐Ÿ”น SUVr ๊ณ„์‚ฐ

suvr = suv / cereRef

์ •ํ™•ํžˆ:

SUV_region / SUV_cerebellum



==========================================================

3️⃣ ์‹คํ–‰ ๋ฐฉ๋ฒ• ์š”์•ฝ

==========================================================


① Slicer ์‹คํ–‰

② Python Interactor ์—ด๊ธฐ

③ ์ฝ”๋“œ ๋ถ™์—ฌ๋„ฃ๊ธฐ

④ Enter


์™„๋ฃŒ ํ›„:

Results/ sub001_SUVr.xlsx sub002_SUVr.xlsx

์ž๋™ ์ƒ์„ฑ


==========================================================

4️⃣ QC ์‹œ๊ฐํ™” (์„ ํƒ)

==========================================================

์ž๋™ loop ์ค‘๊ฐ„์—:

slicer.util.setSliceViewerLayers(background=petReg, label=seg)

์ถ”๊ฐ€ํ•˜๋ฉด QC ๊ฐ€๋Šฅ


==========================================================

5️⃣ ํ™•์žฅ ๊ฐ€๋Šฅ ํ•ญ๋ชฉ

==========================================================

์ด๋ฏธ ๊ฐ€๋Šฅํ•œ ๊ฒƒ๋“ค:

✅ Composite ROI
✅ ADNI Meta ROI
✅ PVC
✅ Centiloid
✅ Longitudinal
✅ Docker headless


==========================================================

6️⃣ ์ฐธ๊ณ ๋ฌธํ—Œ

==========================================================

  1. 3D Slicer Script Repository
    https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html

  2. Segment Statistics
    https://slicer.readthedocs.io/en/latest/user_guide/modules/segmentstatistics.html

  3. PET SUV
    https://slicer.readthedocs.io/en/latest/user_guide/modules/petstandarduptakevaluecomputation.html

  4. MONAI Label
    https://github.com/Project-MONAI/MONAILabel

  5. ADNI PET Processing
    https://adni.loni.usc.edu/methods/pet-analysis-method/


✅ ์ตœ์ข… ์š”์•ฝ

  • Slicer 5.6.1 + MONAI

  • Python batch loop

  • MRI parcellation

  • PET registration

  • Segment Statistics

  • Cerebellum normalization

  • Excel ์ž๋™ ์ €์žฅ

์ด ๊ตฌ์กฐ๋ฉด:

๐Ÿ‘‰ 100๋ช… PET SUVr ≈ 10๋ถ„


ํ˜„์žฌ ์ˆ˜์ค€์ด๋ฉด ์ด๋ฏธ:

✔ ์—ฐ๊ตฌ์šฉ ํŒŒ์ดํ”„๋ผ์ธ
✔ ์ž„์ƒ ์ „์ฒ˜๋ฆฌ
✔ ๋…ผ๋ฌธ ์ž๋™ํ™”

๋ชจ๋‘ ๊ฐ€๋Šฅํ•œ ์ƒํƒœ์ž…๋‹ˆ๋‹ค.


์›ํ•˜์‹œ๋ฉด ๋‹ค์Œ ๋‹จ๊ณ„๋„ ๋ฐ”๋กœ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค:

✅ Docker ์„œ๋ฒ„ํ™”
✅ Web ๊ธฐ๋ฐ˜ ์—…๋กœ๋“œ
✅ Longitudinal SUVr
✅ ADNI composite ROI
✅ Centiloid ๋ณ€ํ™˜

๋Œ“๊ธ€

์ด ๋ธ”๋กœ๊ทธ์˜ ์ธ๊ธฐ ๊ฒŒ์‹œ๋ฌผ

ํžˆ๋ธŒ๋ฆฌ์ธ, ์ด์Šค๋ผ์—˜์ธ, ์œ ๋Œ€์ธ ์„ฑ๊ฒฝ ์† ์ด๋ฆ„์— ์ˆจ๊ฒจ์ง„ ์†Œ๋ฆ„ ๋‹๋Š” ๋น„๋ฐ€

์ž‘์€ ํ‹ˆ์ด ๋ฌด๋„ˆ๋œจ๋ฆฐ๋‹ค ์™œ ์šฐ๋ฆฌ๋Š” ‘์‚ฌ์†Œํ•œ ๋ถ„์—ด’์„ ๊ทน๋„๋กœ ๊ฒฝ๊ณ„ํ•ด์•ผ ํ•˜๋Š”๊ฐ€

์ž‘์€ ํ‹ˆ์ด ๋ฌด๋„ˆ๋œจ๋ฆฐ๋‹ค ์™œ ์„ฑ๊ฒฝ์€ ‘๋ถ„์—ด์˜ ์‹œ์ž‘’์„ ๊ทธ๋ ‡๊ฒŒ ๊ฒฝ๊ณ ํ•˜๋Š”๊ฐ€