repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | transpose_axes | def transpose_axes(image, axes, asaxes=None):
"""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)
"""
for ax in axes:
if ax not in asaxes:
... | python | def transpose_axes(image, axes, asaxes=None):
"""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)
"""
for ax in axes:
if ax not in asaxes:
... | [
"def",
"transpose_axes",
"(",
"image",
",",
"axes",
",",
"asaxes",
"=",
"None",
")",
":",
"for",
"ax",
"in",
"axes",
":",
"if",
"ax",
"not",
"in",
"asaxes",
":",
"raise",
"ValueError",
"(",
"'unknown axis %s'",
"%",
"ax",
")",
"# add missing axes to image"... | 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) | [
"Return",
"image",
"with",
"its",
"axes",
"permuted",
"to",
"match",
"specified",
"axes",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9715-L9738 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | reshape_axes | def reshape_axes(axes, shape, newshape, unknown=None):
"""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'
"""
shape = tuple... | python | def reshape_axes(axes, shape, newshape, unknown=None):
"""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'
"""
shape = tuple... | [
"def",
"reshape_axes",
"(",
"axes",
",",
"shape",
",",
"newshape",
",",
"unknown",
"=",
"None",
")",
":",
"shape",
"=",
"tuple",
"(",
"shape",
")",
"newshape",
"=",
"tuple",
"(",
"newshape",
")",
"if",
"len",
"(",
"axes",
")",
"!=",
"len",
"(",
"sh... | 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' | [
"Return",
"axes",
"matching",
"new",
"shape",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9741-L9786 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | stack_pages | 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 TiffPage.asarray function.
"""
npages = len(pages)
if npages == 0:
raise ValueError('no pages')
if npages == 1:
... | python | 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 TiffPage.asarray function.
"""
npages = len(pages)
if npages == 0:
raise ValueError('no pages')
if npages == 1:
... | [
"def",
"stack_pages",
"(",
"pages",
",",
"out",
"=",
"None",
",",
"maxworkers",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"npages",
"=",
"len",
"(",
"pages",
")",
"if",
"npages",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"'no pages'",
")",
... | Read data from sequence of TiffPage and stack them vertically.
Additional parameters are passsed to the TiffPage.asarray function. | [
"Read",
"data",
"from",
"sequence",
"of",
"TiffPage",
"and",
"stack",
"them",
"vertically",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9789-L9848 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | clean_offsetscounts | def clean_offsetscounts(offsets, counts):
"""Return cleaned offsets and byte counts.
Remove zero offsets and counts.
Use to sanitize StripOffsets and StripByteCounts tag values.
"""
# TODO: cythonize this
offsets = list(offsets)
counts = list(counts)
size = len(offsets)
if size != ... | python | def clean_offsetscounts(offsets, counts):
"""Return cleaned offsets and byte counts.
Remove zero offsets and counts.
Use to sanitize StripOffsets and StripByteCounts tag values.
"""
# TODO: cythonize this
offsets = list(offsets)
counts = list(counts)
size = len(offsets)
if size != ... | [
"def",
"clean_offsetscounts",
"(",
"offsets",
",",
"counts",
")",
":",
"# TODO: cythonize this",
"offsets",
"=",
"list",
"(",
"offsets",
")",
"counts",
"=",
"list",
"(",
"counts",
")",
"size",
"=",
"len",
"(",
"offsets",
")",
"if",
"size",
"!=",
"len",
"... | Return cleaned offsets and byte counts.
Remove zero offsets and counts.
Use to sanitize StripOffsets and StripByteCounts tag values. | [
"Return",
"cleaned",
"offsets",
"and",
"byte",
"counts",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9851-L9879 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | buffered_read | 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:
size = 0
while size < bu... | python | 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:
size = 0
while size < bu... | [
"def",
"buffered_read",
"(",
"fh",
",",
"lock",
",",
"offsets",
",",
"bytecounts",
",",
"buffersize",
"=",
"None",
")",
":",
"if",
"buffersize",
"is",
"None",
":",
"buffersize",
"=",
"2",
"**",
"26",
"length",
"=",
"len",
"(",
"offsets",
")",
"i",
"=... | Return iterator over segments read from file. | [
"Return",
"iterator",
"over",
"segments",
"read",
"from",
"file",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9882-L9902 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | create_output | def create_output(out, shape, dtype, mode='w+', suffix=None):
"""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 w... | python | def create_output(out, shape, dtype, mode='w+', suffix=None):
"""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 w... | [
"def",
"create_output",
"(",
"out",
",",
"shape",
",",
"dtype",
",",
"mode",
"=",
"'w+'",
",",
"suffix",
"=",
"None",
")",
":",
"if",
"out",
"is",
"None",
":",
"return",
"numpy",
".",
"zeros",
"(",
"shape",
",",
"dtype",
")",
"if",
"isinstance",
"(... | 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",
"numpy",
"array",
"where",
"image",
"data",
"of",
"shape",
"and",
"dtype",
"can",
"be",
"copied",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9905-L9941 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | matlabstr2py | def matlabstr2py(string):
"""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;... | python | def matlabstr2py(string):
"""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;... | [
"def",
"matlabstr2py",
"(",
"string",
")",
":",
"# TODO: handle invalid input",
"# TODO: review unboxing of multidimensional arrays",
"def",
"lex",
"(",
"s",
")",
":",
"# return sequence of tokens from matlab string representation",
"tokens",
"=",
"[",
"'['",
"]",
"while",
... | 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",
"Python",
"object",
"from",
"Matlab",
"string",
"representation",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L9944-L10097 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | stripascii | def stripascii(string):
"""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''
"""
# TODO: pythonize this
i = len(string)
... | python | def stripascii(string):
"""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''
"""
# TODO: pythonize this
i = len(string)
... | [
"def",
"stripascii",
"(",
"string",
")",
":",
"# TODO: pythonize this",
"i",
"=",
"len",
"(",
"string",
")",
"while",
"i",
":",
"i",
"-=",
"1",
"if",
"8",
"<",
"byte2int",
"(",
"string",
"[",
"i",
"]",
")",
"<",
"127",
":",
"break",
"else",
":",
... | 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'' | [
"Return",
"string",
"truncated",
"at",
"last",
"byte",
"that",
"is",
"7",
"-",
"bit",
"ASCII",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10115-L10134 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | asbool | 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 value in true: # might raise UnicodeWarning/BytesWarning
return True
if value in fa... | python | 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 value in true: # might raise UnicodeWarning/BytesWarning
return True
if value in fa... | [
"def",
"asbool",
"(",
"value",
",",
"true",
"=",
"(",
"b'true'",
",",
"u'true'",
")",
",",
"false",
"=",
"(",
"b'false'",
",",
"u'false'",
")",
")",
":",
"value",
"=",
"value",
".",
"strip",
"(",
")",
".",
"lower",
"(",
")",
"if",
"value",
"in",
... | Return string as bool if possible, else raise TypeError.
>>> asbool(b' False ')
False | [
"Return",
"string",
"as",
"bool",
"if",
"possible",
"else",
"raise",
"TypeError",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10137-L10149 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | astype | def astype(value, types=None):
"""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'
"""
if types is None:
types = int, float, asbool, bytes2str
for typ in types:
... | python | def astype(value, types=None):
"""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'
"""
if types is None:
types = int, float, asbool, bytes2str
for typ in types:
... | [
"def",
"astype",
"(",
"value",
",",
"types",
"=",
"None",
")",
":",
"if",
"types",
"is",
"None",
":",
"types",
"=",
"int",
",",
"float",
",",
"asbool",
",",
"bytes2str",
"for",
"typ",
"in",
"types",
":",
"try",
":",
"return",
"typ",
"(",
"value",
... | 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' | [
"Return",
"argument",
"as",
"one",
"of",
"types",
"if",
"possible",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10152-L10172 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | format_size | 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'
"""
if size < threshold:
return "%i B" % size
for unit in ('KiB', 'MiB', 'GiB', 'TiB', 'PiB'):
size /= 1024.0
... | python | 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'
"""
if size < threshold:
return "%i B" % size
for unit in ('KiB', 'MiB', 'GiB', 'TiB', 'PiB'):
size /= 1024.0
... | [
"def",
"format_size",
"(",
"size",
",",
"threshold",
"=",
"1536",
")",
":",
"if",
"size",
"<",
"threshold",
":",
"return",
"\"%i B\"",
"%",
"size",
"for",
"unit",
"in",
"(",
"'KiB'",
",",
"'MiB'",
",",
"'GiB'",
",",
"'TiB'",
",",
"'PiB'",
")",
":",
... | Return file size as string from byte size.
>>> format_size(1234)
'1234 B'
>>> format_size(12345678901)
'11.50 GiB' | [
"Return",
"file",
"size",
"as",
"string",
"from",
"byte",
"size",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10175-L10190 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | natural_sorted | def natural_sorted(iterable):
"""Return human sorted list of strings.
E.g. for sorting file names.
>>> natural_sorted(['f1', 'f2', 'f10'])
['f1', 'f2', 'f10']
"""
def sortkey(x):
return [(int(c) if c.isdigit() else c) for c in re.split(numbers, x)]
numbers = re.compile(r'(\d+)')
... | python | def natural_sorted(iterable):
"""Return human sorted list of strings.
E.g. for sorting file names.
>>> natural_sorted(['f1', 'f2', 'f10'])
['f1', 'f2', 'f10']
"""
def sortkey(x):
return [(int(c) if c.isdigit() else c) for c in re.split(numbers, x)]
numbers = re.compile(r'(\d+)')
... | [
"def",
"natural_sorted",
"(",
"iterable",
")",
":",
"def",
"sortkey",
"(",
"x",
")",
":",
"return",
"[",
"(",
"int",
"(",
"c",
")",
"if",
"c",
".",
"isdigit",
"(",
")",
"else",
"c",
")",
"for",
"c",
"in",
"re",
".",
"split",
"(",
"numbers",
","... | Return human sorted list of strings.
E.g. for sorting file names.
>>> natural_sorted(['f1', 'f2', 'f10'])
['f1', 'f2', 'f10'] | [
"Return",
"human",
"sorted",
"list",
"of",
"strings",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10244-L10257 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | excel_datetime | def excel_datetime(timestamp, epoch=None):
"""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)
"""
if epoch is None:
epoch = datetime.datetime.fromordinal(693... | python | def excel_datetime(timestamp, epoch=None):
"""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)
"""
if epoch is None:
epoch = datetime.datetime.fromordinal(693... | [
"def",
"excel_datetime",
"(",
"timestamp",
",",
"epoch",
"=",
"None",
")",
":",
"if",
"epoch",
"is",
"None",
":",
"epoch",
"=",
"datetime",
".",
"datetime",
".",
"fromordinal",
"(",
"693594",
")",
"return",
"epoch",
"+",
"datetime",
".",
"timedelta",
"("... | 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) | [
"Return",
"datetime",
"object",
"from",
"timestamp",
"in",
"Excel",
"serial",
"format",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10260-L10271 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | julian_datetime | def julian_datetime(julianday, milisecond=0):
"""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)
"""
if julianday <= 1721423:
# no dateti... | python | def julian_datetime(julianday, milisecond=0):
"""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)
"""
if julianday <= 1721423:
# no dateti... | [
"def",
"julian_datetime",
"(",
"julianday",
",",
"milisecond",
"=",
"0",
")",
":",
"if",
"julianday",
"<=",
"1721423",
":",
"# no datetime before year 1",
"return",
"None",
"a",
"=",
"julianday",
"+",
"1",
"if",
"a",
">",
"2299160",
":",
"alpha",
"=",
"mat... | 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) | [
"Return",
"datetime",
"from",
"days",
"since",
"1",
"/",
"1",
"/",
"4713",
"BC",
"and",
"ms",
"since",
"midnight",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10274-L10305 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | byteorder_isnative | def byteorder_isnative(byteorder):
"""Return if byteorder matches the system's byteorder.
>>> byteorder_isnative('=')
True
"""
if byteorder in ('=', sys.byteorder):
return True
keys = {'big': '>', 'little': '<'}
return keys.get(byteorder, byteorder) == keys[sys.byteorder] | python | def byteorder_isnative(byteorder):
"""Return if byteorder matches the system's byteorder.
>>> byteorder_isnative('=')
True
"""
if byteorder in ('=', sys.byteorder):
return True
keys = {'big': '>', 'little': '<'}
return keys.get(byteorder, byteorder) == keys[sys.byteorder] | [
"def",
"byteorder_isnative",
"(",
"byteorder",
")",
":",
"if",
"byteorder",
"in",
"(",
"'='",
",",
"sys",
".",
"byteorder",
")",
":",
"return",
"True",
"keys",
"=",
"{",
"'big'",
":",
"'>'",
",",
"'little'",
":",
"'<'",
"}",
"return",
"keys",
".",
"g... | Return if byteorder matches the system's byteorder.
>>> byteorder_isnative('=')
True | [
"Return",
"if",
"byteorder",
"matches",
"the",
"system",
"s",
"byteorder",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10308-L10318 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | recarray2dict | 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))
elif value.ndim < 2:
va... | python | 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))
elif value.ndim < 2:
va... | [
"def",
"recarray2dict",
"(",
"recarray",
")",
":",
"# TODO: subarrays",
"result",
"=",
"{",
"}",
"for",
"descr",
",",
"value",
"in",
"zip",
"(",
"recarray",
".",
"dtype",
".",
"descr",
",",
"recarray",
")",
":",
"name",
",",
"dtype",
"=",
"descr",
"[",... | Return numpy.recarray as dict. | [
"Return",
"numpy",
".",
"recarray",
"as",
"dict",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10321-L10332 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | xml2dict | 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, 'attr': 'name'}}
"""
from xml.etree import cElementTree as etree # delayed import
at = tx = ''
if prefix:
at, tx =... | python | 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, 'attr': 'name'}}
"""
from xml.etree import cElementTree as etree # delayed import
at = tx = ''
if prefix:
at, tx =... | [
"def",
"xml2dict",
"(",
"xml",
",",
"sanitize",
"=",
"True",
",",
"prefix",
"=",
"None",
")",
":",
"from",
"xml",
".",
"etree",
"import",
"cElementTree",
"as",
"etree",
"# delayed import",
"at",
"=",
"tx",
"=",
"''",
"if",
"prefix",
":",
"at",
",",
"... | Return XML as dict.
>>> xml2dict('<?xml version="1.0" ?><root attr="name"><key>1</key></root>')
{'root': {'key': 1, 'attr': 'name'}} | [
"Return",
"XML",
"as",
"dict",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10335-L10382 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | hexdump | def hexdump(bytestr, width=75, height=24, snipat=-2, modulo=2, ellipsis=None):
"""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*.............'
"""
size = len(bytestr)
if size... | python | def hexdump(bytestr, width=75, height=24, snipat=-2, modulo=2, ellipsis=None):
"""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*.............'
"""
size = len(bytestr)
if size... | [
"def",
"hexdump",
"(",
"bytestr",
",",
"width",
"=",
"75",
",",
"height",
"=",
"24",
",",
"snipat",
"=",
"-",
"2",
",",
"modulo",
"=",
"2",
",",
"ellipsis",
"=",
"None",
")",
":",
"size",
"=",
"len",
"(",
"bytestr",
")",
"if",
"size",
"<",
"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*.............' | [
"Return",
"hexdump",
"representation",
"of",
"byte",
"string",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10385-L10456 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | isprintable | def isprintable(string):
"""Return if all characters in string are printable.
>>> isprintable('abc')
True
>>> isprintable(b'\01')
False
"""
string = string.strip()
if not string:
return True
if sys.version_info[0] == 3:
try:
return string.isprintable()
... | python | def isprintable(string):
"""Return if all characters in string are printable.
>>> isprintable('abc')
True
>>> isprintable(b'\01')
False
"""
string = string.strip()
if not string:
return True
if sys.version_info[0] == 3:
try:
return string.isprintable()
... | [
"def",
"isprintable",
"(",
"string",
")",
":",
"string",
"=",
"string",
".",
"strip",
"(",
")",
"if",
"not",
"string",
":",
"return",
"True",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"==",
"3",
":",
"try",
":",
"return",
"string",
".",
"isp... | Return if all characters in string are printable.
>>> isprintable('abc')
True
>>> isprintable(b'\01')
False | [
"Return",
"if",
"all",
"characters",
"in",
"string",
"are",
"printable",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10459-L10485 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | clean_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 (('\n', ' '), ('[ ', '['),
... | python | 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 (('\n', ' '), ('[ ', '['),
... | [
"def",
"clean_whitespace",
"(",
"string",
",",
"compact",
"=",
"False",
")",
":",
"for",
"a",
",",
"b",
"in",
"(",
"(",
"'\\r\\n'",
",",
"'\\n'",
")",
",",
"(",
"'\\r'",
",",
"'\\n'",
")",
",",
"(",
"'\\n\\n'",
",",
"'\\n'",
")",
",",
"(",
"'\\t'... | Return string with compressed whitespace. | [
"Return",
"string",
"with",
"compressed",
"whitespace",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10488-L10497 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | pformat_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, xml_declaration=True,
... | python | 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, xml_declaration=True,
... | [
"def",
"pformat_xml",
"(",
"xml",
")",
":",
"try",
":",
"from",
"lxml",
"import",
"etree",
"# delayed import",
"if",
"not",
"isinstance",
"(",
"xml",
",",
"bytes",
")",
":",
"xml",
"=",
"xml",
".",
"encode",
"(",
"'utf-8'",
")",
"xml",
"=",
"etree",
... | Return pretty formatted XML. | [
"Return",
"pretty",
"formatted",
"XML",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10500-L10514 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | pformat | 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
if width is None or width < 1:
width = 256
npopt = numpy.get_printoptions()
n... | python | 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
if width is None or width < 1:
width = 256
npopt = numpy.get_printoptions()
n... | [
"def",
"pformat",
"(",
"arg",
",",
"width",
"=",
"79",
",",
"height",
"=",
"24",
",",
"compact",
"=",
"True",
")",
":",
"if",
"height",
"is",
"None",
"or",
"height",
"<",
"1",
":",
"height",
"=",
"1024",
"if",
"width",
"is",
"None",
"or",
"width"... | Return pretty formatted representation of object as string.
Whitespace might be altered. | [
"Return",
"pretty",
"formatted",
"representation",
"of",
"object",
"as",
"string",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10517-L10563 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | snipstr | 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 ellipsis is None:
if isinstance(string, bytes):
ellipsis = b'...'
else:... | python | 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 ellipsis is None:
if isinstance(string, bytes):
ellipsis = b'...'
else:... | [
"def",
"snipstr",
"(",
"string",
",",
"width",
"=",
"79",
",",
"snipat",
"=",
"None",
",",
"ellipsis",
"=",
"'...'",
")",
":",
"if",
"snipat",
"is",
"None",
":",
"snipat",
"=",
"0.5",
"if",
"ellipsis",
"is",
"None",
":",
"if",
"isinstance",
"(",
"s... | Return string cut to specified length.
>>> snipstr('abcdefghijklmnop', 8)
'abc...op' | [
"Return",
"string",
"cut",
"to",
"specified",
"length",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10566-L10622 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | enumarg | def enumarg(enum, arg):
"""Return enum member from its name or value.
>>> enumarg(TIFF.PHOTOMETRIC, 2)
<PHOTOMETRIC.RGB: 2>
>>> enumarg(TIFF.PHOTOMETRIC, 'RGB')
<PHOTOMETRIC.RGB: 2>
"""
try:
return enum(arg)
except Exception:
try:
return enum[arg.upper()]
... | python | def enumarg(enum, arg):
"""Return enum member from its name or value.
>>> enumarg(TIFF.PHOTOMETRIC, 2)
<PHOTOMETRIC.RGB: 2>
>>> enumarg(TIFF.PHOTOMETRIC, 'RGB')
<PHOTOMETRIC.RGB: 2>
"""
try:
return enum(arg)
except Exception:
try:
return enum[arg.upper()]
... | [
"def",
"enumarg",
"(",
"enum",
",",
"arg",
")",
":",
"try",
":",
"return",
"enum",
"(",
"arg",
")",
"except",
"Exception",
":",
"try",
":",
"return",
"enum",
"[",
"arg",
".",
"upper",
"(",
")",
"]",
"except",
"Exception",
":",
"raise",
"ValueError",
... | Return enum member from its name or value.
>>> enumarg(TIFF.PHOTOMETRIC, 2)
<PHOTOMETRIC.RGB: 2>
>>> enumarg(TIFF.PHOTOMETRIC, 'RGB')
<PHOTOMETRIC.RGB: 2> | [
"Return",
"enum",
"member",
"from",
"its",
"name",
"or",
"value",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10625-L10640 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | parse_kwargs | def parse_kwargs(kwargs, *keys, **keyvalues):
"""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... | python | def parse_kwargs(kwargs, *keys, **keyvalues):
"""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... | [
"def",
"parse_kwargs",
"(",
"kwargs",
",",
"*",
"keys",
",",
"*",
"*",
"keyvalues",
")",
":",
"result",
"=",
"{",
"}",
"for",
"key",
"in",
"keys",
":",
"if",
"key",
"in",
"kwargs",
":",
"result",
"[",
"key",
"]",
"=",
"kwargs",
"[",
"key",
"]",
... | 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, '... | [
"Return",
"dict",
"with",
"keys",
"from",
"keys|keyvals",
"and",
"values",
"from",
"kwargs|keyvals",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10643-L10667 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | update_kwargs | def update_kwargs(kwargs, **keyvalues):
"""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
"""
for key, value in keyvalues.items():
if key not in kwargs:
... | python | def update_kwargs(kwargs, **keyvalues):
"""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
"""
for key, value in keyvalues.items():
if key not in kwargs:
... | [
"def",
"update_kwargs",
"(",
"kwargs",
",",
"*",
"*",
"keyvalues",
")",
":",
"for",
"key",
",",
"value",
"in",
"keyvalues",
".",
"items",
"(",
")",
":",
"if",
"key",
"not",
"in",
"kwargs",
":",
"kwargs",
"[",
"key",
"]",
"=",
"value"
] | 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 | [
"Update",
"dict",
"with",
"keys",
"and",
"values",
"if",
"keys",
"do",
"not",
"already",
"exist",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10670-L10681 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | validate_jhove | def validate_jhove(filename, jhove=None, ignore=None):
"""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 <htt... | python | def validate_jhove(filename, jhove=None, ignore=None):
"""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 <htt... | [
"def",
"validate_jhove",
"(",
"filename",
",",
"jhove",
"=",
"None",
",",
"ignore",
"=",
"None",
")",
":",
"import",
"subprocess",
"# noqa: delayed import",
"if",
"ignore",
"is",
"None",
":",
"ignore",
"=",
"[",
"'More than 50 IFDs'",
"]",
"if",
"jhove",
"is... | 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>`_ | [
"Validate",
"TIFF",
"file",
"using",
"jhove",
"-",
"m",
"TIFF",
"-",
"hul",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10684-L10711 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | lsm2bin | def lsm2bin(lsmfile, binfile=None, tile=None, verbose=True):
"""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.
"""
verbose = prin... | python | def lsm2bin(lsmfile, binfile=None, tile=None, verbose=True):
"""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.
"""
verbose = prin... | [
"def",
"lsm2bin",
"(",
"lsmfile",
",",
"binfile",
"=",
"None",
",",
"tile",
"=",
"None",
",",
"verbose",
"=",
"True",
")",
":",
"verbose",
"=",
"print_",
"if",
"verbose",
"else",
"nullfunc",
"if",
"tile",
"is",
"None",
":",
"tile",
"=",
"(",
"256",
... | 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. | [
"Convert",
"[",
"MP",
"]",
"TZCYX",
"LSM",
"file",
"to",
"series",
"of",
"BIN",
"files",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10714-L10779 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | imshow | def imshow(data, photometric=None, planarconfig=None, bitspersample=None,
interpolation=None, cmap=None, vmin=None, vmax=None,
figure=None, title=None, dpi=96, subplot=None, maxdim=None,
**kwargs):
"""Plot n-dimensional images using matplotlib.pyplot.
Return figure, subplot and... | python | def imshow(data, photometric=None, planarconfig=None, bitspersample=None,
interpolation=None, cmap=None, vmin=None, vmax=None,
figure=None, title=None, dpi=96, subplot=None, maxdim=None,
**kwargs):
"""Plot n-dimensional images using matplotlib.pyplot.
Return figure, subplot and... | [
"def",
"imshow",
"(",
"data",
",",
"photometric",
"=",
"None",
",",
"planarconfig",
"=",
"None",
",",
"bitspersample",
"=",
"None",
",",
"interpolation",
"=",
"None",
",",
"cmap",
"=",
"None",
",",
"vmin",
"=",
"None",
",",
"vmax",
"=",
"None",
",",
... | 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 ... | [
"Plot",
"n",
"-",
"dimensional",
"images",
"using",
"matplotlib",
".",
"pyplot",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L10782-L11057 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | askopenfilename | 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()
root.withdraw()
root.update()
filenames = filedia... | python | 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()
root.withdraw()
root.update()
filenames = filedia... | [
"def",
"askopenfilename",
"(",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"from",
"Tkinter",
"import",
"Tk",
"import",
"tkFileDialog",
"as",
"filedialog",
"except",
"ImportError",
":",
"from",
"tkinter",
"import",
"Tk",
",",
"filedialog",
"root",
"=",
"Tk",
... | Return file name(s) from Tkinter's file open dialog. | [
"Return",
"file",
"name",
"(",
"s",
")",
"from",
"Tkinter",
"s",
"file",
"open",
"dialog",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L11066-L11078 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | main | 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',
description='Display image data in T... | python | 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',
description='Display image data in T... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"log",
".",
"setLevel",
"(",
"logging",
".",
"INFO",
")",
"import",
"optparse",
"# TODO: use argparse",
"parser",
"=",
"optparse",
".",... | Tifffile command line usage main function. | [
"Tifffile",
"command",
"line",
"usage",
"main",
"function",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L11081-L11246 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffWriter.save | def save(self, data=None, shape=None, dtype=None, returnoffset=False,
photometric=None, planarconfig=None, extrasamples=None, tile=None,
contiguous=True, align=16, truncate=False, compress=0,
rowsperstrip=None, predictor=False, colormap=None,
description=None, datetim... | python | def save(self, data=None, shape=None, dtype=None, returnoffset=False,
photometric=None, planarconfig=None, extrasamples=None, tile=None,
contiguous=True, align=16, truncate=False, compress=0,
rowsperstrip=None, predictor=False, colormap=None,
description=None, datetim... | [
"def",
"save",
"(",
"self",
",",
"data",
"=",
"None",
",",
"shape",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"returnoffset",
"=",
"False",
",",
"photometric",
"=",
"None",
",",
"planarconfig",
"=",
"None",
",",
"extrasamples",
"=",
"None",
",",
"... | 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",
"numpy",
"array",
"and",
"tags",
"to",
"TIFF",
"file",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L890-L1743 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffWriter._write_remaining_pages | 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
self._datadtype = None
self._dat... | python | 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
self._datadtype = None
self._dat... | [
"def",
"_write_remaining_pages",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_tags",
"or",
"self",
".",
"_truncate",
":",
"return",
"pageno",
"=",
"self",
".",
"_shape",
"[",
"0",
"]",
"*",
"self",
".",
"_datashape",
"[",
"0",
"]",
"-",
"1",
... | Write outstanding IFDs and tags to file. | [
"Write",
"outstanding",
"IFDs",
"and",
"tags",
"to",
"file",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L1745-L1862 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffWriter._write_image_description | 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 self._imagej:
isrgb = self._s... | python | 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 self._imagej:
isrgb = self._s... | [
"def",
"_write_image_description",
"(",
"self",
")",
":",
"if",
"(",
"not",
"self",
".",
"_datashape",
"or",
"self",
".",
"_datashape",
"[",
"0",
"]",
"==",
"1",
"or",
"self",
".",
"_descriptionoffset",
"<=",
"0",
")",
":",
"return",
"colormapped",
"=",
... | Write metadata to ImageDescription tag. | [
"Write",
"metadata",
"to",
"ImageDescription",
"tag",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L1865-L1892 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffWriter.close | 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() | python | 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() | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_truncate",
":",
"self",
".",
"_write_remaining_pages",
"(",
")",
"self",
".",
"_write_image_description",
"(",
")",
"self",
".",
"_fh",
".",
"close",
"(",
")"
] | Write remaining pages and close file handle. | [
"Write",
"remaining",
"pages",
"and",
"close",
"file",
"handle",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L1898-L1903 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile.close | def close(self):
"""Close open file handle(s)."""
for tif in self._files.values():
tif.filehandle.close()
self._files = {} | python | def close(self):
"""Close open file handle(s)."""
for tif in self._files.values():
tif.filehandle.close()
self._files = {} | [
"def",
"close",
"(",
"self",
")",
":",
"for",
"tif",
"in",
"self",
".",
"_files",
".",
"values",
"(",
")",
":",
"tif",
".",
"filehandle",
".",
"close",
"(",
")",
"self",
".",
"_files",
"=",
"{",
"}"
] | Close open file handle(s). | [
"Close",
"open",
"file",
"handle",
"(",
"s",
")",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2055-L2059 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile.asarray | def asarray(self, key=None, series=None, out=None, validate=True,
maxworkers=None):
"""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 ind... | python | def asarray(self, key=None, series=None, out=None, validate=True,
maxworkers=None):
"""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 ind... | [
"def",
"asarray",
"(",
"self",
",",
"key",
"=",
"None",
",",
"series",
"=",
"None",
",",
"out",
"=",
"None",
",",
"validate",
"=",
"True",
",",
"maxworkers",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"pages",
":",
"return",
"numpy",
".",
"... | 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",
"image",
"data",
"from",
"selected",
"TIFF",
"page",
"(",
"s",
")",
"as",
"numpy",
"array",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2061-L2179 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile.series | def series(self):
"""Return related pages as TiffPageSeries.
Side effect: after calling this function, TiffFile.pages might contain
TiffPage and TiffFrame instances.
"""
if not self.pages:
return []
useframes = self.pages.useframes
keyframe = self.p... | python | def series(self):
"""Return related pages as TiffPageSeries.
Side effect: after calling this function, TiffFile.pages might contain
TiffPage and TiffFrame instances.
"""
if not self.pages:
return []
useframes = self.pages.useframes
keyframe = self.p... | [
"def",
"series",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"pages",
":",
"return",
"[",
"]",
"useframes",
"=",
"self",
".",
"pages",
".",
"useframes",
"keyframe",
"=",
"self",
".",
"pages",
".",
"keyframe",
".",
"index",
"series",
"=",
"[",
... | Return related pages as TiffPageSeries.
Side effect: after calling this function, TiffFile.pages might contain
TiffPage and TiffFrame instances. | [
"Return",
"related",
"pages",
"as",
"TiffPageSeries",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2182-L2210 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile._series_generic | 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 = False
if pages.cache:
pages._load()
result = []
keys = []... | python | 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 = False
if pages.cache:
pages._load()
result = []
keys = []... | [
"def",
"_series_generic",
"(",
"self",
")",
":",
"pages",
"=",
"self",
".",
"pages",
"pages",
".",
"_clear",
"(",
"False",
")",
"pages",
".",
"useframes",
"=",
"False",
"if",
"pages",
".",
"cache",
":",
"pages",
".",
"_load",
"(",
")",
"result",
"=",... | Return image series in file.
A series is a sequence of TiffPages with the same hash. | [
"Return",
"image",
"series",
"in",
"file",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2212-L2249 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile._series_uniform | 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.pages._getlist(validate=validate)
lenpag... | python | 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.pages._getlist(validate=validate)
lenpag... | [
"def",
"_series_uniform",
"(",
"self",
")",
":",
"page",
"=",
"self",
".",
"pages",
"[",
"0",
"]",
"shape",
"=",
"page",
".",
"shape",
"axes",
"=",
"page",
".",
"axes",
"dtype",
"=",
"page",
".",
"dtype",
"validate",
"=",
"not",
"(",
"page",
".",
... | Return all images in file as single series. | [
"Return",
"all",
"images",
"in",
"file",
"as",
"single",
"series",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2251-L2269 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile._series_shaped | 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):
page = pages[0]
if not... | python | 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):
page = pages[0]
if not... | [
"def",
"_series_shaped",
"(",
"self",
")",
":",
"pages",
"=",
"self",
".",
"pages",
"pages",
".",
"useframes",
"=",
"True",
"lenpages",
"=",
"len",
"(",
"pages",
")",
"def",
"append_series",
"(",
"series",
",",
"pages",
",",
"axes",
",",
"shape",
",",
... | Return image series in "shaped" file. | [
"Return",
"image",
"series",
"in",
"shaped",
"file",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2271-L2358 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile._series_imagej | 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
page = pages[0]
ij = sel... | python | 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
page = pages[0]
ij = sel... | [
"def",
"_series_imagej",
"(",
"self",
")",
":",
"# 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 ImageJ file. | [
"Return",
"image",
"series",
"in",
"ImageJ",
"file",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2360-L2433 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile._series_fluoview | 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')
for i in mmhd i... | python | 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')
for i in mmhd i... | [
"def",
"_series_fluoview",
"(",
"self",
")",
":",
"pages",
"=",
"self",
".",
"pages",
".",
"_getlist",
"(",
"validate",
"=",
"False",
")",
"mm",
"=",
"self",
".",
"fluoview_metadata",
"mmhd",
"=",
"list",
"(",
"reversed",
"(",
"mm",
"[",
"'Dimensions'",
... | Return image series in FluoView file. | [
"Return",
"image",
"series",
"in",
"FluoView",
"file",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2435-L2446 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile._series_mdgel | 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, 128):
dtype = numpy.dtype... | python | 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, 128):
dtype = numpy.dtype... | [
"def",
"_series_mdgel",
"(",
"self",
")",
":",
"# only a single page, scaled according to metadata in second page",
"self",
".",
"pages",
".",
"useframes",
"=",
"False",
"self",
".",
"pages",
".",
"keyframe",
"=",
"0",
"md",
"=",
"self",
".",
"mdgel_metadata",
"if... | Return image series in MD Gel file. | [
"Return",
"image",
"series",
"in",
"MD",
"Gel",
"file",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2448-L2470 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile._series_sis | 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 = md['shape'] + page.shape
axes ... | python | 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 = md['shape'] + page.shape
axes ... | [
"def",
"_series_sis",
"(",
"self",
")",
":",
"pages",
"=",
"self",
".",
"pages",
".",
"_getlist",
"(",
"validate",
"=",
"False",
")",
"page",
"=",
"pages",
"[",
"0",
"]",
"lenpages",
"=",
"len",
"(",
"pages",
")",
"md",
"=",
"self",
".",
"sis_metad... | Return image series in Olympus SIS file. | [
"Return",
"image",
"series",
"in",
"Olympus",
"SIS",
"file",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2472-L2488 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile._series_ome | 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.ParseError as exc:
# TODO: test badly e... | python | 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.ParseError as exc:
# TODO: test badly e... | [
"def",
"_series_ome",
"(",
"self",
")",
":",
"from",
"xml",
".",
"etree",
"import",
"cElementTree",
"as",
"etree",
"# delayed import",
"omexml",
"=",
"self",
".",
"pages",
"[",
"0",
"]",
".",
"description",
"try",
":",
"root",
"=",
"etree",
".",
"fromstr... | Return image series in OME-TIFF file(s). | [
"Return",
"image",
"series",
"in",
"OME",
"-",
"TIFF",
"file",
"(",
"s",
")",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2490-L2694 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile._series_lsm | 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.replace('C', '').replace('XY', 'XYC')
if ... | python | 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.replace('C', '').replace('XY', 'XYC')
if ... | [
"def",
"_series_lsm",
"(",
"self",
")",
":",
"lsmi",
"=",
"self",
".",
"lsm_metadata",
"axes",
"=",
"TIFF",
".",
"CZ_LSMINFO_SCANTYPE",
"[",
"lsmi",
"[",
"'ScanType'",
"]",
"]",
"if",
"self",
".",
"pages",
"[",
"0",
"]",
".",
"photometric",
"==",
"2",
... | Return main and thumbnail series in LSM file. | [
"Return",
"main",
"and",
"thumbnail",
"series",
"in",
"LSM",
"file",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2696-L2728 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile._lsm_load_pages | 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.keyframe = 1
pages.keyframe = ... | python | 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.keyframe = 1
pages.keyframe = ... | [
"def",
"_lsm_load_pages",
"(",
"self",
")",
":",
"# cache all pages to preserve corrected values",
"pages",
"=",
"self",
".",
"pages",
"pages",
".",
"cache",
"=",
"True",
"pages",
".",
"useframes",
"=",
"True",
"# use first and second page as keyframes",
"pages",
".",... | Load and fix all pages from LSM file. | [
"Load",
"and",
"fix",
"all",
"pages",
"from",
"LSM",
"file",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2730-L2750 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile._lsm_fix_strip_offsets | def _lsm_fix_strip_offsets(self):
"""Unwrap strip offsets for LSM files greater than 4 GB.
Each series and position require separate unwrapping (undocumented).
"""
if self.filehandle.size < 2**32:
return
pages = self.pages
npages = len(pages)
series... | python | def _lsm_fix_strip_offsets(self):
"""Unwrap strip offsets for LSM files greater than 4 GB.
Each series and position require separate unwrapping (undocumented).
"""
if self.filehandle.size < 2**32:
return
pages = self.pages
npages = len(pages)
series... | [
"def",
"_lsm_fix_strip_offsets",
"(",
"self",
")",
":",
"if",
"self",
".",
"filehandle",
".",
"size",
"<",
"2",
"**",
"32",
":",
"return",
"pages",
"=",
"self",
".",
"pages",
"npages",
"=",
"len",
"(",
"pages",
")",
"series",
"=",
"self",
".",
"serie... | Unwrap strip offsets for LSM files greater than 4 GB.
Each series and position require separate unwrapping (undocumented). | [
"Unwrap",
"strip",
"offsets",
"for",
"LSM",
"files",
"greater",
"than",
"4",
"GB",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2752-L2803 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile._lsm_fix_strip_bytecounts | def _lsm_fix_strip_bytecounts(self):
"""Set databytecounts to size of compressed data.
The StripByteCounts tag in LSM files contains the number of bytes
for the uncompressed data.
"""
pages = self.pages
if pages[0].compression == 1:
return
# sort pag... | python | def _lsm_fix_strip_bytecounts(self):
"""Set databytecounts to size of compressed data.
The StripByteCounts tag in LSM files contains the number of bytes
for the uncompressed data.
"""
pages = self.pages
if pages[0].compression == 1:
return
# sort pag... | [
"def",
"_lsm_fix_strip_bytecounts",
"(",
"self",
")",
":",
"pages",
"=",
"self",
".",
"pages",
"if",
"pages",
"[",
"0",
"]",
".",
"compression",
"==",
"1",
":",
"return",
"# sort pages by first strip offset",
"pages",
"=",
"sorted",
"(",
"pages",
",",
"key",... | Set databytecounts to size of compressed data.
The StripByteCounts tag in LSM files contains the number of bytes
for the uncompressed data. | [
"Set",
"databytecounts",
"to",
"size",
"of",
"compressed",
"data",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2805-L2829 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile.is_mdgel | 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
except IndexError:
... | python | 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
except IndexError:
... | [
"def",
"is_mdgel",
"(",
"self",
")",
":",
"# TODO: this likely reads the second page from file",
"try",
":",
"ismdgel",
"=",
"self",
".",
"pages",
"[",
"0",
"]",
".",
"is_mdgel",
"or",
"self",
".",
"pages",
"[",
"1",
"]",
".",
"is_mdgel",
"if",
"ismdgel",
... | File has MD Gel format. | [
"File",
"has",
"MD",
"Gel",
"format",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2911-L2920 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile.is_uniform | 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
try:
useframes = pages.useframes
... | python | 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
try:
useframes = pages.useframes
... | [
"def",
"is_uniform",
"(",
"self",
")",
":",
"# 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",
"try... | Return if file contains a uniform series of pages. | [
"Return",
"if",
"file",
"contains",
"a",
"uniform",
"series",
"of",
"pages",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2923-L2941 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile.is_appendable | 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_micromanager) | python | 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_micromanager) | [
"def",
"is_appendable",
"(",
"self",
")",
":",
"# TODO: check other formats",
"return",
"not",
"(",
"self",
".",
"is_lsm",
"or",
"self",
".",
"is_stk",
"or",
"self",
".",
"is_imagej",
"or",
"self",
".",
"is_fluoview",
"or",
"self",
".",
"is_micromanager",
")... | Return if pages can be appended to file without corrupting. | [
"Return",
"if",
"pages",
"can",
"be",
"appended",
"to",
"file",
"without",
"corrupting",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2944-L2948 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile.shaped_metadata | 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.series if s.kind.lower() == 'shaped') | python | 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.series if s.kind.lower() == 'shaped') | [
"def",
"shaped_metadata",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_shaped",
":",
"return",
"None",
"return",
"tuple",
"(",
"json_description_metadata",
"(",
"s",
".",
"pages",
"[",
"0",
"]",
".",
"is_shaped",
")",
"for",
"s",
"in",
"self",
... | Return tifffile metadata from JSON descriptions as dicts. | [
"Return",
"tifffile",
"metadata",
"from",
"JSON",
"descriptions",
"as",
"dicts",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2951-L2956 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile.stk_metadata | 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 page.description:
result['PlaneDesc... | python | 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 page.description:
result['PlaneDesc... | [
"def",
"stk_metadata",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_stk",
":",
"return",
"None",
"page",
"=",
"self",
".",
"pages",
"[",
"0",
"]",
"tags",
"=",
"page",
".",
"tags",
"result",
"=",
"{",
"}",
"result",
"[",
"'NumberPlanes'",
"... | Return STK metadata from UIC tags as dict. | [
"Return",
"STK",
"metadata",
"from",
"UIC",
"tags",
"as",
"dict",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L2974-L3007 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile.imagej_metadata | 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:
try:
result.update(page... | python | 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:
try:
result.update(page... | [
"def",
"imagej_metadata",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_imagej",
":",
"return",
"None",
"page",
"=",
"self",
".",
"pages",
"[",
"0",
"]",
"result",
"=",
"imagej_description_metadata",
"(",
"page",
".",
"is_imagej",
")",
"if",
"'IJM... | Return consolidated ImageJ metadata as dict. | [
"Return",
"consolidated",
"ImageJ",
"metadata",
"as",
"dict",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3010-L3021 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile.fluoview_metadata | 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 stamps from all pages
result['Stamp'] = pag... | python | 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 stamps from all pages
result['Stamp'] = pag... | [
"def",
"fluoview_metadata",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_fluoview",
":",
"return",
"None",
"result",
"=",
"{",
"}",
"page",
"=",
"self",
".",
"pages",
"[",
"0",
"]",
"result",
".",
"update",
"(",
"page",
".",
"tags",
"[",
"'... | Return consolidated FluoView metadata as dict. | [
"Return",
"consolidated",
"FluoView",
"metadata",
"as",
"dict",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3024-L3041 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile.fei_metadata | 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 'FEI_HELIOS' in tags:
return tags['FEI_HELIOS'... | python | 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 'FEI_HELIOS' in tags:
return tags['FEI_HELIOS'... | [
"def",
"fei_metadata",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_fei",
":",
"return",
"None",
"tags",
"=",
"self",
".",
"pages",
"[",
"0",
"]",
".",
"tags",
"if",
"'FEI_SFEG'",
"in",
"tags",
":",
"return",
"tags",
"[",
"'FEI_SFEG'",
"]",
... | Return FEI metadata from SFEG or HELIOS tags as dict. | [
"Return",
"FEI",
"metadata",
"from",
"SFEG",
"or",
"HELIOS",
"tags",
"as",
"dict",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3051-L3060 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile.sis_metadata | 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'].value)
except Exception:
pass
t... | python | 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'].value)
except Exception:
pass
t... | [
"def",
"sis_metadata",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_sis",
":",
"return",
"None",
"tags",
"=",
"self",
".",
"pages",
"[",
"0",
"]",
".",
"tags",
"result",
"=",
"{",
"}",
"try",
":",
"result",
".",
"update",
"(",
"tags",
"["... | Return Olympus SIS metadata from SIS and INI tags as dict. | [
"Return",
"Olympus",
"SIS",
"metadata",
"from",
"SIS",
"and",
"INI",
"tags",
"as",
"dict",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3070-L3084 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile.mdgel_metadata | 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
result = {}
for code in range(33445, 33... | python | 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
result = {}
for code in range(33445, 33... | [
"def",
"mdgel_metadata",
"(",
"self",
")",
":",
"for",
"page",
"in",
"self",
".",
"pages",
"[",
":",
"2",
"]",
":",
"if",
"'MDFileTag'",
"in",
"page",
".",
"tags",
":",
"tags",
"=",
"page",
".",
"tags",
"break",
"else",
":",
"return",
"None",
"resu... | Return consolidated metadata from MD GEL tags as dict. | [
"Return",
"consolidated",
"metadata",
"from",
"MD",
"GEL",
"tags",
"as",
"dict",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3087-L3101 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile.micromanager_metadata | 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
result.update(self.pages[0].tags['MicroManagerMetadat... | python | 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
result.update(self.pages[0].tags['MicroManagerMetadat... | [
"def",
"micromanager_metadata",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_micromanager",
":",
"return",
"None",
"# from file header",
"result",
"=",
"read_micromanager_metadata",
"(",
"self",
".",
"_fh",
")",
"# from tag",
"result",
".",
"update",
"("... | Return consolidated MicroManager metadata as dict. | [
"Return",
"consolidated",
"MicroManager",
"metadata",
"as",
"dict",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3135-L3143 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFile.scanimage_metadata | 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._fh)
result['FrameData'] = framedata
r... | python | 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._fh)
result['FrameData'] = framedata
r... | [
"def",
"scanimage_metadata",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_scanimage",
":",
"return",
"None",
"result",
"=",
"{",
"}",
"try",
":",
"framedata",
",",
"roidata",
"=",
"read_scanimage_metadata",
"(",
"self",
".",
"_fh",
")",
"result",
... | Return ScanImage non-varying frame and ROI metadata as dict. | [
"Return",
"ScanImage",
"non",
"-",
"varying",
"frame",
"and",
"ROI",
"metadata",
"as",
"dict",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3146-L3164 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPages.cache | 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 | python | 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 | [
"def",
"cache",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"bool",
"(",
"value",
")",
"if",
"self",
".",
"_cache",
"and",
"not",
"value",
":",
"self",
".",
"_clear",
"(",
")",
"self",
".",
"_cache",
"=",
"value"
] | Enable or disable caching of pages/frames. Clear cache if False. | [
"Enable",
"or",
"disable",
"caching",
"of",
"pages",
"/",
"frames",
".",
"Clear",
"cache",
"if",
"False",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3241-L3246 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPages.keyframe | 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 == 0:
self._keyframe = self.pages[0]
... | python | 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 == 0:
self._keyframe = self.pages[0]
... | [
"def",
"keyframe",
"(",
"self",
",",
"index",
")",
":",
"index",
"=",
"int",
"(",
"index",
")",
"if",
"index",
"<",
"0",
":",
"index",
"%=",
"len",
"(",
"self",
")",
"if",
"self",
".",
"_keyframe",
".",
"index",
"==",
"index",
":",
"return",
"if"... | Set current keyframe. Load TiffPage from file if necessary. | [
"Set",
"current",
"keyframe",
".",
"Load",
"TiffPage",
"from",
"file",
"if",
"necessary",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3264-L3290 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPages._load | 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:
return
fh = self.pare... | python | 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:
return
fh = self.pare... | [
"def",
"_load",
"(",
"self",
",",
"keyframe",
"=",
"True",
")",
":",
"if",
"self",
".",
"_cached",
":",
"return",
"pages",
"=",
"self",
".",
"pages",
"if",
"not",
"pages",
":",
"return",
"if",
"not",
"self",
".",
"_indexed",
":",
"self",
".",
"_see... | Read all remaining pages from file. | [
"Read",
"all",
"remaining",
"pages",
"from",
"file",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3299-L3318 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPages._load_virtual_frames | 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 already loaded')
p... | python | 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 already loaded')
p... | [
"def",
"_load_virtual_frames",
"(",
"self",
")",
":",
"pages",
"=",
"self",
".",
"pages",
"try",
":",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
"==",
"2",
":",
"raise",
"ValueError",
"(",
"'not supported on Python 2'",
")",
"if",
"len",
"(",
"page... | Calculate virtual TiffFrames. | [
"Calculate",
"virtual",
"TiffFrames",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3320-L3357 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPages._clear | 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 all but first TiffPage/TiffFrame
for i, page in enumerate... | python | 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 all but first TiffPage/TiffFrame
for i, page in enumerate... | [
"def",
"_clear",
"(",
"self",
",",
"fully",
"=",
"True",
")",
":",
"pages",
"=",
"self",
".",
"pages",
"if",
"not",
"pages",
":",
"return",
"self",
".",
"_keyframe",
"=",
"pages",
"[",
"0",
"]",
"if",
"fully",
":",
"# delete all but first TiffPage/TiffFr... | Delete all but first page from cache. Set keyframe to first page. | [
"Delete",
"all",
"but",
"first",
"page",
"from",
"cache",
".",
"Set",
"keyframe",
"to",
"first",
"page",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3359-L3375 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPages._seek | 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
if fh.closed:
raise ValueErr... | python | 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
if fh.closed:
raise ValueErr... | [
"def",
"_seek",
"(",
"self",
",",
"index",
",",
"maxpages",
"=",
"None",
")",
":",
"pages",
"=",
"self",
".",
"pages",
"lenpages",
"=",
"len",
"(",
"pages",
")",
"if",
"lenpages",
"==",
"0",
":",
"raise",
"IndexError",
"(",
"'index out of range'",
")",... | Seek file to offset of page specified by index. | [
"Seek",
"file",
"to",
"offset",
"of",
"page",
"specified",
"by",
"index",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3377-L3451 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPages._getlist | def _getlist(self, key=None, useframes=True, validate=True):
"""Return specified pages as list of TiffPages or TiffFrames.
The first item is a TiffPage, and is used as a keyframe for
following TiffFrames.
"""
getitem = self._getitem
_useframes = self.useframes
... | python | def _getlist(self, key=None, useframes=True, validate=True):
"""Return specified pages as list of TiffPages or TiffFrames.
The first item is a TiffPage, and is used as a keyframe for
following TiffFrames.
"""
getitem = self._getitem
_useframes = self.useframes
... | [
"def",
"_getlist",
"(",
"self",
",",
"key",
"=",
"None",
",",
"useframes",
"=",
"True",
",",
"validate",
"=",
"True",
")",
":",
"getitem",
"=",
"self",
".",
"_getitem",
"_useframes",
"=",
"self",
".",
"useframes",
"if",
"key",
"is",
"None",
":",
"key... | Return specified pages as list of TiffPages or TiffFrames.
The first item is a TiffPage, and is used as a keyframe for
following TiffFrames. | [
"Return",
"specified",
"pages",
"as",
"list",
"of",
"TiffPages",
"or",
"TiffFrames",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3453-L3500 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPages._getitem | 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('index out of range')
if key < len(... | python | 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('index out of range')
if key < len(... | [
"def",
"_getitem",
"(",
"self",
",",
"key",
",",
"validate",
"=",
"False",
")",
":",
"key",
"=",
"int",
"(",
"key",
")",
"pages",
"=",
"self",
".",
"pages",
"if",
"key",
"<",
"0",
":",
"key",
"%=",
"len",
"(",
"self",
")",
"elif",
"self",
".",
... | Return specified page from cache or file. | [
"Return",
"specified",
"page",
"from",
"cache",
"or",
"file",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3502-L3530 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage.asarray | def asarray(self, out=None, squeeze=True, lock=None, reopen=True,
maxsize=None, maxworkers=None, validate=True):
"""Read image data from file and return as numpy array.
Raise ValueError if format is unsupported.
Parameters
----------
out : numpy.ndarray, str, or... | python | def asarray(self, out=None, squeeze=True, lock=None, reopen=True,
maxsize=None, maxworkers=None, validate=True):
"""Read image data from file and return as numpy array.
Raise ValueError if format is unsupported.
Parameters
----------
out : numpy.ndarray, str, or... | [
"def",
"asarray",
"(",
"self",
",",
"out",
"=",
"None",
",",
"squeeze",
"=",
"True",
",",
"lock",
"=",
"None",
",",
"reopen",
"=",
"True",
",",
"maxsize",
"=",
"None",
",",
"maxworkers",
"=",
"None",
",",
"validate",
"=",
"True",
")",
":",
"# prope... | 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.
... | [
"Read",
"image",
"data",
"from",
"file",
"and",
"return",
"as",
"numpy",
"array",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3879-L4151 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage.asrgb | 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 keyframe
photometric = self.photometric
PHO... | python | 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 keyframe
photometric = self.photometric
PHO... | [
"def",
"asrgb",
"(",
"self",
",",
"uint8",
"=",
"False",
",",
"alpha",
"=",
"None",
",",
"colormap",
"=",
"None",
",",
"dmin",
"=",
"None",
",",
"dmax",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"asarray",
"(",
"... | Return image data as RGB(A).
Work in progress. | [
"Return",
"image",
"data",
"as",
"RGB",
"(",
"A",
")",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4153-L4207 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage._gettags | 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 | python | 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 | [
"def",
"_gettags",
"(",
"self",
",",
"codes",
"=",
"None",
",",
"lock",
"=",
"None",
")",
":",
"tags",
"=",
"[",
"]",
"for",
"tag",
"in",
"self",
".",
"tags",
".",
"values",
"(",
")",
":",
"code",
"=",
"tag",
".",
"code",
"if",
"not",
"codes",
... | Return list of (code, TiffTag). | [
"Return",
"list",
"of",
"(",
"code",
"TiffTag",
")",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4209-L4216 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage.hash | 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,
self.extrasamples, self.photometric, self.... | python | 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,
self.extrasamples, self.photometric, self.... | [
"def",
"hash",
"(",
"self",
")",
":",
"return",
"hash",
"(",
"self",
".",
"_shape",
"+",
"(",
"self",
".",
"tilewidth",
",",
"self",
".",
"tilelength",
",",
"self",
".",
"tiledepth",
",",
"self",
".",
"bitspersample",
",",
"self",
".",
"fillorder",
"... | Return checksum to identify pages in same series. | [
"Return",
"checksum",
"to",
"identify",
"pages",
"in",
"same",
"series",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4240-L4247 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage._offsetscounts | 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.databytecounts
return clean_offsetscoun... | python | 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.databytecounts
return clean_offsetscoun... | [
"def",
"_offsetscounts",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_contiguous",
":",
"offset",
",",
"bytecount",
"=",
"self",
".",
"is_contiguous",
"return",
"[",
"offset",
"]",
",",
"[",
"bytecount",
"]",
"if",
"self",
".",
"is_tiled",
":",
"return"... | Return simplified offsets and bytecounts. | [
"Return",
"simplified",
"offsets",
"and",
"bytecounts",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4250-L4257 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage.is_contiguous | 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 not in (8, 16, 32, 64)):
return None
if 'TileWidth' in self.tags:
if... | python | 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 not in (8, 16, 32, 64)):
return None
if 'TileWidth' in self.tags:
if... | [
"def",
"is_contiguous",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"compression",
"!=",
"1",
"or",
"self",
".",
"bitspersample",
"not",
"in",
"(",
"8",
",",
"16",
",",
"32",
",",
"64",
")",
")",
":",
"return",
"None",
"if",
"'TileWidth'",
"in",... | Return offset and size of contiguous data, else None.
Excludes prediction and fill_order. | [
"Return",
"offset",
"and",
"size",
"of",
"contiguous",
"data",
"else",
"None",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4260-L4287 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage.is_final | 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 and not self.is_subsampled) | python | 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 and not self.is_subsampled) | [
"def",
"is_final",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"is_contiguous",
"and",
"self",
".",
"fillorder",
"==",
"1",
"and",
"self",
".",
"predictor",
"==",
"1",
"and",
"not",
"self",
".",
"is_subsampled",
")"
] | Return if page's image data are stored in final form.
Excludes byte-swapping. | [
"Return",
"if",
"page",
"s",
"image",
"data",
"are",
"stored",
"in",
"final",
"form",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4290-L4297 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage.is_memmappable | 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.is_contiguous[0] % self.dtype.itemsize == 0) | python | 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.is_contiguous[0] % self.dtype.itemsize == 0) | [
"def",
"is_memmappable",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"parent",
".",
"filehandle",
".",
"is_file",
"and",
"self",
".",
"is_final",
"and",
"# (self.bitspersample == 8 or self.parent.isnative) and",
"self",
".",
"is_contiguous",
"[",
"0",
"]",
... | Return if page's image data in file can be memory-mapped. | [
"Return",
"if",
"page",
"s",
"image",
"data",
"in",
"file",
"can",
"be",
"memory",
"-",
"mapped",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4300-L4304 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage.flags | def flags(self):
"""Return set of flags."""
return set((name.lower() for name in sorted(TIFF.FILE_FLAGS)
if getattr(self, 'is_' + name))) | python | def flags(self):
"""Return set of flags."""
return set((name.lower() for name in sorted(TIFF.FILE_FLAGS)
if getattr(self, 'is_' + name))) | [
"def",
"flags",
"(",
"self",
")",
":",
"return",
"set",
"(",
"(",
"name",
".",
"lower",
"(",
")",
"for",
"name",
"in",
"sorted",
"(",
"TIFF",
".",
"FILE_FLAGS",
")",
"if",
"getattr",
"(",
"self",
",",
"'is_'",
"+",
"name",
")",
")",
")"
] | Return set of flags. | [
"Return",
"set",
"of",
"flags",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4366-L4369 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage.andor_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
result = {'Id': tags['AndorId'].value}
for tag in list(self.tags.values()):
... | python | 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
result = {'Id': tags['AndorId'].value}
for tag in list(self.tags.values()):
... | [
"def",
"andor_tags",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_andor",
":",
"return",
"None",
"tags",
"=",
"self",
".",
"tags",
"result",
"=",
"{",
"'Id'",
":",
"tags",
"[",
"'AndorId'",
"]",
".",
"value",
"}",
"for",
"tag",
"in",
"list"... | Return consolidated metadata from Andor tags as dict.
Remove Andor tags from self.tags. | [
"Return",
"consolidated",
"metadata",
"from",
"Andor",
"tags",
"as",
"dict",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4382-L4400 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage.epics_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 None
result = {}
tags = self.tags
for tag in list(self.tags.values()):
c... | python | 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 None
result = {}
tags = self.tags
for tag in list(self.tags.values()):
c... | [
"def",
"epics_tags",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_epics",
":",
"return",
"None",
"result",
"=",
"{",
"}",
"tags",
"=",
"self",
".",
"tags",
"for",
"tag",
"in",
"list",
"(",
"self",
".",
"tags",
".",
"values",
"(",
")",
")"... | Return consolidated metadata from EPICS areaDetector tags as dict.
Remove areaDetector tags from self.tags. | [
"Return",
"consolidated",
"metadata",
"from",
"EPICS",
"areaDetector",
"tags",
"as",
"dict",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4403-L4431 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage.ndpi_tags | 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[name] = tags[name].value
for code, name in TIFF.NDP... | python | 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[name] = tags[name].value
for code, name in TIFF.NDP... | [
"def",
"ndpi_tags",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_ndpi",
":",
"return",
"None",
"tags",
"=",
"self",
".",
"tags",
"result",
"=",
"{",
"}",
"for",
"name",
"in",
"(",
"'Make'",
",",
"'Model'",
",",
"'Software'",
")",
":",
"resu... | Return consolidated metadata from Hamamatsu NDPI as dict. | [
"Return",
"consolidated",
"metadata",
"from",
"Hamamatsu",
"NDPI",
"as",
"dict",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4434-L4447 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage.geotiff_tags | 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.warning('GeoTIFF tags: invalid GeoKeyDirectoryTag')
... | python | 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.warning('GeoTIFF tags: invalid GeoKeyDirectoryTag')
... | [
"def",
"geotiff_tags",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_geotiff",
":",
"return",
"None",
"tags",
"=",
"self",
".",
"tags",
"gkd",
"=",
"tags",
"[",
"'GeoKeyDirectoryTag'",
"]",
".",
"value",
"if",
"gkd",
"[",
"0",
"]",
"!=",
"1",
... | Return consolidated metadata from GeoTIFF tags as dict. | [
"Return",
"consolidated",
"metadata",
"from",
"GeoTIFF",
"tags",
"as",
"dict",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4450-L4541 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage.is_imagej | 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=':
return description
return None | python | 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=':
return description
return None | [
"def",
"is_imagej",
"(",
"self",
")",
":",
"for",
"description",
"in",
"(",
"self",
".",
"description",
",",
"self",
".",
"description1",
")",
":",
"if",
"not",
"description",
":",
"return",
"None",
"if",
"description",
"[",
":",
"7",
"]",
"==",
"'Imag... | Return ImageJ description if exists, else None. | [
"Return",
"ImageJ",
"description",
"if",
"exists",
"else",
"None",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4575-L4582 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage.is_shaped | 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] == '{' and '"shape":' in description:
return des... | python | 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] == '{' and '"shape":' in description:
return des... | [
"def",
"is_shaped",
"(",
"self",
")",
":",
"for",
"description",
"in",
"(",
"self",
".",
"description",
",",
"self",
".",
"description1",
")",
":",
"if",
"not",
"description",
":",
"return",
"None",
"if",
"description",
"[",
":",
"1",
"]",
"==",
"'{'",... | Return description containing array shape if exists, else None. | [
"Return",
"description",
"containing",
"array",
"shape",
"if",
"exists",
"else",
"None",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4585-L4594 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage.is_metaseries | 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>') and d.endswith('</MetaData>') | python | 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>') and d.endswith('</MetaData>') | [
"def",
"is_metaseries",
"(",
"self",
")",
":",
"if",
"self",
".",
"index",
">",
"1",
"or",
"self",
".",
"software",
"!=",
"'MetaSeries'",
":",
"return",
"False",
"d",
"=",
"self",
".",
"description",
"return",
"d",
".",
"startswith",
"(",
"'<MetaData>'",... | Page contains MDS MetaSeries metadata in ImageDescription tag. | [
"Page",
"contains",
"MDS",
"MetaSeries",
"metadata",
"in",
"ImageDescription",
"tag",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4638-L4643 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage.is_ome | 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>' | python | 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>' | [
"def",
"is_ome",
"(",
"self",
")",
":",
"if",
"self",
".",
"index",
">",
"1",
"or",
"not",
"self",
".",
"description",
":",
"return",
"False",
"d",
"=",
"self",
".",
"description",
"return",
"d",
"[",
":",
"14",
"]",
"==",
"'<?xml version='",
"and",
... | Page contains OME-XML in ImageDescription tag. | [
"Page",
"contains",
"OME",
"-",
"XML",
"in",
"ImageDescription",
"tag",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4646-L4651 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPage.is_scn | 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>' | python | 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>' | [
"def",
"is_scn",
"(",
"self",
")",
":",
"if",
"self",
".",
"index",
">",
"1",
"or",
"not",
"self",
".",
"description",
":",
"return",
"False",
"d",
"=",
"self",
".",
"description",
"return",
"d",
"[",
":",
"14",
"]",
"==",
"'<?xml version='",
"and",
... | Page contains Leica SCN XML in ImageDescription tag. | [
"Page",
"contains",
"Leica",
"SCN",
"XML",
"in",
"ImageDescription",
"tag",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4654-L4659 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFrame._gettags | 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 = []
with lock:
fh.seek(self.offs... | python | 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 = []
with lock:
fh.seek(self.offs... | [
"def",
"_gettags",
"(",
"self",
",",
"codes",
"=",
"None",
",",
"lock",
"=",
"None",
")",
":",
"fh",
"=",
"self",
".",
"parent",
".",
"filehandle",
"tiff",
"=",
"self",
".",
"parent",
".",
"tiff",
"unpack",
"=",
"struct",
".",
"unpack",
"lock",
"="... | Return list of (code, TiffTag) from file. | [
"Return",
"list",
"of",
"(",
"code",
"TiffTag",
")",
"from",
"file",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4808-L4846 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFrame.aspage | 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) | python | 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) | [
"def",
"aspage",
"(",
"self",
")",
":",
"if",
"self",
".",
"offset",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'cannot return virtual frame as page.'",
")",
"self",
".",
"parent",
".",
"filehandle",
".",
"seek",
"(",
"self",
".",
"offset",
")",
"retu... | Return TiffPage from file. | [
"Return",
"TiffPage",
"from",
"file",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4848-L4853 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFrame.asarray | 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 TiffFrame instance instead)"
if self._keyfram... | python | 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 TiffFrame instance instead)"
if self._keyfram... | [
"def",
"asarray",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: fix TypeError on Python 2",
"# \"TypeError: unbound method asarray() must be called with TiffPage",
"# instance as first argument (got TiffFrame instance instead)\"",
"if",
"self",
".... | Read image data from file and return as numpy array. | [
"Read",
"image",
"data",
"from",
"file",
"and",
"return",
"as",
"numpy",
"array",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4855-L4863 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFrame.asrgb | 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.asrgb(self, *args, **kwargs) | python | 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.asrgb(self, *args, **kwargs) | [
"def",
"asrgb",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_keyframe",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'keyframe not set'",
")",
"kwargs",
"[",
"'validate'",
"]",
"=",
"False",
"return",
"Tif... | Read image data from file and return RGB image as numpy array. | [
"Read",
"image",
"data",
"from",
"file",
"and",
"return",
"RGB",
"image",
"as",
"numpy",
"array",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4865-L4870 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFrame.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 RuntimeError('incompat... | python | 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 RuntimeError('incompat... | [
"def",
"keyframe",
"(",
"self",
",",
"keyframe",
")",
":",
"if",
"self",
".",
"_keyframe",
"==",
"keyframe",
":",
"return",
"if",
"self",
".",
"_keyframe",
"is",
"not",
"None",
":",
"raise",
"RuntimeError",
"(",
"'cannot reset keyframe'",
")",
"if",
"len",... | Set keyframe. | [
"Set",
"keyframe",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4878-L4893 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffFrame.is_contiguous | 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], self._keyframe.is_contiguous[1]
return None | python | 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], self._keyframe.is_contiguous[1]
return None | [
"def",
"is_contiguous",
"(",
"self",
")",
":",
"if",
"self",
".",
"_keyframe",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'keyframe not set'",
")",
"if",
"self",
".",
"_keyframe",
".",
"is_contiguous",
":",
"return",
"self",
".",
"_offsetscounts",
"["... | Return offset and size of contiguous data, else None. | [
"Return",
"offset",
"and",
"size",
"of",
"contiguous",
"data",
"else",
"None",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L4896-L4902 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffTag.name | def name(self):
"""Return name of tag from TIFF.TAGS registry."""
try:
return TIFF.TAGS[self.code]
except KeyError:
return str(self.code) | python | def name(self):
"""Return name of tag from TIFF.TAGS registry."""
try:
return TIFF.TAGS[self.code]
except KeyError:
return str(self.code) | [
"def",
"name",
"(",
"self",
")",
":",
"try",
":",
"return",
"TIFF",
".",
"TAGS",
"[",
"self",
".",
"code",
"]",
"except",
"KeyError",
":",
"return",
"str",
"(",
"self",
".",
"code",
")"
] | Return name of tag from TIFF.TAGS registry. | [
"Return",
"name",
"of",
"tag",
"from",
"TIFF",
".",
"TAGS",
"registry",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L5038-L5043 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffTag._fix_lsm_bitspersample | def _fix_lsm_bitspersample(self, parent):
"""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.
"""
if self.code != 258 or self.count != 2:
return
# TODO: t... | python | def _fix_lsm_bitspersample(self, parent):
"""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.
"""
if self.code != 258 or self.count != 2:
return
# TODO: t... | [
"def",
"_fix_lsm_bitspersample",
"(",
"self",
",",
"parent",
")",
":",
"if",
"self",
".",
"code",
"!=",
"258",
"or",
"self",
".",
"count",
"!=",
"2",
":",
"return",
"# TODO: test this case; need example file",
"log",
".",
"warning",
"(",
"'TiffTag %i: correcting... | 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. | [
"Correct",
"LSM",
"bitspersample",
"tag",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L5045-L5059 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPageSeries.asarray | 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 = self.transform(result)
return result
retur... | python | 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 = self.transform(result)
return result
retur... | [
"def",
"asarray",
"(",
"self",
",",
"out",
"=",
"None",
")",
":",
"if",
"self",
".",
"parent",
":",
"result",
"=",
"self",
".",
"parent",
".",
"asarray",
"(",
"series",
"=",
"self",
",",
"out",
"=",
"out",
")",
"if",
"self",
".",
"transform",
"is... | Return image data from series of TIFF pages as numpy array. | [
"Return",
"image",
"data",
"from",
"series",
"of",
"TIFF",
"pages",
"as",
"numpy",
"array",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L5127-L5134 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPageSeries.offset | 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 None
if not po... | python | 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 None
if not po... | [
"def",
"offset",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_pages",
":",
"return",
"None",
"pos",
"=",
"0",
"for",
"page",
"in",
"self",
".",
"_pages",
":",
"if",
"page",
"is",
"None",
":",
"return",
"None",
"if",
"not",
"page",
".",
"is_... | Return offset to series data in file, if any. | [
"Return",
"offset",
"to",
"series",
"data",
"in",
"file",
"if",
"any",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L5137-L5162 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffPageSeries._getitem | 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
return self.parent.pages._getitem(index + key)... | python | 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
return self.parent.pages._getitem(index + key)... | [
"def",
"_getitem",
"(",
"self",
",",
"key",
")",
":",
"key",
"=",
"int",
"(",
"key",
")",
"if",
"key",
"<",
"0",
":",
"key",
"%=",
"self",
".",
"_len",
"if",
"len",
"(",
"self",
".",
"_pages",
")",
"==",
"1",
"and",
"0",
"<",
"key",
"<",
"s... | Return specified page of series from cache or file. | [
"Return",
"specified",
"page",
"of",
"series",
"from",
"cache",
"or",
"file",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L5180-L5188 |
nion-software/nionswift-io | nionswift_plugin/TIFF_IO/tifffile.py | TiffSequence.asarray | def asarray(self, file=None, out=None, **kwargs):
"""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.
"""
if file is not None:
if isinstance(f... | python | def asarray(self, file=None, out=None, **kwargs):
"""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.
"""
if file is not None:
if isinstance(f... | [
"def",
"asarray",
"(",
"self",
",",
"file",
"=",
"None",
",",
"out",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"file",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"file",
",",
"int",
")",
":",
"return",
"self",
".",
"imread",
... | 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. | [
"Read",
"image",
"data",
"from",
"files",
"and",
"return",
"as",
"numpy",
"array",
"."
] | train | https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L5377-L5400 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.