# Effect of time duration in bandpass filtering

I am new in DSP, but I am trying to process EEG data to decompose into the bands, theta, alpha, and others.

The raw data is processed:

1. Remove the DC offset by subtracting the average value from the entire data channels.
2. High pass filtering. Both such as in.

The using the bandpass function of Matlab it is bandpassed.

delta = [0.1 4];
theta = [4 8];
alpha = [8 12];
beta = [12 30];
gamma = [30 45];
bands = [delta; theta; alpha; beta; gamma];
fs = 128; % sampling freq of the EEG

% choosing a segment of data

time = 2 ; % secs
fs = 128;
size_t = fs * time;
sample_filt = af3(1:size_t); %  AF3, an EEG node

% band passing
eeg_bands = {};
for i = 1  : size(bands, 1)
eeg_bands{i} = bandpass( sample_filt, bands(i,:), fs);
end

% code to plot



I performed bandpass for samples of different time duration, however, I saw the time duration changes the amplitudes of bands at the start and end in gamma and beta (high frequency bands).

here, I plot three figures. Figure 1 of long 5 secs (for me, visually it is reasonable). Figure 2, of 2 secs of duration and notice the start of signals beta and gamma are noisy.

Taking in account EEG, I ask you,

1. is there any ideal time duration (min, or max) of the signal to make band passing ?
2. Mi data has a duration of 22 minutes at 128 Hz of sampling, can I performed band pass of all the length or by small segments or windows?

I thank you in advance, please feel free to comment, I need to be right to extract features in the next step.