design_fir crashes on data with high sampling rates

Open
#4 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
matlab
Domain
data

Research direction

Start with clean_channels and design_fir, especially clean_channels line 89 and design_fir line 47. Reproduce the crash with a 9600 Hz sampling rate and compare it with 9000 Hz, then determine how nfft should be handled and verify that the filter design completes without the duplicate interpolation grid values.

Written by the indexing model from the issue text.

Description

wontfix

Transfered from https://sccn.ucsd.edu/bugzilla/show_bug.cgi?id=12974

This bug involves the design_fir function which is called by the clean_channels function in the clean_rawdata toolbox

The design_fir function crashes on data with a high sampling rate (9600) but performs perfectly well with data with a lower sampling rate (9000).

line 89 of clean_channels:

B = design_fir(100,[2*[0 45 50]/signal.srate 1],[1 1 0 0]);

line 47 of design_fir:

F = interp1(round(F*nfft),A,(0:nfft),'pchip');

The original F ([2*[0 45 50]/signal.srate 1]) is multiplied by the nFFT (512) to produce [ 0 5 5 512] with a sampling rate of 9600, and [ 0 5 6 512] with a sampling rate of 9000. As griddedInterpolate needs unique numbers, the function crashes with the 9600 sr data.

If you increase the nFFT to 1024, then it becomes [ 0 10 11 1024] (round([2*[0 45 50]/9600 1]*1024)). However, it seems that the nFFT cannot be specified in clean_channels and is determined by the order of the filter, which is currently hardcoded into clean_channels (N=100).

Currently I only have a try and catch around it in clean_channels, where I specify the 'nfft':

try
    B = design_fir(100,[2*[0 45 50]/signal.srate 1],[1 1 0 0]);
catch
    B = design_fir(100,[2*[0 45 50]/signal.srate 1],[1 1 0 0],1024);
end

However, I dont know whether this is the best fix.

Regards,
Tyler

PS loving the toolbox

Dominant language
MATLAB
Stars
55
Forks
19
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sccn/clean_rawdata

All issues in sccn/clean_rawdata

Similar issues

More MATLAB issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.