Download hmc/reference/scripts/check_e_sources.py from neurodeskorg/webapps: direct link, hf CLI and curl.
- Browser
- Download file 2.13 kB
-
https://huggingface.co/datasets/neurodeskorg/webapps/resolve/main/hmc/reference/scripts/check_e_sources.py
- Command line
-
hf download hf://datasets/neurodeskorg/webapps/hmc/reference/scripts/check_e_sources.py
-
curl -L -o check_e_sources.py https://huggingface.co/datasets/neurodeskorg/webapps/resolve/main/hmc/reference/scripts/check_e_sources.py
2.13 kB
| """Check that the e1-e3 work folders hold every source that pack_hmc.py needs.""" | |
| import hashlib | |
| import json | |
| from pathlib import Path | |
| R = Path("/var/tmp/dwi-hmc/runs") | |
| QW = "work/qsiprep_26_1_wf/sub_107_wf/dwi_preproc_dir_AP_wf/qsiprep_hmcsdc_wf" | |
| HMC = QW + "/dwi_hmc_wf" | |
| IMAGES = [ | |
| "b0_hmc_wf/initial_template/average.nii", | |
| "b0_hmc_wf/iterative_alignment_000/averaged_images/average.nii", | |
| "b0_hmc_wf/iterative_alignment_000/invert_average/average_trans.nii", | |
| "b0_hmc_wf/iterative_alignment_001/averaged_images/average.nii", | |
| "b0_hmc_wf/iterative_alignment_001/invert_average/average_trans.nii", | |
| "b0_template_mask/synthstrip_wf/mask_brain/masked_brain.nii", | |
| "b0_template_mask/synthstrip_wf/mask_to_original_grid/average_trans_trans_mask_trans.nii.gz", | |
| "dwi_model_hmc_wf/b0_mean/b0_mean.nii.gz", | |
| "dwi_model_hmc_wf/calculate_cnr/SHORELine_CNR.nii.gz", | |
| ] | |
| def sha(p): | |
| return hashlib.sha256(p.read_bytes()).hexdigest() | |
| ref = { | |
| f.name: sha(f) | |
| for f in sorted((R / "qsiprep-r1" / QW / "split_dwis").glob("vol.*.nii")) | |
| } | |
| for name in ("r1", "e1", "e2", "e3"): | |
| run = R / f"qsiprep-{name}" | |
| split = { | |
| f.name: sha(f) for f in sorted((run / QW / "split_dwis").glob("vol.*.nii")) | |
| } | |
| missing = [s for s in IMAGES if not (run / HMC / s).exists()] | |
| man = json.loads((run / "collected/manifest.json").read_text()) | |
| preds = [ | |
| p["path"] for v in man["model_iterations"].values() for p in v["predictions"] | |
| ] | |
| pmiss = [p for p in preds if not Path(p).exists()] | |
| imgs = {s: sha(run / HMC / s) for s in IMAGES if (run / HMC / s).exists()} | |
| print(name, "split", len(split), "equal r1", split == ref, "missing", missing) | |
| print(" preds", len(preds), "missing", len(pmiss), pmiss[:2]) | |
| print( | |
| " ", | |
| {s.split("/")[-1] + ":" + s.split("/")[-3]: v[:8] for s, v in imgs.items()}, | |
| ) | |
| o = run / "out/sub-107/dwi" | |
| print(" out", sorted(p.name for p in o.iterdir()) if o.exists() else "no out") | |
| print(" collected", sorted(p.name for p in (run / "collected").iterdir())) | |
| print(" manifest keys", list(man.keys())) | |