Exemplo n.º 1
0
def gif_lobes_from_excel_sheets():
    """
    sort the gif parcellations as per excel gif sheet lobes.
    e.g. GIF FL = GIF Frontal Lobe - has a list of gif parcellations
    which we want to see in 3D slicer, using the GUI
    """
    _, _, excel_path, _ = file_paths()
    GIF_SHEET_NAMES = gif_sheet_names()

    lobes_mapping = {}

    for gif_lobe in GIF_SHEET_NAMES:
        gif_parcellations = pd.read_excel(
            excel_path,
            header=None,
            usecols="A:B",
            sheet_name=gif_lobe,
            engine="openpyxl",
        )
        gif_parcellations.dropna(axis=0, how='any', inplace=True)
        gif_parcellations.dropna(axis=1, how='all', inplace=True)
        gifs = gif_parcellations.astype({1: 'uint16'})
        gifs = gifs.iloc[:, 1]
        lobes_mapping[gif_lobe] = gifs.values

    return lobes_mapping
from mega_analysis.crosstab.file_paths import file_paths
from mega_analysis.crosstab.gif_sheet_names import gif_sheet_names
from mega_analysis.crosstab.mega_analysis.exclusions import exclusions
from mega_analysis.crosstab.mega_analysis.MEGA_ANALYSIS import MEGA_ANALYSIS
from mega_analysis.semiology import (  # semiology_dict_path,
    QUERY_SEMIOLOGY, Laterality, Semiology, gif_lat_file, map_df_dict)
from mega_analysis.crosstab.hierarchy_class import Hierarchy

# define paths: note dummy data has a tab called test_counts
# a hand crafted test fixture count
repo_dir, resources_dir, dummy_data_path, dummy_semiology_dict_path = \
    file_paths(dummy_data=True)

# Define the gif sheet names
gif_sheet_names = gif_sheet_names()

# Read Excel file only three times at initialisation
test_df, _, _, _, _, _, _ = MEGA_ANALYSIS(
    excel_data=dummy_data_path,
    n_rows=100,
    usecols="A:DH",
    header=1,
    exclude_data=False,
    plot=True,
)

map_df_dict = pd.read_excel(
    dummy_data_path,
    header=1,
    sheet_name=gif_sheet_names,