Allen Brain Institute - 鼠标连接 API 和鼠标连接缓存示例
Allen Brain Institute - Mouse Connectivity API and Mouse Connectivity Cache examples
我正在尝试遵循 Mouse Connectivity sdk 并让他们的两个示例正常工作。
pd
returns None 或所有投影信号密度实验。为什么会这样?
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))
结果:
C:\Anaconda\python.exe C:/Users/user/PycharmProjects/MyFirstAllenBrain/Test.py
<type 'NoneType'>
<type 'NoneType'>
<type 'NoneType'>
<type 'NoneType'>
<type 'NoneType'>
<type 'NoneType'>
... etc
尽管如此,experiments
确实收到了一个值,因此 MouseConnectivityApi 和 nrrd(我按照以下 安装)似乎正在正常工作.
看这里:
对了,现在是第二个例子
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'])
这是从艾伦那里逐字复制的,但这是我收到的错误消息:
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
为什么会发生这种情况?
和以前一样(我假设不需要另一张图片),experiments
变量确实收到了每个实验的值。
不幸的是,现在这是 pynrrd/master github 存储库的一个 Windows 特定问题。我知道一个特定的修订有效:
https://github.com/mhe/pynrrd/commit/3c0f3d577b0b435fb4825c14820322a574311af0
要从 windows 命令提示符安装此修订版,您可以:
> git clone https://github.com/mhe/pynrrd.git
> cd pynrrd
> git checkout 3c0f3d5
> cd ..
> pip install --upgrade pynrrd\
末尾的反斜杠很重要。它告诉 pip 从本地路径安装而不是检查 PyPI。
我正在尝试遵循 Mouse Connectivity sdk 并让他们的两个示例正常工作。
pd
returns None 或所有投影信号密度实验。为什么会这样?
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))
结果:
C:\Anaconda\python.exe C:/Users/user/PycharmProjects/MyFirstAllenBrain/Test.py
<type 'NoneType'>
<type 'NoneType'>
<type 'NoneType'>
<type 'NoneType'>
<type 'NoneType'>
<type 'NoneType'>
... etc
尽管如此,experiments
确实收到了一个值,因此 MouseConnectivityApi 和 nrrd(我按照以下
看这里:
对了,现在是第二个例子
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'])
这是从艾伦那里逐字复制的,但这是我收到的错误消息:
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
为什么会发生这种情况?
和以前一样(我假设不需要另一张图片),experiments
变量确实收到了每个实验的值。
不幸的是,现在这是 pynrrd/master github 存储库的一个 Windows 特定问题。我知道一个特定的修订有效:
https://github.com/mhe/pynrrd/commit/3c0f3d577b0b435fb4825c14820322a574311af0
要从 windows 命令提示符安装此修订版,您可以:
> git clone https://github.com/mhe/pynrrd.git
> cd pynrrd
> git checkout 3c0f3d5
> cd ..
> pip install --upgrade pynrrd\
末尾的反斜杠很重要。它告诉 pip 从本地路径安装而不是检查 PyPI。