agentsclimarketplace

Ibgnn

Skill BioTender-max/awesome-bio-agent-skills/skills/neuroclaw/ibgnn

Use this model doc whenever the user wants to run IBGNN (Interpretable Brain Graph Neural Network) for fMRI phenotype prediction. IBGNN is a PyG-based GNN with a learnable MLP message function over [x_i, x_j, edge_attr], designed for connectome-based brain disorder analysis with post-hoc edge-mask explainer support.From its SKILL.md

Install
npx -y skills add BioTender-max/awesome-bio-agent-skills --skill ibgnn

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

What its file declares

Copied from the file, not written here

The file declares its own license as MIT License (NeuroClaw custom skill - freely modifiable within the project). That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

5.5 KB, ~1.8k tokens by cl100k_base, as published. Nobody here has run it

IBGNN Model Doc

Overview

IBGNN (Interpretable Brain Graph Neural Network) 是面向脑连接组分析的可解释 GNN。核心组件是 MPConv —— 在 GCN 归一化基础上,将消息计算从简单加权聚合改为 MLP([x_i, x_j, edge_attr]) 学习消息函数。模型与 post-hoc 边遮罩 explainer 配合使用,可提取对预测重要的边子图。

  • Paper: Cui et al., 2022, "Interpretable Graph Neural Networks for Connectome-Based Brain Disorder Analysis",MICCAI
  • Official code: https://github.com/HennyJie/IBGNN
  • NeuroClaw reimplementation: models/ibgnn/(移除 explainer 用的 edge_flag 机制,仅保留 encoder)
  • Primary input: PyG Data graph(与 BrainGNN 共享数据格式)
  • Primary output: phenotype prediction(可选 attention/重要边解释)

Research use only.


NeuroClaw 实现要点

  1. MPConv 核心:每条边的消息 = Linear([x_i, x_j, edge_attr]),比 GCN 多一层非线性表达。
  2. GCN 归一化:边权 |corr| 经过对称归一化(与 GCN 相同),再注入 self-loop。
  3. 去除 edge_flag:原版用于 explainer 屏蔽边,普通 forward 中 edge_flag 是全 1 tensor,NeuroClaw 直接砍掉以简化代码。
  4. 正边权约束:edge_attr.abs() 后传入,与 BrainGNN 同样做法(softmax 类操作需要非负)。
  5. 任务统一接口:classification (nclass=N) 与 regression (nclass=1, task='regression') 一套代码。
  6. PyG 2.7 兼容:torch_scatter.scatter_add 已被 torch_geometric.utils.scatter(reduce='sum') 替代。
  7. 数据复用:直接复用 BrainGNN 的 NeuroClawFCDataset,无需额外预处理。

Quick Start (NeuroClaw 内部)

前置条件

  • conda env: neuroclaw (Python 3.11)
  • 已有 data/braingnn_input/<atlas>/sub-*.pt 文件(与 BrainGNN 共享)

训练(分类,单 fold 冒烟测试)

python skills/ibgnn/scripts/train_reference.py \
    --atlas aal_116 \
    --labels-csv data/hcp_gender_labels.csv \
    --fold 0 --n-epochs 10 --batch-size 16

训练(回归,HCP age)

python skills/ibgnn/scripts/train_reference.py \
    --atlas schaefer_100_7net \
    --labels-csv data/hcp_age_labels.csv \
    --task regression --fold 0 --n-epochs 50

核心文件

文件作用
models/ibgnn/net/ibgnn.py模型定义:MPConv + IBGConv stack + MLP head
models/ibgnn/scripts/data_adapter.py数据适配(薄封装复用 models.braingnn)
skills/ibgnn/scripts/train_reference.pyK-fold CV 训练参考实现

模型架构

Input PyG Data (x=[N,N], edge_index, edge_attr, batch)
  -> abs(edge_attr) -> gcn_norm with self-loops
  -> MPConv(N, hidden) + ReLU + Dropout
  -> MPConv(hidden, hidden)  (n_gnn_layers 层)
  -> global_mean_pool (或 sum)
  -> MLP head: Linear(hidden, hidden) + ReLU + shortcut + Linear(hidden, nclass)
Output: logits

每条边的消息:msg(i,j) = Linear([h_i; h_j; edge_weight])


关键训练参数

参数论文默认NeuroClaw 默认说明
--lr1e-41e-3论文 1e-4,对齐其他模型用 1e-3
--wd1e-55e-4权重衰减
--hidden-dim128128GNN/MLP 隐藏维度
--n-gnn-layers2-32MPConv 堆叠层数
--n-mlp-layers11MLP head 深度
--poolingmeanmean'mean' 或 'sum'
--n-epochs10050与其他模型对齐
--batch-size1616

调试经验与注意事项

  1. edge_attr.abs() 必须:FC 矩阵带负相关,但 GCN 归一化和消息聚合假设非负权重,否则归一化得到 NaN。
  2. MPConv 参数量:消息 MLP Linear(2*hidden+1, hidden),每层约 (2H+1)*H 参数,比 GCN 重 ~2 倍。
  3. n_gnn_layers 选择:论文 2-3 层最优;超过 3 层会过平滑。
  4. shortcut connection:MLP head 内 h = net(x) + shortcut(x),避免深网络梯度衰减。
  5. PyG 2.7 兼容:使用 torch_geometric.utils.scatter 替代已废弃的 torch_scatter.scatter_add。
  6. 数据复用:与 BrainGNN 共享 NeuroClawFCDataset,无需重复加载/缓存。
  7. Explainer 未移植:原 repo 的 main_explainer.py(GNNExplainer 后处理)暂未移植,若需可补充。

NeuroClaw 委托规则

  • ROI 生成和预处理:委托 fmri-skill
  • HCP 数据下载/编排:委托 hcpya-skill / hcpa-skill / hcpd-skill / hcpep-skill
  • 依赖检查:dependency-planner + conda-env-manager
  • 执行路由:claw-shell

执行前需明确计划确认。


Reference

Created At: 2026-05-19 01:30 HKT Last Updated At: 2026-05-19 01:30 HKT Author: chengwang96

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.