From 4c3c95fa6e0a5dbb3ea2ab90056ba7f7520b79e7 Mon Sep 17 00:00:00 2001 From: Alexis Thual Date: Sun, 12 Mar 2023 15:41:32 +0100 Subject: [PATCH] Save computed mapping in example --- .gitignore | 4 +++- .../plot_1_aligning_brain_dense.py | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 4d16c49..ef9f2dc 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,6 @@ doc/auto_examples doc/gen_modules doc/generated doc/modules/generated -.vscode \ No newline at end of file +.vscode + +examples/**/*.pkl \ No newline at end of file diff --git a/examples/01_brain_alignment/plot_1_aligning_brain_dense.py b/examples/01_brain_alignment/plot_1_aligning_brain_dense.py index 646888d..f99e16f 100644 --- a/examples/01_brain_alignment/plot_1_aligning_brain_dense.py +++ b/examples/01_brain_alignment/plot_1_aligning_brain_dense.py @@ -7,8 +7,9 @@ In this example, we align 2 low-resolution left hemispheres using 4 fMRI feature maps (z-score contrast maps). """ - # sphinx_gallery_thumbnail_number = 6 +import pickle + import gdist import matplotlib as mpl import matplotlib.gridspec as gridspec @@ -299,6 +300,17 @@ def compute_geometry_from_mesh(mesh_path): verbose=True, ) +# %% +# Computed mappings can easily be saved on disk and loaded back: + +# Save mappings +with open("./mapping.pkl", "wb") as f: + pickle.dump(mapping, f) + +# Load mappings +with open("./mapping.pkl", "rb") as f: + mapping = pickle.load(f) + # %% # Here is the evolution of the FUGW loss during training, # without the entropic term. Note how, in this case,