Note
Click here to download the full example code
The MICrONS Datasets#
In this tutorial we will explore the MICrONS datasets.
The Allen Institute for Brain Science in collaboration with Princeton University, and Baylor College of Medicine released two large connecotmics dataset:
- A "Cortical mm3" of mouse visual cortex. This one is broken into two portions: "65" and "35"
- A smaller "Layer 2/3" dataset of mouse visual cortex.
All of these can be browsed via the MICrONS Explorer using neuroglancer. These data are public and thanks to the excellent cloud-volume and caveclient libraries, developed by William Silversmith, Forrest Collman, Sven Dorkenwald, Casey Schneider-Mizell and others, we can easily fetch neurons and their connectivity.
For easier interaction, NAVis ships with a small interface to these datasets. To use it, we will have to make sure caveclient (and with it cloud-volume) is installed:
pip install caveclient cloud-volume -U
The first time you run below code, you might have to get and set a client secret. Simply follow the instructions in the terminal and when in doubt, check out the section about authentication in the caveclient docs.
Let's get started:
import navis
import navis.interfaces.microns as mi
You will find that most functions in the interface accept a datastack parameter. At the time of writing, the available stacks are:
cortex65(also called "minnie65") is the anterior portion of the cortical mm3 datasetcortex35(also called "minnie35") is the (smaller) posterior portion of the cortical mm3 datasetlayer 2/3(also called "pinky") is the earlier, smaller cortical dataset
If not specified, the default is cortex65. Both cortex65 and cortex35 always map to the most recent version of that dataset. You can use get_datastacks to see all available datastacks:
mi.get_datastacks()
Out:
['minnie35_public_v0', 'pinky_sandbox', 'minnie65_sandbox', 'minnie65_public']
Let's start with some basic queries using the caveclient directly:
# Initialize the client for the 65 part of cortical mm^3 (i.e. "Minnie")
client = mi.get_cave_client(datastack="cortex65")
# Fetch available annotation tables
client.materialize.get_tables()
Out:
['baylor_gnn_cell_type_fine_model_v2', 'nucleus_alternative_points', 'allen_column_mtypes_v2', 'bodor_pt_cells', 'aibs_metamodel_mtypes_v661_v2', 'allen_v1_column_types_slanted_ref', 'aibs_column_nonneuronal_ref', 'nucleus_ref_neuron_svm', 'apl_functional_coreg_vess_fwd', 'vortex_compartment_targets', 'baylor_log_reg_cell_type_coarse_v1', 'gamlin_2023_mcs', 'l5et_column', 'pt_synapse_targets', 'coregistration_manual_v4', 'cg_cell_type_calls', 'synapses_pni_2', 'nucleus_detection_v0', 'vortex_manual_nodes_of_ranvier', 'bodor_pt_target_proofread', 'nucleus_functional_area_assignment', 'coregistration_auto_phase3_fwd_apl_vess_combined_v2', 'vortex_thalamic_proofreading_status', 'multi_input_spine_predictions_ssa', 'synapse_target_structure', 'proofreading_status_and_strategy', 'coregistration_auto_phase3_fwd_v2', 'vortex_peptidergic_proofreading_status', 'digital_twin_properties_bcm_coreg_v4', 'vortex_astrocyte_proofreading_status', 'digital_twin_properties_bcm_coreg_auto_phase3_fwd_v2', 'digital_twin_properties_bcm_coreg_apl_vess_fwd', 'gamlin_2023_mcs_met_types', 'vortex_manual_myelination_v0', 'synapse_target_predictions_ssa', 'aibs_metamodel_celltypes_v661']
These are the available public tables which we can use to fetch meta data. Let's check out baylor_log_reg_cell_type_coarse_v1. Note that there is also a baylor_gnn_cell_type_fine_model_v2 table which contains more detailed cell types.
# Get cell type table
ct = client.materialize.query_table("baylor_log_reg_cell_type_coarse_v1")
ct.head()
ct.cell_type.value_counts()
Out:
cell_type
excitatory 49208
inhibitory 5855
Name: count, dtype: int64
Important
Not all neurons in the dataset have been proofread. In theory, you can check if a neuron has been proofread using the corresponding annotation table:
table = client.materialize.query_table('proofreading_status_public_release')#
fully_proofread = table[
table.status_dendrite.isin(['extented', 'clean']) &
table.status_axon.isin(['extented', 'clean'])
].pt_root_id.values
Let's fetch one of the excitatory neurons:
n = mi.fetch_neurons(
ct[ct.cell_type == "excitatory"].pt_root_id.values[0], with_synapses=False
)[0]
n
Neuron IDs
The neuron IDs in MICrONS are called "root IDs" because they represent collections of supervoxels - or rather hierarchical layers of chunks of which the lowest layer are supervoxel IDs.
MICrONS neurons can be fairly large, i.e. have lots of faces. You can try using using a higher lod ("level of detail", higher = coarser) but not all datastacks actually support multi-resolution meshes. If they don't (like this one) the lod parameter is silently ignored.
For visualization in this documentation we will simplify the neuron a little. For this, you need either open3d (pip3 install open3d), pymeshlab (pip3 install pymeshlab) or Blender 3D on your computer.
# Reduce face counts to 1/3 of the original
n_ds = navis.simplify_mesh(n, F=1 / 3)
# Inspect (note the lower face/vertex counts)
n_ds
Plot the downsample neuron (again: the downsampling is mostly for the sake of this documentation)
navis.plot3d(
n_ds,
radius=False,
color="r",
legend=False, # hide the legend (more space for the plot)
)