I’m writing a script and trying to apply HardenTransform on a segmentation node as follows.
seg_node.SetAndObserveTransformNodeID(transformNodeID.GetID())
seg_node.HardenTransform()
This works fine for most samples but sometimes the script crashes (triggered at HardenTransform) and yields the following error:
Unable to allocate 227735193073740 elements of size 4 bytes.
"Slicer has caught an application error, please save your work and restart.\n\nThe application has run out of memory. Increasing swap size in system settings or adding more RAM may fix this issue.\n\nIf you have a repeatable sequence of steps that causes this message, please report the issue following instructions available at https://slicer.org\n\n\nThe message detail is:\n\nException thrown in event: std::bad_alloc"
transformNode has slizeSizeMM = [float(15.0), float(15.0)]
but when changing to e.g. slizeSizeMM = [float(13.0), float(13.0)]
the script works fine on the samples triggering this error.
From what I’ve read earlier there are some issues related to HardenTransform on large segmentations (see Harden transform on large segmentation hangs 3D Slicer). In my case, the underlying segmentations seem to be “longer” than normal relative to other samples.
Is there any effective more general solution to this issue?
OS: Ubuntu 20.04
Slicer3D version: 5.2.2
Thanks!