This might be helpful, see my notes in brackets...
14 CFR 61.51(e)(1)
(e) Logging pilot-in-command flight time. (1) A sport, recreational, private, commercial, or airline transport pilot may log pilot in command flight time for flights-
(i) When the pilot is the sole manipulator of the controls of an aircraft for which the pilot is rated, or has sport pilot privileges for that category and class of aircraft, if the aircraft class rating is appropriate;[so if you're rated, and touching the controls, you can log PIC regardless of whether you're ACTING as PIC]
(ii) When the pilot is the sole occupant in the aircraft; [allows solo student pilots to log PIC time]
(iii) When the pilot, except for a holder of a sport or recreational pilot certificate, acts as pilot in command of an aircraft for which more than one pilot is required under the type certification of the aircraft or the regulations under which the flight is conducted; [this portion allows a safety pilot who agrees to act as PIC to log PIC time when the sole manipulator of the controls is wearing a view limiting device]
(iv) [not applicable in this situation]