whether the b0s were combined first or not,
        how the roi was transformed from standard space,
        and all the rois
    '''

    b0_orders = get_b0_orders(np.int(n_b0s))

    for b0_order in b0_orders:
    
        print 'Combination: {} {} {} {} {} {}'.format(incl_excl, n_b0s, b0_order, sep_av, transform, roi_name)
    
        results_file, results_dir = wrangle_text_files(data_dir, incl_excl, n_b0s,
                                            b0_order, sep_av, transform,
                                            roi_name, subs, locs, scans)
        
        data = read_in_data(results_file)
        
        plot_data(data, results_dir, roi_name, colors, shapes)

# Now answer specific questions that you care about

Q_ec_vol_n6(data_dir, incl_excl_list, sep_av_list, transform_list, roi_list, colors, shapes)

# How does everything change with the different number of B0s?

Q_n_b0s(data_dir, incl_excl_list, sep_av_list, transform_list, roi_list, ec_b0_list, colors, shapes)


'''
# 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):
Beispiel #2
0
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)
            
Beispiel #3
0
            # Create deviations
            RandomA = self.y_test.sample(1000)
            RandomB = self.y_test.sample(1000)
            deviations = abs(RandomA.values - RandomB.values)
            mad = np.mean((deviations))
            print("Mean Absolute Deviations: {}".format(mad))

            # plot deviations
            plt.hist(deviations, 50, density=True, range=(0, 1000),
                     Label='Absolute Deviations from data', alpha=0.4)
            plt.vlines(mad, 0, 1, linewidth=4, color='k',
                       Label='Mean Absolute Deviations')
            plt.gca().set_ylim([0, max(fig[0]) * 1.1])
            plt.legend()


if __name__ == "__main__":
    # %% ## Example Usage of the code.
    df = read_in_data(
        r'https://archive.ics.uci.edu/ml/machine-learning-databases/00275/Bike-Sharing-Dataset.zip')
    example_pipe = Pipeline(config)
    example_pipe.create_test_training_sets(df)
    example_pipe.hyper_parameter_search()
    example_pipe.build_pipeline()
    example_pipe.assess_model()

 # Not implemented functionatliy.
#    example_pipe.pickle_pipeline()
#    example_pipe.retrain_model(df)
    '''

    b0_orders = get_b0_orders(np.int(n_b0s))

    for b0_order in b0_orders:

        print 'Combination: {} {} {} {} {} {}'.format(incl_excl, n_b0s,
                                                      b0_order, sep_av,
                                                      transform, roi_name)

        results_file, results_dir = wrangle_text_files(data_dir, incl_excl,
                                                       n_b0s, b0_order, sep_av,
                                                       transform, roi_name,
                                                       subs, locs, scans)

        data = read_in_data(results_file)

        plot_data(data, results_dir, roi_name, colors, shapes)

# Now answer specific questions that you care about

Q_ec_vol_n6(data_dir, incl_excl_list, sep_av_list, transform_list, roi_list,
            colors, shapes)

# How does everything change with the different number of B0s?

Q_n_b0s(data_dir, incl_excl_list, sep_av_list, transform_list, roi_list,
        ec_b0_list, colors, shapes)
'''
# 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):
Beispiel #5
0
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)
Beispiel #6
0
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)
Beispiel #7
0
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)