What’s new in 1.6.0 🎉🎉#
New losses: AUC-Margin Loss, Matthews Correlation Coefficient (MCC) Loss
AUC-Margin Loss:
AUCMarginLossdirectly optimizes the AUROC metric via a margin-based surrogate loss, enabling training workflows that target ranking-based performance rather than calibration-based objectives.Matthews Correlation Coefficient (MCC) Loss:
MCCLossprovides a differentiable loss based on the Matthews Correlation Coefficient, which accounts for all four confusion matrix categories and is particularly robust for imbalanced segmentation tasks.
New metric:
EmbeddingCollapseMetricdetects representational collapse in learned embedding spaces, useful for self-supervised and contrastive learning workflows in medical imaging to monitor embedding quality during training.Whole Slide Image (WSI) reader now supports retrieval at a specified microns-per-pixel (MPP) resolution. This simplifies multi-scanner workflows where consistent physical-space resolution is required regardless of scanner magnification levels.
Nested dot-notation key access in
ConfigParser.Auto3DSeg algo serialization migrated from pickle to JSON for improved security and portability.
Global coordinates support in spatial crop transforms. These now support global coordinate mode, allowing crops to be specified in world/global coordinates rather than local image indices, improving interoperability with physical-space annotations.
SoftclDiceLossandSoftDiceclDiceLossenhanced withDiceLoss-compatible APIVariable expansion hardening has been added to the nnUNet app to eliminate code injection attacks when composing shell command lines, addressing concerns in GHSA-rghg-q7wp-9767.
NumpyReaderhas been updated with anallow_pickleboolean argument to enable/disable pickle loading from.npy/.npzfiles. This was previously hard-coded to be enabled, but is now defined by this argument and disabled by default. This addresses GHSA-qxq5-qhx6-94qw.
MONAI now tests for Python 3.10 onwards, having dropped version 3.9 which is now out of support. PyTorch 2.8 onwards is now supported only, older versions will likely continue to function.
Nested Dot-Notation Access in ConfigParser#
ConfigParser now supports nested dot-notation key access, making it easier to read and override deeply nested configuration values programmatically.
For example, accessing a value from the parser with parser["network_def.in_channels"] can instead be parser.network_def.in_channels. This feature supports indexing and assignment, eg. parser.network_def.in_channels[0] = 4 or parser.A.B["C"] = 99.
Auto3DSeg: JSON-Based Algo Serialization#
Auto3DSeg algorithm objects are now serialized using JSON instead of pickle. This removes a class of security risks associated with pickle deserialization and improves cross-environment portability of saved algorithm states. Using pickle for serialization can be re-enabled by setting the environment variable MONAI_ALLOW_PICKLE to 1 or the equivalent true value.
This was implemented to address GHSA-qxq5-qhx6-94qw.
SoftclDiceLoss / SoftDiceclDiceLoss API Alignment#
SoftclDiceLoss and SoftDiceclDiceLoss now accept the same arguments as DiceLoss, including reduction, smooth_nr, smooth_dr, and batch parameters, enabling drop-in use alongside the standard Dice loss in existing pipelines.
Minor Changes#
DiceMetricandDiceHelperaccept additional parameters for finer control of reduction behaviorExtractDataKeyFromMetaKeydnow works withMetaTensorinputsConvertToMultiChannelBasedOnBratsClassessupports configurable GD-enhancing tumor labelTorchScript compatibility: replaced
Tensor | Noneunion syntax withOptional[Tensor]across network modulesCrossAttentionBlockis now only instantiated whenwith_cross_attention=True, reducing memory overheadGlobalMutualInformationLossbin centers andLocalNormalizedCrossCorrelationLosskernels registered as buffers for correct device handling (#8869,#8818)NibabelReaderavoids eager C-order memory copies, reducing peak RAM usage for large NIfTI filesFixed
align_cornersmismatch inAffineTransformFixed nested
Composemap_itemsbehaviour in forward and inverse pathsFixed anchor centering on grid cells in detection
Fixed multi-axis shear transform matrix composition
Fixed
JukeboxLossswappedinput_amplitude/target_amplitudeargumentsFixed memory leak in
optional_importtraceback handlingFixed
RandSimulateLowResolutionto useF.interpolateinstead ofset_track_metaFixed GPU memory leak when checking image/label device in engine utilities
Fixed
AutoencoderKLproj_attn→out_projkey remapping inload_old_state_dictFixed incorrect
truncatedparameter inmake_gaussian_kernelaffectingLocalNormalizedCrossCorrelationLossFixed
compute_shape_offsetnon-tuple indexing for PyTorch ≥ 2.9Auto3DSeg: fixed incorrect device resolution in analyzer and precomputed crop handling
Replaced
np.random.*global calls withnp.random.RandomStateinstances for reproducibilityReplaced
BaseExceptionwithExceptionacross the codebase