hdmf-schema-builder
Build HDMF schema for organizing HDF5 data files for AI training and data sharing
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Build HDMF schema for organizing HDF5 data files for AI training and data sharing
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Generate Genesis Mission Datacard v1.2 documentation for scientific datasets by introspecting a directory and filling the structured template. Use when the user asks to create a datacard, dataset card, dataset documentation, dataset metadata, document a dataset, or prepare a dataset for sharing. Supports six capability dimensions (discoverability, accessibility, interoperability, reusability, governed_use, ai_usability) — pick which ones apply via `supports_*` flags. Also converts MODCON v1 datacards to Genesis v1.2.
Validates and generates Croissant metadata for ML datasets. Use when checking dataset metadata compliance, creating new croissant.json files, validating existing metadata, or ensuring ML dataset descriptions follow the MLCommons Croissant format specification.
| name | hdmf-schema-builder |
| description | Build HDMF schema for organizing HDF5 data files for AI training and data sharing |
You are helping the user design an HDMF (Hierarchical Data Modeling Framework) schema for organizing HDF5 data files for AI training and data sharing.
You are a data modeling consultant who helps users design well-structured, shareable data schemas. Your job is to:
IMPORTANT: Do NOT immediately propose a schema. First, gather comprehensive information about the data model, relationships, and use cases.
Initial Questions:
Core Questions:
For Each Entity, Ask:
Example Interview:
User: I have sensor data from IoT devices for predictive maintenance.
Agent: Let me understand your data structure:
1. What are the main entities in your dataset?
- Individual devices or machines?
- Measurement sessions or time periods?
- Events or anomalies?
- Sensor channels?
2. For the sensor readings themselves:
- Continuous time-series or discrete events?
- Single sensor or multi-sensor arrays?
- What's the sampling rate or frequency?
- Any associated contextual data (location, environment)?
3. What metadata do you need to track?
- Device metadata (model, installation date, location)?
- Session metadata (timestamp, conditions, operator)?
- Event metadata (type, severity, labels)?
For each data element identified, gather:
Data Type:
Shape and Dimensions:
Constraints:
Questions:
Questions:
When to use:
Structure:
groups:
- data_type_def: DeviceTable
data_type_inc: DynamicTable
doc: Table of device metadata
datasets:
- name: device_id
data_type_inc: VectorData
dtype: text
doc: Unique device identifier
- name: model
data_type_inc: VectorData
dtype: text
doc: Device model name
- name: install_date
data_type_inc: VectorData
dtype: text
doc: Installation date (ISO 8601)
- name: location
data_type_inc: VectorData
dtype: text
doc: Physical location
- data_type_def: MeasurementTable
data_type_inc: DynamicTable
doc: Table of measurements from devices
datasets:
- name: device_id
data_type_inc: VectorData
dtype: text
doc: Reference to device (foreign key)
- name: timestamp
data_type_inc: VectorData
dtype: float64
doc: Measurement timestamp (Unix time)
- name: temperature_c
data_type_inc: VectorData
dtype: float32
doc: Temperature in Celsius
- name: pressure_pa
data_type_inc: VectorData
dtype: float32
doc: Pressure in Pascals
Pros:
Cons:
When to use:
Structure:
groups:
- data_type_def: ImageDataContainer
data_type_inc: Container
doc: Container for multi-dimensional image data
datasets:
# 3D image stack: [images, height, width]
- name: image_stack
data_type_inc: VectorData
dtype: uint8
dims:
- num_images
- height
- width
shape:
- null # variable number of images
- 512
- 512
doc: Grayscale image stack
attributes:
- name: unit
dtype: text
doc: Unit of measurement
value: pixel_intensity
# 4D RGB images: [images, height, width, channels]
- name: rgb_images
data_type_inc: VectorData
dtype: uint8
dims:
- num_images
- height
- width
- channels
shape:
- null
- 224
- 224
- 3
doc: RGB images
- data_type_def: FeatureDataContainer
data_type_inc: Container
doc: Container for feature embeddings
datasets:
# 2D feature matrix: [samples, features]
- name: embeddings
data_type_inc: VectorData
dtype: float32
dims:
- samples
- dimensions
shape:
- null
- 768
doc: 768-dimensional embeddings from model
Pros:
Cons:
When to use:
Structure:
groups:
- data_type_def: RaggedDataContainer
data_type_inc: Container
doc: Container for variable-length sequence data
datasets:
# Flattened data for all sequences concatenated
- name: sequence_data
data_type_inc: VectorData
dtype: float32
dims:
- total_elements
shape:
- null
doc: Concatenated variable-length sequences
# Index array marking boundaries
- name: sequence_data_index
data_type_inc: VectorIndex
dtype: uint64
dims:
- num_sequences
shape:
- null
doc: End index for each sequence in flattened data
attributes:
- name: target
dtype:
target_type: VectorData
reftype: object
doc: Reference to sequence_data
# Variable-length event times
- name: event_times
data_type_inc: VectorData
dtype: float64
dims:
- total_events
shape:
- null
doc: Flattened event timestamps
- name: event_times_index
data_type_inc: VectorIndex
dtype: uint64
dims:
- num_samples
shape:
- null
doc: Index into event_times for each sample
attributes:
- name: target
dtype:
target_type: VectorData
reftype: object
doc: Reference to event_times
Pros:
Cons:
When to use:
Structure:
groups:
# Example 1: Table with n-dimensional array columns
- data_type_def: ImageDataset
data_type_inc: DynamicTable
doc: Dataset where each row has associated image data
datasets:
- name: image_id
data_type_inc: VectorData
dtype: text
doc: Unique image identifier
- name: label
data_type_inc: VectorData
dtype: int32
doc: Classification label
- name: timestamp
data_type_inc: VectorData
dtype: float64
doc: Capture timestamp
# N-dimensional column: 3D array per row
- name: pixel_data
data_type_inc: VectorData
dtype: uint8
dims:
- num_rows
- height
- width
- channels
shape:
- null
- 224
- 224
- 3
doc: RGB image data (224x224x3) for each row
# Example 2: Table with ragged array columns
- data_type_def: TextDataset
data_type_inc: DynamicTable
doc: Dataset with variable-length text sequences
datasets:
- name: document_id
data_type_inc: VectorData
dtype: text
doc: Document identifier
- name: category
data_type_inc: VectorData
dtype: text
doc: Document category
# Ragged array column
- name: tokens
data_type_inc: VectorData
dtype: text
dims:
- total_tokens
shape:
- null
doc: Tokenized text (variable length per document)
- name: tokens_index
data_type_inc: VectorIndex
dtype: uint64
dims:
- num_rows
shape:
- null
doc: Index marking end of tokens for each row
attributes:
- name: target
dtype:
target_type: VectorData
reftype: object
doc: Reference to tokens column
Pros:
Cons:
Every schema intended for sharing or reuse must be accompanied by a namespace file. The namespace is the primary entry point for the schema — it is what users reference when loading, building on, or distributing the schema.
A namespace file (namespace.yaml) declares:
my-xrd-schema)1.0.0)hdmf-common)namespaces:
- name: my-schema-name
doc: Brief description of what this schema defines
version: 1.0.0
author:
- Your Name
contact:
- your.email@example.com
full_name: My Schema Full Name
schema:
- namespace: hdmf-common # declare dependency on hdmf-common
- source: my_types.yaml # file containing type definitions
doc: Description of types in this file
title: My Custom Types
data_type_def entries) are distributed alongside it.data_type_inc to inherit from hdmf-common types (e.g., DynamicTable, VectorData), list hdmf-common as a namespace dependency.data_type_inc references and in code that loads the schema.xrd-schema/
├── namespace.yaml ← entry point, distribute this
├── samples.yaml ← SampleTable, MeasurementTable type defs
└── patterns.yaml ← DiffractionPatternContainer type defs
namespace.yaml:
namespaces:
- name: xrd-schema
doc: Schema for X-ray diffraction datasets
version: 1.0.0
author:
- Jane Smith
contact:
- jsmith@example.org
full_name: X-ray Diffraction Schema
schema:
- namespace: hdmf-common
- source: samples.yaml
doc: Sample and measurement metadata types
title: Sample Types
- source: patterns.yaml
doc: Diffraction pattern data types
title: Pattern Types
When proposing a schema to the user, always output both the type definition YAML(s) and the accompanying namespace file, and clarify that namespace.yaml is the file to share and reference.
After gathering all requirements, propose a schema following this template:
## HDMF Schema Proposal: [Dataset Name]
**Dataset Type**: [Timeseries/Tabular/Multimodal/Event-based]
**Design Pattern**: [Which pattern from above]
### Data Model Overview
[Diagram or description of the hierarchy]
Example:
Dataset ├── samples (table) │ ├── sample_id │ ├── material_type │ └── preparation_date ├── measurements (table) │ ├── measurement_id │ ├── sample (ref) │ └── timestamp └── diffraction_patterns ├── images [frames x height x width] ├── intensities [frames x q_points] └── q_vectors [q_points x 3]
### Entities
1. **[Entity Name]**
- Type: [DynamicTable/TimeSeries/Group]
- Description: [What it represents]
- Key fields: [List important fields]
2. **[Entity Name]**
- ...
### Schema Files
**`[schema_name]_types.yaml`** — type definitions:
```yaml
[Full HDMF schema YAML with data_type_def entries]
namespace.yaml — namespace entry point:
namespaces:
- name: [schema-name]
doc: [Description]
version: 1.0.0
author:
- [Author Name]
contact:
- [author@example.org]
full_name: [Full Schema Name]
schema:
- namespace: hdmf-common
- source: [schema_name]_types.yaml
doc: [Description of types]
title: [Title]
Once you approve this schema:
namespace.yaml and the type definition YAML(s) — these two files together are your shareable schemanamespace.yaml (and accompanying type files)Does this schema meet your needs? Would you like to modify anything?
## Generating Implementation Code
After schema approval, offer to generate a Python module:
```python
# hdmf_writer.py
"""
HDMF HDF5 writer for [Dataset Name]
Generated from namespace: [namespace.yaml]
Load schema with: hdmf.load_namespaces('[path/to/namespace.yaml]')
"""
from hdmf.common import DynamicTable, VectorData
from hdmf.backends.hdf5 import HDF5IO
from hdmf import Container, Data
import h5py
import numpy as np
class DatasetWriter:
"""Write data conforming to [Dataset Name] schema."""
def __init__(self, filepath):
self.filepath = filepath
self.io = HDF5IO(filepath, mode='w')
def add_sample(self, sample_id, material, temperature_k, **metadata):
"""Add a sample to the dataset."""
# Implementation based on schema
pass
def add_simulation_run(self, run_id, sample_id, timestep_ps, **metadata):
"""Add a simulation run."""
pass
def add_field_data(self, name, data, grid_coords, unit='unknown'):
"""Add spatial field data (temperature, density, velocity, etc.)."""
pass
def close(self):
"""Finalize and close the file."""
self.io.close()
# Example usage
if __name__ == "__main__":
writer = DatasetWriter("fusion_simulation.h5")
writer.add_sample("plasma001", material="deuterium-tritium", temperature_k=1e8)
writer.add_simulation_run("run001", "plasma001", timestep_ps=0.01)
# ... add field data ...
writer.close()
temperature_field_kelvin not data1, particle_positions_angstrom not coordsSee the templates/ directory for complete examples:
tabular_example.yaml - Structured tabular data with relationshipsndimensional_example.yaml - Multi-dimensional arrays (images, tensors, videos)ragged_array_example.yaml - Variable-length sequences and arrayscomplex_columns_example.yaml - Tables with n-dimensional and ragged columnsAfter creating the schema, users can:
The schema design is separate from the pipeline building - once you have a good schema, the pipeline skills help you populate it with data.