示例#1
0
def import_bv_fiedler_table(path_dataframe):
    """
    Read a fiedler lenght table generated by the associated BrainVISA process
    and reformat it
    :param path_dataframe:
    :return:
    """
    df = pd.read_csv(path_dataframe, sep="\t")
    df = df.d1.iloc[:-1, :]
    # reencode dataframe tab
    for side in SIDES.keys():
        df.loc[df["side"] == SIDES[side], ["side"]] = side
        df = df.rename(
            index=str,
            columns={
                "side": "Hemisphere",
                "subject": "Subject",
                "fidler_length": "Fiedler_Length",
            },
        )
    return df
    U_FIBERS_COORD,
    HEMI_INDEXES_FILT,
    SIDES,
    CLUSTERING_LABELS,
    SUBJ_LIST,
    FIG_CLUSTERS_INDIV_SPACE,
)

if __name__ == "__main__":

    ppfm = pd.read_csv(PPFM_TABLES["final"])
    data = np.load(U_FIBERS_COORD["iso"])
    hemispheres_index = np.load(HEMI_INDEXES_FILT)
    side_index = np.mod(hemispheres_index, 2)

    for j, side in enumerate(SIDES.keys()):
        labels = np.load(CLUSTERING_LABELS[side])
        data_ = data[side_index == j]
        data_ = data_[labels != -1]
        labels_ = labels[labels != -1]
        hemi_index = hemispheres_index[side_index == j]
        hemi_index = hemi_index[labels != -1]

        for i, subject in enumerate(SUBJ_LIST):
            index = i * len(SIDES) + j
            data_sub = data_[hemi_index == index]
            labels_sub = labels_[hemi_index == index]

            title = None
            subject_pp = get_hemisphere_subject_pp(ppfm, subject, side)
            path_fig = FIG_CLUSTERS_INDIV_SPACE[(subject, side)]
from soma import aims


def mesh_transform(path_mesh, path_transfo, path_mesh_out):
    transfo = aims.read(path_transfo)
    mesh = aims.read(path_mesh)
    h = mesh.header()
    aims.SurfaceManip.meshTransform(mesh, transfo)
    aims.write(mesh, path_mesh_out)
    pass


if __name__ == "__main__":

    from configuration.configuration import (
        SUBJ_LIST,
        MESHES_TYPE,
        SIDES,
        T1_2_DWI,
        MESHES_BRAINVISA,
    )

    for i, subject in enumerate(SUBJ_LIST):
        for mesh_type in MESHES_TYPE:
            for side in SIDES.keys():
                mesh_transform(
                    MESHES_BRAINVISA[(subject, side, mesh_type, "t1")],
                    T1_2_DWI,
                    MESHES_BRAINVISA[(subject, side, mesh_type, "dwi")],
                )
"""Interactive script to draw the common extremities of the gyral and sulcal lines.

These points are drawn in each extremity of the central sulcus based on the grey/white interface mesh (geometry) and the
Depth Potential Function computed with default parameter. The script preload the fusion of the mesh and the dpf. Script is supposed to be launched into iPython
"""

import anatomist.api as anatomist
from configuration.configuration import MESHES, DPFS, SUBJ_LIST, SIDES

subject = SUBJ_LIST[0]  # to be modified (0-99)
side = SIDES.keys()[0]  # to be modified (0-1)

path_mesh = MESHES[(subject, side)]
path_dpf = DPFS[(subject, side)]

a = anatomist.Anatomist()
w = a.createWindow("3D")
mesh = a.loadObject(path_mesh)
dpf = a.loadObject(path_dpf)
mesh.setMaterial(polygon_mode="outline")
dpf.setPalette("Purple-Red + Stripes",
               minVal=0,
               maxVal=-1.6,
               absoluteMode=True)
fusion = a.fusionObjects(objects=[mesh, dpf], method="FusionTexSurfMethod")
w.addObjects(fusion)
示例#5
0
    and reformat it
    :param path_dataframe:
    :return:
    """
    df = pd.read_csv(path_dataframe, sep="\t")
    df = df.d1.iloc[:-1, :]
    # reencode dataframe tab
    for side in SIDES.keys():
        df.loc[df["side"] == SIDES[side], ["side"]] = side
        df = df.rename(
            index=str,
            columns={
                "side": "Hemisphere",
                "subject": "Subject",
                "fidler_length": "Fiedler_Length",
            },
        )
    return df


if __name__ == "__main__":
    from configuration.configuration import SIDES, FIEDLER_TABLES, FIEDLER_DF

    fiedler_dfs = [
        import_bv_fiedler_table(FIEDLER_TABLES[side]) for side in SIDES.keys()
    ]
    d = pd.concat(fiedler_dfs)
    # reencoding values to adopt common notation (for future merges)
    d["Subject"] = d["Subject"].astype(int)
    d.to_csv(FIEDLER_DF)
import pandas as pd


def read_mesh_area_df(path_dataframe):
    """
    :param path_dataframe:
    :return:
    """
    df = pd.read_csv(path_dataframe, sep="\t")
    df = df.iloc[:-1, :]
    df.loc[df["side"] == "left", ["side"]] = "L"
    df.loc[df["side"] == "right", ["side"]] = "R"
    df = df.rename(
        index=str,
        columns={
            "side": "Hemisphere",
            "subject": "Subject",
            "area": "Mesh_Area"
        },
    )
    df["Subject"] = df["Subject"].astype(int)
    return df


if __name__ == "__main__":
    from configuration.configuration import SIDES, AREA_TABLES, MESH_AREA_DF

    area_dfs = [read_mesh_area_df(AREA_TABLES[side]) for side in SIDES.keys()]
    d = pd.concat(area_dfs)
    d.to_csv(MESH_AREA_DF)