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.
33 lines
No EOL
1.6 KiB
Python
33 lines
No EOL
1.6 KiB
Python
"""Plan + preprocess the nnU-Net dataset (always --clean), then write the
|
|
subject-level splits_final.json: val = split_val cases, train = the rest
|
|
(all base + pseudo cases), same 5-fold content so -f 0 is the one we use.
|
|
|
|
Usage: python scripts_nnu/02_nnu_plan_preprocess.py --val data/manifests/split_val.jsonl [--npp 8]
|
|
"""
|
|
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 run, nnu_env, plan_preprocess_cmd, dataset_case_keys, write_splits, preproc_ds
|
|
|
|
|
|
def main():
|
|
ap = argparse.ArgumentParser()
|
|
ap.add_argument("--val", required=True, help="jsonl of internal-validation cases (subject-disjoint)")
|
|
ap.add_argument("--npp", type=int, default=8, help="preprocess processes")
|
|
ap.add_argument("--log", default=None)
|
|
args = ap.parse_args()
|
|
log = args.log or os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "logs", "nnu_plan.log")
|
|
run(plan_preprocess_cmd(args.npp), log, env=nnu_env())
|
|
val_keys = [r["key"] for r in load_jsonl(args.val)]
|
|
all_keys = dataset_case_keys()
|
|
assert all_keys, "raw dataset is empty; run 01_nnu_prepare_dataset.py first"
|
|
assert set(val_keys) <= set(all_keys), f"val keys not in dataset: {set(val_keys) - set(all_keys)}"
|
|
n_tr, n_va = write_splits(all_keys, val_keys)
|
|
print(f"[nnu:plan] splits_final.json written to {preproc_ds()}: train={n_tr} val={n_va}", flush=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |