neurodata/ndmg

View on GitHub

Showing 78 of 78 total issues

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

        g1 = mgg(len(np.unique(labels_im.get_data()))-1, labels[idx])
Severity: Minor
Found in ndmg/scripts/ndmg_dwi_pipeline.py and 1 other location - About 50 mins to fix
ndmg/scripts/multigraph_pipeline.py on lines 60..60

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 36.

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

    temp_cc = OrderedDict((subj, nx.clustering(graphs[subj]).values())
Severity: Minor
Found in ndmg/stats/qa_graphs.py and 1 other location - About 50 mins to fix
ndmg/stats/qa_graphs.py on lines 137..137

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 36.

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 reg_mri_pngs has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def reg_mri_pngs(mri, atlas, outdir, loc=0, mean=False, dim=4):
Severity: Minor
Found in ndmg/stats/qa_reg.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if verbose:
                            print "Saving slice:", slices
                        imsave(dirname + '/%04d.png' % slices,
    Severity: Major
    Found in ndmg/utils/nifti_to_png.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if sesh is not None:
                              tpath = op.join(remo, 'sub-{}'.format(sub), 'ses-{}'.format(sesh))
                              tindir = op.join(inDir, 'sub-{}'.format(sub), 'ses-{}'.format(sesh))
                          else:
                              tpath = op.join(remo, 'sub-{}'.format(sub))
      Severity: Major
      Found in ndmg/scripts/ndmg_bids.py - About 45 mins to fix

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

            def apply_warp(self, inp, out, ref, warp, xfm=None, mask=None):
        Severity: Minor
        Found in ndmg/register/register.py - About 45 mins to fix

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

          def visualize_fibs(fibs, fibfile, atlasfile, outdir, opacity, num_samples):
          Severity: Minor
          Found in ndmg/stats/qa_fibers.py - About 45 mins to fix

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

            def plot_density(xs, ys, name=None, ylab=None, xlab=None):
            Severity: Minor
            Found in ndmg/stats/plotly_helper.py - About 35 mins to fix

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

              def tensor2fa(tensors, tensor_name, dwi, derivdir, qcdir):
              Severity: Minor
              Found in ndmg/stats/qa_tensor.py - About 35 mins to fix

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

                def plot_degrees(dats, name=None, ylab=None, xlab=None, hemi=True):
                Severity: Minor
                Found in ndmg/stats/plotly_helper.py - About 35 mins to fix

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

                  def setup(inDir, dwiListFile, bvalListFile, bvecListFile, mprageListFile):
                  Severity: Minor
                  Found in ndmg/scripts/ndmg_setup.py - About 35 mins to fix

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

                    def s3_push_data(bucket, remote, outDir, modifier, creds=True):
                    Severity: Minor
                    Found in ndmg/utils/bids.py - About 35 mins to fix

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

                          def align_nonlinear(self, inp, ref, xfm, warp, mask=None):
                      Severity: Minor
                      Found in ndmg/register/register.py - About 35 mins to fix

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

                        def plot_series(dats, name=None, ylab=None, xlab=None, sort=False):
                        Severity: Minor
                        Found in ndmg/stats/plotly_helper.py - About 35 mins to fix

                          Function traces_to_panels has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def traces_to_panels(traces, names=[], ylabs=None, xlabs=None):
                              r, c, locs = panel_arrangement(len(traces))
                              multi = tools.make_subplots(rows=r, cols=c, subplot_titles=names)
                              for idx, loc in enumerate(locs):
                                  if idx < len(traces):
                          Severity: Minor
                          Found in ndmg/stats/plotly_helper.py - About 35 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 get_braindata has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def get_braindata(brain_file):
                              """
                              Opens a brain data series for a mask, mri image, or atlas.
                              Returns a numpy.ndarray representation of a brain.
                          
                          
                          Severity: Minor
                          Found in ndmg/utils/utils.py - About 35 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 align has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def align(self, inp, ref, xfm=None, out=None, dof=12, searchrad=True,
                                        bins=256, interp=None, cost="mutualinfo"):
                                  """
                                  Aligns two images and stores the transform between them
                          
                          
                          Severity: Minor
                          Found in ndmg/register/register.py - About 35 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 kill_jobs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def kill_jobs(jobdir, reason='"Killing job"'):
                              """
                              Given a list of jobs, kills them all.
                              """
                              cmd_template1 = 'aws batch cancel-job --job-id {} --reason {}'
                          Severity: Minor
                          Found in ndmg/scripts/ndmg_cloud.py - About 25 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

                          Severity
                          Category
                          Status
                          Source
                          Language