From 57b62e4edb38ed1cb75c395741619552c4db52ad Mon Sep 17 00:00:00 2001 From: gauzias Date: Fri, 29 Nov 2024 10:53:00 +0100 Subject: [PATCH] refresh doc manual --- .gitignore | 4 - doc/conf.py | 11 +- examples/example_basics.py | 2 +- examples/example_curvature.py | 2 +- examples/example_differential_geometry.py | 4 +- examples/example_distortion.py | 2 +- examples/example_geodesic.py | 2 +- examples/example_profile_texture.py | 4 +- examples/example_registration.py | 4 +- examples/example_remeshing.py | 10 +- examples/example_spangy.py | 400 +++++++++++----------- examples/example_surface_profiling.py | 2 +- examples/example_texture.py | 2 +- examples/example_topology.py | 258 +++++++------- examples/example_vertex_voronoi.py | 2 +- 15 files changed, 346 insertions(+), 363 deletions(-) diff --git a/.gitignore b/.gitignore index f6020fb..a3b13d1 100644 --- a/.gitignore +++ b/.gitignore @@ -144,7 +144,3 @@ venv.bak/ # modules.xml # .idea/misc.xml # *.ipr - -curv_py.py -.gitignore -slam/plot.py diff --git a/doc/conf.py b/doc/conf.py index a779208..e96f432 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -20,13 +20,10 @@ import sys from datetime import date -from visbrain.config import CONFIG import sphinx_gallery # noqa from sphinx_gallery.sorting import FileNameSortKey import sphinx_bootstrap_theme -CONFIG["MPL_RENDER"] = True - curdir = os.path.dirname(__file__) sys.path.append(os.path.abspath(os.path.join(curdir, ".."))) @@ -200,11 +197,5 @@ "filename_pattern": "^((?!sgskip).)*$", "backreferences_dir": "generated", "within_subsection_order": FileNameSortKey, - "reference_url": { - "numpy": "http://docs.scipy.org/doc/numpy-1.9.1", - "scipy": "http://docs.scipy.org/doc/scipy-0.17.0/reference", - "trimesh": "https://github.com/mikedh/trimesh", - "visbrain": "https://github.com/EtienneCmb/visbrain", - "nibabel": "https://nipy.org/nibabel", - }, + "reference_url": {}, } diff --git a/examples/example_basics.py b/examples/example_basics.py index d191bb2..538bc11 100644 --- a/examples/example_basics.py +++ b/examples/example_basics.py @@ -23,7 +23,7 @@ # loading a mesh stored on the disc as a gifti file, # this is a feature of SLAM -mesh = sio.load_mesh("examples/data/example_mesh.gii") +mesh = sio.load_mesh("../examples/data/example_mesh.gii") ############################################################################### # affine transformations can be applied to mesh objects diff --git a/examples/example_curvature.py b/examples/example_curvature.py index a9e362a..c41de80 100644 --- a/examples/example_curvature.py +++ b/examples/example_curvature.py @@ -27,7 +27,7 @@ ############################################################################### # loading an examplar mesh -mesh_file = "examples/data/example_mesh.gii" +mesh_file = "../examples/data/example_mesh.gii" mesh = sio.load_mesh(mesh_file) ############################################################################### diff --git a/examples/example_differential_geometry.py b/examples/example_differential_geometry.py index ecad9ff..ba3fb48 100644 --- a/examples/example_differential_geometry.py +++ b/examples/example_differential_geometry.py @@ -24,8 +24,8 @@ ############################################################################### # loading an examplar mesh and corresponding texture -mesh_file = "examples/data/example_mesh.gii" -texture_file = "examples/data/example_texture.gii" +mesh_file = "../examples/data/example_mesh.gii" +texture_file = "../examples/data/example_texture.gii" mesh = sio.load_mesh(mesh_file) tex = sio.load_texture(texture_file) diff --git a/examples/example_distortion.py b/examples/example_distortion.py index 2d96918..02077f4 100644 --- a/examples/example_distortion.py +++ b/examples/example_distortion.py @@ -29,7 +29,7 @@ ############################################################################### # Loading an example mesh and a smoothed copy of it -mesh = sio.load_mesh("examples/data/example_mesh.gii") +mesh = sio.load_mesh("../examples/data/example_mesh.gii") mesh_s = sdg.laplacian_mesh_smoothing(mesh, nb_iter=50, dt=0.1) ############################################################################### diff --git a/examples/example_geodesic.py b/examples/example_geodesic.py index b33b92b..ca13459 100644 --- a/examples/example_geodesic.py +++ b/examples/example_geodesic.py @@ -28,7 +28,7 @@ ############################################################################### # Mesh importation -mesh = sio.load_mesh("examples/data/example_mesh.gii") +mesh = sio.load_mesh("../examples/data/example_mesh.gii") ############################################################################### # Getting the vertex index in specified geo_distance of vert diff --git a/examples/example_profile_texture.py b/examples/example_profile_texture.py index 78fca69..3012499 100644 --- a/examples/example_profile_texture.py +++ b/examples/example_profile_texture.py @@ -24,8 +24,8 @@ ############################################################################### # loading an example mesh and its texture -mesh_file = "examples/data/example_mesh.gii" -texture_file = "examples/data/example_texture.gii" +mesh_file = "../examples/data/example_mesh.gii" +texture_file = "../examples/data/example_texture.gii" mesh = sio.load_mesh(mesh_file) texture = sio.load_texture(texture_file) diff --git a/examples/example_registration.py b/examples/example_registration.py index ae43c65..851fb20 100644 --- a/examples/example_registration.py +++ b/examples/example_registration.py @@ -24,8 +24,8 @@ ############################################################################### # loading an two unregistered meshes -mesh_1 = sio.load_mesh("examples/data/example_mesh.gii") -mesh_2 = sio.load_mesh("examples/data/example_mesh_2.gii") +mesh_1 = sio.load_mesh("../examples/data/example_mesh.gii") +mesh_2 = sio.load_mesh("../examples/data/example_mesh_2.gii") ############################################################################### # compute ICP registration diff --git a/examples/example_remeshing.py b/examples/example_remeshing.py index 6ae08bb..92fab96 100644 --- a/examples/example_remeshing.py +++ b/examples/example_remeshing.py @@ -26,14 +26,14 @@ ############################################################################### # Source object files -source_mesh_file = "examples/data/example_mesh.gii" -source_texture_file = "examples/data/example_texture.gii" -source_spherical_mesh_file = "examples/data/example_mesh_spherical.gii" +source_mesh_file = "../examples/data/example_mesh.gii" +source_texture_file = "../examples/data/example_texture.gii" +source_spherical_mesh_file = "../examples/data/example_mesh_spherical.gii" ############################################################################### # Target object files -target_mesh_file = "examples/data/example_mesh_2.gii" -target_spherical_mesh_file = "examples/data/example_mesh_2_spherical.gii" +target_mesh_file = "../examples/data/example_mesh_2.gii" +target_spherical_mesh_file = "../examples/data/example_mesh_2_spherical.gii" source_mesh = sio.load_mesh(source_mesh_file) source_tex = sio.load_texture(source_texture_file) diff --git a/examples/example_spangy.py b/examples/example_spangy.py index e13deb3..a9df385 100644 --- a/examples/example_spangy.py +++ b/examples/example_spangy.py @@ -27,7 +27,7 @@ ############################################################################### # LOAD MESH mesh = sio.load_mesh( - 'examples/data/example_mesh.gii') + '../examples/data/example_mesh.gii') vertices = mesh.vertices num_vertices = len(vertices) print('{} vertices'.format(num_vertices)) @@ -100,203 +100,201 @@ ############################################################################# # VISUALIZATION USING EXTERNAL TOOLS ############################################################################# -""" -import slam.plot as splt -import matplotlib.pyplot as plt -from matplotlib.colors import ListedColormap -import pyvista as pv - -############################################################################### -# Plot of mean curvature on the mesh -visb_sc = splt.visbrain_plot( - mesh=mesh, - tex=mean_curv, - caption='Mean Curvature', - cmap='jet') -visb_sc.preview() - -# Plot coefficients and bands for all mean curvature signal -fig, (ax1, ax2) = plt.subplots(1, 2) -ax1.scatter(np.sqrt(eigVal/2*np.pi), -coefficients, marker='+', s=10, linewidths=0.5) -#ax1.plot(np.sqrt(eigVal[1:]) / (2 * np.pi), -# coefficients[1:]) # remove B0 coefficients -#ax1.scatter(np.sqrt(eigVal[1:]/2*np.pi), -# coefficients[1:], marker='+', s=10, linewidths=0.5) # remove B0 coefficients -ax1.set_xlabel('Frequency (m⁻¹)') -ax1.set_ylabel('Coefficients') - -# print(grouped_spectrum) -ax2.bar(np.arange(0, levels), grouped_spectrum) -#ax2.bar(np.arange(1, nlevels), grouped_spectrum[1:]) # remove B0 -ax2.set_xlabel('Spangy Frequency Bands') -ax2.set_ylabel('Power Spectrum') -plt.show() - -# Plot of spectral dominant bands on the mesh -visb_sc = splt.visbrain_plot(mesh=mesh, tex=loc_dom_band, - caption='Local Dominant Band', cmap='jet') -visb_sc.preview() - -# Plot mean curvature coefficients & compacted power spectrum characterizing -# either Sulci either Gyri folding pattern -# --------------------------------------------------------------------------- -coefficients_colors_sulci \ - = plot_global_coefficients_and_bands_sulci_or_gyri( - group_indices_sulci, - coefficients_sulci, - colormap_sulci -) -coefficients_colors_gyri \ - = plot_global_coefficients_and_bands_sulci_or_gyri( - group_indices_gyri, - coefficients_gyri, - colormap_gyri -) - -fig, axs = plt.subplots(2, 2) - -# GLOBAL FOLDING PATTERN OF SULCI -#axs[0,0].plot(np.sqrt(eigVal/2*np.pi), -# coefficients_sulci, color=coefficients_colors_sulci) -axs[0,0].scatter(np.sqrt(eigVal/2*np.pi), - coefficients_sulci, marker='+', - s=10, linewidths=0.5, color=coefficients_colors_sulci) -#axs[0,0].scatter(np.sqrt(eigVal[1:]/2*np.pi), -# coefficients_sulci[1:], marker='+', s=10, linewidths=0.5, -# color=coefficients_colors_sulci[1:]) # remove B0 coefficient -axs[0,0].set_xlabel('Frequency (m⁻¹)') -axs[0,0].set_ylabel('Coefficients mean_curv<=0') - -axs[0,1].bar(np.arange(0, nlevels), -grouped_spectrum_sulci.squeeze(), color=colormap_sulci) -#axs[0,1].bar(np.arange(1, nlevels), -# grouped_spectrum_sulci[1:].squeeze(), -# color=colormap_sulci[1:]) # remove B0 -axs[0,1].set_xlabel('Spangy frequency bands') -axs[0,1].set_ylabel('Power spectrum mean_curv<=0') - -# GLOBAL FOLDING PATTERN OF GYRI -#axs[1,0].plot(np.sqrt(eigVal/2*np.pi), -# coefficients_gyri, color=coefficients_colors_gyri) -axs[1,0].scatter(np.sqrt(eigVal/2*np.pi), - coefficients_gyri, marker='+', - s=10, linewidths=0.5, color=coefficients_colors_gyri) -#axs[1,0].scatter(np.sqrt(eigVal[1:]/2*np.pi), -# coefficients_gyri[1:], marker='+', s=10, linewidths=0.5, -# color=coefficients_colors_gyri[1:]) # remove B0 coefficient -axs[1,0].set_xlabel('Frequency (m⁻¹)') -axs[1,0].set_ylabel('Coefficients mean_curv>0') - -axs[1,1].bar(np.arange(0, nlevels), - grouped_spectrum_gyri.squeeze(), color=colormap_gyri) -#axs[1,1].bar(np.arange(1, nlevels), -# grouped_spectrum_gyri[1:].squeeze(), color=colormap_gyri[1:]) # remove B0 -axs[1,1].set_xlabel('Spangy frequency bands') -axs[1,1].set_ylabel('Power spectrum mean_curv>0') - -plt.show() - -# LOCAL SPECTRAL BANDS -# -------------------- -# Plot of spectral dominant bands on the mesh, with automatized colormap -number_of_displayed_bands = len(np.unique(loc_dom_band)) - -band_values = np.linspace(np.min(loc_dom_band), - np.max(loc_dom_band), - number_of_displayed_bands+1) -# 13 = 6 positive bands * 2 + Band 0 --> to generalize -band_colors = np.empty((number_of_displayed_bands+1, 4)) -limit = np.max(loc_dom_band) - number_of_high_folding_pattern_bands + 1 -# limit band number under which band is displayed in black - -band_colors[band_values < limit] = colors[0, :] # low frequency bands - -# associate one color per high frequency sulcus band -for i in range(number_of_high_folding_pattern_bands): - band_colors[band_values == -(limit+i)] = colors[i+1, :] - -# associate one color per high frequency gyrus band -for i in range(number_of_high_folding_pattern_bands): - band_colors[band_values == - (limit+i)] = colors[i+1+number_of_high_folding_pattern_bands, :] - -localbands_colormap = ListedColormap(band_colors) -#loc_dom_band = loc_dom_band.astype(int) - -p = pv.Plotter() -p.add_mesh(mesh, scalars=loc_dom_band, - show_edges=False, cmap=localbands_colormap, show_scalar_bar=False) -p.add_text("Local Dominant Bands", font_size=14) -p.add_scalar_bar('Band n°', fmt="%.0f") -p.show() - -################################################# -# DETAILED AND GENERALIZED DISPLAY OPTIONS # -################################################# - -# AUTOMATIZED COLORMAP DEPENDING ON NUMBER OF BANDS -# ------------------------------------------------- -# Define automatically the sulci/gyri folding pattern colormap, -# in correlation with nlevels --> colors, colormap_sulci, colormap_gyri -number_of_high_folding_pattern_bands = int(nlevels/2) - -colors = np.zeros((2*number_of_high_folding_pattern_bands+1, 4)) -# 4 colors for 7 bands (black + B4 + B5 + B6) -color_variations_coef = np.linspace(0, 1, number_of_high_folding_pattern_bands) - -# low frequency bands -colors[0, :] = np.array([0, 0, 0, 1]) -# to display in grey: np.array([0.75, 0.75, 0.75, 1]) - -# colors of high-folding-pattern sulci bands -for i in range(number_of_high_folding_pattern_bands): - colors[i+1, :] = np.array([0, color_variations_coef[i], 1, 1]) - -# colors of high-folding-pattern gyri bands -for i in range(number_of_high_folding_pattern_bands): - colors[i+1+number_of_high_folding_pattern_bands, :] \ - = np.array([1, color_variations_coef[i], 0, 1]) - -# allocate dedicated color to each bar of the global power spectrum: -# Colormap for Sulci folding patterns -colormap_sulci = [] # len = 7 -for i in np.arange(0, nlevels-number_of_high_folding_pattern_bands): - colormap_sulci.append(colors[0, :]) # B0, B-1, B-2, B-3 -for i in np.arange(0, number_of_high_folding_pattern_bands): - colormap_sulci.append(colors[i+1, :]) # B-4, B-5, B-6 - -# Colormap for Gyri folding patterns -colormap_gyri = [] # len = 7 -for i in np.arange(0, nlevels-number_of_high_folding_pattern_bands): - colormap_gyri.append(colors[0, :]) # B0, B1, B2, B3 -for i in np.arange(0, number_of_high_folding_pattern_bands): - colormap_gyri.append( - colors[i+1+number_of_high_folding_pattern_bands, :]) # B4, B5, B6 - -# GLOBAL COEFFICIENTS AND BANDS -# ----------------------------- -def plot_global_coefficients_and_bands_sulci_or_gyri( -group_indices, coefficients, colormap): - coefficients_colors = [] # len = N (e.g. 1500 eigenpairs) - - # coefficient corresponding to band B0 - coefficients_colors.append(colormap[0]) - - # coefficients corresponding to other bands i.e. B1..B6 & B-1..B-6 - band_last_eigenvalue = [] - for i in range(len(group_indices)): - band_last_eigenvalue.append(group_indices[i][1]) - # i, first eigen value of the band Bi - - for i in np.arange(1, len(coefficients)): # len(coefficients) = N - j = 0 - while i > band_last_eigenvalue[j]: - j = j+1 - if i < band_last_eigenvalue[j]: - break - - coefficients_colors.append(colormap[j]) - - return coefficients_colors -""" +# import slam.plot as splt +# import matplotlib.pyplot as plt +# from matplotlib.colors import ListedColormap +# import pyvista as pv +# +# ############################################################################### +# # Plot of mean curvature on the mesh +# visb_sc = splt.visbrain_plot( +# mesh=mesh, +# tex=mean_curv, +# caption='Mean Curvature', +# cmap='jet') +# visb_sc.preview() +# +# # Plot coefficients and bands for all mean curvature signal +# fig, (ax1, ax2) = plt.subplots(1, 2) +# ax1.scatter(np.sqrt(eigVal/2*np.pi), +# coefficients, marker='+', s=10, linewidths=0.5) +# #ax1.plot(np.sqrt(eigVal[1:]) / (2 * np.pi), +# # coefficients[1:]) # remove B0 coefficients +# #ax1.scatter(np.sqrt(eigVal[1:]/2*np.pi), +# # coefficients[1:], marker='+', s=10, linewidths=0.5) # remove B0 coefficients +# ax1.set_xlabel('Frequency (m⁻¹)') +# ax1.set_ylabel('Coefficients') +# +# # print(grouped_spectrum) +# ax2.bar(np.arange(0, levels), grouped_spectrum) +# #ax2.bar(np.arange(1, nlevels), grouped_spectrum[1:]) # remove B0 +# ax2.set_xlabel('Spangy Frequency Bands') +# ax2.set_ylabel('Power Spectrum') +# plt.show() +# +# # Plot of spectral dominant bands on the mesh +# visb_sc = splt.visbrain_plot(mesh=mesh, tex=loc_dom_band, +# caption='Local Dominant Band', cmap='jet') +# visb_sc.preview() +# +# # Plot mean curvature coefficients & compacted power spectrum characterizing +# # either Sulci either Gyri folding pattern +# # --------------------------------------------------------------------------- +# coefficients_colors_sulci \ +# = plot_global_coefficients_and_bands_sulci_or_gyri( +# group_indices_sulci, +# coefficients_sulci, +# colormap_sulci +# ) +# coefficients_colors_gyri \ +# = plot_global_coefficients_and_bands_sulci_or_gyri( +# group_indices_gyri, +# coefficients_gyri, +# colormap_gyri +# ) +# +# fig, axs = plt.subplots(2, 2) +# +# # GLOBAL FOLDING PATTERN OF SULCI +# #axs[0,0].plot(np.sqrt(eigVal/2*np.pi), +# # coefficients_sulci, color=coefficients_colors_sulci) +# axs[0,0].scatter(np.sqrt(eigVal/2*np.pi), +# coefficients_sulci, marker='+', +# s=10, linewidths=0.5, color=coefficients_colors_sulci) +# #axs[0,0].scatter(np.sqrt(eigVal[1:]/2*np.pi), +# # coefficients_sulci[1:], marker='+', s=10, linewidths=0.5, +# # color=coefficients_colors_sulci[1:]) # remove B0 coefficient +# axs[0,0].set_xlabel('Frequency (m⁻¹)') +# axs[0,0].set_ylabel('Coefficients mean_curv<=0') +# +# axs[0,1].bar(np.arange(0, nlevels), +# grouped_spectrum_sulci.squeeze(), color=colormap_sulci) +# #axs[0,1].bar(np.arange(1, nlevels), +# # grouped_spectrum_sulci[1:].squeeze(), +# # color=colormap_sulci[1:]) # remove B0 +# axs[0,1].set_xlabel('Spangy frequency bands') +# axs[0,1].set_ylabel('Power spectrum mean_curv<=0') +# +# # GLOBAL FOLDING PATTERN OF GYRI +# #axs[1,0].plot(np.sqrt(eigVal/2*np.pi), +# # coefficients_gyri, color=coefficients_colors_gyri) +# axs[1,0].scatter(np.sqrt(eigVal/2*np.pi), +# coefficients_gyri, marker='+', +# s=10, linewidths=0.5, color=coefficients_colors_gyri) +# #axs[1,0].scatter(np.sqrt(eigVal[1:]/2*np.pi), +# # coefficients_gyri[1:], marker='+', s=10, linewidths=0.5, +# # color=coefficients_colors_gyri[1:]) # remove B0 coefficient +# axs[1,0].set_xlabel('Frequency (m⁻¹)') +# axs[1,0].set_ylabel('Coefficients mean_curv>0') +# +# axs[1,1].bar(np.arange(0, nlevels), +# grouped_spectrum_gyri.squeeze(), color=colormap_gyri) +# #axs[1,1].bar(np.arange(1, nlevels), +# # grouped_spectrum_gyri[1:].squeeze(), color=colormap_gyri[1:]) # remove B0 +# axs[1,1].set_xlabel('Spangy frequency bands') +# axs[1,1].set_ylabel('Power spectrum mean_curv>0') +# +# plt.show() +# +# # LOCAL SPECTRAL BANDS +# # -------------------- +# # Plot of spectral dominant bands on the mesh, with automatized colormap +# number_of_displayed_bands = len(np.unique(loc_dom_band)) +# +# band_values = np.linspace(np.min(loc_dom_band), +# np.max(loc_dom_band), +# number_of_displayed_bands+1) +# # 13 = 6 positive bands * 2 + Band 0 --> to generalize +# band_colors = np.empty((number_of_displayed_bands+1, 4)) +# limit = np.max(loc_dom_band) - number_of_high_folding_pattern_bands + 1 +# # limit band number under which band is displayed in black +# +# band_colors[band_values < limit] = colors[0, :] # low frequency bands +# +# # associate one color per high frequency sulcus band +# for i in range(number_of_high_folding_pattern_bands): +# band_colors[band_values == -(limit+i)] = colors[i+1, :] +# +# # associate one color per high frequency gyrus band +# for i in range(number_of_high_folding_pattern_bands): +# band_colors[band_values == +# (limit+i)] = colors[i+1+number_of_high_folding_pattern_bands, :] +# +# localbands_colormap = ListedColormap(band_colors) +# #loc_dom_band = loc_dom_band.astype(int) +# +# p = pv.Plotter() +# p.add_mesh(mesh, scalars=loc_dom_band, +# show_edges=False, cmap=localbands_colormap, show_scalar_bar=False) +# p.add_text("Local Dominant Bands", font_size=14) +# p.add_scalar_bar('Band n°', fmt="%.0f") +# p.show() +# +# ################################################# +# # DETAILED AND GENERALIZED DISPLAY OPTIONS # +# ################################################# +# +# # AUTOMATIZED COLORMAP DEPENDING ON NUMBER OF BANDS +# # ------------------------------------------------- +# # Define automatically the sulci/gyri folding pattern colormap, +# # in correlation with nlevels --> colors, colormap_sulci, colormap_gyri +# number_of_high_folding_pattern_bands = int(nlevels/2) +# +# colors = np.zeros((2*number_of_high_folding_pattern_bands+1, 4)) +# # 4 colors for 7 bands (black + B4 + B5 + B6) +# color_variations_coef = np.linspace(0, 1, number_of_high_folding_pattern_bands) +# +# # low frequency bands +# colors[0, :] = np.array([0, 0, 0, 1]) +# # to display in grey: np.array([0.75, 0.75, 0.75, 1]) +# +# # colors of high-folding-pattern sulci bands +# for i in range(number_of_high_folding_pattern_bands): +# colors[i+1, :] = np.array([0, color_variations_coef[i], 1, 1]) +# +# # colors of high-folding-pattern gyri bands +# for i in range(number_of_high_folding_pattern_bands): +# colors[i+1+number_of_high_folding_pattern_bands, :] \ +# = np.array([1, color_variations_coef[i], 0, 1]) +# +# # allocate dedicated color to each bar of the global power spectrum: +# # Colormap for Sulci folding patterns +# colormap_sulci = [] # len = 7 +# for i in np.arange(0, nlevels-number_of_high_folding_pattern_bands): +# colormap_sulci.append(colors[0, :]) # B0, B-1, B-2, B-3 +# for i in np.arange(0, number_of_high_folding_pattern_bands): +# colormap_sulci.append(colors[i+1, :]) # B-4, B-5, B-6 +# +# # Colormap for Gyri folding patterns +# colormap_gyri = [] # len = 7 +# for i in np.arange(0, nlevels-number_of_high_folding_pattern_bands): +# colormap_gyri.append(colors[0, :]) # B0, B1, B2, B3 +# for i in np.arange(0, number_of_high_folding_pattern_bands): +# colormap_gyri.append( +# colors[i+1+number_of_high_folding_pattern_bands, :]) # B4, B5, B6 +# +# # GLOBAL COEFFICIENTS AND BANDS +# # ----------------------------- +# def plot_global_coefficients_and_bands_sulci_or_gyri( +# group_indices, coefficients, colormap): +# coefficients_colors = [] # len = N (e.g. 1500 eigenpairs) +# +# # coefficient corresponding to band B0 +# coefficients_colors.append(colormap[0]) +# +# # coefficients corresponding to other bands i.e. B1..B6 & B-1..B-6 +# band_last_eigenvalue = [] +# for i in range(len(group_indices)): +# band_last_eigenvalue.append(group_indices[i][1]) +# # i, first eigen value of the band Bi +# +# for i in np.arange(1, len(coefficients)): # len(coefficients) = N +# j = 0 +# while i > band_last_eigenvalue[j]: +# j = j+1 +# if i < band_last_eigenvalue[j]: +# break +# +# coefficients_colors.append(colormap[j]) +# +# return coefficients_colors diff --git a/examples/example_surface_profiling.py b/examples/example_surface_profiling.py index 73e4867..529b583 100644 --- a/examples/example_surface_profiling.py +++ b/examples/example_surface_profiling.py @@ -25,7 +25,7 @@ ############################################################################### # loading an example mesh -mesh = sio.load_mesh("examples/data/example_mesh.gii") +mesh = sio.load_mesh("../examples/data/example_mesh.gii") ############################################################################### # Select a vertex and get the coordinate and normal. diff --git a/examples/example_texture.py b/examples/example_texture.py index 45abc4f..ca14af6 100644 --- a/examples/example_texture.py +++ b/examples/example_texture.py @@ -22,7 +22,7 @@ ############################################################################### # -tex = sio.load_texture("examples/data/example_texture.gii") +tex = sio.load_texture("../examples/data/example_texture.gii") print(tex) print(tex.metadata) print(tex.shape) diff --git a/examples/example_topology.py b/examples/example_topology.py index 2407e7d..9a70701 100644 --- a/examples/example_topology.py +++ b/examples/example_topology.py @@ -47,14 +47,14 @@ # here is how to get the vertices that define the boundary of # a texture on a mesh # Let us first load example data -mesh = sio.load_mesh("examples/data/example_mesh.gii") +mesh = sio.load_mesh("../examples/data/example_mesh.gii") # rotate the mesh for better visualization transfo_flip = np.array( [[-1, 0, 0, 0], [0, 1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]]) mesh.apply_transform(transfo_flip) # Load the example texture and compute its boundary -tex_parcel = sio.load_texture("examples/data/example_texture_parcel.gii") +tex_parcel = sio.load_texture("../examples/data/example_texture_parcel.gii") texture_bound = stop.texture_boundary(mesh, tex_parcel.darray[0], 20) ############################################################################### @@ -95,131 +95,129 @@ ############################################################################# # VISUALIZATION USING EXTERNAL TOOLS ############################################################################# -""" -import slam.plot as splt -from vispy.scene import Line -from visbrain.objects import VispyObj, SourceObj - -############################################################################### -# show the result -# WARNING : BrainObj should be added first before -visb_sc = splt.visbrain_plot(mesh=open_mesh, caption="open mesh") -# create points with vispy -for bound in open_mesh_boundary: - points = open_mesh.vertices[bound] - s_rad = SourceObj( - "rad", - points, - color="red", - symbol="square", - radius_min=10) - visb_sc.add_to_subplot(s_rad) - lines = Line(pos=open_mesh.vertices[bound], width=10, color="b") - # wrap the vispy object using visbrain - l_obj = VispyObj("line", lines) - visb_sc.add_to_subplot(l_obj) -visb_sc.preview() - -############################################################################### -# show the result -visb_sc2 = splt.visbrain_plot(mesh=eroded_mesh, caption="eroded mesh") -# show again the boundary of original mesh which have been removed with -# corresponding faces by the erosion -for bound in open_mesh_boundary: - points = open_mesh.vertices[bound] - s_rad = SourceObj( - "rad", - points, - color="red", - symbol="square", - radius_min=10) - visb_sc2.add_to_subplot(s_rad) - lines = Line(pos=open_mesh.vertices[bound], width=10, color="b") - # wrap the vispy object using visbrain - l_obj = VispyObj("line", lines) - visb_sc2.add_to_subplot(l_obj) -visb_sc2.preview() - -############################################################################### -# show the results -visb_sc3 = splt.visbrain_plot( - mesh=mesh, tex=tex_parcel.darray[0], caption="texture boundary" -) -cols = ["red", "green", "yellow", "blue"] -ind = 0 -for bound in texture_bound: - points = mesh.vertices[bound] - s_rad = SourceObj( - "rad", - points, - color="red", - symbol="square", - radius_min=10) - visb_sc3.add_to_subplot(s_rad) - lines = Line(pos=mesh.vertices[bound], width=10, color=cols[ind]) - # wrap the vispy object using visbrain - l_obj = VispyObj("line", lines) - visb_sc3.add_to_subplot(l_obj) - ind += 1 - if ind == len(cols): - ind = 0 -visb_sc3.preview() - -############################################################################### -# show the mesh with the cuted subparts in different colors -scene_list = list() -cuted_mesh = sub_meshes[-1] -joint_mesh = sub_meshes[0] -joint_tex = np.zeros((sub_meshes[0].vertices.shape[0],)) -last_ind = sub_meshes[0].vertices.shape[0] -for ind, sub_mesh in enumerate(sub_meshes[1:]): - sub_tex = np.ones((sub_mesh.vertices.shape[0],)) * (ind + 1) - joint_mesh += sub_mesh - joint_tex = np.hstack((joint_tex, sub_tex)) -visb_sc3 = splt.visbrain_plot( - mesh=joint_mesh, - tex=joint_tex, - caption="mesh parts shown in different colors" -) -ind = 0 -boundaries = stop.mesh_boundary(cuted_mesh) -for bound in boundaries: - s_rad = SourceObj( - "rad", - cuted_mesh.vertices[bound], - color=cols[ind], - symbol="square", - radius_min=10, - ) - visb_sc3.add_to_subplot(s_rad) - lines = Line(pos=cuted_mesh.vertices[bound], color=cols[ind], width=10) - # wrap the vispy object using visbrain - l_obj = VispyObj("line", lines) - visb_sc3.add_to_subplot(l_obj) - ind += 1 - if ind == len(cols): - ind = 0 -visb_sc3.preview() -############################################################################### -# show the largest submesh with the boundaries of cutted parts -visb_sc4 = splt.visbrain_plot(mesh=cuted_mesh, caption="open mesh") -# create points with vispy -for bound in boundaries: - points = cuted_mesh.vertices[bound] - s_rad = SourceObj( - "rad", - points, - color="blue", - symbol="square", - radius_min=10) - visb_sc4.add_to_subplot(s_rad) - lines = Line(pos=cuted_mesh.vertices[bound], width=10, color="r") - # wrap the vispy object using visbrain - l_obj = VispyObj("line", lines) - visb_sc4.add_to_subplot(l_obj) -visb_sc4.preview() -############################################################################### -# show the closed mesh -visb_sc5 = splt.visbrain_plot(mesh=mesh_closed, caption="closed mesh") -visb_sc5.preview() -""" +# import slam.plot as splt +# from vispy.scene import Line +# from visbrain.objects import VispyObj, SourceObj +# +# ############################################################################### +# # show the result +# # WARNING : BrainObj should be added first before +# visb_sc = splt.visbrain_plot(mesh=open_mesh, caption="open mesh") +# # create points with vispy +# for bound in open_mesh_boundary: +# points = open_mesh.vertices[bound] +# s_rad = SourceObj( +# "rad", +# points, +# color="red", +# symbol="square", +# radius_min=10) +# visb_sc.add_to_subplot(s_rad) +# lines = Line(pos=open_mesh.vertices[bound], width=10, color="b") +# # wrap the vispy object using visbrain +# l_obj = VispyObj("line", lines) +# visb_sc.add_to_subplot(l_obj) +# visb_sc.preview() +# +# ############################################################################### +# # show the result +# visb_sc2 = splt.visbrain_plot(mesh=eroded_mesh, caption="eroded mesh") +# # show again the boundary of original mesh which have been removed with +# # corresponding faces by the erosion +# for bound in open_mesh_boundary: +# points = open_mesh.vertices[bound] +# s_rad = SourceObj( +# "rad", +# points, +# color="red", +# symbol="square", +# radius_min=10) +# visb_sc2.add_to_subplot(s_rad) +# lines = Line(pos=open_mesh.vertices[bound], width=10, color="b") +# # wrap the vispy object using visbrain +# l_obj = VispyObj("line", lines) +# visb_sc2.add_to_subplot(l_obj) +# visb_sc2.preview() +# +# ############################################################################### +# # show the results +# visb_sc3 = splt.visbrain_plot( +# mesh=mesh, tex=tex_parcel.darray[0], caption="texture boundary" +# ) +# cols = ["red", "green", "yellow", "blue"] +# ind = 0 +# for bound in texture_bound: +# points = mesh.vertices[bound] +# s_rad = SourceObj( +# "rad", +# points, +# color="red", +# symbol="square", +# radius_min=10) +# visb_sc3.add_to_subplot(s_rad) +# lines = Line(pos=mesh.vertices[bound], width=10, color=cols[ind]) +# # wrap the vispy object using visbrain +# l_obj = VispyObj("line", lines) +# visb_sc3.add_to_subplot(l_obj) +# ind += 1 +# if ind == len(cols): +# ind = 0 +# visb_sc3.preview() +# +# ############################################################################### +# # show the mesh with the cuted subparts in different colors +# scene_list = list() +# cuted_mesh = sub_meshes[-1] +# joint_mesh = sub_meshes[0] +# joint_tex = np.zeros((sub_meshes[0].vertices.shape[0],)) +# last_ind = sub_meshes[0].vertices.shape[0] +# for ind, sub_mesh in enumerate(sub_meshes[1:]): +# sub_tex = np.ones((sub_mesh.vertices.shape[0],)) * (ind + 1) +# joint_mesh += sub_mesh +# joint_tex = np.hstack((joint_tex, sub_tex)) +# visb_sc3 = splt.visbrain_plot( +# mesh=joint_mesh, +# tex=joint_tex, +# caption="mesh parts shown in different colors" +# ) +# ind = 0 +# boundaries = stop.mesh_boundary(cuted_mesh) +# for bound in boundaries: +# s_rad = SourceObj( +# "rad", +# cuted_mesh.vertices[bound], +# color=cols[ind], +# symbol="square", +# radius_min=10, +# ) +# visb_sc3.add_to_subplot(s_rad) +# lines = Line(pos=cuted_mesh.vertices[bound], color=cols[ind], width=10) +# # wrap the vispy object using visbrain +# l_obj = VispyObj("line", lines) +# visb_sc3.add_to_subplot(l_obj) +# ind += 1 +# if ind == len(cols): +# ind = 0 +# visb_sc3.preview() +# ############################################################################### +# # show the largest submesh with the boundaries of cutted parts +# visb_sc4 = splt.visbrain_plot(mesh=cuted_mesh, caption="open mesh") +# # create points with vispy +# for bound in boundaries: +# points = cuted_mesh.vertices[bound] +# s_rad = SourceObj( +# "rad", +# points, +# color="blue", +# symbol="square", +# radius_min=10) +# visb_sc4.add_to_subplot(s_rad) +# lines = Line(pos=cuted_mesh.vertices[bound], width=10, color="r") +# # wrap the vispy object using visbrain +# l_obj = VispyObj("line", lines) +# visb_sc4.add_to_subplot(l_obj) +# visb_sc4.preview() +# ############################################################################### +# # show the closed mesh +# visb_sc5 = splt.visbrain_plot(mesh=mesh_closed, caption="closed mesh") +# visb_sc5.preview() diff --git a/examples/example_vertex_voronoi.py b/examples/example_vertex_voronoi.py index 9f7079b..804ec45 100644 --- a/examples/example_vertex_voronoi.py +++ b/examples/example_vertex_voronoi.py @@ -27,7 +27,7 @@ ############################################################################### -mesh = sio.load_mesh("examples/data/example_mesh.gii") +mesh = sio.load_mesh("../examples/data/example_mesh.gii") mesh.apply_transform(mesh.principal_inertia_transform) ###############################################################################