As a part of the research with which I am involved, I would like to understand how to compute the effect of the Atkin-Lehner Operator/Fricke Involution $W_2 = \begin{pmatrix} 0 & 1 \\ -2 & 0 \end{pmatrix}$ on the q-expansion modular forms with $\Gamma_0(2)$ level structure. I know of the Magma function $AtkinLehnerOperator(f,q)$, but I would like to understand how this works at a theoretical level, both to get at theoretical results and to extend this function to work on Modular Forms over rings that are not the Rationals, (specifically the integers and the 3-adic integers). 

If anyone has any sources on or explanations as to how to compute how q-expansions are transformed under the Atkin-Lehner/Fricke Involution, it would be greatly appreciated!