[Discussion] Diagnostic tests exploring discretization, boundary effects, and null approximation in ALE
Hi! While preparing for GSoC and working with NiMARE locally (Python 3.13 + recent Pandas), I explored a few numerical edge cases in the ALE implementation and put together a small diagnostic test file (test_mathematical_fidelity.py) to better understand the behavior.
I focused on a few specific parts of the code:
1. Coordinate discretization (mm2vox in nimare/utils.py) The current implementation applies integer casting after the affine transform: ijk = np.dot(np.linalg.inv(affine), xyz)[:3].astype(int)
This appears to behave similarly to a floor operation for sub-voxel coordinates. In a small synthetic test (mapping a sub-voxel point in a 2mm grid), I observed a measurable spatial shift (~3–4 mm Euclidean deviation compared to a rounded mapping).
- I’d be interested to know whether this behavior is intentional for consistency, or if alternatives like rounding or interpolation have been considered for higher-resolution grids (e.g., 1.5mm).
2. Kernel behavior near mask boundaries (compute_ale_ma) In nimare/meta/utils.py, values outside the mask are zeroed: ma_values[~mask_data] = 0
In a simple edge-case setup (focus placed near the boundary of a small mask), I observed a substantial reduction in total retained mass within the mask (on the order of ~80–90% in this synthetic scenario).
- I’m not sure whether this reduction is expected as part of the modeling assumptions, or if renormalization is typically unnecessary in practice.
3. Approximate null computation (_compute_null_approximate) While examining the iterative histogram updates, I noticed discretization steps (e.g., integer casting / binning) within the convolution process. In a simplified simulation, repeated discretization introduced a small cumulative shift in the distribution tail (on the order of ~0.005 absolute difference after multiple iterations, compared to a rounded variant). I’d be interested to know whether this behavior has been evaluated relative to Monte Carlo-based null estimation.
I’ve implemented these checks as lightweight synthetic tests to explore behavior under controlled conditions (including sub-voxel coordinates and boundary cases).
I’d really appreciate guidance on:
- whether these observations align with expected design choices
- or if they point toward areas where robustness improvements might be useful Happy to share the test file or convert these into formal tests if this direction is helpful!