How to replace the independent components obtained by ICA?

The corresponding independent components can be obtained by ICA, and some components can be marked as physiological artifacts. If I get an artifact independent component, I do not want to remove this component completely (corresponding to the exclude method under the ICA class). I want to do some signal processing on this artifact component and use the obtained signal to replace the original artifact independent component. How can I achieve it? I don’t seem to see any replacement functionality under the ICA class in MNE.

We don’t provide functionality to do this directly. However, the ICA class ultimately applies a linear spatial operator to the data IIRC, so one simple option is to exclude the component, apply the ICA to your data, and take the difference between the “cleaned” data array and original data array. This will contain your component of interest. For example if you do a SVD of this difference you should find one meaningful component above numerical noise. Then you can process it however you want, and then add it back to the data by constructing a new RawArray or by using raw.apply_function to add the extra component channel by channel.