In 'Von den Stricken meiner Sünden' from the St. Johannes passion. Ignoring the strange B.C. realisation (why all the accidentals and intervals not matching the figuration?), I'm very confused about how exactly this modulation from D minor to G minor happens.
Our first two bars seem to go | III i | iv bII viio7, then into this chain of diminished chords, where the second beat of the third bar could be, I think, interpreted a secondary dominant to G minor, being an F# diminished, but I can't really follow the whole progression here.
I'm interested in an analysis of the progression and how it leads to the key change and the thought process that lead to it, because I'm struggling to analyse the rest of the piece, too, with many interesting key changes.
Of course, the harmony actually returns to F major right after this section, so the modulation is very temporary.