Communitygithub.com

腦部影像資料結構 (BIDS)

一個用於組織和描述神經科學與生物醫學研究資料集的社群標準,定義統一的檔案命名、目錄結構與中繼資料格式,使人類與軟體工具都能立即理解資料集。

腦部影像資料結構 (BIDS) 是什麼?

BIDS 是一個社群驅動的標準,用於組織和描述神經科學與生物醫學研究資料集,涵蓋 MRI、PET、EEG、MEG、iEEG 等 11 種模態。它定義了一套一致的檔案命名慣例、目錄層級結構與中繼資料綱要,使得資料集能被人類與軟體工具立即理解。此技能的核心 Python 生態系包括用於查詢與索引 BIDS 資料集的 PyBIDS,以及用於合規性檢查的 bids-validator。技能還涵蓋了使用 HeuDiConv、dcm2bids 或 BIDScoin 將 DICOM 轉換為 BIDS,以及 BIDS Extension Proposals (BEPs) 的列表,這些提案將 BIDS 擴展到新模態或衍生資料。此技能支援的主要平台包括 Claude Code、Cursor 和 Codex,並提供 12 個詳細的核心工作流程與參考資料,以協助使用者組織、查詢、驗證及轉換神經科學資料集。

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

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

腦部影像資料結構 (BIDS) 是做什麼的?

概述

腦部影像資料結構 (Brain Imaging Data Structure, 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。

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 檔案讀取(由轉換器使用)

核心工作流程

十二個工作流程領域,每個都附有完整的程式碼範例,記錄在 references/core_workflows.md 中:

  1. BIDS 目錄結構 — 所需的佈局以及每個模態應放置的位置。
  2. dataset_description.json — 必填欄位及其產生方式。
  3. 使用 PyBIDS 進行查詢 — BIDSLayout、實體過濾器、具有自動繼承功能的側車中繼資料,以及從實體建構路徑。
  4. 驗證 — 透過 PyPI 包裝(推薦)、直接透過 Deno、舊版 Node 驗證器使用 bids-validator,以及使用 .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 在索引資料集時會驗證結構,因此索引失敗通常表示命名或中繼資料問題,而非程式碼錯誤。

參考資料

此技能包含詳細的參考文件:

使用以下指令更新綱要與 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 與 x/y/z 與 LR/AP/SI)令人困惑。 修正:在 BIDS 中,使用 NIfTI 影像軸:i=第一軸,j=第二軸,k=第三軸。- 表示負方向。對於標準軸向採集: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 換行符號)。 修正:確保使用 Tab 分隔的值、UTF-8 編碼以及 Unix 換行符號 (\n)。對於缺失值,使用 n/a(而非 NA、NaN 或空白)。

最佳實務

  1. 及早並經常驗證 - 在每次轉換或修改後執行 BIDS 驗證器。在錯誤累積之前修正它們。

  2. 使用中繼資料繼承 - 將共享的中繼資料(例如 TaskName、掃描儀參數)置於頂層側車檔案中,而不是在每個受試者的目錄中重複。

  3. 保留原始資料 - 將原始 DICOM(或其他原始)資料儲存在 sourcedata/ 下,以便轉換可重現。將 sourcedata/ 加入 .bidsignore。

  4. 從一開始就使用一致的名稱 - 在資料收集之前定義您的 BIDS 命名方案。對掃描協定使用 ReproIn 命名慣例,以實現自動轉換。

  5. 記錄您的資料集 - 撰寫詳盡的 README,描述研究設計、採集參數、已知問題以及任何與 BIDS 的偏差。

  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 儲存庫是典型 BIDS 資料集的權威集合,涵蓋不同的模態和使用案例(MRI、fMRI、DWI、EEG、MEG、iEEG、PET、ASL、遺傳學、衍生資料等)。將其用作建構您自己資料集時的參考、BIDS 工具的測試資料,或了解特定模態應如何組織。每個範例都通過 BIDS 驗證器的檢查。

BIDS 擴展提案 (BEP)

BEP 是由社群驅動的提案,旨在將 BIDS 擴展到新的模態、衍生資料或中繼資料。包含狀態、負責人和連結的完整清單位於 references/beps.yml(從 bids-website 取得)。特定 BEP 的綱要預覽在 https://github.com/bids-standard/bids-schema/tree/main/BEPs 中呈現。

當前 BEP(截至綱要更新):

BEP標題內容狀態
004磁敏感加權成像原始正在尋找新負責人
011結構性預處理衍生資料衍生資料有 PR (#518)
012功能性預處理衍生資料衍生資料有 PR (#519),綱要已實作
014仿射變換與非線性場扭曲衍生資料X5 格式開發中
016擴散加權成像衍生資料衍生資料有 PR (#2211)
017通用 BIDS 連結資料綱要衍生資料開發中
021通用電生理衍生資料衍生資料開發中
023PET 預處理衍生資料衍生資料開發中
024電腦斷層掃描原始正在尋找貢獻者
026微電極記錄原始正在尋找新負責人
028來源中繼資料有 PR (#2099)
032微電極電生理學原始有 PR (#2307),預覽可用 — 涵蓋 Neuropixels 和其他細胞外探針;與 neuropixels-analysis 技能相關
033進階擴散加權成像原始正在尋找貢獻者
034計算建模衍生資料有 PR (#967)
035使用非合規衍生資料的超級分析衍生資料開發中
036表型資料指南原始社群審查中
037非侵入性腦部刺激原始開發中
039基於降維的網路原始開發中
040功能性超音波原始開發中
041統計模型衍生資料衍生資料收集回饋中
043BIDS 術語對應中繼資料收集回饋中
044刺激原始有 PR (#2022),社群審查中
045週邊生理記錄原始有 PR (#2267)
046擴散追蹤成像衍生資料開發中
047行為實驗的音訊/視訊記錄原始有 PR (#2231)

相關標準:

  • BIDS-Stats Models:用於定義基於 GLM 的神經影像分析的 JSON 規範
  • BIDS-Derivatives (BEP003):預處理/分析輸出的標準(已部分合併至規範中)

相關工具生態系

工具用途
fMRIPrepfMRI 預處理(產生 BIDS 衍生資料)
MRIQCMRI 品質控制(產生 BIDS 衍生資料)
QSIPrep擴散 MRI 預處理
TemplateFlow使用類似 BIDS 命名法的神經影像範本與圖譜
FitlinsBIDS Stats Models 的實作
DataLad大型資料集的版本控制,與 BIDS 整合
OpenNeuro免費的 BIDS 資料集儲存庫
DANDI神經生理學資料檔案庫(對某些模態使用 BIDS)
HeuDiConv使用啟發式 Python 檔案的 DICOM 轉 BIDS
dcm2bids使用 JSON 設定的 DICOM 轉 BIDS
BIDScoin具有 GUI 和 YAML 設定的 DICOM 轉 BIDS
nwb2bids將 NWB 檔案轉換為 BIDS
CuBIDSBIDS 資料集的策展與調和
bids2tableBIDS 資料集的高效表格索引
bids-examples所有模態的典型 BIDS 資料集權威集合

文件

  • BIDS S

...

[為翻譯而截斷]

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.

相關技能