You have a few options to do what you want. If your primary goal is to denoise the signal but keep the transients then you can use wavelet denoising.
This is what the results look like:

If you want to remove the transients but keep the noise then you can simply subtract the denoised signal from the original signal to get a noisy signal with no transients:

But since this requires you to first denoise the signal and the subtract it from the original, you could directly remove the transients by high pass filtering:

Here is the code:
clear;
Fs = 10000;
t = linspace(0,10,10*Fs);
f = 100;
i = zeros(size(t));
imp = [0 0.12 -0.2 0.1 1 -0.7 -0.2 0.1 0];
impTime = 0.2;
nSamp = impTime*Fs;
impFull = linspace(0,impTime,nSamp);
impUse = interp1(linspace(0,impTime,length(imp)),imp,impFull,'spline');
figure(1);
plot(impFull,impUse)
rate = 2;
nCycles = 10/rate;
cycleLen = rateFs;
cycle=zeros(1,cycleLen);
cycle(1:impTimeFs) = impUse;
cycles = repmat(cycle,1,10/rate);
x = 0.2sin(2pif/4t);
x1 = 0.1sin(2pift/3);
n = 0.3*randn(size(x));
y =x+x1+n;
y = y+2*cycles;
threshold = 2; % Adjust this threshold in INTEGER amounts only
wavelet = 'db4'; % You can choose a different Wavelet
denoised_y = wdenoise(y, threshold, 'Wavelet', wavelet);
figure(2);
subplot(2, 1, 1);
plot(t, y);
title('Original Noisy Signal');
subplot(2, 1, 2);
plot(t, denoised_y);
title('Denoised Signal');
% Transient Removal (Indirectly High-Pass Filtering)
transient_removed_y = y - denoised_y;
figure(3);
subplot(2, 1, 1);
plot(t, y);
title('Original Noisy Signal');
subplot(2, 1, 2);
plot(t, transient_removed_y);
title('Transient Removed Signal');
% Transient Removal (Directly High-Pass Filtering)
cutoff_frequency = 17/(Fs/2);
[b, a] = butter(6, cutoff_frequency, 'high'); % Not necessary to use Butterworth filter
butter_transient_removed_y = filtfilt(b, a, y);
figure(4);
subplot(2, 1, 1);
plot(t, y);
title('Original Noisy Signal');
subplot(2, 1, 2);
plot(t, butter_transient_removed_y);
title('Transient Removed Signal (Butterworth)');
MAE = compute_mae(butter_transient_removed_y, transient_removed_y, 100000); % Maximum Absolute Error between the two methods
fprintf("MAE between the transient removal methods is %.8f \n", MAE)
function mae = compute_mae (y1 , y2 ,N)
for el =1:1: N
mae = (abs (y1(el)-y2(el)));
end
mae = max(mae);
end
I have also added a measure for computing the difference between the two transient removal methods. You can play with the different parameters as you see fit to achieve even better results.
If you are looking for some other alternatives then this answer might also help!