DGN model bundles¶
HemiSpec v0.1.0 deploys trained generator checkpoints for inference. Model training is reference-only and is not a public workflow requirement.
ANS/RNS and the cross-hemispheric DGN framework originate from Wang et al. (2024); see Citation.
Current asset layout¶
assets/models/dgn/
├── outputs_bi_stable_L/
│ └── ckpts/
│ └── best_netG_L.pth # R_to_L target-left bundle
└── outputs_bi_stable_R/
└── ckpts/
└── best_netG_R.pth # L_to_R target-right bundle
Explicit direction filenames such as best_netG_R2L.pth and best_netG_L2R.pth are also supported and preferred when both naming styles exist.
The public bundle should contain only approved runtime assets. Subject-level reconstructions or training metrics must not be included.
Direction mapping¶
outputs_bi_stable_L = R_to_L = source right -> generated left
outputs_bi_stable_R = L_to_R = source left -> generated right
discover_local_dgn_bundles() implements this mapping for the API, CLI, and GUI.
Runtime contract¶
For one direction, the inference adapter:
- loads a preprocessed
*_GM_masked.nii.gzvolume; - applies the low-value inference mask;
- crops the source hemisphere;
- loads the matching generator checkpoint;
- predicts the target-hemisphere patch;
- pastes the prediction into the original whole-volume grid;
- saves a reconstructed NIfTI with the source affine/header.
The bilateral workflow runs both directions and combines target-side results.
Checkpoint format¶
Supported generator checkpoints may contain a direct state dictionary or a wrapper containing state_dict. The runtime loader normalizes supported formats before loading the generator architecture.
The expected single-channel patch shape is:
Crops¶
These constants are owned by package runtime code.
Thresholds¶
The thresholds serve different stages and must remain separately named and reported.
Output naming¶
Direction-specific reconstructed full volumes use:
The bilateral workflow then writes final hemisphere-specific metric maps under voxel_maps/.