Detailed discussion is in the CEBAF tech-note JLAB-TN-25-14.
The Matlab file tmm_2D.m reconstructs 2x2 transfer matrices and tmm_4D.m does the same for 4x4 transfer matrices which can be arbitrarily coupled.
I extended the method to handle nonlinear maps which is described in CEBAF tech-note JLAB-TN-25-16. The Matlab script with the example is called tmm_2d_nonlin.m.