bio-imaging-mass-cytometry-interactive-annotation
Interactive cell type annotation for IMC data. Covers napari-based annotation, marker-guided labeling, training data generation, and annotation validation…
от BioTender-max★ 235 звёзд на GitHub
Установить bio-imaging-mass-cytometry-interactive-annotation в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Version Compatibility
Reference examples tested with: matplotlib 3.8+, numpy 1.26+, pandas 2.2+, scikit-learn 1.4+
Before using code patterns, verify installed versions match. If versions differ:
- Python:
pip show <package>thenhelp(module.function)to check signatures
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Interactive Annotation
"Manually annotate cell types in my IMC data" → Interactively label cells using napari visualization with marker overlays for training classifiers or validating automated phenotyping results.
- Python:
napari.Viewer()with label layer for interactive annotation
Napari-Based Annotation
import napari
import numpy as np
from skimage import io
import pandas as pd
# Load IMC image stack
image_stack = io.imread('imc_image.tiff') # (C, H, W)
segmentation_mask = io.imread('cell_segmentation.tiff')
# Create napari viewer
viewer = napari.Viewer()
# Add channels as separate layers for visualization
channel_names = ['CD45', 'CD3', 'CD68', 'panCK', 'DNA']
for i, name in enumerate(channel_names):
viewer.add_image(image_stack[i], name=name, visible=False, colormap='gray', blending='additive')
# Add segmentation
viewer.add_labels(segmentation_mask, name='Cells')
# Add annotation layer (start empty)
annotation_layer = viewer.add_labels(
np.zeros_like(segmentation_mask),
name='Cell_Types'
)
# Define cell types
cell_type_mapping = {1: 'T_cell', 2: 'Macrophage', 3: 'Epithelial', 4: 'Stromal', 5: 'Other'}
Marker-Guided Annotation
def create_marker_overlay(image_stack, channel_indices, colors):
'''Create RGB overlay of selected markers for easier annotation.'''
h, w = image_stack.shape[1:]
overlay = np.zeros((h, w, 3), dtype=np.float32)
for idx, color in zip(channel_indices, colors):
channel = image_stack[idx].astype(np.float32)
channel = (channel - channel.min()) / (channel.max() - channel.min() + 1e-8)
for c, weight in enumerate(color):
overlay[:, :, c] += channel * weight
overlay = np.clip(overlay, 0, 1)
return overlay
# Create T cell overlay (CD3=green, CD45=blue)
t_cell_overlay = create_marker_overlay(
image_stack,
channel_indices=[0, 1], # CD45, CD3
colors=[[0, 0, 1], [0, 1, 0]] # Blue, Green
)
# Create tumor overlay (panCK=red)
tumor_overlay = create_marker_overlay(
image_stack,
channel_indices=[3], # panCK
colors=1, 0, 0 # Red
)
# Add overlays to viewer
viewer.add_image(t_cell_overlay, name='T_cell_markers', visible=True)
viewer.add_image(tumor_overlay, name='Tumor_markers', visible=False)
Training Data Generation
def extract_training_data(image_stack, segmentation_mask, annotation_mask, channel_names):
'''Extract mean marker intensities per cell with annotations.'''
from skimage.measure import regionprops_table
cells = []
for cell_id in np.unique(segmentation_mask):
if cell_id == 0:
continue
cell_mask = segmentation_mask == cell_id
annotation = annotation_mask[cell_mask]
annotation = annotation[annotation > 0]
if len(annotation) == 0:
continue
cell_type = int(np.median(annotation))
cell_data = {'cell_id': cell_id, 'cell_type': cell_type}
for i, name in enumerate(channel_names):
cell_data[name] = np.mean(image_stack[i][cell_mask])
cells.append(cell_data)
return pd.DataFrame(cells)
# After manual annotation in napari
annotation_data = annotation_layer.data
training_df = extract_training_data(image_stack, segmentation_mask, annotation_data, channel_names)
training_df.to_csv('training_annotations.csv', index=False)
print(f'Annotated {len(training_df)} cells')
print(training_df['cell_type'].value_counts())
Semi-Automated Annotation
Goal: Propagate a small set of manual cell type annotations to all unannotated cells using marker expression similarity.
Approach: Train a k-nearest-neighbors classifier on manually annotated cells' marker intensities, predict labels for remaining cells, and report classification confidence to flag uncertain assignments for review.
from sklearn.neighbors import KNeighborsClassifier
from sklearn.preprocessing import StandardScaler
def propagate_annotations(training_df, all_cells_df, marker_columns):
'''Use annotated cells to classify unannotated cells.'''
X_train = training_df[marker_columns].values
y_train = training_df['cell_type'].values
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
knn = KNeighborsClassifier(n_neighbors=5)
knn.fit(X_train_scaled, y_train)
unannotated = all_cells_df[~all_cells_df['cell_id'].isin(training_df['cell_id'])]
X_test = scaler.transform(unannotated[marker_columns].values)
predictions = knn.predict(X_test)
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- examples/napari_annotation.py
- usage-guide.md
FAQ
Что делает скилл bio-imaging-mass-cytometry-interactive-annotation?
Interactive cell type annotation for IMC data. Covers napari-based annotation, marker-guided labeling, training data generation, and annotation validation. Use when manually annotating cell types for training classifiers or validating automated phenotyping results.
Как установить скилл bio-imaging-mass-cytometry-interactive-annotation?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл bio-imaging-mass-cytometry-interactive-annotation запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…