Ejemplo n.º 1
0
def select_column_from_mindboggle_tables(subjects, hemi, index, tables_dir,
        table_name, is_surface_table=True, write_table=True, output_table=''):
    """
    Select column from Mindboggle shape tables and make a new table.

    For example, extract the median travel depth column for the label regions
    across a set of subjects, and make a new table.

    Expects::
        <tables_dir>/<subject>/tables/['left','right']_cortical_surface/<table_name>

    Parameters
    ----------
    subjects :  list of strings
        names of subjects processed by Mindboggle
    hemi :  string
        hemisphere in {'left', 'right}
    index : integer
        index for column to select
    tables_dir : string
        name of Mindboggle tables directory
    table_name : string
        name of Mindboggle table file
    is_surface_table : Boolean
        if True, use path to surface tables
    write_table : Boolean
        write output table?
    output_table : string
        output table file name

    Returns
    -------
    tables : list of strings
        input table files (full paths)
    columns : list of lists of floats or integers
        columns of data
    output_table :  string
        output table file name

    Examples
    --------
    >>> import os
    >>> from mindboggle.mio.tables import select_column_from_mindboggle_tables
    >>> subjects = ['Twins-2-1', 'Colin27-1']
    >>> hemi = 'left'
    >>> index = 2
    >>> tables_dir = os.path.join(os.environ['HOME'], 'mindboggled')
    >>> table_name = "label_shapes.csv"
    >>> label_name = 'Label name'
    >>> is_surface_table = True
    >>> write_table = True
    >>> output_table = ''
    >>> select_column_from_mindboggle_tables(subjects, hemi, index, tables_dir,
    >>>     table_name, is_surface_table, write_table, output_table)

    """
    import os

    from mindboggle.mio.tables import select_column_from_tables

    #-------------------------------------------------------------------------
    # Construct list of Mindboggle shape table file names:
    #-------------------------------------------------------------------------
    tables = []
    for subject in subjects:
        if is_surface_table:
            table = os.path.join(tables_dir, subject, 'tables',
                                 hemi+'_cortical_surface', table_name)
        else:
            table = os.path.join(tables_dir, subject, 'tables', table_name)
        tables.append(table)

    #-------------------------------------------------------------------------
    # Extract columns and construct new table:
    #-------------------------------------------------------------------------
    tables, columns, output_table = select_column_from_tables(tables, index,
        write_table, output_table)

    return tables, columns, output_table
Ejemplo n.º 2
0
def select_column_from_mindboggle_tables(subjects,
                                         hemi,
                                         index,
                                         tables_dir,
                                         table_name,
                                         is_surface_table=True,
                                         write_table=True,
                                         output_table=''):
    """
    Select column from Mindboggle shape tables and make a new table.

    For example, extract the median travel depth column for the label regions
    across a set of subjects, and make a new table.

    Expects::
        <tables_dir>/<subject>/tables/['left','right']_cortical_surface/<table_name>

    Parameters
    ----------
    subjects :  list of strings
        names of subjects processed by Mindboggle
    hemi :  string
        hemisphere in {'left', 'right}
    index : integer
        index for column to select
    tables_dir : string
        name of Mindboggle tables directory
    table_name : string
        name of Mindboggle table file
    is_surface_table : Boolean
        if True, use path to surface tables
    write_table : Boolean
        write output table?
    output_table : string
        output table file name

    Returns
    -------
    tables : list of strings
        input table files (full paths)
    columns : list of lists of floats or integers
        columns of data
    output_table :  string
        output table file name

    Examples
    --------
    >>> import os
    >>> from mindboggle.mio.tables import select_column_from_mindboggle_tables
    >>> subjects = ['Twins-2-1', 'Colin27-1']
    >>> hemi = 'left'
    >>> index = 2
    >>> tables_dir = os.path.join(os.environ['HOME'], 'mindboggled')
    >>> table_name = "label_shapes.csv"
    >>> label_name = 'Label name'
    >>> is_surface_table = True
    >>> write_table = True
    >>> output_table = ''
    >>> select_column_from_mindboggle_tables(subjects, hemi, index, tables_dir,
    >>>     table_name, is_surface_table, write_table, output_table)

    """
    import os

    from mindboggle.mio.tables import select_column_from_tables

    #-------------------------------------------------------------------------
    # Construct list of Mindboggle shape table file names:
    #-------------------------------------------------------------------------
    tables = []
    for subject in subjects:
        if is_surface_table:
            table = os.path.join(tables_dir, subject, 'tables',
                                 hemi + '_cortical_surface', table_name)
        else:
            table = os.path.join(tables_dir, subject, 'tables', table_name)
        tables.append(table)

    #-------------------------------------------------------------------------
    # Extract columns and construct new table:
    #-------------------------------------------------------------------------
    tables, columns, output_table = select_column_from_tables(
        tables, index, write_table, output_table)

    return tables, columns, output_table
Ejemplo n.º 3
0
def select_column_from_mindboggle_tables(subjects,
                                         hemi,
                                         index,
                                         tables_dir,
                                         table_name,
                                         is_surface_table=True,
                                         write_table=True,
                                         output_table=''):
    """
    Select column from Mindboggle shape tables and make a new table.

    For example, extract the median travel depth column for the label regions
    across a set of subjects, and make a new table.

    Expects::
        <tables_dir>/<subject>/tables/['left','right']_cortical_surface/<table_name>

    Parameters
    ----------
    subjects :  list of strings
        names of subjects processed by Mindboggle
    hemi :  string
        hemisphere in {'left', 'right}
    index : integer
        index for column to select
    tables_dir : string
        name of Mindboggle tables directory
    table_name : string
        name of Mindboggle table file
    is_surface_table : bool
        if True, use path to surface tables
    write_table : bool
        write output table?
    output_table : string
        output table file name

    Returns
    -------
    tables : list of strings
        input table files (full paths)
    columns : list of lists of floats or integers
        columns of data
    output_table :  string
        output table file name

    Examples
    --------
    >>> import os
    >>> from mindboggle.mio.tables import select_column_from_mindboggle_tables
    >>> path = os.environ['MINDBOGGLE_DATA'] # doctest: +SKIP
    >>> subject1 = os.path.basename(path) # doctest: +SKIP
    >>> subject2 = os.path.basename(path) # doctest: +SKIP
    >>> subjects = [subject1, subject2] # doctest: +SKIP
    >>> hemi = 'left'
    >>> index = 2
    >>> tables_dir = os.path.dirname(path) # doctest: +SKIP
    >>> table_name = "label_shapes.csv"
    >>> label_name = 'Label name'
    >>> is_surface_table = True
    >>> write_table = True
    >>> output_table = ''
    >>> tables, cols, output = select_column_from_mindboggle_tables(subjects,
    ...     hemi, index, tables_dir, table_name, is_surface_table,
    ...     write_table, output_table) # doctest: +SKIP
    >>> cols[0][0] # doctest: +SKIP
    878.03969839999979
    >>> cols[0][1] # doctest: +SKIP
    3085.6236725000008
    >>> cols[0][2] # doctest: +SKIP
    1761.2330760000002

    """
    import os

    from mindboggle.mio.tables import select_column_from_tables

    # ------------------------------------------------------------------------
    # Construct list of Mindboggle shape table file names:
    # ------------------------------------------------------------------------
    tables = []
    for subject in subjects:
        if is_surface_table:
            table = os.path.join(tables_dir, subject, 'tables',
                                 hemi + '_cortical_surface', table_name)
        else:
            table = os.path.join(tables_dir, subject, 'tables', table_name)
        tables.append(table)

    # ------------------------------------------------------------------------
    # Extract columns and construct new table:
    # ------------------------------------------------------------------------
    tables, columns, output_table = select_column_from_tables(
        tables, index, write_table, output_table)

    return tables, columns, output_table
Ejemplo n.º 4
0
def select_column_from_mindboggle_tables(subjects, hemi, index, tables_dir,
        table_name, is_surface_table=True, write_table=True, output_table=''):
    """
    Select column from Mindboggle shape tables and make a new table.

    For example, extract the median travel depth column for the label regions
    across a set of subjects, and make a new table.

    Expects::
        <tables_dir>/<subject>/tables/['left','right']_cortical_surface/<table_name>

    Parameters
    ----------
    subjects :  list of strings
        names of subjects processed by Mindboggle
    hemi :  string
        hemisphere in {'left', 'right}
    index : integer
        index for column to select
    tables_dir : string
        name of Mindboggle tables directory
    table_name : string
        name of Mindboggle table file
    is_surface_table : bool
        if True, use path to surface tables
    write_table : bool
        write output table?
    output_table : string
        output table file name

    Returns
    -------
    tables : list of strings
        input table files (full paths)
    columns : list of lists of floats or integers
        columns of data
    output_table :  string
        output table file name

    Examples
    --------
    >>> import os
    >>> from mindboggle.mio.tables import select_column_from_mindboggle_tables
    >>> path = os.environ['MINDBOGGLE_DATA'] # doctest: +SKIP
    >>> subject1 = os.path.basename(path) # doctest: +SKIP
    >>> subject2 = os.path.basename(path) # doctest: +SKIP
    >>> subjects = [subject1, subject2] # doctest: +SKIP
    >>> hemi = 'left'
    >>> index = 2
    >>> tables_dir = os.path.dirname(path) # doctest: +SKIP
    >>> table_name = "label_shapes.csv"
    >>> label_name = 'Label name'
    >>> is_surface_table = True
    >>> write_table = True
    >>> output_table = ''
    >>> tables, cols, output = select_column_from_mindboggle_tables(subjects,
    ...     hemi, index, tables_dir, table_name, is_surface_table,
    ...     write_table, output_table) # doctest: +SKIP
    >>> cols[0][0] # doctest: +SKIP
    878.03969839999979
    >>> cols[0][1] # doctest: +SKIP
    3085.6236725000008
    >>> cols[0][2] # doctest: +SKIP
    1761.2330760000002

    """
    import os

    from mindboggle.mio.tables import select_column_from_tables

    #-------------------------------------------------------------------------
    # Construct list of Mindboggle shape table file names:
    #-------------------------------------------------------------------------
    tables = []
    for subject in subjects:
        if is_surface_table:
            table = os.path.join(tables_dir, subject, 'tables',
                                 hemi+'_cortical_surface', table_name)
        else:
            table = os.path.join(tables_dir, subject, 'tables', table_name)
        tables.append(table)

    #-------------------------------------------------------------------------
    # Extract columns and construct new table:
    #-------------------------------------------------------------------------
    tables, columns, output_table = select_column_from_tables(tables, index,
        write_table, output_table)

    return tables, columns, output_table