I am currently revising a paper and I am completely confused about the commas. Is it correct English to write

1) "The canonical map $X \to Y$, $x \mapsto f(x)$, is injective."

or is it

2) "The canonical map $X \to Y$, $x \mapsto f(x)$ is injective." ,

i.e. is the second comma mandatory, optional or wrong?