File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -41,10 +41,20 @@ def __create_general_modality_plot(df):
4141
4242def 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
You can’t perform that action at this time.
0 commit comments