Skip to content

Commit 60c0375

Browse files
author
Ivan Cao-Berg
committed
Refactor square function. Use math.pow instead of multiplication.
1 parent 4c81654 commit 60c0375

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

braininventory/get.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,20 @@ def __create_general_modality_plot(df):
4141

4242
def get_random_sample(df):
4343
"""
44-
Returns a random sample from the dataframe from a dataset with non-zero score.
44+
Retrieve a random JSON file from the DataFrame.
4545
46-
Input: dataframe
47-
Output:open the json file that was located in datasets Brain Image Library dataframe
46+
This function takes a pandas DataFrame as input and filters it to keep only the rows that have
47+
a non-zero 'score' value. From the filtered rows, it selects a random row using the 'random.randint()'
48+
function. It then generates a valid link to the JSON file by replacing '/bil/data' with
49+
'https://download.brainimagelibrary.org' in the 'json_file' column of the selected row. The function
50+
performs an HTTP GET request to download the JSON file from the generated link, and it returns the
51+
JSON data as a Python dictionary.
52+
53+
Parameters:
54+
df (pandas.DataFrame): The input DataFrame containing the 'score' and 'json_file' columns.
55+
56+
Returns:
57+
dict: A Python dictionary containing the JSON data retrieved from a random row's JSON file.
4858
"""
4959

5060
isNotZero = df[df["score"] != 0.0] # only have files with the correct data

0 commit comments

Comments
 (0)