Skip to content

Commit 64ca732

Browse files
authored
Add __get_json_file() and create variable "link"
I created the link variable as we are now using the BIL website in multiple locations. The __get_json_file() will access a dataset's json_file.
1 parent 34b1a23 commit 64ca732

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

braininventory/get.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
import json
44
from datetime import date
55

6+
link = "https://download.brainimagelibrary.org"
7+
68
def today():
79
"""
810
Get today's snapshot of Brain Image Library.
911
"""
1012

11-
server = "https://download.brainimagelibrary.org/inventory/daily/reports/"
13+
server = f"{link}/inventory/daily/reports/"
1214
filename = "today.json"
1315

1416
response = requests.get(f"{server}{filename}")
@@ -71,6 +73,20 @@ def __get_technique(df):
7173
def __get_locations(df):
7274
return df['locations'].value_counts().to_dict()
7375

76+
def __get_json_file(df):
77+
"""
78+
Retrieve the json_file from the Brain Image Library of a dataset.
79+
"""
80+
81+
# Make sure there is data to request
82+
assert df['score'].values[0] != 0
83+
84+
# Create working link
85+
url = sample['json_file'].values[0].replace('/bil/data', link)
86+
response = requests.get(url)
87+
88+
return response.json()
89+
7490
def report():
7591
# Get today's date
7692
tdate = date.today()

0 commit comments

Comments
 (0)