Communitygithub.com

脳画像データ構造(BIDS)

脳画像データ構造(BIDS)は、神経科学および生体医工学の研究データセットを整理・記述するためのコミュニティ標準です。画像、脳波、行動データなど11のモダリティをカバーし、PyBIDSによるデータ検索やbids-validatorによる検証、DICOM変換ツールを提供します。

脳画像データ構造(BIDS) とは?

このスキルは、脳画像データ構造(BIDS)の作成、検証、変換、クエリを支援します。BIDSは、神経科学・生体医工学分野で広く採用されているデータ整理の標準規格であり、OpenNeuroやDANDIなどの主要リポジトリで必須または強く推奨されています。スキルはMRI、PET、EEG、MEG、iEEG、NIRS、行動データ、顕微鏡画像など11のモダリティをサポートし、BIDS拡張提案(BEP)を継続的に取り込んでいます。ユーザーはPyBIDSを使用してBIDSデータセットをプログラムでクエリし、bids-validatorでコンプライアンスをチェックし、HeuDiConv/dcm2bids/BIDScoinでDICOMデータを変換できます。詳細なリファレンス資料(BIDSスキーマ、BEP一覧、メタデータフィールド、変換ツールのワークフロー)が同梱されており、一般的な問題(データセット未検出、被験者不一致、スライスタイミング欠落、位相エンコード方向の混乱など)に対する解決策やベストプラクティスも提供します。このスキールはClaude Code、Cursor、CodexなどのAIエージェントが神経科学データを体系的に扱うために設計されています。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/bids

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

脳画像データ構造(BIDS) は何をしますか?

概要

脳画像データ構造(BIDS)は、神経科学および生体医工学の研究データセットを整理・記述するためのコミュニティ標準です。一貫したファイル命名規則、ディレクトリ階層、メタデータスキーマを定義しており、データセットを人間とソフトウェアツールの両方に即座に理解可能にします。BIDSはBIDS仕様(現在v1.11.x)によって管理され、BIDS-Standard GitHub組織を通じてコミュニティによって保守されています。

BIDSはMRIを起源としますが、神経画像をはるかに超えて成長しています。現在の仕様は、画像、電気生理学、行動データにわたる11のモダリティをカバーしています:

  • 画像:MRI(構造、機能、拡散、フィールドマップ、灌流/ASL)、PET、顕微鏡
  • 電気生理学:EEG、MEG、iEEG(頭蓋内脳波)、EMG
  • その他:NIRS(近赤外分光法)、モーションキャプチャ、行動データ(画像なし)、MRスペクトロスコピー

現在進行中のBEPはBIDSをさらに拡張しています——特にBEP032(微小電極電気生理学)はNeuropixelsプローブを含む細胞外記録のサポートを追加し、動物神経科学研究で一般的な方法論にBIDSをもたらします(neuropixels-analysisスキルも参照)。

主要データリポジトリ(OpenNeuro、DANDI)、主要ジャーナル(NeuroImage、Human Brain Mapping、Scientific Data)、および資金提供機関(NIH、ERC)によって採用または強く推奨されています。

BIDSのPythonエコシステムは、BIDSデータセットのクエリとインデックス作成のためのPyBIDS(pybids)と、コンプライアンスチェックのためのbids-validator(Denoベース、PyPIパッケージbids-validator-denoとして利用可能、またはDenoから直接利用)を中心としています。DICOMからの変換は通常、HeuDiConv、dcm2bids、またはBIDScoinを使用して行われます。

このスキルを使用するタイミング

以下の場合にこのスキルを適用してください:

  • 生神経科学データ(画像、電気生理学、行動データ)をBIDS準拠のディレクトリ構造に整理する場合
  • 既存のBIDSデータセットをクエリし、被験者、セッション、タスク、ラン、モダリティで特定のファイルを検索する場合
  • 共有または提出前にBIDS仕様に対してデータセットを検証する場合
  • スキャナからのDICOMデータをBIDS形式に変換する場合
  • JSONサイドカーメタデータファイルを作成または編集する場合
  • BIDS準拠の派生物(前処理データ、解析出力)を作成する場合
  • 新しいデータセットのdataset_description.jsonを設定する場合
  • BIDSエンティティ(被験者、セッション、タスク、取得、ランなど)を扱う場合
  • .bidsignoreを設定して検証からファイルを除外する場合
  • OpenNeuro、DANDI、またはその他のBIDS対応リポジトリにアップロードするデータを準備する場合

インストール

# コアBIDSクエリライブラリ
uv pip install pybids

# BIDSバリデータ(Denoベース、PyPIラッパー経由でインストール)
uv pip install bids-validator-deno
# 代替:Denoから直接インストール
# deno install -g -A npm:bids-validator

# DICOM→BIDS変換ツール(必要に応じてインストール)
uv pip install heudiconv       # HeuDiConv - ヒューリスティックベースのDICOM変換
uv pip install dcm2bids        # dcm2bids - 設定ファイルベースの変換
# BIDScoin: uv pip install bidscoin

# 便利な補助ツール
uv pip install nibabel          # NIfTI/その他神経画像ファイルI/O
uv pip install pydicom          # DICOMファイル読み取り(変換ツールで使用)

コアワークフロー

12のワークフロー領域と実コードは、 references/core_workflows.mdに文書化されています:

  1. BIDSディレクトリ構造 — 必須レイアウトと各モダリティの配置場所。
  2. dataset_description.json — 必須フィールドとその生成方法。
  3. PyBIDSによるクエリ — BIDSLayout、エンティティフィルター、自動継承を含むサイドカーメタデータ、エンティティからのパス構築。
  4. 検証 — PyPIラッパー経由のbids-validator(推奨)、Denoから直接、レガシーNodeバリデータ、.bidsignoreを使用したファイル除外。
  5. エンティティとファイル命名 — エンティティの順序と命名文法。
  6. DICOMからBIDSへの変換 — HeuDiConv(ターンキーReproInパス、偵察→ヒューリスティック→変換の順序を含む)およびdcm2bids(設定ファイルベース)。
  7. メタデータサイドカー — モダリティごとの必須および推奨JSONフィールド。
  8. イベントファイル — タスクfMRIのイベントタイミングと列の慣例。
  9. 参加者ファイル — participants.tsvとそのデータ辞書。
  10. 派生物 — 派生物レイアウトとそのdataset_description.json。
  11. 高度なPyBIDS — インデックスキャッシュ、派生物の包含、交絡回帰変数、DataFrame出力。
  12. BIDS-Apps — 標準呼び出しパターン、fMRIPrep、MRIQC、QSIPrep。

早期に頻繁に検証してください:PyBIDSはデータセットのインデックス作成時に構造を検証するため、インデックス作成の失敗は通常、コードのバグではなく命名またはメタデータの問題を示します。

参考資料

このスキルには詳細なリファレンス文書が含まれています:

  • bids_schema.json:機械可読なBIDSスキーマ(https://bids-specification.readthedocs.io/en/stable/schema.json から)。これはエンティティ定義、順序付けルール、ファイル名テンプレート、データタイプごとの許可されたサフィックス、メタデータフィールド要件の情報源です。BEP固有のスキーマはhttps://github.com/bids-standard/bids-schema/tree/main/BEPsにあります。
  • beps.yml:すべてのBIDS拡張提案の現在のリスト(タイトル、リーダー、ステータス、リンク付き)(https://github.com/bids-standard/bids-website/blob/main/data/beps/beps.yml から)
  • bids_specification.md:エンティティテーブル、データタイプリファレンス、ディレクトリ構造ルール、テンプレートスペース、仕様変更履歴の人間可読な要約
  • metadata_fields.md:すべてのBIDSモダリティ(anat、func、dwi、fmap、eeg、meg、petなど)の必須および推奨JSONサイドカーフィールド
  • conversion_tools.md:HeuDiConv、dcm2bids、BIDScoinの詳細なワークフロー(ヒューリスティック/設定例とトラブルシューティングを含む)

スキーマとBEPの更新方法:python scripts/update_schema.py

一般的な問題と解決策

1. バリデータが「BIDSデータセットではありません」と報告する

原因:ルートにdataset_description.jsonがありません。 修正:最低限{"Name": "...", "BIDSVersion": "1.10.0"}を含むファイルを作成します。

2. 被験者の不整合警告

原因:すべての被験者が同じファイルセットを持っているわけではありません(セッション、ランなどが欠落)。 修正:これは警告でありエラーではありません。意図的な場合は--ignoreSubjectConsistencyを使用します。欠落データはparticipants.tsvまたはscans.tsvに文書化します。

3. SliceTimingの欠落

原因:dcm2niixがDICOMヘッダーからスライスタイミングを抽出できませんでした。 修正:スキャンプロトコルからスライス順序を特定し、JSONサイドカーに手動で追加します。一般的なパターン:昇順、降順、インターレース(奇数ファーストまたは偶数ファースト)。

4. 位相エンコード方向の混乱

原因:軸ラベル(i/j/k vs x/y/z vs LR/AP/SI)が混乱します。 修正:BIDSでは、NIfTI画像軸を使用します:i=最初の軸、j=2番目、k=3番目。-は負の方向を意味します。標準的な軸方向取得では、jは通常前後方向です。取得プロトコルで確認します。

5. 大規模データセットでPyBIDSが遅い

原因:すべてのBIDSLayout()呼び出しで完全なファイルシステムインデックスを作成します。 修正:database_pathを使用してインデックスをSQLiteファイルにキャッシュします:

layout = BIDSLayout("/data", database_path="/data/.pybids_cache.db")

6. PyBIDSが派生物を見つけられない

原因:派生物ディレクトリに独自のdataset_description.jsonがありません。 修正:すべての派生物ディレクトリには"DatasetType": "derivative"を含むdataset_description.jsonが必要です。

7. イベントファイルのタイミングがずれている

原因:onset時間が誤った基準(例:トリガー時間 vs 最初のボリューム)を基準にしています。 修正:オンセットは、そのランの最初のボリュームを基準とした秒単位である必要があります。ダミースキャンが破棄された場合はそれを考慮します。

8. TSVファイルが検証に失敗する

原因:エンコーディングまたは区切り文字の問題(スペースとタブの混在、BOM文字、Windows改行コード)。 修正:タブ区切り値、UTF-8エンコーディング、Unix改行コード(\n)を確保します。欠落値にはn/aを使用します(NA、NaN、空欄は不可)。

ベストプラクティス

  1. 早期に頻繁に検証する - 変換または変更のたびにBIDSバリデータを実行します。問題が大きくなる前に修正します。

  2. メタデータ継承を使用する - 共有メタデータ(例:TaskName、スキャナパラメータ)は、各被験者のディレクトリに複製するのではなく、最上位のサイドカーファイルに配置します。

  3. ソースデータを保持する - 元のDICOM(またはその他生データ)をsourcedata/の下に保存し、変換を再現可能にします。sourcedata/を.bidsignoreに追加します。

  4. 最初から一貫した命名を使用する - データ収集前にBIDS命名スキームを定義します。スキャンプロトコルにはReproIn命名規則を使用して自動変換を可能にします。

  5. データセットを文書化する - 研究デザイン、取得パラメータ、既知の問題、BIDSからの逸脱を説明する詳細なREADMEを作成します。

  6. ランごとのメタデータにはscans.tsvを使用する - 実行ごとの取得時間と品質メモを記録します:

    filename	acq_time	quality
    func/sub-01_task-rest_bold.nii.gz	2025-01-15T10:30:00	good
    
  7. データセットをバージョン管理する - CHANGESを使用してデータセットの変更を文書化します。大規模データセットの完全なバージョン管理にはDataLadを検討します。

  8. 解剖画像を匿名化する - 共有前にT1w/T2w画像から顔の特徴を削除します(例:pydeface、mri_deface、afni_refacerを使用)。匿名化バージョンをプライマリデータとして保存するか、_defacemaskファイルを使用します。

  9. 派生物にBIDS URIを使用する - 派生物では、BIDS URIを使用してソースファイルを参照します:bids::sub-01/anat/sub-01_T1w.nii.gz。

  10. コミュニティツールを優先する - 可能な場合はカスタムパイプラインではなく、確立されたBIDS-Apps(fMRIPrep、MRIQC、QSIPrep)を使用します。これらはBIDSの入出力を正しく処理し、BIDS準拠の派生物を生成します。

  11. bids-examplesを研究する - bids-examplesリポジトリは、さまざまなモダリティとユースケース(MRI、fMRI、DWI、EEG、MEG、iEEG、PET、ASL、遺伝学、派生物など)をカバーする典型的なBIDSデータセットの正規コレクションです。自分のデータセットを構成する際の参考として、BIDSツールのテストデータとして、または特定のモダリティの整理方法を理解するために使用してください。各例はBIDSバリデータに合格しています。

BIDS拡張提案(BEP)

BEPは、BIDSを新しいモダリティ、派生物、メタデータに拡張するためのコミュニティ主導の提案です。完全なリスト(ステータス、リーダー、リンク付き)はreferences/beps.ymlにあります(https://github.com/bids-standard/bids-website/blob/main/data/beps/beps.yml から取得)。BEP固有のスキーマプレビューはhttps://github.com/bids-standard/bids-schema/tree/main/BEPsでレンダリングされます。

現在のBEP(スキーマ更新時点):

BEPタイトル内容ステータス
004磁化率強調画像rawリーダー募集中
011構造前処理派生物derivativePRあり (#518)
012機能的プレプロセッシング派生物derivativePRあり (#519)、スキーマ実装済み
014アフィン変換と非線形フィールドワープderivativeX5形式開発中
016拡散強調画像派生物derivativePRあり (#2211)
017汎用BIDS結合データスキーマderivative開発中
021共通電気生理学派生物derivative開発中
023PET前処理派生物derivative開発中
024コンピュータ断層撮影スキャンrawコントリビューター募集中
026微小電極記録rawリーダー募集中
028来歴metadataPRあり (#2099)
032微小電極電気生理学rawPRあり (#2307)、プレビュー利用可能 — Neuropixelsおよびその他の細胞外プローブをカバー;neuropixels-analysisスキルに関連
033拡散強調画像の高度化rawコントリビューター募集中
034計算モデリングderivativePRあり (#967)
035非準拠派生物によるメガ分析derivative開発中
036表現型データガイドラインrawコミュニティレビュー中
037非侵襲的脳刺激raw開発中
039次元削減ベースのネットワークraw開発中
040機能的超音波raw開発中
041統計モデル派生物derivativeフィードバック収集中
043BIDS用語マッピングmetadataフィードバック収集中
044刺激rawPRあり (#2022)、コミュニティレビュー中
045末梢生理学的記録rawPRあり (#2267)
046拡散トラクトグラフィーderivative開発中
047行動実験のためのオーディオ/ビデオ録画rawPRあり (#2231)

関連規格:

  • BIDS-Stats Models:GLMベースの神経画像解析を定義するためのJSON仕様
  • BIDS-Derivatives(BEP003):前処理/解析出力の標準(部分的に仕様にマージ済み)

関連ツールエコシステム

ツール目的
fMRIPrepfMRI前処理(BIDS派生物を生成)
MRIQCMRI品質管理(BIDS派生物を生成)
QSIPrep拡散MRI前処理
TemplateFlowBIDSライクな命名規則の神経画像テンプレートとアトラス
FitlinsBIDS Stats Models実装
DataLad大規模データセットのバージョン管理、BIDSと統合
OpenNeuro無料BIDSデータセットリポジトリ
DANDI神経生理学データアーカイブ(一部モダリティでBIDS使用)
HeuDiConvPythonヒューリスティックファイルによるDICOM→BIDS変換
dcm2bidsJSON設定によるDICOM→BIDS変換
BIDScoinGUIとYAML設定によるDICOM→BIDS変換
nwb2bidsNWB(Neurodata Without Borders)ファイルをBIDSに変換
CuBIDSBIDSデータセットのキュレーションと調和
bids2tableBIDSデータセットの効率的な表形式インデックス
bids-examplesすべてのモダリティの典型的なBIDSデータセットの正規コレクション

ドキュメント

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

adaptyv

How to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.

aeon

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

alphagenome

Look up precomputed AlphaGenome Atlas effects for any GRCh38 single-nucleotide variant (AVI score with Phred and 18 SHAP feature attributions, plus raw and quantile scores for RNA-seq, DNase, ATAC, ChIP-TF, ChIP-histone, CAGE, PRO-cap, splicing, polyadenylation and contact-map tracks), score variants or scan windows on demand with the AlphaGenome model for human and mouse (variant scoring, in silico mutagenesis, REF-versus-ALT track prediction), and build Atlas website deep links. Use when the user mentions AlphaGenome, AlphaGenome Atlas, AVI or AlphaGenome Variant Impact, DeepMind variant effect prediction, or wants to prioritise or mechanistically interpret non-coding, regulatory, splicing, enhancer, promoter, or chromatin-accessibility effects of SNVs from a VCF, credible set, or region. Research use only; not a clinical tool.

analytical-method-validation

Plan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include

anndata

Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.

arbor

Autonomously improve a real artifact (code, training recipe, agent harness, data pipeline, prompt) against an objective and an evaluator, using Hypothesis Tree Refinement (HTR) from the Arbor paper. Use this whenever someone wants to iteratively optimize something over many experiments without overfitting — e.g.

arboreto

Infer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.

astropy

Core Python library for astronomy and astrophysics workflows that need Astropy APIs, including units/quantities, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use when implementing or debugging astronomical data analysis code with Astropy.

autoskill

Observe the user

benchling-integration

Benchling Python SDK and REST API integration for registry entities, inventory, ELN entries, workflows, Benchling Apps, and Data Warehouse queries. Use when automating lab data with benchling-sdk or the v2 API.

bgpt-paper-search

Search scientific papers and retrieve structured experimental data extracted from full-text studies via the BGPT MCP server. Returns 25+ fields per paper including methods, results, sample sizes, quality scores, and conclusions. Use for literature reviews, evidence synthesis, and finding experimental details not available in abstracts alone.

biopython

Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.

bioservices

Unified Python interface to 40+ bioinformatics services. Use when querying multiple databases (UniProt, KEGG, ChEMBL, Reactome) in a single workflow with consistent API. Best for cross-database analysis, ID mapping across services. For quick single-database lookups use gget; for sequence/file manipulation use biopython.

bulk-rnaseq

End-to-end bulk RNA-seq orchestrator — takes raw FASTQ reads through QC and trimming (FastQC, fastp/Trim Galore), alignment and quantification (STAR, Salmon, featureCounts), assembles a gene-level counts matrix, then hands off to differential expression (pydeseq2), pathway/GSEA enrichment (pathway-enrichment), and publication figures (scientific-visualization). Use whenever the user has bulk RNA-seq reads or quant output and wants a complete, reproducible differential-expression workflow — e.g.

cellxgene-census

Query the CZ CELLxGENE Census programmatically for versioned public single-cell and spatial transcriptomics data. Use when you need population-scale cell metadata, gene expression slices, Census summary counts, source H5AD URIs/downloads, embeddings, spatial Census data, or reference atlas comparisons across organisms, tissues, diseases, assays, and cell types. For analyzing your own local single-cell data use scanpy, anndata, or scvi-tools.

cirq

Google quantum computing framework. Use when targeting Google Quantum AI hardware, designing noise-aware circuits, or running quantum characterization experiments. Best for Google hardware, noise modeling, and low-level circuit design. For IBM hardware use qiskit; for quantum ML with autodiff use pennylane; for physics simulations use qutip.

citation-management

Comprehensive citation management for academic research. Search OpenAlex, PubMed, and Google Scholar for papers, extract accurate metadata, validate citations, and generate properly formatted BibTeX entries. This skill should be used when you need to find papers, verify citation information, convert DOIs to BibTeX, or ensure reference accuracy in scientific writing.

clinical-decision-support

Prepare and validate research-only clinical decision-support evaluation, evidence-profile, cohort, survival, biomarker/model, privacy, and governance artifacts. Use for aggregate or synthetic research documentation and traceability—not patient care or live clinical operation.

clinical-reports

Create safety-bounded draft structures and run local deterministic checks for clinical case, diagnostic, trial, safety, and aggregate research reports. Use only with synthetic, de-identified, or aggregate inputs and verified source-fact manifests; every output requires qualified review.

cobrapy

Constraint-based metabolic modeling (COBRA). FBA, FVA, gene knockouts, flux sampling, SBML models, for systems biology and metabolic engineering analysis.

関連スキル