AllenInstitute/mouse_connectivity_models

RegionalizedModel not working as expected?

LudovicoColetta opened this issue · 2 comments

Dear Joseph,

first of all thanks for the great work.

We are trying to build a regionalized version of the connectome with brain regions that are not necessarily part of the summary structures. I tried the following

from mcmodels.core import VoxelModelCache
from mcmodels.models.voxel import RegionalizedModel
import numpy as np

cache = VoxelModelCache(manifest_file='connectivity/voxel_model_manifest.json')

model, right_hem_mask, whole_brain_mask= cache.get_voxel_connectivity_array()

source_key = right_hem_mask.get_key(structure_ids=[31,864]) # ACA, DORsm
target_key = whole_brain_mask.get_key(structure_ids=[31,864]) # ACA, DORsm

regional_model = RegionalizedModel.from_voxel_array(model, source_key, target_key)

ncd=regional_model.normalized_connection_density 

and according to these examples (here and bottom of here) I was expecting a 2x4 numpy array as a result, instead I got a 2x2

I then tried to include the hemisphere_id for the target key variable, and it seemed to work

target_key_right_hem = whole_brain_mask.get_key(structure_ids=[31,864],hemisphere_id=2) # ACA, DORsm for right hem
target_key_left_hem = whole_brain_mask.get_key(structure_ids=[31,864],hemisphere_id=1) # ACA, DORsm for left hem

regional_model_right_hem = RegionalizedModel.from_voxel_array(model, source_key, target_key_right_hem)
regional_model_left_hem = RegionalizedModel.from_voxel_array(model, source_key, target_key_left_hem)

ncd_right=regional_model_right_hem.normalized_connection_density
ncd_left=regional_model_left_hem.normalized_connection_density

new_ncd=np.concatenate((ncd_right,ncd_left),axis=1)

Is the second piece of code the right way to obtain what we want or the first one should output a 2x4 matrix?

Thanks for your time
Ludovico

Hi Ludovico,

Yes, the second piece of code is currently the only way to get a regional connecitivty matrix both ipsilateral and contralateral connection weights.

Regionalizing the voxel-level connectivity using a Mask object with hemisphere==3 will produce a regional connectivity matrix with weights equal to the integral of the voxel-scale weights between regions both ipsilaterally and contralatteraly.

I admit this does not make much sense in terms of regional connectivity, but has been implemented in this way for other purposes.

Great, thanks for the quick answer!