Auto rotating Optical Coherence Tomography images

Hi everyone, I’ve been trying to produce a macro that can automatically straighten an OCT scan such as the 1st pic into the 2nd pic. oct1 oct2

This is can be done manually via the Image>Transform>Rotate… option. I’ve tried to implement a macro posted in this thread: Is it possible to minimise Feret Angle automatically? but perhaps due to my image not being one solid object, it isn’t able to minimise the angle automatically. Any Ideas? Thanks.