class_docstr: Memory context to provide caching for interfaces
  
  Parameters
  ==========
  base_dir: string
      The directory name of the location for the caching
  
  Methods
  =======
  cache
      Creates a cacheable function from an nipype Interface class
  clear_previous_runs
      Removes from the disk all the runs that where not used after
      the creation time of the specific Memory instance
  clear_previous_runs
      Removes from the disk all the runs that where not used after
      the given time
class_docstr_tok: ["Memory","context","to","provide","caching","for","interfaces","Parameters","==========","base_dir",":","string","The","directory","name","of","the","location","for","the","caching","Methods","=======","cache","Creates","a","cacheable","function","from","an","nipype","Interface","class","clear_previous_runs","Removes","from","the","disk","all","the","runs","that","where","not","used","after","the","creation","time","of","the","specific","Memory","instance","clear_previous_runs","Removes","from","the","disk","all","the","runs","that","where","not","used","after","the","given","time"]
docstr: Returns a callable that caches the output of an interface
  
  Parameters
  ==========
  interface: nipype interface
      The nipype interface class to be wrapped and cached
  
  Returns
  =======
  pipe_func: a PipeFunc callable object
      An object that can be used as a function to apply the
      interface to arguments. Inputs of the interface are given
      as keyword arguments, bearing the same name as the name
      in the inputs specs of the interface.
  
  Examples
  ========
  
  >>> from tempfile import mkdtemp
  >>> mem = Memory(mkdtemp())
  >>> from nipype.interfaces import fsl
  
  Here we create a callable that can be used to apply an
  fsl.Merge interface to files
  
  >>> fsl_merge = mem.cache(fsl.Merge)
  
  Now we apply it to a list of files. We need to specify the
  list of input files and the dimension along which the files
  should be merged.
  
  >>> results = fsl_merge(in_files=['a.nii', 'b.nii'],
  ...                     dimension='t') # doctest: +SKIP
  
  We can retrieve the resulting file from the outputs:
  >>> results.outputs.merged_file # doctest: +SKIP
  '...'
docstr_tok: ["Returns","a","callable","that","caches","the","output","of","an","interface","Parameters","==========","interface",":","nipype","interface","The","nipype","interface","class","to","be","wrapped","and","cached","Returns","=======","pipe_func",":","a","PipeFunc","callable","object","An","object","that","can","be","used","as","a","function","to","apply","the","interface","to","arguments",".","Inputs","of","the","interface","are","given","as","keyword","arguments",",","bearing","the","same","name","as","the","name","in","the","inputs","specs","of","the","interface",".","Examples","========",">",">",">","from","tempfile","import","mkdtemp",">",">",">","mem","=","Memory","(","mkdtemp","(",")",")",">",">",">","from","nipype.interfaces","import","fsl","Here","we","create","a","callable","that","can","be","used","to","apply","an","fsl.Merge","interface","to","files",">",">",">","fsl_merge","=","mem.cache","(","fsl.Merge",")","Now","we","apply","it","to","a","list","of","files",".","We","need","to","specify","the","list","of","input","files","and","the","dimension","along","which","the","files","should","be","merged",".",">",">",">","results","=","fsl_merge","(","in_files=","[","'","a.nii","'",",","'","b.nii","'","]",",","...","dimension='t","'",")","#","doctest",":","+SKIP","We","can","retrieve","the","resulting","file","from","the","outputs",":",">",">",">","results.outputs.merged_file","#","doctest",":","+SKIP","'","...","'"]
code: def cache(self, interface):
      """Returns a callable that caches the output of an interface
  
      Parameters
      ==========
      interface: nipype interface
          The nipype interface class to be wrapped and cached
  
      Returns
      =======
      pipe_func: a PipeFunc callable object
          An object that can be used as a function to apply the
          interface to arguments. Inputs of the interface are given
          as keyword arguments, bearing the same name as the name
          in the inputs specs of the interface.
  
      Examples
      ========
  
      >>> from tempfile import mkdtemp
      >>> mem = Memory(mkdtemp())
      >>> from nipype.interfaces import fsl
  
      Here we create a callable that can be used to apply an
      fsl.Merge interface to files
  
      >>> fsl_merge = mem.cache(fsl.Merge)
  
      Now we apply it to a list of files. We need to specify the
      list of input files and the dimension along which the files
      should be merged.
  
      >>> results = fsl_merge(in_files=['a.nii', 'b.nii'],
      ...                     dimension='t') # doctest: +SKIP
  
      We can retrieve the resulting file from the outputs:
      >>> results.outputs.merged_file # doctest: +SKIP
      '...'
      """
      return PipeFunc(interface, self.base_dir, _MemoryCallback(self))
  
imports: import os
  import hashlib
  import pickle
  import time
  import shutil
  import glob
  from ..interfaces.base import BaseInterface
  from ..pipeline.engine import Node
  from ..pipeline.engine.utils import modify_paths
label_desc: Use image node_id 2 for calling the Memory obj's underlying member method code with example usage: obj.cache(interface) and returns: PipeFunc