Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get_structure_mesh always returns the same tessellation #750

Closed
mpompolas opened this issue Jun 15, 2019 · 4 comments

Comments

@mpompolas
Copy link

commented Jun 15, 2019

Hi, I want to get the mesh (Vertices, Faces) of specific areas. These are the commands I'm using:

import allensdk.core.reference_space_cache as p
a = p.ReferenceSpaceCache(25, None)

object_id = 8

[vertices, vertex_normals, faces, face_normals] = a.get_structure_mesh(object_id , 'None')

However, even when I use a different object_id, I always get the same mesh (vertices: 87732x2, Faces: 174225x3) which is actually the entire brain.

Any ideas?
Thanks

@NileGraddis

This comment has been minimized.

Copy link
Member

commented Jun 17, 2019

Hi @mpompolas,

get_structure_mesh has 2 parameters (& self, of course): "structure_id", and "file_name".

def get_structure_mesh(self, structure_id, file_name=None):

when you call a.get_structure_mesh(object_id , 'None') you are passing object_id as the structure_id and the string value "None" as the file_name. The first time you run this code, a mesh is downloaded and stored in a file called "None". All future times, get_structure_mesh checks for a file called "None" and reads the mesh out of it.

To solve this problem, just don't supply the second parameter. It will default to None (not a string!) and save the file to an appropriate place relative to your cache's manifest.

@NileGraddis NileGraddis self-assigned this Jun 17, 2019

@mpompolas

This comment has been minimized.

Copy link
Author

commented Jun 18, 2019

Thanks, your solution did the trick.
However, until I decide which meshes I will use for my atlases, I downloaded all of them, and many failed to download (broken links maybe).

I have one more question:
Let's assume that I have the coordinates of an electrode in the cortex. Is it possible to retrieve the area (or structure tree of areas) that it belongs to?

Thanks

@NileGraddis

This comment has been minimized.

Copy link
Member

commented Jun 18, 2019

@mpompolas

Glad to hear that worked.

  1. We can only build meshes for annotated structures, and not all of the structures in our ontology are annotated (unannotated structures might have had annotations in a previous version of CCF, for instance). You can filter these out using your reference space object:

    def remove_unassigned(self, update_self=True):

    There is an example of how to do this in the example notebook:
    https://allensdk.readthedocs.io/en/latest/_static/examples/nb/reference_space.html#Removing-unassigned-structures
    If this isn't the issue, then please post the code that you are using (and the error you are getting).

  2. Yes! As long as the coordinates are in CCF space, simply look up the corresponding voxel in the annotation volume. In addition to the reference space example notebook, see the mouse connectivity notebook for more explanation and code snippets:
    https://allensdk.readthedocs.io/en/latest/_static/examples/nb/mouse_connectivity.html

@mpompolas

This comment has been minimized.

Copy link
Author

commented Jun 20, 2019

Thanks Nile,
the importing in Brainstorm worked perfectly:

image

When I find some time I'll look into the structure retrieval from the electrode positions.
The idea is to set the tip and the skull entry of the electrode, and automatically retrieve the structure each channel belongs to (it would be a pain to do this manually in neuropixels).

@mpompolas mpompolas closed this Jun 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.