使用 Allen SDK 从神经递质研究中获取更多元数据
Get more of the metadata from the Neurotransmitter study using Allen SDK
我正在使用以下脚本从艾伦大脑图谱的神经递质研究中下载所有图像:
from allensdk.api.queries.image_download_api import ImageDownloadApi
from allensdk.config.manifest import Manifest
import pandas as pd
import os
#getting transmitter study
#product id from http://api.brain-map.org/api/v2/data/query.json?criteria=model::Product
nt_datasets = image_api.get_section_data_sets_by_product([27])
#an instance of Image Api for downloading
image_api = ImageDownloadApi()
for index, row in df_nt.iterrows():
#get section dataset id
section_dataset_id= row['id']
#each section dataset id has multiple image sections
section_images = pd.DataFrame(
image_api.section_image_query(
section_data_set_id=section_dataset_id)
)
for section_image_id in section_images['id'].tolist():
file_path = os.path.join('/path/to/save/dir/',
str(section_image_id) + '.jpg' )
Manifest.safe_make_parent_dirs(file_path)
image_api.download_section_image(section_image_id,
file_path=file_path,
downsample=downsample)
此脚本可能会下载所有可用的 ISH 实验。但是,我想知道获取更多元数据的最佳方法是什么,如下所示:
1) ISH 实验的类型,称为 "gene"(例如图像是否经过 MBP 染色、尼氏染色等)。如下图红圈所示。
2) 结构和与图谱图像的对应关系(注释,例如查看某个部分属于大脑的哪个部分)。我认为这可以通过 tree_search
获得,但不确定如何获得。下图中红色圆圈显示的是 Allen 网站上两个不同的网页。
3) 图片的比例,例如下载的图片中一个像素有多大(例如,0.001x0.001 mm)。例如,我需要它来进行 MRI 图像分析。如下图红圈所示。
以上所有信息都可以在网站上以某种方式获得,我的问题是您是否可以帮助我通过 SDK[=49=以编程方式做到这一点].
编辑:
以编程方式下载 "Nissl" 污渍也很好,因为它们不会使用上述循环迭代显示。图片如下。
要访问此信息,您需要制定一个稍微复杂的 API 查询。
from allensdk.api.queries.rma_api import RmaApi
api = RmaApi()
data_set_id = 146586401
data = api.model_query('SectionDataSet',
criteria='[id$eq%d]' % data_set_id,
include='section_images,treatments,probes(gene),specimen(structure)')
print("gene symbol: %s" % data[0]['probes'][0]['gene']['acronym'])
print("treatment name: %s" % data[0]['treatments'][0]['name'])
print("specimen location: %s" % data[0]['specimen']['structure']['name'])
print("section xy resolution: %f um" % data[0]['section_images'][0]['resolution'])
gene symbol: MBP
treatment name: ISH
specimen location: Cingulate Cortex
section xy resolution: 1.008000 um
无需深入研究 API 数据模型,SectionDataSets
的组成部分 SectionImages
、Treatments
、Probes
和来源 [=16] =]. Probes
目标 Genes
,并且 Specimens
可以与 Structure
相关联。查询正在将单个 SectionDataSet
的所有信息下载到嵌套字典中。
我不记得如何找到标本块范围了。如果我找到它,我会更新答案。
我正在使用以下脚本从艾伦大脑图谱的神经递质研究中下载所有图像:
from allensdk.api.queries.image_download_api import ImageDownloadApi
from allensdk.config.manifest import Manifest
import pandas as pd
import os
#getting transmitter study
#product id from http://api.brain-map.org/api/v2/data/query.json?criteria=model::Product
nt_datasets = image_api.get_section_data_sets_by_product([27])
#an instance of Image Api for downloading
image_api = ImageDownloadApi()
for index, row in df_nt.iterrows():
#get section dataset id
section_dataset_id= row['id']
#each section dataset id has multiple image sections
section_images = pd.DataFrame(
image_api.section_image_query(
section_data_set_id=section_dataset_id)
)
for section_image_id in section_images['id'].tolist():
file_path = os.path.join('/path/to/save/dir/',
str(section_image_id) + '.jpg' )
Manifest.safe_make_parent_dirs(file_path)
image_api.download_section_image(section_image_id,
file_path=file_path,
downsample=downsample)
此脚本可能会下载所有可用的 ISH 实验。但是,我想知道获取更多元数据的最佳方法是什么,如下所示:
1) ISH 实验的类型,称为 "gene"(例如图像是否经过 MBP 染色、尼氏染色等)。如下图红圈所示。
2) 结构和与图谱图像的对应关系(注释,例如查看某个部分属于大脑的哪个部分)。我认为这可以通过 tree_search
获得,但不确定如何获得。下图中红色圆圈显示的是 Allen 网站上两个不同的网页。
3) 图片的比例,例如下载的图片中一个像素有多大(例如,0.001x0.001 mm)。例如,我需要它来进行 MRI 图像分析。如下图红圈所示。
以上所有信息都可以在网站上以某种方式获得,我的问题是您是否可以帮助我通过 SDK[=49=以编程方式做到这一点].
编辑:
以编程方式下载 "Nissl" 污渍也很好,因为它们不会使用上述循环迭代显示。图片如下。
要访问此信息,您需要制定一个稍微复杂的 API 查询。
from allensdk.api.queries.rma_api import RmaApi
api = RmaApi()
data_set_id = 146586401
data = api.model_query('SectionDataSet',
criteria='[id$eq%d]' % data_set_id,
include='section_images,treatments,probes(gene),specimen(structure)')
print("gene symbol: %s" % data[0]['probes'][0]['gene']['acronym'])
print("treatment name: %s" % data[0]['treatments'][0]['name'])
print("specimen location: %s" % data[0]['specimen']['structure']['name'])
print("section xy resolution: %f um" % data[0]['section_images'][0]['resolution'])
gene symbol: MBP
treatment name: ISH
specimen location: Cingulate Cortex
section xy resolution: 1.008000 um
无需深入研究 API 数据模型,SectionDataSets
的组成部分 SectionImages
、Treatments
、Probes
和来源 [=16] =]. Probes
目标 Genes
,并且 Specimens
可以与 Structure
相关联。查询正在将单个 SectionDataSet
的所有信息下载到嵌套字典中。
我不记得如何找到标本块范围了。如果我找到它,我会更新答案。