In some places, people who were imprisoned and later acquitted because of actual innocence have been awarded cash compensation - I recall a figure of about $80,000/year. In one case in Texas, a man got well over $1,000,000. Seems like a lot, but I'm sure he would rather have had a couple decades of his life back.
I don't have any idea of whether or not this sort of cash compensation would apply to pre-trial incarceration.