Filtering of fNIRS signal

  • MNE-Python version: 0.21
  • operating system: Ubuntu

I have done preprocessing of fNIRS signal using MNE-python 0.21. I want to do band pass filtering of the signal in the range of 0.01-0.1 Hz. I plot the power spectral data before and after filtering. Unfortunately, I could not see any effect of filtering in the PSD plot. What would be good way to extract desired frequency (0.01-0.1 Hz) from from the raw data? I would appreciate any help or suggestions. Thanks.
I attached the snippet of my code below.

# Filtering of the signal
l_freq=0.01 # lower cut off frequency
h_freq=0.1 # higher cut off frequency
fnirs_filt= fnirs_data_haemo.filter(l_freq=l_freq, h_freq=h_freq, method='fir', phase='zero-double')

# Power spectral density
tmin, tmax=100, 400
fmin, fmax=0.00001, 0.96
sfreq=fnirs_filt.info['sfreq']
wd_time=130 # Window length in sec
wd=int(sfreq*wd_time)
N_fft=int(sfreq* (tmax-tmin))
psds, freqs=mne.time_frequency.psd_welch(fnirs_data_haemo.pick_types(fnirs='hbo'), n_fft=N_fft, 
                     n_overlap=int(wd/2), n_per_seg=wd, tmin=tmin, tmax=tmax, 
       		fmin=fmin, fmax=fmax, verbose=False) 
fig, ax=plt.subplots(2,1, sharex=True)
psds_mean=psds.mean(axis=0)
psds_std=psds.std(axis=0)
ax[0].plot(freqs, psds_mean, color='b')
ax[0].fill_between(freqs, psds_mean-psds_std, psds_mean+ psds_std, color='b', alpha=0.2)
ax[0].set(title='PSD spectrum of raw data', ylabel='Power Spectral Density')
ax[0].grid()



psds_filt, freqs_filt=mne.time_frequency.psd_welch(fnirs_filt.pick_types(fnirs='hbo'), n_fft=N_fft, 
											n_overlap=int(wd/2), n_per_seg=wd, tmin=tmin, tmax=tmax, 
											fmin=fmin, fmax=fmax, verbose=False) #window='boxcar', 
psds_mean_filt=psds_filt.mean(axis=0)
psds_std_filt=psds_filt.std(axis=0)
ax[1].plot(freqs_filt, psds_mean_filt, color='b')
ax[1].fill_between(freqs, psds_mean_filt-psds_std_filt, psds_mean_filt+ psds_std_filt, color='b', alpha=0.2)
ax[1].set(title='PSD spectrum of FIR-filtered data', ylabel='Power Spectral Density')
ax[1].grid()
plt.show()

The plots are shown below.


Zoomed version

Filtering in MNE-Python modifies the instance in-place. To do comparison plots like these, you need to do fnirs_filt = fnirs_data_haemo.copy().filter(...) (note the addition of .copy()) on line 4 of your script.

Thank you Dan McCloy. It is working.