rongguangw commited on
Commit
d8c11b4
·
verified ·
1 Parent(s): 170d7f0

update descriptions

Browse files
Files changed (1) hide show
  1. app.py +14 -17
app.py CHANGED
@@ -6,19 +6,19 @@ import pandas as pd
6
 
7
 
8
  description = """
9
- # 🧠 Neuro-Synth
10
 
11
  <!-- Provide a quick summary of the dataset. -->
12
 
13
- Neuro-Synth is a synthetic neuroimaging dataset ...
14
 
15
  ## Dataset Details
16
 
17
  The dataset has the following characteristics:
18
 
19
- *
20
- *
21
- *
22
 
23
  ## Dataset Download
24
 
@@ -26,9 +26,9 @@ The dataset has the following characteristics:
26
  * Other browser users can directly click on the "Download" button to save the data
27
  * Download via command line:
28
  ```
29
- wget https://rongguangw-neuro-synth.hf.space/file=dataset/synth_kde_all.csv
30
  ```
31
- * You can also customize the number of samples by generating online in the below panels. The synthesized data will be showing in the lower right panel, and then, you can save the data by clicking on the "Download" button.
32
  """
33
 
34
  citation = """
@@ -45,21 +45,20 @@ citation = """
45
  ```
46
  """
47
 
48
- file_name = "dataset/synth_kde_all.csv"
49
- save_name = "dataset/customized_neuro_synth.csv"
50
  example_df = pd.read_csv(file_name)
51
 
52
 
53
- def infer(sex, race, num_sample):
54
- #print(sex, race, num_sample)
55
  num_sample = int(num_sample)
56
  col_dict = np.load("model/col_dict.npz", allow_pickle=True)['dict'].item()
57
- input = np.load("model/kde_{}_{}.npz".format(race.lower(), sex.lower()), allow_pickle=True)['model'].item() # "model/kde_white_female.npz"
58
  kde, scaler, cols_names = input['model'], input['scaler'], input['columns']
59
 
60
  sample = kde.sample(num_sample, random_state=0)
61
  sample = scaler.inverse_transform(sample)
62
- cov_list = np.array([[f'Synth_{i+1}', sex[0], race] for i in range(num_sample)]) # 'F', 'White'
63
  new_data = np.concatenate([cov_list, sample], axis=1)
64
  cols=['PTID','Sex','Race','Age']
65
  cols.extend([col_dict[i] for i in fnmatch.filter(cols_names,'H_*')])
@@ -96,13 +95,11 @@ with gr.Blocks() as demo:
96
  interactive=True,
97
  ),
98
  gr.Textbox(
99
- label='Generate samples',
100
  show_label=True,
101
- placeholder='Enter sample number (in integer)...'
102
  )],
103
- #title='Customized data generation',
104
  outputs=["dataframe", "button"],
105
- #description='',
106
  cache_examples=False
107
  )
108
 
 
6
 
7
 
8
  description = """
9
+ # 🧠 NeuroSynth
10
 
11
  <!-- Provide a quick summary of the dataset. -->
12
 
13
+ NeuroSynth is a dataset which consists of 18,000 synthetic neuroimaging data samples covering worldwide healthy population across human lifespan.
14
 
15
  ## Dataset Details
16
 
17
  The dataset has the following characteristics:
18
 
19
+ * Generative models were trained on 40,000 subjects from the iSTAGING consortium to synthesize 145 brain anatomical region-of-interest (ROI) volumes which are derived from structural T1-weighted magnetic resonance imaging (MRI).
20
+ * The dataset includes participants’ demographic information, such as sex, age and race, which are beneficial for research focusing on mitigating algorithmic bias and promoting fairnes.
21
+ * Besides 18,000 samples in the dataset, we also share the pre-trained generative models for users to customize their needs for data synthesis.
22
 
23
  ## Dataset Download
24
 
 
26
  * Other browser users can directly click on the "Download" button to save the data
27
  * Download via command line:
28
  ```
29
+ wget https://rongguangw-neuro-synth.hf.space/file=dataset/neurosynth_dataset.csv
30
  ```
31
+ * You can also customize sex and race for the subjects and sample size by generating online in the below panels. The synthesized data will be showing in the lower right panel, and then, you can save the data by clicking on the "Download" button.
32
  """
33
 
34
  citation = """
 
45
  ```
46
  """
47
 
48
+ file_name = "dataset/neurosynth_dataset.csv"
49
+ save_name = "dataset/customized_neurosynth.csv"
50
  example_df = pd.read_csv(file_name)
51
 
52
 
53
+ def infer(sex, race, num_sample=10):
 
54
  num_sample = int(num_sample)
55
  col_dict = np.load("model/col_dict.npz", allow_pickle=True)['dict'].item()
56
+ input = np.load("model/kde_{}_{}.npz".format(race.lower(), sex.lower()), allow_pickle=True)['model'].item()
57
  kde, scaler, cols_names = input['model'], input['scaler'], input['columns']
58
 
59
  sample = kde.sample(num_sample, random_state=0)
60
  sample = scaler.inverse_transform(sample)
61
+ cov_list = np.array([[f'Synth_{i+1}', sex[0], race] for i in range(num_sample)])
62
  new_data = np.concatenate([cov_list, sample], axis=1)
63
  cols=['PTID','Sex','Race','Age']
64
  cols.extend([col_dict[i] for i in fnmatch.filter(cols_names,'H_*')])
 
95
  interactive=True,
96
  ),
97
  gr.Textbox(
98
+ label='Number of subject',
99
  show_label=True,
100
+ placeholder='Enter sample size (in integer) ...'
101
  )],
 
102
  outputs=["dataframe", "button"],
 
103
  cache_examples=False
104
  )
105