nodes: 0, module; 1, function_definition; 2, function_name:fromtif; 3, parameters; 4, block; 5, identifier:path; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, default_parameter; 14, default_parameter; 15, default_parameter; 16, expression_statement; 17, import_from_statement; 18, if_statement; 19, function_definition; 20, expression_statement; 21, expression_statement; 22, if_statement; 23, return_statement; 24, identifier:ext; 25, string; 26, identifier:start; 27, None; 28, identifier:stop; 29, None; 30, identifier:recursive; 31, False; 32, identifier:nplanes; 33, None; 34, identifier:npartitions; 35, None; 36, identifier:labels; 37, None; 38, identifier:engine; 39, None; 40, identifier:credentials; 41, None; 42, identifier:discard_extra; 43, False; 44, comment:"""
      Loads images from single or multi-page TIF files.
  
      Parameters
      ----------
      path : str
          Path to data files or directory, specified as either a local filesystem path
          or in a URI-like format, including scheme. May include a single '*' wildcard character.
  
      ext : string, optional, default = 'tif'
          Extension required on data files to be loaded.
  
      start, stop : nonnegative int, optional, default = None
          Indices of the first and last-plus-one file to load, relative to the sorted
          filenames matching 'path' and 'ext'. Interpreted using python slice indexing conventions.
  
      recursive : boolean, optional, default = False
          If true, will recursively descend directories from path, loading all files
          with an extension matching 'ext'.
  
      nplanes : positive integer, optional, default = None
          If passed, will cause single files to be subdivided into nplanes separate images.
          Otherwise, each file is taken to represent one image.
  
      npartitions : int, optional, default = None
          Number of partitions for computational engine,
          if None will use default for engine.
  
      labels : array, optional, default = None
          Labels for records. If provided, should be one-dimensional.
  
      discard_extra : boolean, optional, default = False
          If True and nplanes doesn't divide by the number of pages in a multi-page tiff, the reminder will
          be discarded and a warning will be shown. If False, it will raise an error
      """; 45, dotted_name; 46, dotted_name; 47, boolean_operator; 48, block; 49, function_name:getarray; 50, parameters; 51, block; 52, assignment; 53, assignment; 54, boolean_operator; 55, block; 56, identifier:data; 57, string_content:tif; 58, identifier:tifffile; 59, identifier:TiffFile; 60, comparison_operator:nplanes is not None; 61, comparison_operator:nplanes <= 0; 62, raise_statement; 63, identifier:idx_buffer_filename; 64, expression_statement; 65, expression_statement; 66, expression_statement; 67, expression_statement; 68, expression_statement; 69, if_statement; 70, expression_statement; 71, if_statement; 72, expression_statement; 73, expression_statement; 74, return_statement; 75, identifier:recount; 76, conditional_expression:False if nplanes is None else True; 77, identifier:data; 78, call; 79, boolean_operator; 80, comparison_operator:data.npartitions() < npartitions; 81, expression_statement; 82, identifier:nplanes; 83, None; 84, identifier:nplanes; 85, integer:0; 86, call; 87, assignment; 88, assignment; 89, assignment; 90, assignment; 91, assignment; 92, comparison_operator:nplanes is not None; 93, block; 94, else_clause; 95, call; 96, comparison_operator:ary.ndim == 3; 97, block; 98, assignment; 99, assignment; 100, call; 101, False; 102, comparison_operator:nplanes is None; 103, True; 104, identifier:frompath; 105, argument_list; 106, comparison_operator:engine is not None; 107, comparison_operator:npartitions is not None; 108, call; 109, identifier:npartitions; 110, assignment; 111, identifier:ValueError; 112, argument_list; 113, pattern_list; 114, identifier:idx_buffer_filename; 115, identifier:fbuf; 116, call; 117, identifier:tfh; 118, call; 119, identifier:ary; 120, call; 121, identifier:pageCount; 122, subscript; 123, identifier:nplanes; 124, None; 125, expression_statement; 126, if_statement; 127, expression_statement; 128, block; 129, attribute; 130, argument_list; 131, attribute; 132, integer:3; 133, expression_statement; 134, identifier:nvals; 135, call; 136, identifier:keys; 137, list_comprehension; 138, identifier:zip; 139, argument_list; 140, identifier:nplanes; 141, None; 142, identifier:path; 143, keyword_argument; 144, keyword_argument; 145, keyword_argument; 146, keyword_argument; 147, keyword_argument; 148, keyword_argument; 149, keyword_argument; 150, keyword_argument; 151, keyword_argument; 152, keyword_argument; 153, identifier:engine; 154, None; 155, identifier:npartitions; 156, None; 157, attribute; 158, argument_list; 159, identifier:data; 160, call; 161, binary_operator:'nplanes must be positive if passed, got %d' % nplanes; 162, identifier:idx; 163, identifier:buf; 164, identifier:fname; 165, identifier:BytesIO; 166, argument_list; 167, identifier:TiffFile; 168, argument_list; 169, attribute; 170, argument_list; 171, attribute; 172, integer:0; 173, assignment; 174, identifier:extra; 175, block; 176, assignment; 177, expression_statement; 178, identifier:tfh; 179, identifier:close; 180, identifier:ary; 181, identifier:ndim; 182, assignment; 183, identifier:len; 184, argument_list; 185, tuple; 186, for_in_clause; 187, identifier:keys; 188, identifier:values; 189, identifier:accessor; 190, identifier:getarray; 191, identifier:ext; 192, identifier:ext; 193, identifier:start; 194, identifier:start; 195, identifier:stop; 196, identifier:stop; 197, identifier:recursive; 198, identifier:recursive; 199, identifier:npartitions; 200, identifier:npartitions; 201, identifier:recount; 202, identifier:recount; 203, identifier:labels; 204, identifier:labels; 205, identifier:engine; 206, identifier:engine; 207, identifier:credentials; 208, identifier:credentials; 209, identifier:data; 210, identifier:npartitions; 211, attribute; 212, argument_list; 213, string; 214, identifier:nplanes; 215, identifier:buf; 216, identifier:fbuf; 217, identifier:tfh; 218, identifier:asarray; 219, identifier:ary; 220, identifier:shape; 221, identifier:extra; 222, binary_operator:pageCount % nplanes; 223, if_statement; 224, identifier:values; 225, list_comprehension; 226, assignment; 227, identifier:values; 228, list_comprehension; 229, identifier:values; 230, binary_operator:idx*nvals + timepoint; 231, identifier:timepoint; 232, call; 233, identifier:data; 234, identifier:repartition; 235, identifier:npartitions; 236, string_content:nplanes must be positive if passed, got %d; 237, identifier:pageCount; 238, identifier:nplanes; 239, identifier:discard_extra; 240, block; 241, else_clause; 242, subscript; 243, for_in_clause; 244, identifier:values; 245, list; 246, call; 247, for_in_clause; 248, binary_operator:idx*nvals; 249, identifier:timepoint; 250, identifier:range; 251, argument_list; 252, expression_statement; 253, expression_statement; 254, block; 255, identifier:ary; 256, slice; 257, identifier:i; 258, call; 259, identifier:ary; 260, attribute; 261, argument_list; 262, identifier:val; 263, identifier:values; 264, identifier:idx; 265, identifier:nvals; 266, identifier:nvals; 267, assignment; 268, call; 269, raise_statement; 270, identifier:i; 271, parenthesized_expression; 272, identifier:range; 273, argument_list; 274, identifier:val; 275, identifier:squeeze; 276, identifier:pageCount; 277, binary_operator:pageCount - extra; 278, attribute; 279, argument_list; 280, call; 281, binary_operator:i+nplanes; 282, integer:0; 283, identifier:pageCount; 284, identifier:nplanes; 285, identifier:pageCount; 286, identifier:extra; 287, call; 288, identifier:warn; 289, binary_operator:'Ignored %d pages in file %s' % (extra, fname); 290, identifier:ValueError; 291, argument_list; 292, identifier:i; 293, identifier:nplanes; 294, attribute; 295, argument_list; 296, string; 297, tuple; 298, binary_operator:"nplanes '%d' does not evenly divide '%d in file %s'" % (nplanes, pageCount,
                                                                                                fname); 299, identifier:logging; 300, identifier:getLogger; 301, string; 302, string_content:Ignored %d pages in file %s; 303, identifier:extra; 304, identifier:fname; 305, string:"nplanes '%d' does not evenly divide '%d in file %s'"; 306, tuple; 307, string_content:thunder; 308, identifier:nplanes; 309, identifier:pageCount; 310, identifier:fname
code: def fromtif(path, ext='tif', start=None, stop=None, recursive=False, nplanes=None, npartitions=None, labels=None, engine=None, credentials=None, discard_extra=False):
      """
      Loads images from single or multi-page TIF files.
  
      Parameters
      ----------
      path : str
          Path to data files or directory, specified as either a local filesystem path
          or in a URI-like format, including scheme. May include a single '*' wildcard character.
  
      ext : string, optional, default = 'tif'
          Extension required on data files to be loaded.
  
      start, stop : nonnegative int, optional, default = None
          Indices of the first and last-plus-one file to load, relative to the sorted
          filenames matching 'path' and 'ext'. Interpreted using python slice indexing conventions.
  
      recursive : boolean, optional, default = False
          If true, will recursively descend directories from path, loading all files
          with an extension matching 'ext'.
  
      nplanes : positive integer, optional, default = None
          If passed, will cause single files to be subdivided into nplanes separate images.
          Otherwise, each file is taken to represent one image.
  
      npartitions : int, optional, default = None
          Number of partitions for computational engine,
          if None will use default for engine.
  
      labels : array, optional, default = None
          Labels for records. If provided, should be one-dimensional.
  
      discard_extra : boolean, optional, default = False
          If True and nplanes doesn't divide by the number of pages in a multi-page tiff, the reminder will
          be discarded and a warning will be shown. If False, it will raise an error
      """
      from tifffile import TiffFile
  
      if nplanes is not None and nplanes <= 0:
          raise ValueError('nplanes must be positive if passed, got %d' % nplanes)
  
      def getarray(idx_buffer_filename):
          idx, buf, fname = idx_buffer_filename
          fbuf = BytesIO(buf)
          tfh = TiffFile(fbuf)
          ary = tfh.asarray()
          pageCount = ary.shape[0]
          if nplanes is not None:
              extra = pageCount % nplanes
              if extra:
                  if discard_extra:
                      pageCount = pageCount - extra
                      logging.getLogger('thunder').warn('Ignored %d pages in file %s' % (extra, fname))
                  else:
                      raise ValueError("nplanes '%d' does not evenly divide '%d in file %s'" % (nplanes, pageCount,
                                                                                                fname))
              values = [ary[i:(i+nplanes)] for i in range(0, pageCount, nplanes)]
          else:
              values = [ary]
          tfh.close()
  
          if ary.ndim == 3:
              values = [val.squeeze() for val in values]
  
          nvals = len(values)
          keys = [(idx*nvals + timepoint,) for timepoint in range(nvals)]
          return zip(keys, values)
  
      recount = False if nplanes is None else True
      data = frompath(path, accessor=getarray, ext=ext, start=start, stop=stop,
                      recursive=recursive, npartitions=npartitions, recount=recount,
                      labels=labels, engine=engine, credentials=credentials)
      if engine is not None and npartitions is not None and data.npartitions() < npartitions:
          data = data.repartition(npartitions)
      return data