cognitive function and pain