neuropsychology/NeuroKit.py

View on GitHub
neurokit/bio/bio_ecg_preprocessing.py

Summary

Maintainability
C
1 day
Test Coverage

File bio_ecg_preprocessing.py has 345 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
"""
Subsubmodule for ecg processing.
"""
import numpy as np
Severity: Minor
Found in neurokit/bio/bio_ecg_preprocessing.py - About 4 hrs to fix

    Function segmenter_pekkanen has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def segmenter_pekkanen(ecg, sampling_rate, window_size=5.0, lfreq=5.0, hfreq=15.0):
        """
        ECG R peak detection based on `Kathirvel et al. (2001) <http://link.springer.com/article/10.1007/s13239-011-0065-3/fulltext.html>`_ with some tweaks (mainly robust estimation of the rectified signal cutoff threshold).
    
        Parameters
    Severity: Minor
    Found in neurokit/bio/bio_ecg_preprocessing.py - About 1 hr to fix

      Function ecg_preprocess has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def ecg_preprocess(ecg, sampling_rate=1000, filter_type="FIR", filter_band="bandpass", filter_frequency=[3, 45], filter_order=0.3, segmenter="hamilton"):
          """
          ECG signal preprocessing.
      
          Parameters
      Severity: Minor
      Found in neurokit/bio/bio_ecg_preprocessing.py - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function ecg_wave_detector has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def ecg_wave_detector(ecg, rpeaks):
          """
          Returns the localization of the P, Q, T waves. This function needs massive help!
      
          Parameters
      Severity: Minor
      Found in neurokit/bio/bio_ecg_preprocessing.py - About 55 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function ecg_preprocess has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def ecg_preprocess(ecg, sampling_rate=1000, filter_type="FIR", filter_band="bandpass", filter_frequency=[3, 45], filter_order=0.3, segmenter="hamilton"):
      Severity: Major
      Found in neurokit/bio/bio_ecg_preprocessing.py - About 50 mins to fix

        Function segmenter_pekkanen has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def segmenter_pekkanen(ecg, sampling_rate, window_size=5.0, lfreq=5.0, hfreq=15.0):
        Severity: Minor
        Found in neurokit/bio/bio_ecg_preprocessing.py - About 35 mins to fix

          There are no issues that match your filters.

          Category
          Status