text
stringlengths
81
112k
Return image with its axes permuted to match specified axes. A view is returned if possible. >>> transpose_axes(numpy.zeros((2, 3, 4, 5)), 'TYXC', asaxes='CTZYX').shape (5, 2, 1, 3, 4) def transpose_axes(image, axes, asaxes=None): """Return image with its axes permuted to match specified axes. A...
Return axes matching new shape. By default, unknown dimensions are labelled 'Q'. >>> reshape_axes('YXS', (219, 301, 1), (219, 301)) 'YX' >>> reshape_axes('IYX', (12, 219, 301), (3, 4, 219, 1, 301, 1)) 'QQYQXQ' def reshape_axes(axes, shape, newshape, unknown=None): """Return axes matching new ...
Read data from sequence of TiffPage and stack them vertically. Additional parameters are passsed to the TiffPage.asarray function. def stack_pages(pages, out=None, maxworkers=None, **kwargs): """Read data from sequence of TiffPage and stack them vertically. Additional parameters are passsed to the TiffPa...
Return cleaned offsets and byte counts. Remove zero offsets and counts. Use to sanitize StripOffsets and StripByteCounts tag values. def clean_offsetscounts(offsets, counts): """Return cleaned offsets and byte counts. Remove zero offsets and counts. Use to sanitize StripOffsets and StripByteCount...
Return iterator over segments read from file. def buffered_read(fh, lock, offsets, bytecounts, buffersize=None): """Return iterator over segments read from file.""" if buffersize is None: buffersize = 2**26 length = len(offsets) i = 0 while i < length: data = [] with lock: ...
Return numpy array where image data of shape and dtype can be copied. The 'out' parameter may have the following values or types: None An empty array of shape and dtype is created and returned. numpy.ndarray An existing writable array of compatible dtype and shape. A view of the sa...
Return Python object from Matlab string representation. Return str, bool, int, float, list (Matlab arrays or cells), or dict (Matlab structures) types. Use to access ScanImage metadata. >>> matlabstr2py('1') 1 >>> matlabstr2py("['x y z' true false; 1 2.0 -3e4; NaN Inf @class]") [['x y z',...
Return string truncated at last byte that is 7-bit ASCII. Clean NULL separated and terminated TIFF strings. >>> stripascii(b'string\\x00string\\n\\x01\\x00') b'string\\x00string\\n' >>> stripascii(b'\\x00') b'' def stripascii(string): """Return string truncated at last byte that is 7-bit ASCI...
Return string as bool if possible, else raise TypeError. >>> asbool(b' False ') False def asbool(value, true=(b'true', u'true'), false=(b'false', u'false')): """Return string as bool if possible, else raise TypeError. >>> asbool(b' False ') False """ value = value.strip().lower() if ...
Return argument as one of types if possible. >>> astype('42') 42 >>> astype('3.14') 3.14 >>> astype('True') True >>> astype(b'Neee-Wom') 'Neee-Wom' def astype(value, types=None): """Return argument as one of types if possible. >>> astype('42') 42 >>> astype('3.14') ...
Return file size as string from byte size. >>> format_size(1234) '1234 B' >>> format_size(12345678901) '11.50 GiB' def format_size(size, threshold=1536): """Return file size as string from byte size. >>> format_size(1234) '1234 B' >>> format_size(12345678901) '11.50 GiB' """ ...
Return human sorted list of strings. E.g. for sorting file names. >>> natural_sorted(['f1', 'f2', 'f10']) ['f1', 'f2', 'f10'] def natural_sorted(iterable): """Return human sorted list of strings. E.g. for sorting file names. >>> natural_sorted(['f1', 'f2', 'f10']) ['f1', 'f2', 'f10'] ...
Return datetime object from timestamp in Excel serial format. Convert LSM time stamps. >>> excel_datetime(40237.029999999795) datetime.datetime(2010, 2, 28, 0, 43, 11, 999982) def excel_datetime(timestamp, epoch=None): """Return datetime object from timestamp in Excel serial format. Convert LSM ...
Return datetime from days since 1/1/4713 BC and ms since midnight. Convert Julian dates according to MetaMorph. >>> julian_datetime(2451576, 54362783) datetime.datetime(2000, 2, 2, 15, 6, 2, 783) def julian_datetime(julianday, milisecond=0): """Return datetime from days since 1/1/4713 BC and ms since...
Return if byteorder matches the system's byteorder. >>> byteorder_isnative('=') True def byteorder_isnative(byteorder): """Return if byteorder matches the system's byteorder. >>> byteorder_isnative('=') True """ if byteorder in ('=', sys.byteorder): return True keys = {'big':...
Return numpy.recarray as dict. def recarray2dict(recarray): """Return numpy.recarray as dict.""" # TODO: subarrays result = {} for descr, value in zip(recarray.dtype.descr, recarray): name, dtype = descr[:2] if dtype[1] == 'S': value = bytes2str(stripnull(value)) eli...
Return XML as dict. >>> xml2dict('<?xml version="1.0" ?><root attr="name"><key>1</key></root>') {'root': {'key': 1, 'attr': 'name'}} def xml2dict(xml, sanitize=True, prefix=None): """Return XML as dict. >>> xml2dict('<?xml version="1.0" ?><root attr="name"><key>1</key></root>') {'root': {'key': 1...
Return hexdump representation of byte string. >>> hexdump(binascii.unhexlify('49492a00080000000e00fe0004000100')) '49 49 2a 00 08 00 00 00 0e 00 fe 00 04 00 01 00 II*.............' def hexdump(bytestr, width=75, height=24, snipat=-2, modulo=2, ellipsis=None): """Return hexdump representation of byte strin...
Return if all characters in string are printable. >>> isprintable('abc') True >>> isprintable(b'\01') False def isprintable(string): """Return if all characters in string are printable. >>> isprintable('abc') True >>> isprintable(b'\01') False """ string = string.strip() ...
Return string with compressed whitespace. def clean_whitespace(string, compact=False): """Return string with compressed whitespace.""" for a, b in (('\r\n', '\n'), ('\r', '\n'), ('\n\n', '\n'), ('\t', ' '), (' ', ' ')): string = string.replace(a, b) if compact: for a, b in...
Return pretty formatted XML. def pformat_xml(xml): """Return pretty formatted XML.""" try: from lxml import etree # delayed import if not isinstance(xml, bytes): xml = xml.encode('utf-8') xml = etree.parse(io.BytesIO(xml)) xml = etree.tostring(xml, pretty_print=True...
Return pretty formatted representation of object as string. Whitespace might be altered. def pformat(arg, width=79, height=24, compact=True): """Return pretty formatted representation of object as string. Whitespace might be altered. """ if height is None or height < 1: height = 1024 ...
Return string cut to specified length. >>> snipstr('abcdefghijklmnop', 8) 'abc...op' def snipstr(string, width=79, snipat=None, ellipsis='...'): """Return string cut to specified length. >>> snipstr('abcdefghijklmnop', 8) 'abc...op' """ if snipat is None: snipat = 0.5 if elli...
Return enum member from its name or value. >>> enumarg(TIFF.PHOTOMETRIC, 2) <PHOTOMETRIC.RGB: 2> >>> enumarg(TIFF.PHOTOMETRIC, 'RGB') <PHOTOMETRIC.RGB: 2> def enumarg(enum, arg): """Return enum member from its name or value. >>> enumarg(TIFF.PHOTOMETRIC, 2) <PHOTOMETRIC.RGB: 2> >>> en...
Return dict with keys from keys|keyvals and values from kwargs|keyvals. Existing keys are deleted from kwargs. >>> kwargs = {'one': 1, 'two': 2, 'four': 4} >>> kwargs2 = parse_kwargs(kwargs, 'two', 'three', four=None, five=5) >>> kwargs == {'one': 1} True >>> kwargs2 == {'two': 2, 'four': 4, '...
Update dict with keys and values if keys do not already exist. >>> kwargs = {'one': 1, } >>> update_kwargs(kwargs, one=None, two=2) >>> kwargs == {'one': 1, 'two': 2} True def update_kwargs(kwargs, **keyvalues): """Update dict with keys and values if keys do not already exist. >>> kwargs = {'...
Validate TIFF file using jhove -m TIFF-hul. Raise ValueError if jhove outputs an error message unless the message contains one of the strings in 'ignore'. JHOVE does not support bigtiff or more than 50 IFDs. See `JHOVE TIFF-hul Module <http://jhove.sourceforge.net/tiff-hul.html>`_ def validate_jhove...
Convert [MP]TZCYX LSM file to series of BIN files. One BIN file containing 'ZCYX' data are created for each position, time, and tile. The position, time, and tile indices are encoded at the end of the filenames. def lsm2bin(lsmfile, binfile=None, tile=None, verbose=True): """Convert [MP]TZCYX LSM file...
Plot n-dimensional images using matplotlib.pyplot. Return figure, subplot and plot axis. Requires pyplot already imported C{from matplotlib import pyplot}. Parameters ---------- data : nd array The image data. photometric : {'MINISWHITE', 'MINISBLACK', 'RGB', or 'PALETTE'} The ...
Return file name(s) from Tkinter's file open dialog. def askopenfilename(**kwargs): """Return file name(s) from Tkinter's file open dialog.""" try: from Tkinter import Tk import tkFileDialog as filedialog except ImportError: from tkinter import Tk, filedialog root = Tk() roo...
Tifffile command line usage main function. def main(argv=None): """Tifffile command line usage main function.""" if argv is None: argv = sys.argv log.setLevel(logging.INFO) import optparse # TODO: use argparse parser = optparse.OptionParser( usage='usage: %prog [options] path', ...
Write numpy array and tags to TIFF file. The data shape's last dimensions are assumed to be image depth, height (length), width, and samples. If a colormap is provided, the data's dtype must be uint8 or uint16 and the data values are indices into the last dimension of the colorm...
Write outstanding IFDs and tags to file. def _write_remaining_pages(self): """Write outstanding IFDs and tags to file.""" if not self._tags or self._truncate: return pageno = self._shape[0] * self._datashape[0] - 1 if pageno < 1: self._tags = None se...
Write metadata to ImageDescription tag. def _write_image_description(self): """Write metadata to ImageDescription tag.""" if (not self._datashape or self._datashape[0] == 1 or self._descriptionoffset <= 0): return colormapped = self._colormap is not None if ...
Write remaining pages and close file handle. def close(self): """Write remaining pages and close file handle.""" if not self._truncate: self._write_remaining_pages() self._write_image_description() self._fh.close()
Close open file handle(s). def close(self): """Close open file handle(s).""" for tif in self._files.values(): tif.filehandle.close() self._files = {}
Return image data from selected TIFF page(s) as numpy array. By default, the data from the first series is returned. Parameters ---------- key : int, slice, or sequence of indices Defines which pages to return as array. If None (default), data from a series (def...
Return related pages as TiffPageSeries. Side effect: after calling this function, TiffFile.pages might contain TiffPage and TiffFrame instances. def series(self): """Return related pages as TiffPageSeries. Side effect: after calling this function, TiffFile.pages might contain ...
Return image series in file. A series is a sequence of TiffPages with the same hash. def _series_generic(self): """Return image series in file. A series is a sequence of TiffPages with the same hash. """ pages = self.pages pages._clear(False) pages.useframes =...
Return all images in file as single series. def _series_uniform(self): """Return all images in file as single series.""" page = self.pages[0] shape = page.shape axes = page.axes dtype = page.dtype validate = not (page.is_scanimage or page.is_nih) pages = self.pag...
Return image series in "shaped" file. def _series_shaped(self): """Return image series in "shaped" file.""" pages = self.pages pages.useframes = True lenpages = len(pages) def append_series(series, pages, axes, shape, reshape, name, truncated): ...
Return image series in ImageJ file. def _series_imagej(self): """Return image series in ImageJ file.""" # ImageJ's dimension order is always TZCYXS # TODO: fix loading of color, composite, or palette images pages = self.pages pages.useframes = True pages.keyframe = 0 ...
Return image series in FluoView file. def _series_fluoview(self): """Return image series in FluoView file.""" pages = self.pages._getlist(validate=False) mm = self.fluoview_metadata mmhd = list(reversed(mm['Dimensions'])) axes = ''.join(TIFF.MM_DIMENSIONS.get(i[0].upper(), 'Q')...
Return image series in MD Gel file. def _series_mdgel(self): """Return image series in MD Gel file.""" # only a single page, scaled according to metadata in second page self.pages.useframes = False self.pages.keyframe = 0 md = self.mdgel_metadata if md['FileTag'] in (2, ...
Return image series in Olympus SIS file. def _series_sis(self): """Return image series in Olympus SIS file.""" pages = self.pages._getlist(validate=False) page = pages[0] lenpages = len(pages) md = self.sis_metadata if 'shape' in md and 'axes' in md: shape = ...
Return image series in OME-TIFF file(s). def _series_ome(self): """Return image series in OME-TIFF file(s).""" from xml.etree import cElementTree as etree # delayed import omexml = self.pages[0].description try: root = etree.fromstring(omexml) except etree.ParseErro...
Return main and thumbnail series in LSM file. def _series_lsm(self): """Return main and thumbnail series in LSM file.""" lsmi = self.lsm_metadata axes = TIFF.CZ_LSMINFO_SCANTYPE[lsmi['ScanType']] if self.pages[0].photometric == 2: # RGB; more than one channel axes = axes.re...
Load and fix all pages from LSM file. def _lsm_load_pages(self): """Load and fix all pages from LSM file.""" # cache all pages to preserve corrected values pages = self.pages pages.cache = True pages.useframes = True # use first and second page as keyframes pages...
Unwrap strip offsets for LSM files greater than 4 GB. Each series and position require separate unwrapping (undocumented). def _lsm_fix_strip_offsets(self): """Unwrap strip offsets for LSM files greater than 4 GB. Each series and position require separate unwrapping (undocumented). "...
Set databytecounts to size of compressed data. The StripByteCounts tag in LSM files contains the number of bytes for the uncompressed data. def _lsm_fix_strip_bytecounts(self): """Set databytecounts to size of compressed data. The StripByteCounts tag in LSM files contains the number o...
File has MD Gel format. def is_mdgel(self): """File has MD Gel format.""" # TODO: this likely reads the second page from file try: ismdgel = self.pages[0].is_mdgel or self.pages[1].is_mdgel if ismdgel: self.is_uniform = False return ismdgel ...
Return if file contains a uniform series of pages. def is_uniform(self): """Return if file contains a uniform series of pages.""" # the hashes of IFDs 0, 7, and -1 are the same pages = self.pages page = pages[0] if page.is_scanimage or page.is_nih: return True ...
Return if pages can be appended to file without corrupting. def is_appendable(self): """Return if pages can be appended to file without corrupting.""" # TODO: check other formats return not (self.is_lsm or self.is_stk or self.is_imagej or self.is_fluoview or self.is_microman...
Return tifffile metadata from JSON descriptions as dicts. def shaped_metadata(self): """Return tifffile metadata from JSON descriptions as dicts.""" if not self.is_shaped: return None return tuple(json_description_metadata(s.pages[0].is_shaped) for s in self.ser...
Return STK metadata from UIC tags as dict. def stk_metadata(self): """Return STK metadata from UIC tags as dict.""" if not self.is_stk: return None page = self.pages[0] tags = page.tags result = {} result['NumberPlanes'] = tags['UIC2tag'].count if pag...
Return consolidated ImageJ metadata as dict. def imagej_metadata(self): """Return consolidated ImageJ metadata as dict.""" if not self.is_imagej: return None page = self.pages[0] result = imagej_description_metadata(page.is_imagej) if 'IJMetadata' in page.tags: ...
Return consolidated FluoView metadata as dict. def fluoview_metadata(self): """Return consolidated FluoView metadata as dict.""" if not self.is_fluoview: return None result = {} page = self.pages[0] result.update(page.tags['MM_Header'].value) # TODO: read sta...
Return FEI metadata from SFEG or HELIOS tags as dict. def fei_metadata(self): """Return FEI metadata from SFEG or HELIOS tags as dict.""" if not self.is_fei: return None tags = self.pages[0].tags if 'FEI_SFEG' in tags: return tags['FEI_SFEG'].value if 'FE...
Return Olympus SIS metadata from SIS and INI tags as dict. def sis_metadata(self): """Return Olympus SIS metadata from SIS and INI tags as dict.""" if not self.is_sis: return None tags = self.pages[0].tags result = {} try: result.update(tags['OlympusINI']...
Return consolidated metadata from MD GEL tags as dict. def mdgel_metadata(self): """Return consolidated metadata from MD GEL tags as dict.""" for page in self.pages[:2]: if 'MDFileTag' in page.tags: tags = page.tags break else: return None...
Return consolidated MicroManager metadata as dict. def micromanager_metadata(self): """Return consolidated MicroManager metadata as dict.""" if not self.is_micromanager: return None # from file header result = read_micromanager_metadata(self._fh) # from tag r...
Return ScanImage non-varying frame and ROI metadata as dict. def scanimage_metadata(self): """Return ScanImage non-varying frame and ROI metadata as dict.""" if not self.is_scanimage: return None result = {} try: framedata, roidata = read_scanimage_metadata(self....
Enable or disable caching of pages/frames. Clear cache if False. def cache(self, value): """Enable or disable caching of pages/frames. Clear cache if False.""" value = bool(value) if self._cache and not value: self._clear() self._cache = value
Set current keyframe. Load TiffPage from file if necessary. def keyframe(self, index): """Set current keyframe. Load TiffPage from file if necessary.""" index = int(index) if index < 0: index %= len(self) if self._keyframe.index == index: return if index ...
Read all remaining pages from file. def _load(self, keyframe=True): """Read all remaining pages from file.""" if self._cached: return pages = self.pages if not pages: return if not self._indexed: self._seek(-1) if not self._cache: ...
Calculate virtual TiffFrames. def _load_virtual_frames(self): """Calculate virtual TiffFrames.""" pages = self.pages try: if sys.version_info[0] == 2: raise ValueError('not supported on Python 2') if len(pages) > 1: raise ValueError('pages...
Delete all but first page from cache. Set keyframe to first page. def _clear(self, fully=True): """Delete all but first page from cache. Set keyframe to first page.""" pages = self.pages if not pages: return self._keyframe = pages[0] if fully: # delete al...
Seek file to offset of page specified by index. def _seek(self, index, maxpages=None): """Seek file to offset of page specified by index.""" pages = self.pages lenpages = len(pages) if lenpages == 0: raise IndexError('index out of range') fh = self.parent.filehandle...
Return specified pages as list of TiffPages or TiffFrames. The first item is a TiffPage, and is used as a keyframe for following TiffFrames. def _getlist(self, key=None, useframes=True, validate=True): """Return specified pages as list of TiffPages or TiffFrames. The first item is a T...
Return specified page from cache or file. def _getitem(self, key, validate=False): """Return specified page from cache or file.""" key = int(key) pages = self.pages if key < 0: key %= len(self) elif self._indexed and key >= len(pages): raise IndexError('...
Read image data from file and return as numpy array. Raise ValueError if format is unsupported. Parameters ---------- out : numpy.ndarray, str, or file-like object Buffer where image data will be saved. If None (default), a new array will be created. ...
Return image data as RGB(A). Work in progress. def asrgb(self, uint8=False, alpha=None, colormap=None, dmin=None, dmax=None, **kwargs): """Return image data as RGB(A). Work in progress. """ data = self.asarray(**kwargs) self = self.keyframe # self or ke...
Return list of (code, TiffTag). def _gettags(self, codes=None, lock=None): """Return list of (code, TiffTag).""" tags = [] for tag in self.tags.values(): code = tag.code if not codes or code in codes: tags.append((code, tag)) return tags
Return checksum to identify pages in same series. def hash(self): """Return checksum to identify pages in same series.""" return hash( self._shape + ( self.tilewidth, self.tilelength, self.tiledepth, self.bitspersample, self.fillorder, self.predictor, ...
Return simplified offsets and bytecounts. def _offsetscounts(self): """Return simplified offsets and bytecounts.""" if self.is_contiguous: offset, bytecount = self.is_contiguous return [offset], [bytecount] if self.is_tiled: return self.dataoffsets, self.data...
Return offset and size of contiguous data, else None. Excludes prediction and fill_order. def is_contiguous(self): """Return offset and size of contiguous data, else None. Excludes prediction and fill_order. """ if (self.compression != 1 or self.bitspersample ...
Return if page's image data are stored in final form. Excludes byte-swapping. def is_final(self): """Return if page's image data are stored in final form. Excludes byte-swapping. """ return (self.is_contiguous and self.fillorder == 1 and self.predictor == 1 an...
Return if page's image data in file can be memory-mapped. def is_memmappable(self): """Return if page's image data in file can be memory-mapped.""" return (self.parent.filehandle.is_file and self.is_final and # (self.bitspersample == 8 or self.parent.isnative) and self.i...
Return set of flags. def flags(self): """Return set of flags.""" return set((name.lower() for name in sorted(TIFF.FILE_FLAGS) if getattr(self, 'is_' + name)))
Return consolidated metadata from Andor tags as dict. Remove Andor tags from self.tags. def andor_tags(self): """Return consolidated metadata from Andor tags as dict. Remove Andor tags from self.tags. """ if not self.is_andor: return None tags = self.tags ...
Return consolidated metadata from EPICS areaDetector tags as dict. Remove areaDetector tags from self.tags. def epics_tags(self): """Return consolidated metadata from EPICS areaDetector tags as dict. Remove areaDetector tags from self.tags. """ if not self.is_epics: ...
Return consolidated metadata from Hamamatsu NDPI as dict. def ndpi_tags(self): """Return consolidated metadata from Hamamatsu NDPI as dict.""" if not self.is_ndpi: return None tags = self.tags result = {} for name in ('Make', 'Model', 'Software'): result[...
Return consolidated metadata from GeoTIFF tags as dict. def geotiff_tags(self): """Return consolidated metadata from GeoTIFF tags as dict.""" if not self.is_geotiff: return None tags = self.tags gkd = tags['GeoKeyDirectoryTag'].value if gkd[0] != 1: log....
Return ImageJ description if exists, else None. def is_imagej(self): """Return ImageJ description if exists, else None.""" for description in (self.description, self.description1): if not description: return None if description[:7] == 'ImageJ=': r...
Return description containing array shape if exists, else None. def is_shaped(self): """Return description containing array shape if exists, else None.""" for description in (self.description, self.description1): if not description: return None if description[:1]...
Page contains MDS MetaSeries metadata in ImageDescription tag. def is_metaseries(self): """Page contains MDS MetaSeries metadata in ImageDescription tag.""" if self.index > 1 or self.software != 'MetaSeries': return False d = self.description return d.startswith('<MetaData>'...
Page contains OME-XML in ImageDescription tag. def is_ome(self): """Page contains OME-XML in ImageDescription tag.""" if self.index > 1 or not self.description: return False d = self.description return d[:14] == '<?xml version=' and d[-6:] == '</OME>'
Page contains Leica SCN XML in ImageDescription tag. def is_scn(self): """Page contains Leica SCN XML in ImageDescription tag.""" if self.index > 1 or not self.description: return False d = self.description return d[:14] == '<?xml version=' and d[-6:] == '</scn>'
Return list of (code, TiffTag) from file. def _gettags(self, codes=None, lock=None): """Return list of (code, TiffTag) from file.""" fh = self.parent.filehandle tiff = self.parent.tiff unpack = struct.unpack lock = NullContext() if lock is None else lock tags = [] ...
Return TiffPage from file. def aspage(self): """Return TiffPage from file.""" if self.offset is None: raise ValueError('cannot return virtual frame as page.') self.parent.filehandle.seek(self.offset) return TiffPage(self.parent, index=self.index)
Read image data from file and return as numpy array. def asarray(self, *args, **kwargs): """Read image data from file and return as numpy array.""" # TODO: fix TypeError on Python 2 # "TypeError: unbound method asarray() must be called with TiffPage # instance as first argument (got...
Read image data from file and return RGB image as numpy array. def asrgb(self, *args, **kwargs): """Read image data from file and return RGB image as numpy array.""" if self._keyframe is None: raise RuntimeError('keyframe not set') kwargs['validate'] = False return TiffPage....
Set keyframe. def keyframe(self, keyframe): """Set keyframe.""" if self._keyframe == keyframe: return if self._keyframe is not None: raise RuntimeError('cannot reset keyframe') if len(self._offsetscounts[0]) != len(keyframe.dataoffsets): raise Runtime...
Return offset and size of contiguous data, else None. def is_contiguous(self): """Return offset and size of contiguous data, else None.""" if self._keyframe is None: raise RuntimeError('keyframe not set') if self._keyframe.is_contiguous: return self._offsetscounts[0][0],...
Return name of tag from TIFF.TAGS registry. def name(self): """Return name of tag from TIFF.TAGS registry.""" try: return TIFF.TAGS[self.code] except KeyError: return str(self.code)
Correct LSM bitspersample tag. Old LSM writers may use a separate region for two 16-bit values, although they fit into the tag value element of the tag. def _fix_lsm_bitspersample(self, parent): """Correct LSM bitspersample tag. Old LSM writers may use a separate region for two 16-bit...
Return image data from series of TIFF pages as numpy array. def asarray(self, out=None): """Return image data from series of TIFF pages as numpy array.""" if self.parent: result = self.parent.asarray(series=self, out=out) if self.transform is not None: result = s...
Return offset to series data in file, if any. def offset(self): """Return offset to series data in file, if any.""" if not self._pages: return None pos = 0 for page in self._pages: if page is None: return None if not page.is_final: ...
Return specified page of series from cache or file. def _getitem(self, key): """Return specified page of series from cache or file.""" key = int(key) if key < 0: key %= self._len if len(self._pages) == 1 and 0 < key < self._len: index = self._pages[0].index ...
Read image data from files and return as numpy array. The kwargs parameters are passed to the imread function. Raise IndexError or ValueError if image shapes do not match. def asarray(self, file=None, out=None, **kwargs): """Read image data from files and return as numpy array. The k...