def save(filename, data, format=None, **kwargs):
filename = os.path.expanduser(os.path.expandvars(filename))<EOL>if format is None:<EOL><INDENT>format = guess_export_format(filename, data, **kwargs)<EOL>if format is None:<EOL><INDENT>raise ValueError('<STR_LIT>' % filename)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>format = format.lower()<EOL>if format not in exporters:<EOL><INDENT>fmt = next((k for (k,(_,es,_)) in six.iteritems(exporters) if format in es), None)<EOL>if fmt is None:<EOL><INDENT>raise ValueError('<STR_LIT>' % format)<EOL><DEDENT>format = fmt<EOL><DEDENT><DEDENT>(f,_,_) = exporters[format]<EOL>return f(filename, data, **kwargs)<EOL>
save(filename, data) writes the given data to the given filename then yieds that filename.
save(filename, data, format) specifies that the given format should be used; this should be the
  name of the exporter (though a file extension that is recognized also will work).

Additionally, functions located in save.<format> may be used; so, for example, the following
are equivalent calls:
  save(filename, image, 'nifti')
  save.nifti(filename, image)
In fact, the save.nifti function is just the nifti exporter, so help(save.nifti) will also
yield documentation for the nifti exporter.

Keyword options may be passed to save; these must match those accepted by the given export
function.