Functional optical detection based on pH dependent fluorescence lifetime