pub fn chisepnet_toolbox(
local_field_ppm: &[f64],
r2: ChiSepNetR2<'_>,
mask: &[u8],
grid: &Grid,
b0_dir: (f64, f64, f64),
b0_tesla: f64,
models: &ChiSepNetToolboxModels<'_>,
norm: &ChiSepNetNorm,
params: &ChiSepNetParams,
) -> Result<ChiSepMaps, OnnxError>Expand description
χ-sepnet by the authors’ route: the χ-separation toolbox v1.1.3’s chi_sepnet_general
(Chisep_script.m:177-194), recovered by black-box probing in licensed MATLAB R2023b
(QSM.rs#377; method in [crate::utils::chisep_frame]). Unlike chisepnet it takes no QSM:
- the local field, the R2 map and the mask go into the training frame
(
TrainingFrame: B0 along the third axis, 1 mm,interp3 'spline'/'linear'> 0.5); - the QSM channel is QSMnetME’s ([
crate::inversion::qsmnetme], whose field channel is χ-sepnet’s field channel too); - the R2′ channel is
(R2′/Dr − mean)/stdfor a measured R2′, or, given R2*, R2PRIMEnet’s raw z-scored output for(R2*/Dr − r2star_mean)/r2star_std. Neither is clipped: the toolbox clips its de-normalised R2′ (max(·, 0)) but feeds χ-sepnet the unclipped channel, and does not clip negative R2* before R2PRIMEnet (measured: the channels matched the unclipped forms to float32 rounding, 2 040 and 4 691 negative frame voxels). These are intermediates the route never returns, so QSM.rs’s rule against negative R2′ maps (applied byr2primenet) does not reach them; - every channel is 0 outside the frame mask; χ-sepnet runs on the whole frame;
χ± = max(std·y + mean, 0)inside the frame mask; - each map is resampled back onto the acquired grid (
interp3 'spline'), set to 0 where negative (the spline overshoots) and outside the mask.χ_total = χ+ − |χ−|.
local_field_ppm is in ppm (the toolbox takes Hz and divides by CF·1e-6; the same).
b0_tesla is only checked for ChiSepNetR2::R2Star: R2PRIMEnet is trained at 3 T and the
v1.1.3 toolbox has no 7 T network (v1.2’s R2PNET_7T.onnx is not available to us), so other
field strengths are refused unless ChiSepNetParams::ignore_field_mismatch is set.
Returns (χ+ ≥ 0, χ− ≤ 0, χ_total) in ppm on the acquired grid.