0

I'm trying to follow the Mouse Connectivity sdk and get their two examples working.

pd returns None or all projection signal density experiments. Why might this be?

from allensdk.api.queries.mouse_connectivity_api import MouseConnectivityApi

mca = MouseConnectivityApi()

# get metadata for all non-Cre experiments
experiments = mca.experiment_source_search(injection_structures='root', transgenic_lines=0)

# download the projection density volume for one of the experiments
#pd = mca.download_projection_density('example.nrrd', experiments[0]['id'], resolution=25)

for exp in range(len(experiments)):
    pd = mca.download_projection_density('example.nrrd', experiments[exp]['id'], resolution=25)
    print(type(pd))

Results:

C:\Anaconda\python.exe C:/Users/user/PycharmProjects/MyFirstAllenBrain/Test.py
<type 'NoneType'>
<type 'NoneType'>
<type 'NoneType'>
<type 'NoneType'>
<type 'NoneType'>
<type 'NoneType'>
... etc

The thing though is, is that experiments does recieve a value so it appears to be the case that the MouseConnectivityApi and nrrd (which I installed as per the following post) are working appropriately.

See here: enter image description here

Right, and now the second example

from allensdk.core.mouse_connectivity_cache import MouseConnectivityCache

# tell the cache class what resolution (in microns) of data you want to download
mcc = MouseConnectivityCache(resolution=25)

# use the ontology class to get the id of the isocortex structure
ontology = mcc.get_ontology()
isocortex = ontology['Isocortex']

# a list of dictionaries containing metadata for non-Cre experiments
experiments = mcc.get_experiments(injection_structure_ids=isocortex['id'])

# download the projection density volume for one of the experiments
pd = mcc.get_projection_density(experiments[0]['id'])

This is copied word for word from Allen and yet this is the error message I get:

C:\Anaconda\python.exe C:/Users/user/PycharmProjects/MyFirstAllenBrain/Test.py
Traceback (most recent call last):
  File "C:/Users/user/PycharmProjects/MyFirstAllenBrain/Test.py", line 14, in <module>
    pd = mcc.get_projection_density(experiments[0]['id'])
  File "C:\Users\user\AppData\Roaming\Python\Python27\site-packages\allensdk\core\mouse_connectivity_cache.py", line 170, in get_projection_density
    return nrrd.read(file_name)
  File "C:\Anaconda\lib\site-packages\nrrd.py", line 384, in read
    data = read_data(header, filehandle, filename)
  File "C:\Anaconda\lib\site-packages\nrrd.py", line 235, in read_data
    mmap.MAP_PRIVATE, mmap.PROT_READ)
AttributeError: 'module' object has no attribute 'MAP_PRIVATE'

Process finished with exit code 1

Why might this occur?

And again as before (no need for another picture I assume), the experiments variable does recieve what appears to be values for each experiment.

Community
  • 1
  • 1
Frikster
  • 2,755
  • 5
  • 37
  • 71

1 Answers1

0

Unfortunately this is a Windows-specific issue with the pynrrd/master github repository right now. I know that one specific revision works:

https://github.com/mhe/pynrrd/commit/3c0f3d577b0b435fb4825c14820322a574311af0

To install this revision from a windows command prompt, you can:

> git clone https://github.com/mhe/pynrrd.git
> cd pynrrd
> git checkout 3c0f3d5
> cd ..
> pip install --upgrade pynrrd\

The backslash on the end is important. It tells pip to install from a local path instead of checking PyPI.

Issue logged: https://github.com/mhe/pynrrd/issues/18

davidf
  • 313
  • 1
  • 6
  • I see, thanx. I've been looking at dual booting the PC at our lab with Ubuntu and it shouldn't be an issue as I'm just getting started. Would you recommend that we (and I suppose other researchers too) do that? I ask because If the Allen Institute - going forward - is likely going a more Linux route I'm more than happy to follow. – Frikster Aug 28 '15 at 22:11
  • 1
    We are definitely aiming to support Windows users. The pynrrd developers are a bit more linux-oriented, but I'm working with them to resolve this issue. Thanks for your patience. – davidf Aug 29 '15 at 22:31
  • So this did solve my second issue with the Mouse Connectivity Cache - i.e. It gave me the projection density volume but my first problem remains unresolved. I still get nothing but NoneTypes when I run my code. Is that normal? an issue with download_projection_density perhaps? – Frikster Oct 08 '15 at 05:05
  • 1
    Good question. The MouseConnectivityApi.download_projection_density function does not have a return value. All it does is download the file from the API to a given file location. If you would like to open it, you will need to read it with pynrrd. The MouseConnectivityCache.get_projection_density function wraps this for you. – davidf Oct 08 '15 at 19:26