When talking about Counterspelling you are probably talking about Spell Defense (you also use Counterspelling for Dispelling).
In this edition Spell Defense is actually declared at the time you (or anyone in your line of sight) are being targeted by a hostile spell (during the Declare Action phase of the hostile magician) or as soon as you (or anyone in your line of sight) are called upon to oppose a spell (if for example your movement put you in the area of effect of a sustained spell). You may declare Spell Defense as a Free Action (which you are allowed to take out of order, but normally only once per action phase) or as an Interrupt action costing 5 initiative score (which you are also allowed to take out of order).
Game Mechanic wise there does not seem to be a requirement that you need to be using Astral Perception or Notice Magic with a regular perception test or even have the offending magician within line of sight to use spell defense. In fact you are even allowed to spend a Free Action or Interrupt Action to declare Spell Defense as soon as you walk into the area of effect of a Detect Enemies spell (even if you are unaware of the spell and you don't even see the subject that is sustaining the spell).
SR5 p. 294-295 Spell Defense
Spell Defense Spell defense is used against hostile spells cast at you or at targets that are within your line of sight (using the same rules as for targeting spells) that you decide to protect with spell defense. Declaring this protection is either a Free Action or, if you don’t have one left, an Interrupt Action that reduces your Initiative Score by 5. Each Combat Turn, you have a pool of dice for spell defense equal to your Counterspelling skill. When a spell is cast, you may choose to use some or all of your Counterspelling dice to defend against an incoming spell. Against each spell attack, you have to choose how many dice from this pool to allocate for defense, and you can select how many people (including yourself if you desire) are covered by these defensive dice. You can protect a number of people at one time equal to your Magic Rating. These dice are then added to the defense tests of everyone you’re covering. The pool refreshes at the beginning of each Combat Turn.
SR5 p. 285 Detection Spells
Counterspelling may be used to defend against active detection spells, even if the target is unaware of them being cast (for example, if they walk within range of an active Detect Enemies spell).
Counterspelling cannot be used to defend against a passive sense, but once an opposing spellcaster realizes there is an active sustained spell, she can try dispelling it (see Dispelling, p. 295).
SR5 p. 295 Example
Chordae’s team is fighting a wiz gang. She has a Counterspelling skill of 7, which means she has 7 bonus spell defense dice to use each Combat Turn. Early in the Combat Turn she is targeted by a Manabolt spell, so she decides to use 3 Counterspelling dice to help fend it off. As a result, she adds 3 dice to her Defense Test against the spell.