ICA on specific windows of time for artifact removal

I was wondering if there was a way to provide a specified interval for ICA (I.e., a tmin and tmax)? I have a stimulation artifact that I am removing from some of my data (MNE epochs object) and when I use longer windows, the component that correlates the most with the artifact also removes other non-stimulus aspects of the time series data, in my case slow wave sleep data. When I take a more narrow window around the artifact, it successfully removes the artifact but I can’t overwrite only a portion of data, it has to be a full epoch, resembling the original.

Any tips/suggestions?

You can run ICA on the subset of your original data, i.e. epochs around the artifact, and then apply it to the original epochs.

FYI, there is also the start/stop argument of ICA.fit which let you select which timespan to include in the ICA fit for Raw objects.