neuropsychology/NeuroKit.py

View on GitHub

Showing 176 of 176 total issues

Function save_nk_object has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def save_nk_object(obj, filename="file", path="", extension="nk", compress=False, compatibility=-1):
Severity: Minor
Found in neurokit/miscellaneous/data.py - About 45 mins to fix

    Similar blocks of code found in 3 locations. Consider refactoring.
    Open

        events["onsets"] = np.array(events["onsets"])[np.array(toremove)]
    Severity: Major
    Found in neurokit/signal/events.py and 2 other locations - About 45 mins to fix
    neurokit/signal/events.py on lines 192..192
    neurokit/signal/events.py on lines 193..194

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 35.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function eeg_add_channel has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def eeg_add_channel(raw, channel, sync_index_eeg=0, sync_index_channel=0, channel_type=None, channel_name=None):
    Severity: Minor
    Found in neurokit/eeg/eeg_data.py - About 45 mins to fix

      Function eeg_to_df has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def eeg_to_df(eeg, index=None, include="all", exclude=None, hemisphere="both", central=True):
      Severity: Minor
      Found in neurokit/eeg/eeg_data.py - About 45 mins to fix

        Function complexity_entropy_shannon has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def complexity_entropy_shannon(signal):
            """
            Computes the shannon entropy. Copied from the `pyEntropy <https://github.com/nikdon/pyEntropy>`_ repo by tjugo.
        
            Parameters
        Severity: Minor
        Found in neurokit/signal/complexity.py - About 45 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

        Similar blocks of code found in 9 locations. Consider refactoring.
        Open

                if band == "Mu":
                    frequencies[band] = np.arange(8, 13+0.1, step)
        Severity: Major
        Found in examples/UnderDev/eeg/eeg_time_frequency.py and 8 other locations - About 45 mins to fix
        examples/UnderDev/eeg/eeg_time_frequency.py on lines 216..217
        examples/UnderDev/eeg/eeg_time_frequency.py on lines 218..219
        examples/UnderDev/eeg/eeg_time_frequency.py on lines 220..221
        examples/UnderDev/eeg/eeg_time_frequency.py on lines 222..223
        examples/UnderDev/eeg/eeg_time_frequency.py on lines 224..225
        examples/UnderDev/eeg/eeg_time_frequency.py on lines 226..227
        examples/UnderDev/eeg/eeg_time_frequency.py on lines 228..229
        examples/UnderDev/eeg/eeg_time_frequency.py on lines 230..231

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 35.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                            results[participant][run]["parameters"][microstate]["occurence"] = 0
        Severity: Minor
        Found in examples/UnderDev/eeg/eeg_microstates.py and 1 other location - About 45 mins to fix
        examples/UnderDev/eeg/eeg_microstates.py on lines 305..305

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 35.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function eeg_gfp_peaks has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def eeg_gfp_peaks(data, gflp_method='GFPL1', smoothing=False, smoothing_window=100, peak_method="wavelet", normalize=False):
        Severity: Minor
        Found in examples/UnderDev/eeg/eeg_microstates.py - About 45 mins to fix

          Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def __init__(self, signal=[0, 100], treshold=0.50, burn=5, stop_n_inversions=False, prior_signal=[], prior_response=[]):
          Severity: Minor
          Found in neurokit/statistics/routines.py - About 45 mins to fix

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

                    response[prefix + "_Max"] = epoch[variable][0:window_end].max()
            Severity: Major
            Found in neurokit/bio/bio_ecg.py and 4 other locations - About 45 mins to fix
            neurokit/bio/bio_ecg.py on lines 857..857
            neurokit/bio/bio_ecg.py on lines 859..859
            neurokit/bio/bio_ecg.py on lines 862..862
            neurokit/bio/bio_ecg.py on lines 863..863

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 35.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                                results[participant][run]["parameters"][microstate]["coverage"] = 0
            Severity: Minor
            Found in examples/UnderDev/eeg/eeg_microstates.py and 1 other location - About 45 mins to fix
            examples/UnderDev/eeg/eeg_microstates.py on lines 307..307

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 35.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    RSP_Response["RSP_Inspiration_Completion"] = -1*phase_beg/(phase_end - phase_beg)*100
            Severity: Minor
            Found in neurokit/bio/bio_rsp.py and 1 other location - About 45 mins to fix
            neurokit/bio/bio_ecg.py on lines 897..897

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 35.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

                    response[prefix + "_Min"] = epoch[variable][0:window_end].min()
            Severity: Major
            Found in neurokit/bio/bio_ecg.py and 4 other locations - About 45 mins to fix
            neurokit/bio/bio_ecg.py on lines 859..859
            neurokit/bio/bio_ecg.py on lines 860..860
            neurokit/bio/bio_ecg.py on lines 862..862
            neurokit/bio/bio_ecg.py on lines 863..863

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 35.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

                    response[prefix + "_MaxTime"] = epoch[variable][0:window_end].idxmax()
            Severity: Major
            Found in neurokit/bio/bio_ecg.py and 4 other locations - About 45 mins to fix
            neurokit/bio/bio_ecg.py on lines 857..857
            neurokit/bio/bio_ecg.py on lines 859..859
            neurokit/bio/bio_ecg.py on lines 860..860
            neurokit/bio/bio_ecg.py on lines 863..863

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 35.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 5 locations. Consider refactoring.
            Open

                    response[prefix + "_MinTime"] = epoch[variable][0:window_end].idxmin()
            Severity: Major
            Found in neurokit/bio/bio_ecg.py and 4 other locations - About 45 mins to fix
            neurokit/bio/bio_ecg.py on lines 857..857
            neurokit/bio/bio_ecg.py on lines 860..860
            neurokit/bio/bio_ecg.py on lines 862..862
            neurokit/bio/bio_ecg.py on lines 863..863

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 35.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                        for i in epoch[0:window_end].index:
                            if epoch["ECG_Systole"][i] != ECG_Response["ECG_Phase_Systole"]:
                                systole_end = i
                                break
            Severity: Minor
            Found in neurokit/bio/bio_ecg.py and 1 other location - About 40 mins to fix
            neurokit/bio/bio_ecg.py on lines 891..894

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 34.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                        for i in epoch[:0].index[::-1]:
                            if epoch["ECG_Systole"][i] != ECG_Response["ECG_Phase_Systole"]:
                                systole_beg = i
                                break
            Severity: Minor
            Found in neurokit/bio/bio_ecg.py and 1 other location - About 40 mins to fix
            neurokit/bio/bio_ecg.py on lines 887..890

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 34.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    relative_time = np.linspace(start=onset[event], stop=duration[event], num=len(epoch), endpoint=True).astype(int).tolist()
            Severity: Minor
            Found in neurokit/signal/epochs.py and 1 other location - About 40 mins to fix
            neurokit/signal/epochs.py on lines 96..96

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 34.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    epoch.index  = np.linspace(start=onset_in_s[event], stop=duration_in_s[event], num=len(epoch), endpoint=True)
            Severity: Minor
            Found in neurokit/signal/epochs.py and 1 other location - About 40 mins to fix
            neurokit/signal/epochs.py on lines 99..99

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 34.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

            def eeg_microstates_features(results, method, ecg=True, nonlinearity=True, verbose=True):
            Severity: Minor
            Found in examples/UnderDev/eeg/eeg_microstates.py - About 35 mins to fix
              Severity
              Category
              Status
              Source
              Language