code: def compare_results(subj, run, other_root, mask_fname):
      """Find and compare calculated results images from a previous run
  
      This script checks that another directory containing results of this same
      analysis are similar in the sense of numpy ``allclose`` within a brain mask.
  
      Parameters
      ----------
      subj : int
          subject number (1..6)
      run : int
          run number (1..12)
      other_root : str
          path to previous run estimation
      mask_fname:
          path to a mask image defining area in which to compare differences
      """
      # Get information for this subject and run
      path_dict = path_info_run(subj, run)
      # Get mask
      msk = load_image(mask_fname).get_fdata().copy().astype(bool)
      # Get results directories for this run
      rootdir = path_dict["rootdir"]
      res_dir = pjoin(rootdir, "results_run%03d" % run)
      if not isdir(res_dir):
          return
      for dirpath, dirnames, filenames in os.walk(res_dir):
          for fname in filenames:
              froot, ext = splitext(fname)
              if froot in ("effect", "sd", "F", "t"):
                  this_fname = pjoin(dirpath, fname)
                  other_fname = this_fname.replace(DATADIR, other_root)
                  if not exists(other_fname):
                      print(
                          this_fname,
                          "present but ",
                          other_fname,
                          "missing",
                      )
                      continue
                  this_arr = load_image(this_fname).get_fdata()
                  other_arr = load_image(other_fname).get_fdata()
                  ok = np.allclose(this_arr[msk], other_arr[msk])
                  if not ok and froot in (
                      "effect",
                      "sd",
                      "t",
                  ):  # Maybe a sign flip
                      ok = np.allclose(this_arr[msk], -other_arr[msk])
                  if not ok:
                      print(
                          "Difference between", this_fname, other_fname
                      )
  
file_path: nipy/examples/ds105/ds105_util.py
imports: import os
  from os import listdir, makedirs
  from os.path import abspath, exists, isdir, splitext
  from os.path import join
  import numpy
  import pandas
  from nipy.io.api import load_image
label_desc: Use image node_id 11 for calling a global function with example usage: compare_results(subj, run, other_root, mask_fname) without return types