unravel.cluster_stats.mean_IF module#

Use cstats_mean_IF (cmi) from UNRAVEL to measure mean intensity of immunofluorescence staining in clusters.

By default, this measures mean IF intensity in each cluster.

If an atlas is provided with --atlas/-a, this measures mean IF intensity in each atlas region within each cluster.

Prereqs:
  • vstats

  • cstats_fdr or cstats_clusters to generate a rev_cluster_index.nii.gz

Inputs:
  • Cluster index image from cstats_fdr or cstats_clusters

  • NIfTI images to measure

  • Optional atlas image in the same space/resolution as the cluster index

Outputs:
  • Cluster-only mode:

    ./cluster_mean_IF_<cluster_index>/image_name.csv Columns: condition, sample, cluster_ID, n_voxels, mean_intensity

  • Cluster-region mode:

    ./cluster_region_mean_IF_<cluster_index>/image_name.csv Columns: condition, sample, cluster_ID, region_ID, region, abbr, n_voxels, mean_intensity

Next steps:
  • cd cluster_mean_IF… or cluster_region_mean_IF…

  • Concatenate outputs:

    tabular_concat -i ‘*.csv’ -a 0 -o concat/concat.csv -v

  • Summarize:

    cstats_mean_IF_summary –order Control Treatment –labels Control Treatment -t ttest

Usage:#

cstats_mean_IF -i path/rev_cluster_index.nii.gz [-ip ‘*.nii.gz’] [-c 1 2 3] [-v]

Usage for region means within clusters:#

cstats_mean_IF -i path/rev_cluster_index.nii.gz -a path/atlas.nii.gz [-ip ‘*.nii.gz’] [-c 1 2 3] [-r 10 20 30] [-v]

unravel.cluster_stats.mean_IF.parse_args()[source]#
unravel.cluster_stats.mean_IF.build_label_index(cluster_index, atlas=None, clusters=None, regions=None)[source]#

Precompute voxel membership for cluster-only or cluster-region mean IF.

Cluster-only mode:

key = cluster_ID

Cluster-region mode:

key = cluster_ID * key_base + region_ID

unravel.cluster_stats.mean_IF.calculate_mean_intensity(img, valid_mask, keys, counts, keep, key_base=None)[source]#

Calculate mean IF intensity for precomputed cluster or cluster-region labels.

unravel.cluster_stats.mean_IF.write_rows_to_csv(rows, output_file, condition, sample)[source]#

Write mean intensity rows to CSV with a stable column order.

unravel.cluster_stats.mean_IF.condition_sample_from_filename(file)[source]#

Extract condition and sample from filename.

Expected after utils_prepend-style naming:

Condition_sampleXX_….

Falls back gracefully if the filename does not contain both fields.

unravel.cluster_stats.mean_IF.add_region_metadata(rows, region_lut)[source]#

Add region and abbr columns to cluster-region rows.

unravel.cluster_stats.mean_IF.resolve_lut_path(lut)[source]#

Resolve LUT path from explicit path or unravel/core/csvs/.

unravel.cluster_stats.mean_IF.load_region_lut(lut)[source]#

Load region LUT as a dictionary keyed by Region_ID.

unravel.cluster_stats.mean_IF.main()[source]#