def test_queries(): doi = "10.1016/j.neurobiolaging.2012.11.002" # A DOI is associated with a collection. Download it. collection = collections_from_dois(doi) assert_equal(collection.shape[0],1) collections = collections_from_dois([doi,doi]) assert_equal(collections.shape[0],2)
def test_queries(): doi = "10.1016/j.neurobiolaging.2012.11.002" # A DOI is associated with a collection. Download it. collection = collections_from_dois(doi) assert_equal(collection.shape[0], 1) collections = collections_from_dois([doi, doi]) assert_equal(collections.shape[0], 2)
def test_NeuroVault_metadata(): from pyneurovault import api # Test for all images print "Checking metadata extraction for images..." images = api.get_images() check_df(df=images,size_min=7000,columns=["url","name","map_type"]) # Test for subset of images images = api.get_images(pks=images.image_id[0:10].tolist()) check_df(df=images,size_min=10,columns=["url","name","map_type"]) # Test for collections print "Checking metadata extraction for collections..." collections = api.get_collections() check_df(df=collections,size_min=300,columns=["used_smoothing","url","collection_id"]) # Test metadata from specific DOIs dois = collections.DOI[collections.DOI.isnull()==False].tolist()[0:15] results = api.collections_from_dois(dois) check_df(df=results,size_min=len(dois),columns=["used_smoothing","url","collection_id"]) # Test get_images_and_collections combined_df = api.get_images_with_collections(collection_pks=[877,437]) check_df(df=combined_df,size_min=50,columns=["url_image","collection_id","name_image","map_type","image_id"]) # Test metadata for subset of collections collections = api.get_collections(pks=[877,437]) check_df(df=collections,size_min=1,columns=["used_smoothing","url","collection_id"]) # Test metadata of images from specific collections images = api.get_images(collection_pks=[877,437]) check_df(df=images,size_min=50,columns=["url","name","map_type"])
#!/usr/bin/env python2 # This script will use the pyneurovault module to perform single REST queries from NeuroVault. from pyneurovault.api import collections_from_dois, images_from_collections, get_images_with_collections from pyneurovault import pubmed as pm # 1) SINGLE REST QUERY EXAMPLE # Here is a doi that we are interested in doi = "10.1016/j.neurobiolaging.2012.11.002" # A DOI is associated with a collection. Download it. collection = collections_from_dois(doi) # Here is the identifier # collection[0]["id"] # 77 # Get the images images = images_from_collections(collection[0]["id"])[0] # Here are the file URLs for the images, as well as contrasts # and cognitive atlas contrasts IDs. (we can use this later to tag to CA) for image in images: print "<file:%s><contrast:%s><ca-contrast:%s>" % ( image["file"], image["contrast_definition"], image["contrast_definition_cogatlas"]) # We now want to use the doi to look up the pmid pubmed = pm.Pubmed(email="*****@*****.**") article = pubmed.get_single_article(doi)
#!/usr/bin/env python2 # This script will use the pyneurovault module to perform single REST queries from NeuroVault. This strategy is intended for smaller/single queries that use the REST api. For larger analysis to download all of NeuroVault meta at once, see download_example.py. from pyneurovault import api, pubmed as pm # 1) SINGLE REST QUERY EXAMPLE # Here is a doi that we are interested in doi = "10.1016/j.neurobiolaging.2012.11.002" # A DOI is associated with a collection. Download it. collection = api.collections_from_dois(doi) # Get the images images = api.images_from_collections(collection) # Here are the file URLs for the images, as well as contrasts # and cognitive atlas contrasts IDs. (we can use this later to tag to CA) for image in images: print "<file:%s><contrast:%s><ca-contrast:%s>" %(image["file"],image["contrast_definition"],image["contrast_definition_cogatlas"]) # We now want to use the doi to look up the pmid pubmed = pm.Pubmed(email="*****@*****.**") article = pubmed.get_single_article(doi) pmid = article.get_pmid() # 2) SEARCH FIELD ACROSS ALL COLLECTIONS OR DATA nv = api.NeuroVault() df = nv.get_images_with_collections_df() result = nv.search(df=df,column_name="description_collection",search_string="OpenfMRI")
#!/usr/bin/env python2 # This script will use the pyneurovault module to perform single REST queries from NeuroVault. from pyneurovault.api import collections_from_dois, images_from_collections, get_images_with_collections from pyneurovault import pubmed as pm # 1) SINGLE REST QUERY EXAMPLE # Here is a doi that we are interested in doi = "10.1016/j.neurobiolaging.2012.11.002" # A DOI is associated with a collection. Download it. collection = collections_from_dois(doi) # Here is the identifier # collection[0]["id"] # 77 # Get the images images = images_from_collections(collection[0]["id"])[0] # Here are the file URLs for the images, as well as contrasts # and cognitive atlas contrasts IDs. (we can use this later to tag to CA) for image in images: print "<file:%s><contrast:%s><ca-contrast:%s>" %(image["file"],image["contrast_definition"],image["contrast_definition_cogatlas"]) # We now want to use the doi to look up the pmid pubmed = pm.Pubmed(email="*****@*****.**") article = pubmed.get_single_article(doi) pmid = article.get_pmid()