Beispiel #1
0
from tqdm import tqdm
bfp_path = '/home/sychoi/Documents/MATLAB/bfp/'
sys.path.append(os.path.join(str(bfp_path), 'src/BrainSync/'))
from brainsync import IDrefsub_BrainSync, groupBrainSync, brainSync
sys.path.append(os.path.join(bfp_path, 'src/stats/'))
from read_data_utils import load_bfp_data, write_text_timestamp
#%%
dirname = "/NCAdisk/SCD_structural_analysis/BOLD_study/SCD_BOLDdata/"
out_dir = '/NCAdisk/SCD_structural_analysis/BOLD_study/BOLD_Analysis/032519/rest/'
ext = '_rest_bold.32k.GOrd.filt.mat'
LenTime = 240
#%% checks and loads data
if not os.path.isdir(out_dir):
    os.makedirs(out_dir)
flog = os.path.join(out_dir, 'bfp_stat_log.txt')
write_text_timestamp(flog, 'starting group-MDS_atlas')

os.chdir(bfp_path)
subj = os.listdir(dirname)
sub_fname = []
sub_ID = []
n = 0

pbar = tqdm(total=len(subj))
for i in range(len(subj)):
    print(str(n))
    n = n + 1
    fname = os.path.join(dirname, subj[i], 'func', subj[i] + ext)
    if os.path.isfile(fname):
        df = spio.loadmat(fname)
        data = df['dtseries'].T
### Import BrainSync libraries
config = configparser.ConfigParser()
config.read(config_file)
section = config.sections()
bfp_path = config.get('inputs', 'bfp_path')
sys.path.append(os.path.join(bfp_path, 'src/stats/'))
sys.path.append(os.path.join(str(bfp_path), 'src/BrainSync/'))
from read_data_utils import load_bfp_data, read_demoCSV, write_text_timestamp, readConfig
os.chdir(bfp_path)
cf = readConfig(config_file)
from stats_utils import randpairs_regression, multiLinReg_resid, LinReg_resid, multiLinReg_corr
from grayord_utils import vis_grayord_sigcorr, vis_grayord_sigpval
#%%
log_fname = os.path.join(cf.out_dir, 'bfp_linregr_stat_log.txt')
write_text_timestamp(log_fname, 'Config file used: ' + config_file)
if not os.path.isdir(cf.out_dir):
    os.makedirs(cf.out_dir)
write_text_timestamp(log_fname,
                     "All outputs will be written in: " + cf.out_dir)
# read demographic csv file
sub_ID, sub_fname, _, reg_var, reg_cvar1, reg_cvar2 = read_demoCSV(
    cf.csv_fname, cf.data_dir, cf.file_ext, cf.colsubj, cf.colvar_exclude,
    cf.colvar_atlas, cf.colvar_main, cf.colvar_reg1, cf.colvar_reg2)
#%% makes file list for subjects
print(
    'Identifying subjects for hypothesis testing, no atlas needs to be created...'
)
subTest_fname = []
subTest_IDs = []
for ind in range(len(sub_ID)):
Beispiel #3
0
bfp_path = config.get('inputs', 'bfp_path')
sys.path.append(os.path.join(bfp_path, 'src/stats/'))

from read_data_utils import load_bfp_data, read_demoCSV, write_text_timestamp, readConfig, read_demoCSV_list
from stats_utils import randpair_groupdiff, randpair_groupdiff_ftest
from grayord_utils import vis_grayord_sigcorr


os.chdir(bfp_path)
cf = readConfig(config_file)

# Import BrainSync libraries

# %%
log_fname = os.path.join(cf.out_dir, 'bfp_group_stat_log.txt')
write_text_timestamp(log_fname, 'Config file used: ' + config_file)
if not os.path.isdir(cf.out_dir):
    os.makedirs(cf.out_dir)
write_text_timestamp(log_fname,
                     "All outputs will be written in: " + cf.out_dir)
# read demographic csv file
subIDs, sub_fname, group, reg_var, reg_cvar1, reg_cvar2 = read_demoCSV(
    cf.csv_fname, cf.data_dir, cf.file_ext, cf.colsubj, cf.colvar_exclude,
    cf.colvar_group, cf.colvar_main, cf.colvar_reg1, cf.colvar_reg2)

group = np.int16(group)
# for boolan indexing, need to convert to numpy array
subIDs = np.array(subIDs)
sub_fname = np.array(sub_fname)

print('Identifying subjects for each group...')
Beispiel #4
0
section = config.sections()
bfp_path = config.get('inputs','bfp_path')
sys.path.append(os.path.join(bfp_path, 'src/stats/') )
from read_data_utils import load_bfp_data, read_demoCSV, write_text_timestamp, readConfig, read_demoCSV_list
os.chdir(bfp_path)
cf = readConfig(config_file)

### Import BrainSync libraries
sys.path.append(os.path.join(str(bfp_path), 'src/BrainSync/')) 
from brainsync import IDrefsub_BrainSync, groupBrainSync, generate_avgAtlas
from stats_utils import dist2atlas, sync2atlas, multiLinReg_corr
from grayord_utils import vis_grayord_sigcorr

#%% 
log_fname = os.path.join(cf.out_dir, 'bfp_group_stat_log.txt')
write_text_timestamp(log_fname, 'Config file used: ' + config_file)
if not os.path.isdir(cf.out_dir):
    os.makedirs(cf.out_dir)
write_text_timestamp(log_fname, "All outputs will be written in: " + cf.out_dir )
# read demographic csv file
sub_ID, sub_fname, subAtlas_idx, reg_var, reg_cvar1, reg_cvar2 = read_demoCSV(cf.csv_fname,
                cf.data_dir,
                cf.file_ext,
                cf.colsubj,
                cf.colvar_exclude,
                cf.colvar_group,
                cf.colvar_main,
                cf.colvar_reg1,
                cf.colvar_reg2)
#%%
data = read_demoCSV_list(cf.csv_fname)
Beispiel #5
0
section = config.sections()
bfp_path = config.get('inputs','bfp_path')
sys.path.append(os.path.join(bfp_path, 'src/stats/') )
sys.path.append(os.path.join(str(bfp_path), 'src/BrainSync/')) 
from read_data_utils import load_bfp_dataT, read_demoCSV, write_text_timestamp,readConfig
os.chdir(bfp_path)
cf = readConfig(config_file)
from brainsync import IDrefsub_BrainSync, groupBrainSync, generate_avgAtlas
from stats_utils import dist2atlas, sync2atlas, multiLinReg_corr
from stats_utils import randpairs_regression, multiLinReg_resid, LinReg_resid, multiLinReg_corr
from grayord_utils import vis_grayord_sigcorr, vis_grayord_sigpval
#%% 
if not os.path.isdir(cf.out_dir):
    os.makedirs(cf.out_dir)
log_fname = os.path.join(cf.out_dir, 'bfp_linregr_stat_log.txt')
write_text_timestamp(log_fname, 'Config file used: ' + config_file)
write_text_timestamp(log_fname, "All outputs will be written in: " + cf.out_dir )
# read demographic csv file
sub_ID, sub_fname, subAtlas_idx, reg_var, reg_cvar1, reg_cvar2 = read_demoCSV(cf.csv_fname,
                cf.data_dir,
                cf.file_ext,
                cf.colsubj,
                cf.colvar_exclude,
                cf.colvar_atlas,
                cf.colvar_main,
                cf.colvar_reg1,
                cf.colvar_reg2,
                cf.matcht,
                cf.lentime)
#%% makes file list for subjects
print('Identifying subjects for atlas creation and hypothesis testing...')
Beispiel #6
0
section = config.sections()
bfp_path = config.get('inputs','bfp_path')
sys.path.append(os.path.join(bfp_path, 'src/stats/') )
sys.path.append(os.path.join(str(bfp_path), 'src/BrainSync/')) 
from read_data_utils import load_bfp_dataT, read_demoCSV, write_text_timestamp,readConfig,load_bfp_dataT_dist2atlas
os.chdir(bfp_path)
cf = readConfig(config_file)
from brainsync import IDrefsub_BrainSync, groupBrainSync, generate_avgAtlas
from stats_utils import dist2atlas, sync2atlas, multiLinReg_corr
from stats_utils import randpairs_regression, multiLinReg_resid, LinReg_resid, multiLinReg_corr
from grayord_utils import vis_grayord_sigcorr, vis_grayord_sigpval
#%% 
if not os.path.isdir(cf.out_dir):
    os.makedirs(cf.out_dir)
log_fname = os.path.join(cf.out_dir, 'bfp_stat.log')
write_text_timestamp(log_fname, 'Config file used: ' + config_file +"\n All outputs will be written in: " + cf.out_dir )
# read demographic csv file
sub_ID, sub_fname, subAtlas_idx, reg_var, reg_cvar1, reg_cvar2 = read_demoCSV(cf.csv_fname,
                cf.data_dir,
                cf.file_ext,
                cf.colsubj,
                cf.colvar_exclude,
                cf.colvar_atlas,
                cf.colvar_main,
                cf.colvar_reg1,
                cf.colvar_reg2,
                cf.matcht,
                cf.lentime)
#%% makes file list for subjects
print('Identifying subjects for atlas creation and hypothesis testing...')
subTest_fname = []; subTest_IDs = []; subAtlas_fname = []; subAtlas_IDs = []