Пример #1
0
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...')
subIDs_grp2 = subIDs[group == 1]
sub_fname_grp2 = sub_fname[group == 1]

subIDs_grp1 = subIDs[group == 0]
sub_fname_grp1 = sub_fname[group == 0]

# %% makes file list for subcjects
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)):
    sub = sub_ID[ind]
    fname = sub_fname[ind]
    subTest_fname.append(fname)
    subTest_IDs.append(sub)

if cf.test_all == 'False':
    numT = len(subTest_IDs)
Пример #3
0
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...')
subTest_fname = []; subTest_IDs = []; subAtlas_fname = []; subAtlas_IDs = []
for ind in range(len(sub_ID)):
    sub = sub_ID[ind]
    fname = sub_fname[ind]
    if cf.stat_test == 'atlas-linear' or cf.stat_test == 'atlas-group':
        if int(subAtlas_idx[ind]) ==1:
            subAtlas_fname.append(fname)  
            subAtlas_IDs.append(sub)