def collapse_data(data_dir, incl_excl_list, n_b0s_list, sep_av_list, transform_list, roi_list): """ collapse_data reads in files from a series of results_files and collapses across all of them so they can be plotted together Inputs: data_dir incl_excl_list n_b0s_list sep_av_list transform_list roi_list Output: data array """ #========================================================================== import os import numpy as np import numpy.lib.recfunctions as rfn from glob import glob import itertools as it #------------------------------------------------------------------------------ from combine_data import combine_data from get_b0_orders import get_b0_orders #========================================================================== print ' Collapsing data: B0 orders by ec volume' # Find all the results files in all the b0_order folders for incl_excl, n_b0s, sep_av, transform, roi_name in it.product(incl_excl_list, n_b0s_list, sep_av_list, transform_list, roi_list): # Start off with an empty data array data_allorders = None b0_orders = get_b0_orders(np.int(n_b0s)) for b0_order in b0_orders: glob_string = os.path.join(data_dir, 'RESULTS', incl_excl, 'B0S_{}'.format(n_b0s), 'B0_ORDER_{}'.format(b0_order), sep_av, transform, '{}_FA_MD_vol.txt'.format(roi_name)) files = glob(glob_string) dict = {'b0_order': b0_order} # Read in every file and combine them for file in files: data = np.genfromtxt(file, dtype=None, delimiter=' ', names=True) data_allorders = combine_data(data_allorders, data, dict) # Name the results dir that this is going into: results_allorders_dir = os.path.join(data_dir, 'RESULTS', incl_excl, 'B0S_{}'.format(n_b0s), 'ALL_ORDERS', sep_av, transform) return data_allorders, results_allorders_dir
def Q_ec_vol_n6(data_dir, incl_excl_list, sep_av_list, transform_list, roi_list, colors, shapes): """ Q_ec_vol_n6 asks the question: "How does the volume that you register to affect the measurement when you use all the data" It reads in all the necessary files from a series of results_files and collapses across all of them so they can be plotted together Inputs: data_dir incl_excl_list sep_av_list transform_list roi_list Output: data array """ #========================================================================== import os import numpy as np import numpy.lib.recfunctions as rfn from glob import glob import itertools as it #--------------------------------------------------------------------------- from combine_data import combine_data from get_b0_orders import get_b0_orders from plot_data import plot_data from read_in_data import read_in_data #========================================================================== print ' Question: How does the choice of eddy correct volume affect the measurements?' # Find all the results files in all the b0_order folders for incl_excl, sep_av, transform, roi_name in it.product(incl_excl_list, sep_av_list, transform_list, roi_list): # Start off with an empty data array data_allorders = None b0_orders = get_b0_orders(np.int(6)) for b0_order in b0_orders: glob_string = os.path.join(data_dir, 'RESULTS', incl_excl, 'B0S_6', 'B0_ORDER_{}'.format(b0_order), sep_av, transform, '{}_FA_MD_vol.txt'.format(roi_name)) files = glob(glob_string) dict = {'b0_order': b0_order} # Read in every file and combine them for file in files: data = read_in_data(file) data_allorders = combine_data(data_allorders, data, dict) # Name the results dir that this is going into: results_allorders_dir = os.path.join(data_dir, 'RESULTS', incl_excl, 'B0S_6', 'ALL_ORDERS', sep_av, transform) # Now plot the data plot_data(data_allorders, results_allorders_dir, roi_name, colors, shapes)
scans = [ 'DTI_2A', 'DTI_2B' ] incl_excl_list = [ 'EXCL_VOL31' ] n_b0s_list = [ '6' ] ec_b0_list = [ '00', '14', '27', '41', '54', '68' ] #b0_order = [ '00_14_27_41_54_68' ] sep_av_list = [ 'SEPARATE' ] transform_list = [ 'MNI_DIFF_FA_DIRECT', 'MNI_DIFF_VIA_HIGHRES_LIN', 'MNI_DIFF_VIA_HIGHRES_NL_BBR' ] roi_list = [ 'lcing', 'rcing', 'wholebrain', 'bodycc' ] data_allorders = None colors, shapes = set_colors_shapes() #============================================================================== #============================================================================== # And now get going: b0_orders = get_b0_orders(1) for incl_excl, sep_av, b0_order in it.product(incl_excl_list, sep_av_list, b0_orders): ''' Loop through the combinations of include/exclude volume 31, whether the b0s were combined first or not, and the ways of ordering just 1 b0 (6) ''' run_registrations(data_dir, incl_excl, 1, b0_order, sep_av, subs, locs, scans) for incl_excl, sep_av, n_b0s in it.product(incl_excl_list, sep_av_list, n_b0s_list): ''' Loop through the combinations of include/exclude volume 31, whether the b0s were combined first or not, and the number of b0s that were included '''
ec_b0_list = ['00', '14', '27', '41', '54', '68'] #b0_order = [ '00_14_27_41_54_68' ] sep_av_list = ['SEPARATE'] transform_list = [ 'MNI_DIFF_FA_DIRECT', 'MNI_DIFF_VIA_HIGHRES_LIN', 'MNI_DIFF_VIA_HIGHRES_NL_BBR' ] roi_list = ['lcing', 'rcing', 'wholebrain', 'bodycc'] data_allorders = None colors, shapes = set_colors_shapes() #============================================================================== #============================================================================== # And now get going: b0_orders = get_b0_orders(1) for incl_excl, sep_av, b0_order in it.product(incl_excl_list, sep_av_list, b0_orders): ''' Loop through the combinations of include/exclude volume 31, whether the b0s were combined first or not, and the ways of ordering just 1 b0 (6) ''' run_registrations(data_dir, incl_excl, 1, b0_order, sep_av, subs, locs, scans) for incl_excl, sep_av, n_b0s in it.product(incl_excl_list, sep_av_list, n_b0s_list): ''' Loop through the combinations of include/exclude volume 31,
def Q_n_b0s(data_dir, incl_excl_list, sep_av_list, transform_list, roi_list, ec_b0_list, colors, shapes): """ Q_ec_vol_n6 asks the question: "How does the number of B0s you include change your measurement?" It reads in all the necessary files from a series of results_files and collapses across all of them so they can be plotted together Inputs: data_dir incl_excl_list sep_av_list transform_list roi_list Output: data array """ #========================================================================== import os import numpy as np import numpy.lib.recfunctions as rfn from glob import glob import itertools as it #--------------------------------------------------------------------------- from combine_data import combine_data from get_b0_orders import get_b0_orders from plot_data import plot_data from read_in_data import read_in_data #========================================================================== print ' Question: How does the number of B0s change your measurement' # Find all the results files in all the b0_order folders for incl_excl, sep_av, transform, roi_name, ec_b0 in it.product( incl_excl_list, sep_av_list, transform_list, roi_list, ec_b0_list): # Start off with an empty data array data_allorders_allb0s = None for n_b0s in range(1, 7): b0_orders = get_b0_orders(np.int(n_b0s)) b0_orders = [order for order in b0_orders if order[:2] == ec_b0] for b0_order in b0_orders: glob_string = os.path.join(data_dir, 'RESULTS', incl_excl, 'B0S_{}'.format(n_b0s), 'B0_ORDER_{}'.format(b0_order), sep_av, transform, '{}_FA_MD_vol.txt'.format(roi_name)) files = glob(glob_string) dict = {'b0_order': b0_order, 'n_b0s': n_b0s} # Read in every file and combine them for file in files: data = read_in_data(file) data_allorders_allb0s = combine_data( data_allorders_allb0s, data, dict) # Name the results dir that this is going into: results_allorders_allb0s_dir = os.path.join(data_dir, 'RESULTS', incl_excl, 'ALL_B0S', 'B0_{}'.format(ec_b0), sep_av, transform) # Now plot the data plot_data(data_allorders_allb0s, results_allorders_allb0s_dir, roi_name, colors, shapes) # Now do the same thing, but with REALLY all the B0s # Find all the results files in all the b0_order folders for incl_excl, sep_av, transform, roi_name in it.product( incl_excl_list, sep_av_list, transform_list, roi_list): # Start off with an empty data array data_allorders_allb0s = None for n_b0s in range(1, 7): b0_orders = get_b0_orders(np.int(n_b0s)) for b0_order in b0_orders: glob_string = os.path.join(data_dir, 'RESULTS', incl_excl, 'B0S_{}'.format(n_b0s), 'B0_ORDER_{}'.format(b0_order), sep_av, transform, '{}_FA_MD_vol.txt'.format(roi_name)) files = glob(glob_string) dict = {'b0_order': b0_order, 'n_b0s': n_b0s} # Read in every file and combine them for file in files: data = read_in_data(file) data_allorders_allb0s = combine_data( data_allorders_allb0s, data, dict) # Name the results dir that this is going into: results_allorders_allb0s_dir = os.path.join(data_dir, 'RESULTS', incl_excl, 'ALL_B0S', 'ALL_B0S', sep_av, transform) # Now plot the data plot_data(data_allorders_allb0s, results_allorders_allb0s_dir, roi_name, colors, shapes)
def collapse_data(data_dir, incl_excl_list, n_b0s_list, sep_av_list, transform_list, roi_list): """ collapse_data reads in files from a series of results_files and collapses across all of them so they can be plotted together Inputs: data_dir incl_excl_list n_b0s_list sep_av_list transform_list roi_list Output: data array """ #========================================================================== import os import numpy as np import numpy.lib.recfunctions as rfn from glob import glob import itertools as it #------------------------------------------------------------------------------ from combine_data import combine_data from get_b0_orders import get_b0_orders #========================================================================== print ' Collapsing data: B0 orders by ec volume' # Find all the results files in all the b0_order folders for incl_excl, n_b0s, sep_av, transform, roi_name in it.product( incl_excl_list, n_b0s_list, sep_av_list, transform_list, roi_list): # Start off with an empty data array data_allorders = None b0_orders = get_b0_orders(np.int(n_b0s)) for b0_order in b0_orders: glob_string = os.path.join(data_dir, 'RESULTS', incl_excl, 'B0S_{}'.format(n_b0s), 'B0_ORDER_{}'.format(b0_order), sep_av, transform, '{}_FA_MD_vol.txt'.format(roi_name)) files = glob(glob_string) dict = {'b0_order': b0_order} # Read in every file and combine them for file in files: data = np.genfromtxt(file, dtype=None, delimiter=' ', names=True) data_allorders = combine_data(data_allorders, data, dict) # Name the results dir that this is going into: results_allorders_dir = os.path.join(data_dir, 'RESULTS', incl_excl, 'B0S_{}'.format(n_b0s), 'ALL_ORDERS', sep_av, transform) return data_allorders, results_allorders_dir
def Q_ec_vol_n6(data_dir, incl_excl_list, sep_av_list, transform_list, roi_list, colors, shapes): """ Q_ec_vol_n6 asks the question: "How does the volume that you register to affect the measurement when you use all the data" It reads in all the necessary files from a series of results_files and collapses across all of them so they can be plotted together Inputs: data_dir incl_excl_list sep_av_list transform_list roi_list Output: data array """ #========================================================================== import os import numpy as np import numpy.lib.recfunctions as rfn from glob import glob import itertools as it #--------------------------------------------------------------------------- from combine_data import combine_data from get_b0_orders import get_b0_orders from plot_data import plot_data from read_in_data import read_in_data #========================================================================== print ' Question: How does the choice of eddy correct volume affect the measurements?' # Find all the results files in all the b0_order folders for incl_excl, sep_av, transform, roi_name in it.product( incl_excl_list, sep_av_list, transform_list, roi_list): # Start off with an empty data array data_allorders = None b0_orders = get_b0_orders(np.int(6)) for b0_order in b0_orders: glob_string = os.path.join(data_dir, 'RESULTS', incl_excl, 'B0S_6', 'B0_ORDER_{}'.format(b0_order), sep_av, transform, '{}_FA_MD_vol.txt'.format(roi_name)) files = glob(glob_string) dict = {'b0_order': b0_order} # Read in every file and combine them for file in files: data = read_in_data(file) data_allorders = combine_data(data_allorders, data, dict) # Name the results dir that this is going into: results_allorders_dir = os.path.join(data_dir, 'RESULTS', incl_excl, 'B0S_6', 'ALL_ORDERS', sep_av, transform) # Now plot the data plot_data(data_allorders, results_allorders_dir, roi_name, colors, shapes)
def Q_n_b0s(data_dir, incl_excl_list, sep_av_list, transform_list, roi_list, ec_b0_list, colors, shapes): """ Q_ec_vol_n6 asks the question: "How does the number of B0s you include change your measurement?" It reads in all the necessary files from a series of results_files and collapses across all of them so they can be plotted together Inputs: data_dir incl_excl_list sep_av_list transform_list roi_list Output: data array """ #========================================================================== import os import numpy as np import numpy.lib.recfunctions as rfn from glob import glob import itertools as it #--------------------------------------------------------------------------- from combine_data import combine_data from get_b0_orders import get_b0_orders from plot_data import plot_data from read_in_data import read_in_data #========================================================================== print ' Question: How does the number of B0s change your measurement' # Find all the results files in all the b0_order folders for incl_excl, sep_av, transform, roi_name, ec_b0 in it.product(incl_excl_list, sep_av_list, transform_list, roi_list, ec_b0_list): # Start off with an empty data array data_allorders_allb0s = None for n_b0s in range(1,7): b0_orders = get_b0_orders(np.int(n_b0s)) b0_orders = [ order for order in b0_orders if order[:2] == ec_b0 ] for b0_order in b0_orders: glob_string = os.path.join(data_dir, 'RESULTS', incl_excl, 'B0S_{}'.format(n_b0s), 'B0_ORDER_{}'.format(b0_order), sep_av, transform, '{}_FA_MD_vol.txt'.format(roi_name)) files = glob(glob_string) dict = { 'b0_order': b0_order, 'n_b0s' : n_b0s } # Read in every file and combine them for file in files: data = read_in_data(file) data_allorders_allb0s = combine_data(data_allorders_allb0s, data, dict) # Name the results dir that this is going into: results_allorders_allb0s_dir = os.path.join(data_dir, 'RESULTS', incl_excl, 'ALL_B0S', 'B0_{}'.format(ec_b0), sep_av, transform) # Now plot the data plot_data(data_allorders_allb0s, results_allorders_allb0s_dir, roi_name, colors, shapes) # Now do the same thing, but with REALLY all the B0s # Find all the results files in all the b0_order folders for incl_excl, sep_av, transform, roi_name in it.product(incl_excl_list, sep_av_list, transform_list, roi_list): # Start off with an empty data array data_allorders_allb0s = None for n_b0s in range(1,7): b0_orders = get_b0_orders(np.int(n_b0s)) for b0_order in b0_orders: glob_string = os.path.join(data_dir, 'RESULTS', incl_excl, 'B0S_{}'.format(n_b0s), 'B0_ORDER_{}'.format(b0_order), sep_av, transform, '{}_FA_MD_vol.txt'.format(roi_name)) files = glob(glob_string) dict = { 'b0_order': b0_order, 'n_b0s' : n_b0s } # Read in every file and combine them for file in files: data = read_in_data(file) data_allorders_allb0s = combine_data(data_allorders_allb0s, data, dict) # Name the results dir that this is going into: results_allorders_allb0s_dir = os.path.join(data_dir, 'RESULTS', incl_excl, 'ALL_B0S', 'ALL_B0S', sep_av, transform) # Now plot the data plot_data(data_allorders_allb0s, results_allorders_allb0s_dir, roi_name, colors, shapes)