本文整理汇总了Python中ClearMap.IO.readMetaData方法的典型用法代码示例。如果您正苦于以下问题:Python IO.readMetaData方法的具体用法?Python IO.readMetaData怎么用?Python IO.readMetaData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClearMap.IO
的用法示例。
在下文中一共展示了IO.readMetaData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: readMetaData
# 需要导入模块: from ClearMap import IO [as 别名]
# 或者: from ClearMap.IO import readMetaData [as 别名]
def readMetaData(source, info=all, sort=True):
"""Reads the meta data from the image files
Arguments:
source: the data source
info (list or all): optional list of keywords
sort (bool): if True use first file to infer meta data, otherwise arbitrary file
Returns:
object: an object with the meta data
"""
firstfile = firstFile(source, sort=sort)
mdata = io.readMetaData(firstfile, info=info)
if "size" in mdata.keys():
mdata["size"] = dataSize(source)
return mdata
示例2:
# 需要导入模块: from ClearMap import IO [as 别名]
# 或者: from ClearMap.IO import readMetaData [as 别名]
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 14 17:21:40 2016
@author: ckirst
"""
import os
import ClearMap.Settings as settings
import ClearMap.IO as io
fn = os.path.join(settings.ClearMapPath, 'Test/Data/OME/16-17-27_0_8X-s3-20HF_UltraII_C00_xyz-Table Z1000.ome.tif')
io.readMetaData(fn, info = ['overlap', 'resolution', 'size'])
fn = os.path.join(settings.ClearMapPath, 'Test/Data/Tif/test.tif')
io.readMetaData(fn, info = ['overlap', 'resolution', 'size', 'description'])
io.readMetaData(fn)
fn = os.path.join(settings.ClearMapPath, 'Test/Data/OME/16-17-27_0_8X-s3-20HF_UltraII_C00_xyz-Table Z\d{4}.ome.tif')
io.readMetaData(fn, info = ['overlap', 'resolution', 'size'])
import tifffile as t;
示例3: cropData
# 需要导入模块: from ClearMap import IO [as 别名]
# 或者: from ClearMap.IO import readMetaData [as 别名]
def cropData(source, sink=None, x=all, y=all, z=all, adjustOverlap=False, verbose=True, processes=all):
"""Crop source from start to stop point
Arguments:
source (str or array): filename or data array of source
sink (str or None): filename or sink
x,y,z (tuple or all): the range to crop the data to
adjustOverlap (bool): correct overlap meta data if exists
Return:
str or array: array or filename with cropped data
"""
if sink is None:
return readDataFiles(source, x=x, y=y, z=z)
else: # sink assumed to be file expression
if not io.isFileExpression(sink):
raise RuntimeError("cropping data to different format not supported!")
fileheader, fileext, digitfrmt = splitFileExpression(sink)
# read first image to get data size and type
fp, fl = readFileList(source)
nz = len(fl)
rz = io.toDataRange(nz, r=z)
if adjustOverlap: # change overlap in first file
try:
fn = os.path.join(fp, fl[0])
info = io.readMetaData(fn, info=["description", "overlap", "resolution"])
description = str(info["description"])
overlap = numpy.array(info["overlap"], dtype=float)
resolution = numpy.array(info["resolution"], dtype=float)
except:
raise RuntimeWarning("could not modify overlap!")
fullsize = io.dataSize(fn)
data = io.readData(fn, x=x, y=y)
# overlap in pixels
poverlap = overlap[:2] / resolution[:2]
print poverlap
# cropped pixel
xr = io.toDataRange(fullsize[0], r=x)
yr = io.toDataRange(fullsize[1], r=y)
print xr
print yr
print fullsize
poverlap[0] = poverlap[0] - xr[0] - (fullsize[0] - xr[1])
poverlap[1] = poverlap[1] - yr[0] - (fullsize[1] - yr[1])
print poverlap
# new overlap in microns
overlap = poverlap * resolution[:2]
# check for consistency
if numpy.abs(fullsize[0] - xr[1] - xr[0]) > 1 or numpy.abs(fullsize[1] - yr[1] - yr[0]) > 1:
raise RuntimeWarning("cropping is inconsistent with overlap )modification!")
# change image description
import ClearMap.IO.TIF as CMTIF
description = CMTIF.changeOMEMetaDataString(description, {"overlap": overlap})
print len(description)
# write first file
fnout = fileheader + (digitfrmt % 0) + fileext
io.writeData(fnout, data, info=description)
zr = range(rz[0] + 1, rz[1])
else:
zr = range(rz[0], rz[1])
print zr
nZ = len(zr)
if processes is None:
processes = 1
if processes is all:
processes = multiprocessing.cpu_count()
if processes > 1: # parallel processing
pool = multiprocessing.Pool(processes=processes)
argdata = []
for i, z in enumerate(zr):
if verbose:
argdata.append(
(os.path.join(fp, fl[z]), fileheader + (digitfrmt % (i + 1)) + fileext, x, y, (i + 1), (nZ + 1))
)
else:
argdata.append(
(os.path.join(fp, fl[z]), fileheader + (digitfrmt % (i + 1)) + fileext, x, y, None, None)
)
#.........这里部分代码省略.........
示例4: x
# 需要导入模块: from ClearMap import IO [as 别名]
# 或者: from ClearMap.IO import readMetaData [as 别名]
fn = os.path.join(datadir, r'160412_mosaic_15-20-19/15-20-19_mosaic_UltraII\[(?P<row>\d{2}) x (?P<col>\d{2})\]_C00_xyz-Table Z(?P<z>\d{4}).ome.tif')
_, gr = st.findFileList(fn , sort = True, groups = ['row','col'], absolute = True)
groups = [];
for i in range(gr.shape[1]):
groups.append(np.unique(gr[:,i]));
print groups
for i in groups[0]:
for j in groups[1]:
fileExpression = os.path.join(datadir, r'160412_mosaic_15-20-19/15-20-19_mosaic_UltraII\[%s x %s]_C00_xyz-Table Z\d{4}.ome.tif' % (i,j))
io.dataSize(fileExpression)
io.readMetaData(fileExpression, info = ['size', 'overlap', 'resolution'])
import ClearMap.IO.FileList as fl;
reload(fl)
fncrop = os.path.join(datadir, r'cropped/15-20-19_mosaic_UltraII_%s_x_%s_C00_xyz-Table Z\d{4}.ome.tif' % (i,j))
fc = fl.cropData(fileExpression, fncrop, x = (400, -400), y = (550, -550), adjustOverlap = True, processes = all)
#fc1 = fl.firstFile(fc)
#io.readMetaData(fc1, info = ['overlap', 'resolution', 'size']);