[ PROMPT_NODE_26926 ]
tables
[ SKILL_DOCUMENTATION ]
# OMERO 表格
本参考指南涵盖了使用 OMERO.tables 在 OMERO 中创建和管理结构化表格数据。
## OMERO.tables 概述
OMERO.tables 提供了一种存储与 OMERO 对象关联的结构化表格数据的方法。表格以 HDF5 文件形式存储,并可进行高效查询。常见用例包括:
- 存储图像的定量测量结果
- 记录分析结果
- 跟踪实验元数据
- 将测量结果链接到特定图像或 ROI
## 列类型
OMERO.tables 支持多种列类型:
- **LongColumn**: 整数值 (64-bit)
- **DoubleColumn**: 浮点数值
- **StringColumn**: 文本数据 (固定最大长度)
- **BoolColumn**: 布尔值
- **LongArrayColumn**: 整数数组
- **DoubleArrayColumn**: 浮点数数组
- **FileColumn**: OMERO 文件引用
- **ImageColumn**: OMERO 图像引用
- **RoiColumn**: OMERO ROI 引用
- **WellColumn**: OMERO 孔板引用
## 创建表格
### 基础表格创建
python
from random import random
import omero.grid
# 创建唯一表格名称
table_name = f"MyAnalysisTable_{random()}"
# 定义列(初始化时为空数据)
col1 = omero.grid.LongColumn('ImageID', '图像标识符', [])
col2 = omero.grid.DoubleColumn('MeanIntensity', '平均像素强度', [])
col3 = omero.grid.StringColumn('Category', '分类', 64, [])
columns = [col1, col2, col3]
# 获取资源并创建表格
resources = conn.c.sf.sharedResources()
repository_id = resources.repositories().descriptions[0].getId().getValue()
table = resources.newTable(repository_id, table_name)
# 使用列定义初始化表格
table.initialize(columns)
### 向表格添加数据
python
# 准备数据
image_ids = [1, 2, 3, 4, 5]
intensities = [123.4, 145.2, 98.7, 156.3, 132.8]
categories = ["Good", "Good", "Poor", "Excellent", "Good"]
# 创建数据列
data_col1 = omero.grid.LongColumn('ImageID', '图像标识符', image_ids)
data_col2 = omero.grid.DoubleIntensity('MeanIntensity', '平均像素强度', intensities)
data_col3 = omero.grid.StringColumn('Category', '分类', 64, categories)
data = [data_col1, data_col2, data_col3]
# 向表格添加数据
table.addData(data)
# 获取文件引用
orig_file = table.getOriginalFile()
table.close() # 完成后务必关闭表格
### 将表格链接到数据集
python
# 从表格创建文件注释
orig_file_id = orig_file.id.val
file_ann = omero.model.FileAnnotatio