# Filtering and detrending questions

**URL:** https://mne.discourse.group/t/filtering-and-detrending-questions/8860
**Category:** Support & Discussions
**Tags:** preprocessing, eeg, epochs
**Created:** [May 28, 2024, 12:22am UTC](https://mne.discourse.group/t/filtering-and-detrending-questions/8860 "2024-05-28T00:22:56Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Chris-Winnard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/chris-winnard/32/3541_2.png) [@Chris-Winnard](https://mne.discourse.group/u/Chris-Winnard)
#### Post date: [May 28, 2024, 12:22am UTC](https://mne.discourse.group/t/filtering-and-detrending-questions/8860/1 "2024-05-28T00:22:56Z")

</div>

Hi,

I had a couple of closely related queries.

I’m currently using PyPrep’s NoisyChannels class to autoremove bad channels, and I’ve read a couple of slightly different things about the included filtering/detrending. Originally I was applying a 1-45Hz bp filter, a 50Hz notch filter, and then using NoisyChannels and the related functions, assuming these wouldn’t include any additional filtering or detrending. In one iterative workflow I actually run NoisyChannels() twice.

However I have been getting a message about a 1Hz highpass filter being applied and I was a little confused by the docs/the code on GitHub. Obviously I don’t want to be filtering repeatedly if I don’t need to, and if any other steps are included in detrending (it’s a little hard to tell from the GitHub code), I’d want to at least know what these are.

If I run the following, will it simply find the noisy channels without any other filtering/DSP steps?

```python
chans = NoisyChannels(eeg_fF, do_detrend=False)
chans.find_bad_by_correlation()
chans.find_bad_by_deviation()
chans.find_bad_by_ransac()

```

Similarly, I was also curious about what _exactly_ linear detrending in the MNE epochs function entails(?) I currently have it set to “linear\_detrend=1”.

Any help would be really appreciated.

This is for PyPrep 0.4.3/MNE-Python 1.6.1 (Win10).

---

<div class="post-metadata">

### Author: ![mscheltienne](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/mscheltienne/32/827_2.png) [@mscheltienne](https://mne.discourse.group/u/mscheltienne)
#### Post date: [May 28, 2024, 8:27am UTC](https://mne.discourse.group/t/filtering-and-detrending-questions/8860/2 "2024-05-28T08:27:11Z")

</div>

@sappelhoff could tell you more than I, but here is what I found: `find_bad_by_correlation` starts with [those 2 lines](https://github.com/sappelhoff/pyprep/blob/e4840d9c31ccd880e427448edd8317ff9f6f7909/pyprep/find_noisy_channels.py#L401-L402C37):

```python
if self.EEGFiltered is None:
    self.EEGFiltered = self._get_filtered_data()

```

Which runs this method: [pyprep/pyprep/find\_noisy\_channels.py at e4840d9c31ccd880e427448edd8317ff9f6f7909 · sappelhoff/pyprep · GitHub](https://github.com/sappelhoff/pyprep/blob/e4840d9c31ccd880e427448edd8317ff9f6f7909/pyprep/find_noisy_channels.py#L108-L127)

Which **copies** the data and applies a (1, 50) Hz filter on the copy.

Mathieu

---

<div class="post-metadata">

### Author: ![richard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/richard/32/15_2.png) [@richard](https://mne.discourse.group/u/richard)
#### Post date: [May 28, 2024, 8:40am UTC](https://mne.discourse.group/t/filtering-and-detrending-questions/8860/3 "2024-05-28T08:40:49Z")

</div>

I can confirm that PyPREP doesn’t alter the input data.

---

<div class="post-metadata">

### Author: ![Chris-Winnard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/chris-winnard/32/3541_2.png) [@Chris-Winnard](https://mne.discourse.group/u/Chris-Winnard)
#### Post date: [May 28, 2024, 5:49pm UTC](https://mne.discourse.group/t/filtering-and-detrending-questions/8860/4 "2024-05-28T17:49:50Z")

</div>

My mistake- I’d actually looked at the docs and misread it as possibly meaning there was a filter on the data itself. Thanks 😄

---

<div class="post-metadata">

### Author: ![Chris-Winnard](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/chris-winnard/32/3541_2.png) [@Chris-Winnard](https://mne.discourse.group/u/Chris-Winnard)
#### Post date: [May 28, 2024, 5:51pm UTC](https://mne.discourse.group/t/filtering-and-detrending-questions/8860/5 "2024-05-28T17:51:21Z")

</div>

Thanks. 🙂 Do you know if the linear detrend (i.e detrend=1) method used in epoching includes filtering? Apologies if it’s a silly question.
