-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathoutliers.py
executable file
·51 lines (35 loc) · 1.35 KB
/
outliers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Import functions #
import argparse,datetime,os,sys,time
import pandas as pd
from tools import load_groupfile, query_api, filterIQM, merge_dfs, make_vio_plot
# Arguments #
# laziness helper
here = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
# path to input of local data from MRIQC on your own dataset
group_file = os.path.join(here,'test_data', 'group2_bold.tsv')
# scan type to query the API for [bold, T1w, T2w]
modality = 'bold'
# any scan parameters that you want to filter the API search results by
"""Current possible filters:
SNR, TSNR, DVAR, FD,
FWHM, Tesla, gsr_x, gsr_y, TE, TR
NOTE: Only working as *and* right now!
"""
filter_list = ['TR > 2.0','FD < .3']
# IQM variables to visualize
IQM_to_plot = ['fwhm_avg','fber']
userdf = load_groupfile(group_file)
T1apicsv = os.path.join(here, 'demo_api', 'T1w_demo.csv')
T2apicsv = os.path.join(here, 'demo_api', 'T2w_demo.csv')
boldapicsv = os.path.join(here, 'demo_api', 'bold_demo.csv')
if modality == 'T1w':
api_file = T1apicsv
elif modality == 'T2w':
api_file = T1apicsv
elif modality == 'bold':
api_file = boldapicsv
# This will return a pandas dataframe with data from all scans of the given scan type
# with the given parameters
apidf = pd.read_csv(api_file)
filtered_apidf = filterIQM(apidf,filter_list)
vis_ready_df = merge_dfs(userdf.copy(), filtered_apidf.copy())