Preheat oven to 350°F (175°C), line muffin tin with 12 liners.
Process pistachios into fine, flour-like texture.
Whisk flour, baking powder, salt, and pistachios.
Beat butter and sugar until light and fluffy.
Add eggs one at a time, then extracts.
Alternate adding dry mixture and milk, ending with dry.
Gently fold in sour cream and optional food coloring.
Divide batter into liners, ⅔ full.
Bake 18–22 mins; toothpick should come out clean.
Cool 5 mins in pan, then transfer to wire rack.
Beat frosting ingredients, spread on cooled cupcakes.
Sprinkle with chopped pistachios.