Defect analysis in electron microscopy