Editing
Computational Pathology
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''WSI classification with CLAM (MIL):''' <syntaxhighlight lang="python"> import torch import torch.nn as nn import torch.nn.functional as F class Attn_Net_Gated(nn.Module): """Gated attention network for MIL aggregation.""" def __init__(self, L=1024, D=256, dropout=0.25): super().__init__() self.attention_a = nn.Sequential(nn.Linear(L, D), nn.Tanh(), nn.Dropout(dropout)) self.attention_b = nn.Sequential(nn.Linear(L, D), nn.Sigmoid(), nn.Dropout(dropout)) self.attention_c = nn.Linear(D, 1) def forward(self, x): a = self.attention_a(x) b = self.attention_b(x) A = self.attention_c(a * b) # Gated attention scores return A, x # (N, 1), (N, L) class CLAM_SB(nn.Module): """CLAM single-branch for binary WSI classification.""" def __init__(self, feature_dim=1024, n_classes=2, dropout=0.25): super().__init__() self.attention_net = Attn_Net_Gated(L=feature_dim, D=256, dropout=dropout) self.classifiers = nn.Linear(feature_dim, n_classes) self.instance_classifier = nn.Linear(feature_dim, 2) # For instance-level clustering def forward(self, h): # h: (N, feature_dim) β patch embeddings from pre-trained feature extractor A, h = self.attention_net(h) A = F.softmax(A, dim=0).transpose(0, 1) # Softmax over patches: (1, N) M = torch.mm(A, h) # Weighted aggregation: (1, feature_dim) logits = self.classifiers(M) # Slide-level prediction Y_hat = torch.argmax(logits, dim=1) Y_prob = F.softmax(logits, dim=1) return logits, Y_prob, Y_hat, A # A contains attention scores for visualization # Feature extraction pipeline # 1. Segment tissue from background (Otsu thresholding) # 2. Extract non-overlapping 256Γ256 patches at 20Γ magnification # 3. Extract features using pathology foundation model (UNI, CONCH, ResNet50-ImageNet) # 4. Feed patch features to CLAM for WSI-level prediction # Using UNI (pre-trained ViT on 100K pathology images) # import timm # uni = timm.create_model("hf_hub:MahmoodLab/uni", pretrained=True) </syntaxhighlight> ; Computational pathology tools : '''WSI viewing''' β QuPath (open-source), Aperio ImageScope, SlideViewer : '''MIL frameworks''' β CLAM (GitHub), TransMIL, DTFD-MIL : '''Foundation models''' β UNI, CONCH (Mahmood Lab), Prov-GigaPath (Microsoft/Providence) : '''Cell segmentation''' β HoverNet, StarDist, CellViT, CellPose : '''Commercial AI''' β Paige, PathAI, Aiforia, Ibex Medical Analytics </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information