Exploring structural and electronic heterogeneity in nanoscale systems using scanning tunneling microscopy