Free SKILL.md scraped from GitHub. Clone the repo or copy the file directly into your Claude Code skills directory.
npx versuz@latest install hiyenwong-ai-collection-collection-skills-atlas-free-brain-network-transformergit clone https://github.com/hiyenwong/ai_collection.gitcp ai_collection/SKILL.MD ~/.claude/skills/hiyenwong-ai-collection-collection-skills-atlas-free-brain-network-transformer/SKILL.md---
name: atlas-free-brain-network-transformer
description: "Atlas-free Brain Network Transformer using individualized functional brain network (iFBN) framework. Constructs subject-specific brain networks via spatial ICA components as nodes and functional connectivity as edges. Eliminates atlas dependency. Activation: atlas-free brain network, iFBN, brain network transformer, individualized brain network, spatial ICA brain network, parcellation-free brain network, fMRI transformer."
---
# Atlas-Free Brain Network Transformer (iFBN)
## Overview
The **Atlas-free Brain Network Transformer (iFBN)** is a deep learning framework that eliminates the dependency on predefined brain atlas parcellations. Instead of using atlas-defined ROIs as nodes, iFBN leverages spatial Independent Component Analysis (ICA) to automatically discover subject-specific functional brain network nodes, then constructs functional connectivity matrices and processes them with a specialized brain network transformer for disease classification.
## Source Paper
- **Title:** Atlas-free Brain Network Transformer using individualized functional brain network
- **arXiv:** 2604.11204v1
- **Published:** 2026-04-17
- **Categories:** cs.LG, cs.CV
- **PDF:** https://arxiv.org/pdf/2604.11204v1.pdf
## Core Concepts
### Key Contributions
1. **Atlas-free node discovery**: Spatial ICA automatically finds individualized functional nodes without requiring predefined brain atlases
2. **Subject-specific networks**: Each subject gets their own functional brain network structure based on data-driven ICA components
3. **End-to-end differentiable pipeline**: From ICA decomposition through FC computation to transformer-based classification
### The Problem with Atlas-Based Methods
Traditional brain network analysis relies on predefined atlases (AAL, Harvard-Oxford, etc.) to define ROI nodes:
- **Individual variability**: Atlases don't capture subject-specific functional organization
- **Scale limitation**: Atlas resolution is fixed and cannot adapt to different analysis needs
- **Boundary artifacts**: Hard parcel boundaries create artificial network edges
### The iFBN Solution
**Three-stage pipeline:**
1. **Spatial ICA Decomposition**: Extract subject-specific spatial maps (functional nodes)
2. **Functional Connectivity**: Compute correlations between ICA component time courses
3. **Brain Network Transformer**: Process FC matrices with specialized transformer for classification
## Implementation
### Stage 1: Spatial ICA Decomposition
```python
import numpy as np
from sklearn.decomposition import FastICA
from nilearn.decomposition import CanICA
def extract_individualized_nodes(fmri_data, n_components=50):
"""
Extract subject-specific functional brain network nodes using spatial ICA.
Args:
fmri_data: 4D fMRI array (x, y, z, time)
n_components: Number of ICA components to extract
Returns:
spatial_maps: 4D array (x, y, z, n_components)
time_courses: 2D array (n_components, time)
"""
# CanICA performs group-level ICA
canica = CanICA(
n_components=n_components,
memory_level=2,
verbose=1,
random_state=0
)
canica.fit([fmri_data])
spatial_maps = canica.components_img_
# Get time courses
from nilearn.input_data import NiftiMapsMasker
masker = NiftiMapsMasker(maps_img=spatial_maps)
time_courses = masker.fit_transform(fmri_data)
return spatial_maps, time_courses
# Individualized ICA (subject-specific)
def individualized_ca(fmri_data, n_components=50):
"""Subject-specific ICA decomposition."""
ica = FastICA(n_components=n_components, random_state=0)
# Reshape: flatten spatial dims, keep time
spatial_size = fmri_data.shape[:3]
n_timepoints = fmri_data.shape[3]
data_2d = fmri_data.reshape(-1, n_timepoints).T
time_courses = ica.fit_transform(data_2d)
spatial_maps = ica.components_.T.reshape(-1, n_components)
return spatial_maps, time_courses
```
### Stage 2: Functional Connectivity Computation
```python
def compute_ica_connectivity(time_courses):
"""
Compute functional connectivity between ICA components.
Args:
time_courses: 2D array (n_components, n_timepoints)
Returns:
fc_matrix: Connectivity matrix (n_components, n_components)
"""
# Pearson correlation
fc_matrix = np.corrcoef(time_courses)
# Optional: Fisher z-transform
fc_matrix = np.arctanh(np.clip(fc_matrix, -0.9999, 0.9999))
# Set diagonal to zero
np.fill_diagonal(fc_matrix, 0)
return fc_matrix
```
### Stage 3: Brain Network Transformer
```python
import torch
import torch.nn as nn
import torch.nn.functional as F
class AtlasFreeBrainNetTransformer(nn.Module):
"""
Atlas-free Brain Network Transformer for disease classification.
Uses ICA-derived nodes and FC edges as input.
"""
def __init__(self, n_components=50, d_model=64, n_heads=4,
n_layers=4, num_classes=2, dropout=0.1):
super().__init__()
# Edge embedding
self.edge_embed = nn.Linear(1, d_model)
# Node embedding (learned initial)
self.node_embed = nn.Embedding(n_components, d_model)
# Transformer encoder
encoder_layer = nn.TransformerEncoderLayer(
d_model=d_model,
nhead=n_heads,
dim_feedforward=d_model * 4,
dropout=dropout,
batch_first=True
)
self.transformer = nn.TransformerEncoder(
encoder_layer, num_layers=n_layers
)
# Classification head
self.classifier = nn.Sequential(
nn.Linear(d_model * n_components, 256),
nn.ReLU(),
nn.Dropout(dropout),
nn.Linear(256, num_classes)
)
def forward(self, fc_matrix):
"""
Args:
fc_matrix: (batch, n_components, n_components) connectivity matrix
"""
batch_size, n_comp, _ = fc_matrix.shape
# Reshape FC for edge embedding
edges = fc_matrix.unsqueeze(-1) # (B, N, N, 1)
edge_features = self.edge_embed(edges) # (B, N, N, d_model)
# Combine with node embeddings
node_emb = self.node_embed(torch.arange(n_comp).to(fc_matrix.device))
node_emb = node_emb.unsqueeze(0).unsqueeze(2) # (1, N, 1, d_model)
node_emb = node_emb.expand(batch_size, -1, n_comp, -1)
features = edge_features + node_emb # (B, N, N, d_model)
# Reshape for transformer
features = features.reshape(batch_size, n_comp, -1)
# Transformer encoding
encoded = self.transformer(features)
# Flatten and classify
flat = encoded.reshape(batch_size, -1)
logits = self.classifier(flat)
return logits
# Training loop
def train_atlas_free_model(fc_matrices, labels, n_components=50,
epochs=100, lr=1e-3):
"""Train atlas-free brain network transformer."""
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = AtlasFreeBrainNetTransformer(n_components=n_components).to(device)
optimizer = torch.optim.Adam(model.parameters(), lr=lr)
fc_tensor = torch.FloatTensor(fc_matrices).to(device)
labels_tensor = torch.LongTensor(labels).to(device)
for epoch in range(epochs):
model.train()
optimizer.zero_grad()
logits = model(fc_tensor)
loss = F.cross_entropy(logits, labels_tensor)
loss.backward()
optimizer.step()
if epoch % 10 == 0:
preds = logits.argmax(dim=1)
acc = (preds == labels_tensor).float().mean().item()
print(f'Epoch {epoch}: loss={loss:.4f}, acc={acc:.4f}')
return model
```
## Practical Applications
### Use Case 1: Disease Classification without Atlas Bias
```python
# Load fMRI data and labels
fmri_data = load_subject_fmri(subject_id)
spatial_maps, time_courses = extract_individualized_nodes(fmri_data)
fc_matrix = compute_ica_connectivity(time_courses)
```
### Use Case 2: Comparing Atlas vs Atlas-Free
```python
# Atlas-based approach (baseline)
atlas_fc = compute_atlas_fc(fmri_data, atlas='AAL')
atlas_acc = train_and_evaluate(atlas_fc, labels)
# Atlas-free approach (iFBN)
ica_fc = compute_ica_connectivity(ica_time_courses)
ifbn_acc = train_and_evaluate(ica_fc, labels)
# Compare: iFBN typically outperforms on heterogeneous datasets
```
## Limitations
- ICA component ordering is not guaranteed across subjects
- Computational overhead of per-subject ICA decomposition
- Component interpretation requires manual labeling or automated matching
## References
- arXiv:2604.11204v1 (2026-04-17)
## Activation Keywords
- atlas-free brain network, iFBN, individualized brain network, brain network transformer, spatial ICA brain network, parcellation-free