Linking fish habitat to their population dynamics