Glad to hear you were able to generate the matrix!
As you say, the region-level summary data (structure unionizes) won’t tell you about the within-region distribution of the injection signal. However, we also make available the voxel-level grid data on which these structure-level summaries are based. See this section of the mouse connectivity examples for some visuals and examples and the informatics whitepaper for more details on how these data are used in our pipeline.
You mentioned that your goal is to get a feel for the distribution of the available data. One potential starting point would be to ask for each thalamic voxel “how many experiments injected into this voxel”:
from allensdk.core.mouse_connectivity_cache import MouseConnectivityCache
import numpy as np
# setting isometric resolution to 50 microns for speedy downloads & low memory use
# other options are 10, 25, & 100
mcc = MouseConnectivityCache(resolution=50)
structure_tree = mcc.get_structure_tree()
# obtain the unique numeric identifier for the thalamus
thalamus_id = structure_tree.get_structures_by_name(["Thalamus"])["id"]
# obtain all experiments with injections into the thalamus
th_experiment_ids = [
# count a voxel as "injection" if it is at least half-full of injection signal
inj_threshold = 0.5
# loop over the thalamic injection experiments, counting injections per voxel
inj_counts = None
for exp_id in th_experiment_ids:
# injection density is "how much of this voxel is filled with injection signal"
# it ranges from 0 to 1
inj_density, header = mcc.get_injection_density(exp_id)
inj_density[inj_density < inj_threshold] = 0.0
inj_density[inj_density >= inj_threshold] = 1.0
if inj_counts is None:
inj_counts = inj_density
inj_counts += inj_density
# write the counts out to a nrrd file
nrrd.write("injection_counts.nrrd", inj_counts, header)
# write itksnap-friendly files for overlaying the injection counts with structures
This saves out a counts volume and a copy of the annotation, you can load these into a 3d visualization tool like itk-SNAP in order to see the spatial distribution of thalamic injections at a glance:
(in this example, the voxel under the cursor is part of the Mediodorsal nucleus and has >=50% covered during 7 injections).
In addition to visualizing these data, you can also compute on them. For instance, if you masked a particular substructure, you could
- count the number of voxels within the structure that have been injected at least
- divide by the total number of voxels in the structure
in order to get a single “fraction of voxels covered across all experiments” number for the structure.