longitudinal/scripts_nnu/01_nnu_prepare_dataset.py
Furen Xiao 8c813db209 docs(readme): update project documentation and directory structure
Update README.md to include detailed project overview, environment
requirements, data sources, and a comprehensive directory layout.
Add nnU-Net pipeline documentation and directory descriptions.

Update .gitignore to exclude nnU-Net specific directories and add
new scripts directory for nnU-Net pipeline.

Add initial nnU-Net pipeline scripts.
2026-09-26 06:45:36 +08:00

27 lines
No EOL
889 B
Python

"""Build/rebuild the nnU-Net raw dataset (Dataset210_NTUH_T1C_PL) from rows jsonl.
rows: {key, pimg, label} where label is an absolute path to a 0/1 nifti mask.
Rebuilds imagesTr/labelsTr as symlinks and writes dataset.json.
Usage: python scripts_nnu/01_nnu_prepare_dataset.py --rows <rows.jsonl>
"""
import argparse
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from src.common import load_jsonl
from nnu_common import make_raw_dataset, raw_ds
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--rows", required=True, help="jsonl with {key, pimg, label}")
args = ap.parse_args()
rows = load_jsonl(args.rows)
n = make_raw_dataset(rows)
print(f"[nnu:prepare] {raw_ds()}: {n} cases", flush=True)
if __name__ == "__main__":
main()