def file_writer(filename, signal, export_scale=True, extratags=[], **kwds): """Writes data to tif using Christoph Gohlke's tifffile library Parameters ---------- filename: str signal: a BaseSignal instance export_scale: bool default: True Export the scale and the units (compatible with DM and ImageJ) to appropriate tags. If the scikit-image version is too old, use the hyperspy embedded tifffile library to allow exporting the scale and the unit. """ imsave, TiffFile = _import_tifffile_library(export_scale) data = signal.data if signal.is_rgbx is True: data = rgb_tools.rgbx2regular_array(data) photometric = "rgb" else: photometric = "minisblack" if 'description' in kwds and export_scale: kwds.pop('description') # Comment this warning, since it was not passing the test online... # warnings.warn( # "Description and export scale cannot be used at the same time, " # "because of incompability with the 'ImageJ' format") if export_scale: kwds.update(_get_tags_dict(signal, extratags=extratags)) _logger.info("kwargs passed to tifffile.py imsave: {0}".format(kwds)) imsave(filename, data, software="hyperspy", photometric=photometric, **kwds)
def file_writer(filename, signal, export_scale=True, extratags=[], **kwds): """Writes data to tif using Christoph Gohlke's tifffile library Parameters ---------- filename: str signal: a BaseSignal instance export_scale: bool default: True Export the scale and the units (compatible with DM and ImageJ) to appropriate tags. If the scikit-image version is too old, use the hyperspy embedded tifffile library to allow exporting the scale and the unit. """ _logger.debug('************* Saving *************') imsave, TiffFile = _import_tifffile_library(export_scale) data = signal.data if signal.is_rgbx is True: data = rgb_tools.rgbx2regular_array(data) photometric = "rgb" else: photometric = "minisblack" if 'description' in kwds and export_scale: kwds.pop('description') # Comment this warning, since it was not passing the test online... # warnings.warn( # "Description and export scale cannot be used at the same time, " # "because of incompability with the 'ImageJ' format") if export_scale: kwds.update(_get_tags_dict(signal, extratags=extratags)) _logger.debug("kwargs passed to tifffile.py imsave: {0}".format(kwds)) if 'date' in signal.metadata['General']: dt = get_date_time_from_metadata(signal.metadata, formatting='datetime') kwds['datetime'] = dt imsave(filename, data, software="hyperspy", photometric=photometric, **kwds)
def file_writer(filename, signal, export_scale=True, extratags=[], **kwds): """Writes data to tif using Christoph Gohlke's tifffile library Parameters ---------- filename: str signal: a BaseSignal instance export_scale: bool default: True Export the scale and the units (compatible with DM and ImageJ) to appropriate tags. """ _logger.debug('************* Saving *************') data = signal.data if signal.is_rgbx is True: data = rgb_tools.rgbx2regular_array(data) photometric = "RGB" else: photometric = "MINISBLACK" if 'description' in kwds and export_scale: kwds.pop('description') _logger.warning( "Description and export scale cannot be used at the same time, " "because it is incompability with the 'ImageJ' tiff format") if export_scale: kwds.update(_get_tags_dict(signal, extratags=extratags)) _logger.debug("kwargs passed to tifffile.py imsave: {0}".format(kwds)) if 'date' in signal.metadata['General']: dt = get_date_time_from_metadata(signal.metadata, formatting='datetime') kwds['datetime'] = dt imsave(filename, data, software="hyperspy", photometric=photometric, **kwds)