Skip to content

Commit dfc1c94

Browse files
committed
Add data_access script
1 parent 53a4cb4 commit dfc1c94

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

data_access.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# ### Accessing NeuroVault Archived Data
2+
3+
# First, tar unzip the desired archive file:
4+
5+
# +
6+
# #!tar -xvf november_2022.tar.gz
7+
# -
8+
9+
# Next, we will load the files into pandas DataFrames:
10+
11+
import pandas as pd
12+
13+
# Load collections:
14+
15+
collections = pd.read_csv('november_2022/statmaps_statisticmap.csv')
16+
17+
collections.head()
18+
19+
# Now, we load the statistical images, which require merging several tables.
20+
#
21+
# In order to merge `StatisticMap` to `Image`, we need the table `BaseStatisticMap`
22+
23+
image = pd.read_csv('november_2022/statmaps_image.csv')
24+
basecollectionitem = pd.read_csv('november_2022/statmaps_basecollectionitem.csv')
25+
statisticmap = pd.read_csv('november_2022/statmaps_statisticmap.csv')
26+
27+
# `image` table is first merged to `basecollectionitem` using `basecollectionitem_ptr_id`:
28+
29+
image_merged = pd.merge(image, basecollectionitem, left_on='basecollectionitem_ptr_id', right_on='id')
30+
31+
# Next, the `statisticmap` table can be merged to `image` using `image_ptr_id', which corresponds to 'basecollectionitem_ptr_id'
32+
33+
statisticmap_merged = pd.merge(statisticmap, image_merged, left_on='image_ptr_id', right_on='basecollectionitem_ptr_id')
34+
35+
statisticmap_merged.head()

0 commit comments

Comments
 (0)