"inhomogenous arrays" error when writing to matfile was caused by numpy version (we were at version 1.24.4, recommendations is numpy>=1.13.0, < 1.24). Reverting to numpy 1.23.5 resovled the error. Solution is to save to RAM instead of to a temp matfile, making the process independent of numpy versions.