Skip to content

Commit ceb30c7

Browse files
committed
- Update logo image in README.
- Refactor `today()` function. Add import statements for `squarify` and `matplotlib.pyplot` modules. - Refactor `get_genotypes()` function. Add documentation. - Refactor `get_genotype_frequency()` function. Add documentation. - Refactor `get_techniques()` function. Add documentation. - Refactor `techniques_frequency()` function. Add documentation. - Refactor `get_generalmodality()` function. - Refactor `get_contributors()` function. - Refactor `get_list_of_projects()` function. - Refactor `get_number_of_projects()` function. - Create `get_projects_treemap()` function for visualization of project frequency. - Refactor `__get__percentage_of_metadata_version_1()` function.
2 parents a09a85c + da454fd commit ceb30c7

File tree

3 files changed

+64
-28
lines changed

3 files changed

+64
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<img src="images/logo.jpg" width="150%">
1+
<img src="images/banner.jpg" width="150%">
22

33
The Brain Image Library (BIL) is a national public resource enabling researchers to deposit, analyze, mine, share and interact with large brain image datasets. BIL encompasses the deposition of datasets, the integration of datasets into a searchable web-accessible system, the redistribution of datasets, and a computational enclave to allow researchers to process datasets in-place and share restricted and pre-release datasets.
44

braininventory/get.py

Lines changed: 63 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
import pandas as pd
33
import json
44
from datetime import date
5+
import squarify
6+
import matplotlib.pyplot as plt
57

68

79
def today():
810
"""
9-
Get today's snapshot of Brain Image Library.
10-
"""
11+
Get today's snapshot of Brain Image Library.
12+
"""
1113

1214
server = "https://download.brainimagelibrary.org/inventory/daily/reports/"
1315
filename = "today.json"
@@ -55,6 +57,10 @@ def __get_affilation(df):
5557
return df["affiliation"].value_counts().to_dict()
5658

5759

60+
def __get_awards(df):
61+
return df["award_number"].unique()
62+
63+
5864
def __get_award_number(df):
5965
return df["award_number"].value_counts().to_dict()
6066

@@ -67,19 +73,35 @@ def __get_cnbtaxonomy(df):
6773
return df["cnbtaxonomy"].value_counts().to_dict()
6874

6975

70-
def __get_samplelocalid(df):
71-
return df["samplelocalid"].value_counts().to_dict()
76+
def __get_genotypes(df):
77+
"""
78+
Write documentation here.
79+
"""
80+
return df["genotype"].unique()
7281

7382

74-
def __get_genotype(df):
75-
return df["genotype"].value_counts().to_dict()
83+
def __get_genotype_frequency(df):
84+
"""
85+
Write documentation here.
86+
"""
87+
return df["genotypes"].value_counts().to_dict()
7688

7789

7890
def __get_generalmodality(df):
7991
return df["generalmodality"].value_counts().to_dict()
8092

8193

82-
def __get_technique(df):
94+
def __get_techniques(df):
95+
"""
96+
Write documentation here.
97+
"""
98+
return df["technique"].unique().to_dict()
99+
100+
101+
def techniques_frequency(df):
102+
"""
103+
Write documentation here.
104+
"""
83105
return df["technique"].value_counts().to_dict()
84106

85107

@@ -94,43 +116,54 @@ def __get_contributors(df):
94116
return df["contributorname"].unique()
95117

96118

97-
def __get_project_names(df):
98-
'''
99-
Gets the unique list of project names.
100-
101-
Input: dataframe
102-
Output: list
103-
'''
104-
return df['project'].unique()
105-
106119
def __get_list_of_projects(df):
107-
'''
120+
"""
108121
Get the list of names for unique projects
109122
110123
Input parameter: dataframe
111124
Output: list of projects
112-
'''
113-
114-
return df['project'].unique().to_dict()
125+
"""
126+
127+
return df["project"].unique().to_dict()
128+
115129

116130
def __get_number_of_projects(df):
117-
'''
131+
"""
118132
Get the number of unique projects
119133
120134
Input parameter: dataframe
121135
Output: number of projects
122-
'''
123-
124-
return len(df['project'].unique())
136+
"""
137+
138+
return len(df["project"].unique())
139+
140+
141+
def get_projects_treemap(df):
142+
"""
143+
Created a code for the visualization of projects frequency
144+
145+
Input: project values
146+
Output: treemap graph of projects frequency
147+
"""
148+
149+
df = df["project"].value_counts().to_dict()
150+
sizes_list = list(df.values())
151+
names_list = list(df.keys())
152+
squarify.plot(sizes_list)
153+
154+
filename = f'treemap-projects-{datetime.now().strftime("%Y%m%d")}.png'
155+
plt.savefig("path/to/save/plot.png")
156+
125157

126158
def __get__percentage_of_metadata_version_1(df):
127-
'''
159+
"""
128160
Get the percentage/ratio of metadata version 1 from all datasets
129161
130162
Input: dataframe
131163
Output: an integer
132-
'''
133-
return len(df[df['metadata_version'] == 1])/len(df)
164+
"""
165+
return len(df[df["metadata_version"] == 1]) / len(df)
166+
134167

135168
def report():
136169
# Get today's date
@@ -159,4 +192,7 @@ def report():
159192
report["percentage_of_version_1"] = __get__percentage_of_metadata_version_1(df)
160193
report["is_reachable"] = df["URL"].apply(__is_reachable)
161194

195+
# plots
196+
get_projects_treemap(df)
197+
162198
return report
File renamed without changes.

0 commit comments

Comments
 (0)