AllenInstitute/mouse_connectivity_models

subset voxel_array by region

jw156605 opened this issue · 3 comments

Hello, thanks for the great package and documentation.
I'm trying to figure out how to extract voxel-level connectivity to and from a region of interest (say, VISp). Note that I want the voxel-level data, not a regionalized summary. From the examples provided, I see how to use masks to extract a regionalized summary. But I want to be able to do something like this:
#VISp is region 385
region_mask = Mask.from_cache(cache, hemisphere_id=2, structure_ids=[385])
from_VISp = voxel_array[region_mask,:]
to_VISp = voxel_array[:,region_mask]

Obviously, this doesn't work as written. How can I find the indices to subset the voxel array in this fashion? Thanks for any suggestions you can offer.

kamdh commented

Hi, if you look into the tests for masks code, you'll see some like this:

def test_mask_to_hemisphere(ipsi_mask, contra_mask, bi_mask):

    midline = bi_mask.mask.shape[2]//2
    ipsi_left_hemi = ipsi_mask.mask[:,:,:midline]
    contra_right_hemi = contra_mask.mask[:,:,midline:]

So I think you want to use region_mask.mask to get a 0-1 array to work with for indexing.

kamdh commented

There are some other helper functions in the Mask class that tab-complete may help you find.

kamdh commented

@jw156605 did this get the job done for you?