Skip to content

Adding Digital Filtering in NI-Scope - #2234

Draft
NI-velmurugan wants to merge 3 commits into
ni:masterfrom
NI-velmurugan:users/velmurugan/add-niscope-digital-filtering
Draft

NI-velmurugan wants to merge 3 commits into
ni:masterfrom
NI-velmurugan:users/velmurugan/add-niscope-digital-filtering

Conversation

@NI-velmurugan

Copy link
Copy Markdown
Contributor
  • This contribution adheres to CONTRIBUTING.md.
  • I've updated CHANGELOG.md if applicable.
    - [ ] I've added tests applicable for this pull request

What does this Pull Request accomplish?

This PR adds niscope_digital_filtering.py, a Python adaptation of the LabVIEW niScope EX Digital Filtering.vi along with the pipeline changes required for using matplotlib package.

What testing has been done?

Manually tested the example using simulated hardware and the real hardware

@codecov-commenter

codecov-commenter commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.12%. Comparing base (49c8447) to head (45bc826).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2234      +/-   ##
==========================================
+ Coverage   86.40%   88.12%   +1.72%     
==========================================
  Files          86       88       +2     
  Lines       21563    22830    +1267     
==========================================
+ Hits        18631    20119    +1488     
+ Misses       2932     2711     -221     
Flag Coverage Δ
codegenunittests 84.78% <ø> (ø)
nidcpowersystemtests 94.40% <ø> (+0.04%) ⬆️
nidcpowerunittests 89.53% <ø> (ø)
nidigitalsystemtests 92.04% <ø> (ø)
nidigitalunittests 68.43% <ø> (ø)
nidmmsystemtests 92.33% <ø> (ø)
nifakeunittests 86.08% <ø> (ø)
nifgensystemtests 94.34% <ø> (ø)
nimodinstsystemtests 73.85% <ø> (ø)
nimodinstunittests 94.20% <ø> (ø)
nirfsasystemtests 82.71% <ø> (?)
nirfsaunittests 63.37% <ø> (-0.03%) ⬇️
nirfsgsystemtests 81.22% <ø> (ø)
niscopesystemtests 89.99% <ø> (ø)
niscopeunittests 43.20% <ø> (ø)
nisesystemtests 91.50% <ø> (ø)
niswitchsystemtests 81.66% <ø> (ø)
nitclksystemtests 94.87% <ø> (ø)
nitclkunittests 98.26% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +37 to +43
def _update_chart(waveform_axes, waveform_line, filtered, spectrum_axes, spectrum_line, spectrum):
for axes, line, waveforms in ((waveform_axes, waveform_line, filtered), (spectrum_axes, spectrum_line, spectrum)):
for waveform in waveforms:
x = [waveform.relative_initial_x + i * waveform.x_increment for i in range(len(waveform.samples))]
line.set_data(x, waveform.samples)
axes.relim()
axes.autoscale_view()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, each waveform is written to the same plot line. If multiple channels are selected, each update replaces the previous one, so only the last channel is shown. Could we create or update one line per returned waveform, and label each line by channel, so all selected channels are visible and identifiable?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like,

def _update_chart(axes, waveforms):
    while len(axes.lines) < len(waveforms):
        axes.plot([], [])
    for line, waveform in zip(axes.lines, waveforms):
        x = [waveform.relative_initial_x + i * waveform.x_increment for i in range(len(waveform.samples))]
        line.set_data(x, waveform.samples)
    for line in axes.lines[len(waveforms):]:
        line.set_data([], [])
    axes.relim()
    axes.autoscale_view()

and updating the parameters accordingly in other instances.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the code to display list of channels

parser.add_argument('-t', '--fir-taps', default=25, type=int, help='Defines the number of taps (coefficients) for an FIR filter.')
parser.add_argument('-fw', '--fir-window', default='HANNING', choices=niscope.FIRFilterWindow.__members__.keys(), type=str.upper, help='Specifies the FIR window type.')
parser.add_argument('-o', '--iir-order', default=2, type=int, help='Specifies the order of an IIR filter.')
parser.add_argument('-fft', '--fft-function', default='DB', choices=FFT_FUNCTIONS.keys(), type=str.upper, help='FFT amplitude spectrum function')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this example, is this the same function? Can we remove this from the CLI parameters as we did in the other PRs?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Even if we have this as a CLI parameter, let's move it to the top to follow the similar order in the LabVIEW example for better readability.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have rearranged the parameters to match the LabVIEW example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants