AllenInstitute / mouse_connectivity_models

Python package providing mesoscale connectivity models for mouse.
http://mouse-connectivity-models.readthedocs.io/en/latest/
Other
39 stars 14 forks source link

subset voxel_array by region #37

Closed jw156605 closed 4 years ago

jw156605 commented 5 years ago

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 5 years ago

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 5 years ago

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

kamdh commented 4 years ago

@jw156605 did this get the job done for you?