docs: def _mat2dict(obj): 
      '''
      A recursive function which constructs from matobjects nested dictionaries
      Enforce lists for conns, synMechs and stims even if 1 element (matlab converts to dict otherwise)
      '''
      import scipy.io as spio
      import numpy as np
  
      if isinstance(obj, dict):
          out = {}
          for key in obj:
              if isinstance(obj[key], spio.matlab.mio5_params.mat_struct):
                  if key in ['conns', 'stims', 'synMechs']:
                      out[key] = [_mat2dict(obj[key])]  # convert to 1-element list
                  else:
                      out[key] = _mat2dict(obj[key])
              elif isinstance(obj[key], np.ndarray):
                  out[key] = _mat2dict(obj[key])
              else:
                  out[key] = obj[key]
  
      elif isinstance(obj, spio.matlab.mio5_params.mat_struct):
          out = {}
          for key in obj._fieldnames:
              val = obj.__dict__[key]
              if isinstance(val, spio.matlab.mio5_params.mat_struct):
                  if key in ['conns', 'stims', 'synMechs']:
                      out[key] = [_mat2dict(val)]  # convert to 1-element list
                  else:
                      out[key] = _mat2dict(val)
              elif isinstance(val, np.ndarray):
                  out[key] = _mat2dict(val)
              else:
                  out[key] = val
  
      elif isinstance(obj, np.ndarray):
          out = []
          for item in obj:
              if isinstance(item, spio.matlab.mio5_params.mat_struct) or isinstance(item, np.ndarray):
                  out.append(_mat2dict(item))
              else:
                  out.append(item)
  
      else:
          out = obj
  
      return out