/bio-imaging-mass-cytometry-quality-metrics
Quality metrics for IMC data including signal-to-noise, channel correlation, tissue integrity, and acquisition QC. Use when assessing data quality before analysis or troubleshooting problematic acquisitions.
$ npx -y skills add FreedomIntelligence/OpenClaw-Medical-Skills --skill bio-imaging-mass-cytometry-quality-metrics --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/bio-imaging-mass-cytometry-quality-metrics
Context preview
The summary Claude sees to decide when to auto-load this skill.
Quality metrics for IMC data including signal-to-noise, channel correlation, tissue integrity, and acquisition QC. Use when assessing data quality before analysis or troubleshooting problematic acquisitions.
SKILL.md
bio-imaging-mass-cytometry-quality-metrics.SKILL.mdname: bio-imaging-mass-cytometry-quality-metrics
description: Quality metrics for IMC data including signal-to-noise, channel correlation, tissue integrity, and acquisition QC. Use when assessing data quality before analysis or troubleshooting problematic acquisitions.
tool_type: python
primary_tool: numpy
Version Compatibility
Reference examples tested with: matplotlib 3.8+, numpy 1.26+, pandas 2.2+, scipy 1.12+
Before using code patterns, verify installed versions match. If versions differ:
- Python: `pip show <package>` then `help(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.
Quality Metrics
**"Assess quality of my IMC acquisition"** → Evaluate IMC data quality through signal-to-noise ratios, channel correlations, tissue integrity scores, and acquisition-specific QC metrics.
- Python: `numpy`/`scipy` for SNR calculation and channel correlation analysis
Signal-to-Noise Ratio
import numpy as np
from scipy import ndimage
from skimage import io
def calculate_snr(image, mask=None):
'''Calculate signal-to-noise ratio for an image channel.'''
if mask is None:
mask = image > np.percentile(image, 10)
signal = np.mean(image[mask])
noise = np.std(image[~mask])
if noise == 0:
return np.inf
snr = signal / noise
return snr
def calculate_snr_all_channels(image_stack, channel_names, tissue_mask=None):
'''Calculate SNR for all channels in stack.'''
results = {}
for i, name in enumerate(channel_names):
snr = calculate_snr(image_stack[i], tissue_mask)
results[name] = snr
return results
image_stack = io.imread('imc_image.tiff')
channel_names = ['CD45', 'CD3', 'CD68', 'panCK', 'DNA']
snr_values = calculate_snr_all_channels(image_stack, channel_names)
for ch, snr in snr_values.items():
status = 'PASS' if snr > 3 else 'WARN' if snr > 1.5 else 'FAIL'
print(f'{ch}: SNR = {snr:.2f} [{status}]')Channel Correlation
def calculate_channel_correlation(image_stack, channel_names):
'''Calculate pairwise correlation between channels.'''
n_channels = image_stack.shape[0]
flat_data = image_stack.reshape(n_channels, -1)
corr_matrix = np.corrcoef(flat_data)
import pandas as pd
corr_df = pd.DataFrame(corr_matrix, index=channel_names, columns=channel_names)
return corr_df
def flag_unexpected_correlations(corr_df, expected_pairs=None, threshold=0.7):
'''Flag unexpected high correlations (possible spillover).'''
issues = []
if expected_pairs is None:
expected_pairs = []
for i, ch1 in enumerate(corr_df.columns):
for j, ch2 in enumerate(corr_df.columns):
if i >= j:
continue
corr = corr_df.loc[ch1, ch2]
pair = (ch1, ch2)
is_expected = pair in expected_pairs or (ch2, ch1) in expected_pairs
if corr > threshold and not is_expected:
issues.append({'channel_1': ch1, 'channel_2': ch2, 'correlation': corr, 'expected': is_expected})
return pd.DataFrame(issues)
corr_matrix = calculate_channel_correlation(image_stack, channel_names)
print('Channel correlations:')
print(corr_matrix.round(2))
expected = [('CD3', 'CD45')]
issues = flag_unexpected_correlations(corr_matrix, expected)
if len(issues) > 0:
print('\nUnexpected high correlations:')
print(issues)Tissue Integrity
def assess_tissue_integrity(dna_channel, min_coverage=0.3):
'''Assess tissue coverage and integrity from DNA channel.'''
threshold = np.percentile(dna_channel, 50)
tissue_mask = dna_channel > threshold
total_pixels = dna_channel.size
tissue_pixels = np.sum(tissue_mask)
coverage = tissue_pixels / total_pixels
labeled, n_fragments = ndimage.label(tissue_mask)
fragment_sizes = ndimage.sum(tissue_mask, labeled, range(1, n_fragments + 1))
largest_fragment = np.max(fragment_sizes) if len(fragment_sizes) > 0 else 0
fragmentation = 1 - (largest_fragment / tissue_pixels) if tissue_pixels > 0 else 1
return {
'coverage': coverage,
'n_fragments': n_fragments,
'fragmentation': fragmentation,
'intact': coverage > min_coverage and fragmentation < 0.5
}
dna_channel = image_stack[channel_names.index('DNA')]
integrity = assess_tissue_integrity(dna_channel)
print(f"Tissue coverage: {integrity['coverage']:.1%}")
print(f"Fragments: {integrity['n_fragments']}")
print(f"Fragmentation: {integrity['fragmentation']:.2f}")
print(f"Status: {'PASS' if integrity['intact'] else 'FAIL'}")Acquisition QC
def check_acquisition_artifacts(image_stack, channel_names):
'''Check for common acquisition artifacts.'''
results = []
for i, name in enumerate(channel_names):
channel = image_stack[i]
saturated = np.sum(channel >= channel.max() * 0.99) / channel.size
if saturated > 0.01:
results.append({'channel': name, 'issue': 'saturation', 'severity': saturated})
hot_pixels = np.sum(channel > np.percentile(channel, 99.9) * 2) / channel.size
if hot_pixels > 0.001:
results.append({'channel': name, 'issue': 'hot_pixels', 'severity': hot_pixels})
dead_regions = np.sum(channel == 0) / channel.size
if dead_regions > 0.05:
results.append({'channel': name, 'issue': 'dead_regions', 'severity': dead_regions})
row_means = np.mean(channel, axis=1)
row_cv = np.std(row_means) / np.mean(row_means)
if row_cv > 0.3:
results.append({'channel': name, 'issue': 'striping', 'severity': row_cv})
return pd.DataFrame(results)
artifacts = check_acquisition_artifacts(image_stack, channel_names)
if len(artifacts) > 0:
print('Artifacts detected:')
print(artifacts)
else:
print('No major artifacts detectedRead more
name: bio-imaging-mass-cytometry-quality-metrics description: Quality metrics for IMC data including signal-to-noise, channel correlation, tissue integrity, and acquisition QC. Use when assessing data quality before analysis or troubleshooting problematic acquisitions. tool_type: python primary_tool: numpy
Version Compatibility
Reference examples tested with: matplotlib 3.8+, numpy 1.26+, pandas 2.2+, scipy 1.12+
Before using code patterns, verify installed versions match. If versions differ:
- Python: `pip show <package>` then `help(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.
Quality Metrics
**"Assess quality of my IMC acquisition"** → Evaluate IMC data quality through signal-to-noise ratios, channel correlations, tissue integrity scores, and acquisition-specific QC metrics.
- Python: `numpy`/`scipy` for SNR calculation and channel correlation analysis
Signal-to-Noise Ratio
import numpy as np
from scipy import ndimage
from skimage import io
def calculate_snr(image, mask=None):
'''Calculate signal-to-noise ratio for an image channel.'''
if mask is None:
mask = image > np.percentile(image, 10)
signal = np.mean(image[mask])
noise = np.std(image[~mask])
if noise == 0:
return np.inf
snr = signal / noise
return snr
def calculate_snr_all_channels(image_stack, channel_names, tissue_mask=None):
'''Calculate SNR for all channels in stack.'''
results = {}
for i, name in enumerate(channel_names):
snr = calculate_snr(image_stack[i], tissue_mask)
results[name] = snr
return results
image_stack = io.imread('imc_image.tiff')
channel_names = ['CD45', 'CD3', 'CD68', 'panCK', 'DNA']
snr_values = calculate_snr_all_channels(image_stack, channel_names)
for ch, snr in snr_values.items():
status = 'PASS' if snr > 3 else 'WARN' if snr > 1.5 else 'FAIL'
print(f'{ch}: SNR = {snr:.2f} [{status}]')Channel Correlation
def calculate_channel_correlation(image_stack, channel_names):
'''Calculate pairwise correlation between channels.'''
n_channels = image_stack.shape[0]
flat_data = image_stack.reshape(n_channels, -1)
corr_matrix = np.corrcoef(flat_data)
import pandas as pd
corr_df = pd.DataFrame(corr_matrix, index=channel_names, columns=channel_names)
return corr_df
def flag_unexpected_correlations(corr_df, expected_pairs=None, threshold=0.7):
'''Flag unexpected high correlations (possible spillover).'''
issues = []
if expected_pairs is None:
expected_pairs = []
for i, ch1 in enumerate(corr_df.columns):
for j, ch2 in enumerate(corr_df.columns):
if i >= j:
continue
corr = corr_df.loc[ch1, ch2]
pair = (ch1, ch2)
is_expected = pair in expected_pairs or (ch2, ch1) in expected_pairs
if corr > threshold and not is_expected:
issues.append({'channel_1': ch1, 'channel_2': ch2, 'correlation': corr, 'expected': is_expected})
return pd.DataFrame(issues)
corr_matrix = calculate_channel_correlation(image_stack, channel_names)
print('Channel correlations:')
print(corr_matrix.round(2))
expected = [('CD3', 'CD45')]
issues = flag_unexpected_correlations(corr_matrix, expected)
if len(issues) > 0:
print('\nUnexpected high correlations:')
print(issues)Tissue Integrity
def assess_tissue_integrity(dna_channel, min_coverage=0.3):
'''Assess tissue coverage and integrity from DNA channel.'''
threshold = np.percentile(dna_channel, 50)
tissue_mask = dna_channel > threshold
total_pixels = dna_channel.size
tissue_pixels = np.sum(tissue_mask)
coverage = tissue_pixels / total_pixels
labeled, n_fragments = ndimage.label(tissue_mask)
fragment_sizes = ndimage.sum(tissue_mask, labeled, range(1, n_fragments + 1))
largest_fragment = np.max(fragment_sizes) if len(fragment_sizes) > 0 else 0
fragmentation = 1 - (largest_fragment / tissue_pixels) if tissue_pixels > 0 else 1
return {
'coverage': coverage,
'n_fragments': n_fragments,
'fragmentation': fragmentation,
'intact': coverage > min_coverage and fragmentation < 0.5
}
dna_channel = image_stack[channel_names.index('DNA')]
integrity = assess_tissue_integrity(dna_channel)
print(f"Tissue coverage: {integrity['coverage']:.1%}")
print(f"Fragments: {integrity['n_fragments']}")
print(f"Fragmentation: {integrity['fragmentation']:.2f}")
print(f"Status: {'PASS' if integrity['intact'] else 'FAIL'}")Acquisition QC
def check_acquisition_artifacts(image_stack, channel_names):
'''Check for common acquisition artifacts.'''
results = []
for i, name in enumerate(channel_names):
channel = image_stack[i]
saturated = np.sum(channel >= channel.max() * 0.99) / channel.size
if saturated > 0.01:
results.append({'channel': name, 'issue': 'saturation', 'severity': saturated})
hot_pixels = np.sum(channel > np.percentile(channel, 99.9) * 2) / channel.size
if hot_pixels > 0.001:
results.append({'channel': name, 'issue': 'hot_pixels', 'severity': hot_pixels})
dead_regions = np.sum(channel == 0) / channel.size
if dead_regions > 0.05:
results.append({'channel': name, 'issue': 'dead_regions', 'severity': dead_regions})
row_means = np.mean(channel, axis=1)
row_cv = np.std(row_means) / np.mean(row_means)
if row_cv > 0.3:
results.append({'channel': name, 'issue': 'striping', 'severity': row_cv})
return pd.DataFrame(results)
artifacts = check_acquisition_artifacts(image_stack, channel_names)
if len(artifacts) > 0:
print('Artifacts detected:')
print(artifacts)
else:
print('No major artifacts detectedThe largest open-source medical AI skill library for OpenClaw.
Other skills on openclaw-medical-skills.
- /aav-vector-design-agent
<!--
Open skill - /adaptyv
Cloud laboratory platform for automated protein testing and validation. Use when designing proteins and needing experimental validation including binding assays, expression testing, thermostability measurements, enzyme activity assays, or protein sequence optimization. Also use
Open skill - /adhd-daily-planner
Time-blind friendly planning, executive function support, and daily structure for ADHD brains. Specializes in realistic time estimation, dopamine-aware task design, and building systems that
Open skill - /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
Open skill - /agent-browser
Browse the web for any task — research topics, read articles, interact with web apps, fill forms, take screenshots, extract data, and test web pages. Use whenever a browser would be useful, not just when the user explicitly asks.
Open skill - /agentd-drug-discovery
<!--
Open skill

