Have you still got the original ecu, or the one that came with your new engine?
You could try swapping them over but if it were an ecu issue, I’d expect it to be an all the time issue, not every now n then.
Perhaps even look at the fuel pump, might be dodgy. Might not be delivering enough fuel, or cutting out occasionally. I’m just throwing ideas at you now, lol