  Standard methodologies for the extraction of the stochastic gravitational
wave background (SGWB) from auto- or cross-correlation of interferometric
signals often involve the use of a filter function. The standard optimal filter
maximizes the signal-to-noise ratio (SNR) between the total SGWB and the noise.
We derive expressions for the optimal filter and SNR in the presence of a
target SGWB plus other unwanted components. We also generalize the methodology
to the case of template-free reconstruction. The formalism allows to easily
perform analyses and forecasts that marginalize over foreground signals, such
as the typical $\Omega_{\rm GW} \propto f^{2/3}$ background arising from binary
coalescence. We demonstrate the methodology with the LISA mission and discuss
possible extensions and domains of application.
