bsplot 0.0.10__tar.gz → 0.0.11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bsplot-0.0.10 → bsplot-0.0.11}/MANIFEST.in +6 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/PKG-INFO +15 -3
- {bsplot-0.0.10 → bsplot-0.0.11}/README.md +11 -1
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/__init__.py +1 -1
- bsplot-0.0.11/bsplot/_glass_brain.py +151 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/brain.py +12 -9
- bsplot-0.0.11/bsplot/data/glass_brain/NILEARN_LICENSE +26 -0
- bsplot-0.0.11/bsplot/data/glass_brain/README.md +34 -0
- bsplot-0.0.11/bsplot/data/glass_brain/brain_schematics_back.json +5626 -0
- bsplot-0.0.11/bsplot/data/glass_brain/brain_schematics_side.json +3565 -0
- bsplot-0.0.11/bsplot/data/glass_brain/brain_schematics_top.json +7339 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/data/surface.py +57 -1
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/surface.py +9 -1
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/volume.py +40 -6
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot.egg-info/SOURCES.txt +8 -1
- {bsplot-0.0.10 → bsplot-0.0.11}/pyproject.toml +8 -1
- bsplot-0.0.11/tests/test_nilearn_free.py +273 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/LICENSE +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/anat.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/animate.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/ascii.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/ascii_movie.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/bioicons.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/colors.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/data/HCP_avg-SC.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/data/MNI152.rh.pial +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/data/STN_lh.nii.gz +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/data/STN_rh.nii.gz +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/data/__init__.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/data/parcellations/HCP-MMP1.L.label.gii +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/data/parcellations/HCP-MMP1.R.label.gii +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/figure.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/graph/__init__.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/graph/edges.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/graph/flowchart.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/graph/layout.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/graph/network.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/graph/nodes.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/panels.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/__init__.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/_sync_from_zenodo_download.sh +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/batlowK.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/batlowW.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/cyclic/bamO.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/cyclic/brocO.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/cyclic/corkO.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/cyclic/romaO.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/cyclic/vikO.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/diverging/bam.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/diverging/berlin.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/diverging/broc.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/diverging/cork.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/diverging/lisbon.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/diverging/managua.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/diverging/roma.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/diverging/tofino.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/diverging/vanimo.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/diverging/vik.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/multisequential/bukavu.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/multisequential/fes.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/multisequential/oleron.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/naviaW.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/acton.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/bamako.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/batlow.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/bilbao.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/buda.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/davos.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/devon.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/glasgow.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/grayC.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/hawaii.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/imola.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/lajolla.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/lapaz.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/lipari.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/navia.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/nuuk.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/oslo.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/tokyo.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/scientific_color_maps/sequential/turku.txt +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/streamlines.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/style.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/styles/black.mplstyle +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/styles/bss.mplstyle +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/styles/bwcomp.mplstyle +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/styles/nature.mplstyle +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/styles/template.mplstyle +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/styles/transparent.mplstyle +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/styles/tvbo.mplstyle +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/styles/white.mplstyle +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/templates.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/text.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/text2obj.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/timeseries.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/bsplot/utils.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/setup.cfg +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/tests/test_ascii.py +0 -0
- {bsplot-0.0.10 → bsplot-0.0.11}/tests/test_ascii_movie.py +0 -0
|
@@ -8,6 +8,12 @@ include bsplot/data/HCP_avg-SC.txt
|
|
|
8
8
|
include bsplot/data/MNI152.rh.pial
|
|
9
9
|
include bsplot/data/parcellations/HCP-MMP1.L.label.gii
|
|
10
10
|
include bsplot/data/parcellations/HCP-MMP1.R.label.gii
|
|
11
|
+
# Glass-brain schematics vendored from nilearn (BSD-3-Clause). The JSON data
|
|
12
|
+
# AND the NILEARN_LICENSE must ship with the source distribution to satisfy the
|
|
13
|
+
# BSD licence's source-redistribution clause.
|
|
14
|
+
recursive-include bsplot/data/glass_brain *.json
|
|
15
|
+
include bsplot/data/glass_brain/NILEARN_LICENSE
|
|
16
|
+
include bsplot/data/glass_brain/README.md
|
|
11
17
|
recursive-include bsplot/scientific_color_maps *
|
|
12
18
|
|
|
13
19
|
prune docs
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bsplot
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.11
|
|
4
4
|
Summary: Plotting utilities for neuroscience: styles, palettes, surfaces, glass-brain, and panel helpers.
|
|
5
5
|
License-Expression: EUPL-1.2
|
|
6
6
|
Project-URL: Repository, https://github.com/leon-k-martin/bsplot
|
|
@@ -11,8 +11,8 @@ Requires-Dist: matplotlib
|
|
|
11
11
|
Requires-Dist: pybtex
|
|
12
12
|
Requires-Dist: pyaml
|
|
13
13
|
Requires-Dist: scikit-image
|
|
14
|
+
Requires-Dist: scipy
|
|
14
15
|
Requires-Dist: nibabel
|
|
15
|
-
Requires-Dist: nilearn
|
|
16
16
|
Requires-Dist: templateflow
|
|
17
17
|
Requires-Dist: graphviz
|
|
18
18
|
Requires-Dist: cmap
|
|
@@ -22,6 +22,8 @@ Requires-Dist: quartodoc; extra == "docs"
|
|
|
22
22
|
Requires-Dist: griffe<1.0; extra == "docs"
|
|
23
23
|
Requires-Dist: jupyter-cache; extra == "docs"
|
|
24
24
|
Requires-Dist: cairosvg; extra == "docs"
|
|
25
|
+
Provides-Extra: projection
|
|
26
|
+
Requires-Dist: nilearn; extra == "projection"
|
|
25
27
|
Provides-Extra: tvbo
|
|
26
28
|
Requires-Dist: xarray; extra == "tvbo"
|
|
27
29
|
Requires-Dist: h5netcdf; extra == "tvbo"
|
|
@@ -109,11 +111,21 @@ Reading tvbo result files needs `pip install "bsplot[tvbo]"`.
|
|
|
109
111
|
pip install bsplot
|
|
110
112
|
```
|
|
111
113
|
|
|
114
|
+
Two optional features — volume-to-surface projection (`project_vol_to_surf`)
|
|
115
|
+
and fsaverage cortical flatmaps (`get_flat_surface_geometry`) — additionally
|
|
116
|
+
need `nilearn`:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
pip install "bsplot[projection]"
|
|
120
|
+
```
|
|
121
|
+
|
|
112
122
|
## Dependencies
|
|
113
123
|
|
|
114
124
|
- `matplotlib`
|
|
115
125
|
- `nibabel`
|
|
116
|
-
- `
|
|
126
|
+
- `scipy`
|
|
117
127
|
- `templateflow`
|
|
118
128
|
- `scikit-image`
|
|
129
|
+
- `nilearn` — optional, only for `project_vol_to_surf` and cortical flatmaps
|
|
130
|
+
(`pip install "bsplot[projection]"`)
|
|
119
131
|
|
|
@@ -79,11 +79,21 @@ Reading tvbo result files needs `pip install "bsplot[tvbo]"`.
|
|
|
79
79
|
pip install bsplot
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
+
Two optional features — volume-to-surface projection (`project_vol_to_surf`)
|
|
83
|
+
and fsaverage cortical flatmaps (`get_flat_surface_geometry`) — additionally
|
|
84
|
+
need `nilearn`:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pip install "bsplot[projection]"
|
|
88
|
+
```
|
|
89
|
+
|
|
82
90
|
## Dependencies
|
|
83
91
|
|
|
84
92
|
- `matplotlib`
|
|
85
93
|
- `nibabel`
|
|
86
|
-
- `
|
|
94
|
+
- `scipy`
|
|
87
95
|
- `templateflow`
|
|
88
96
|
- `scikit-image`
|
|
97
|
+
- `nilearn` — optional, only for `project_vol_to_surf` and cortical flatmaps
|
|
98
|
+
(`pip install "bsplot[projection]"`)
|
|
89
99
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Copyright © Charité Universitätsmedizin Berlin. This software is licensed under the terms of the European Union Public Licence (EUPL) version 1.2 or later.
|
|
2
2
|
from os.path import abspath, dirname, join
|
|
3
3
|
|
|
4
|
-
__version__ = "0.0.
|
|
4
|
+
__version__ = "0.0.11"
|
|
5
5
|
|
|
6
6
|
ROOT = abspath(dirname(__file__))
|
|
7
7
|
datadir = join(ROOT, "data")
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Copyright © Charité Universitätsmedizin Berlin. This software is licensed under
|
|
2
|
+
# the terms of the European Union Public Licence (EUPL) version 1.2 or later.
|
|
3
|
+
#
|
|
4
|
+
# ---------------------------------------------------------------------------
|
|
5
|
+
# Third-party attribution (BSD-3-Clause)
|
|
6
|
+
#
|
|
7
|
+
# This module and the brain-schematic data files in ``bsplot/data/glass_brain/``
|
|
8
|
+
# are derived from nilearn 0.13.1 (https://github.com/nilearn/nilearn):
|
|
9
|
+
# * code: ``nilearn/plotting/glass_brain.py`` — the helpers ``_codes*``,
|
|
10
|
+
# ``_invert_color``, ``_get_mpl_patches`` and
|
|
11
|
+
# ``_get_json_and_transform`` below are adapted from it;
|
|
12
|
+
# * data: ``nilearn/plotting/glass_brain_files/brain_schematics_{side,back,
|
|
13
|
+
# top}.json`` — redistributed byte-for-byte unmodified.
|
|
14
|
+
#
|
|
15
|
+
# nilearn is distributed under the BSD 3-Clause License:
|
|
16
|
+
#
|
|
17
|
+
# Copyright (c) The nilearn developers.
|
|
18
|
+
# All rights reserved.
|
|
19
|
+
#
|
|
20
|
+
# The BSD 3-Clause conditions and disclaimer are reproduced verbatim in
|
|
21
|
+
# ``bsplot/data/glass_brain/NILEARN_LICENSE`` and retained here as that licence
|
|
22
|
+
# requires. Vendoring lets bsplot draw glass-brain outlines without depending on
|
|
23
|
+
# nilearn (whose private API previously supplied them).
|
|
24
|
+
# ---------------------------------------------------------------------------
|
|
25
|
+
"""Vendored glass-brain schematic outlines (adapted from nilearn, BSD-3-Clause).
|
|
26
|
+
|
|
27
|
+
Provides drop-in replacements for the private ``nilearn.plotting.glass_brain``
|
|
28
|
+
functions that ``bsplot.volume.plot_brain_schematics`` relied on:
|
|
29
|
+
``_get_json_and_transform`` and ``_get_mpl_patches``.
|
|
30
|
+
"""
|
|
31
|
+
import pathlib
|
|
32
|
+
|
|
33
|
+
from matplotlib import colors, patches, transforms
|
|
34
|
+
from matplotlib.path import Path
|
|
35
|
+
|
|
36
|
+
# Directory holding the vendored ``brain_schematics_*.json`` files.
|
|
37
|
+
_FILES_DIR = pathlib.Path(__file__).resolve().parent / "data" / "glass_brain"
|
|
38
|
+
|
|
39
|
+
# Only the views used by bsplot are vendored (sagittal/coronal/horizontal ->
|
|
40
|
+
# x/y/z -> side/back/top). ``l``/``r`` map to the side view, mirroring nilearn.
|
|
41
|
+
_DIRECTION_TO_VIEW_NAME = {
|
|
42
|
+
"x": "side",
|
|
43
|
+
"y": "back",
|
|
44
|
+
"z": "top",
|
|
45
|
+
"l": "side",
|
|
46
|
+
"r": "side",
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# Affine parameters hand-tuned by nilearn to align each schematic with the MNI
|
|
50
|
+
# template, in matplotlib ``Affine2D.from_values`` order (a, b, c, d, e, f).
|
|
51
|
+
_DIRECTION_TO_TRANSFORM_PARAMS = {
|
|
52
|
+
"x": [0.38, 0, 0, 0.38, -108, -70],
|
|
53
|
+
"y": [0.39, 0, 0, 0.39, -73, -73],
|
|
54
|
+
"z": [0.36, 0, 0, 0.37, -71, -107],
|
|
55
|
+
"l": [0.38, 0, 0, 0.38, -108, -70],
|
|
56
|
+
"r": [0.38, 0, 0, 0.38, -108, -70],
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _codes_bezier(pts):
|
|
61
|
+
bezier_num = len(pts)
|
|
62
|
+
# Next two lines are meant to handle both Bezier 3 and 4
|
|
63
|
+
path_attr = f"CURVE{bezier_num}"
|
|
64
|
+
codes = [getattr(Path, path_attr)] * (bezier_num - 1)
|
|
65
|
+
return [Path.MOVETO, *codes]
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def _codes_segment(pts):
|
|
69
|
+
# pts is accepted for API consistency with _codes_bezier
|
|
70
|
+
return [Path.MOVETO, Path.LINETO]
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def _codes(atype, pts):
|
|
74
|
+
dispatch = {"bezier": _codes_bezier, "segment": _codes_segment}
|
|
75
|
+
return dispatch[atype](pts)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _invert_color(color):
|
|
79
|
+
"""Return inverted color.
|
|
80
|
+
|
|
81
|
+
If ``color`` is (R, G, B) it returns (1 - R, 1 - G, 1 - B). If ``color``
|
|
82
|
+
cannot be converted to a color it is returned unmodified.
|
|
83
|
+
"""
|
|
84
|
+
try:
|
|
85
|
+
color_converter = colors.ColorConverter()
|
|
86
|
+
color_rgb = color_converter.to_rgb(color)
|
|
87
|
+
return tuple(1 - level for level in color_rgb)
|
|
88
|
+
except ValueError:
|
|
89
|
+
return color
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _get_mpl_patches(json_content, transform=None, invert_color=False, **kwargs):
|
|
93
|
+
"""Walk over the json content and build a list of matplotlib patches."""
|
|
94
|
+
mpl_patches = []
|
|
95
|
+
kwargs_edgecolor = kwargs.pop("edgecolor", None)
|
|
96
|
+
kwargs_linewidth = kwargs.pop("linewidth", None)
|
|
97
|
+
for path in json_content["paths"]:
|
|
98
|
+
if kwargs_edgecolor is not None:
|
|
99
|
+
edgecolor = kwargs_edgecolor
|
|
100
|
+
else:
|
|
101
|
+
edgecolor = path["edgecolor"]
|
|
102
|
+
if invert_color:
|
|
103
|
+
edgecolor = _invert_color(edgecolor)
|
|
104
|
+
linewidth = kwargs_linewidth or path["linewidth"]
|
|
105
|
+
path_id = path["id"]
|
|
106
|
+
|
|
107
|
+
for item in path["items"]:
|
|
108
|
+
type = item["type"]
|
|
109
|
+
pts = item["pts"]
|
|
110
|
+
codes = _codes(type, pts)
|
|
111
|
+
path = Path(pts, codes)
|
|
112
|
+
patch = patches.PathPatch(
|
|
113
|
+
path,
|
|
114
|
+
edgecolor=edgecolor,
|
|
115
|
+
linewidth=linewidth,
|
|
116
|
+
facecolor="none",
|
|
117
|
+
gid=path_id,
|
|
118
|
+
transform=transform,
|
|
119
|
+
**kwargs,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
mpl_patches.append(patch)
|
|
123
|
+
|
|
124
|
+
return mpl_patches
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _get_json_and_transform(direction):
|
|
128
|
+
"""Return the vendored json path and its hand-tuned MNI affine transform.
|
|
129
|
+
|
|
130
|
+
Parameters
|
|
131
|
+
----------
|
|
132
|
+
direction : {'x', 'y', 'z', 'l', 'r'}
|
|
133
|
+
Viewing direction. ``x``/``l``/``r`` -> side, ``y`` -> back,
|
|
134
|
+
``z`` -> top.
|
|
135
|
+
|
|
136
|
+
Returns
|
|
137
|
+
-------
|
|
138
|
+
(pathlib.Path, matplotlib.transforms.Affine2D)
|
|
139
|
+
"""
|
|
140
|
+
view_name = _DIRECTION_TO_VIEW_NAME.get(direction)
|
|
141
|
+
if view_name is None:
|
|
142
|
+
raise ValueError(
|
|
143
|
+
f"No glass brain view associated with direction '{direction}'. "
|
|
144
|
+
f"Possible directions are {list(_DIRECTION_TO_VIEW_NAME)}."
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
json_filename = _FILES_DIR / f"brain_schematics_{view_name}.json"
|
|
148
|
+
transform = transforms.Affine2D.from_values(
|
|
149
|
+
*_DIRECTION_TO_TRANSFORM_PARAMS[direction]
|
|
150
|
+
)
|
|
151
|
+
return json_filename, transform
|
|
@@ -4,7 +4,6 @@ import inspect
|
|
|
4
4
|
|
|
5
5
|
import matplotlib.pyplot as plt
|
|
6
6
|
import numpy as np
|
|
7
|
-
from nilearn import surface
|
|
8
7
|
|
|
9
8
|
from bsplot import anat, data
|
|
10
9
|
|
|
@@ -124,22 +123,26 @@ def glass_brain_3d(img, ax=None, surf="fsaverage", cmap="viridis", brain_color="
|
|
|
124
123
|
img_data = img.get_fdata()
|
|
125
124
|
|
|
126
125
|
if surf == "fsaverage":
|
|
127
|
-
|
|
128
|
-
# mesh = surface.load_surf_mesh(fsaverage.pial_right)
|
|
129
|
-
mesh = surface.load_surf_mesh(
|
|
126
|
+
mesh = data.surface.load_mesh(
|
|
130
127
|
data.surface.get_surface_geometry(
|
|
131
128
|
template="fsaverage", hemi="rh", suffix="pial", density="10k"
|
|
132
129
|
)
|
|
133
130
|
)
|
|
134
131
|
linewidth = 0.1
|
|
135
132
|
elif surf == "mni09c":
|
|
136
|
-
mesh = surface.
|
|
133
|
+
mesh = data.surface.load_mesh(join(data.surface.root, "MNI152.rh.pial"))
|
|
137
134
|
linewidth = 0.05
|
|
135
|
+
elif surf == "nilearn":
|
|
136
|
+
# No schematic mesh outline; render only the intensity projection.
|
|
137
|
+
mesh = None
|
|
138
|
+
else:
|
|
139
|
+
raise ValueError(
|
|
140
|
+
f"Unknown surf '{surf}'. Expected 'fsaverage', 'mni09c', or 'nilearn'."
|
|
141
|
+
)
|
|
138
142
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if surf != "nilearn":
|
|
143
|
+
if mesh is not None:
|
|
144
|
+
coords, faces = mesh[0], mesh[1]
|
|
145
|
+
x, y, z = coords.T
|
|
143
146
|
ax.triplot(
|
|
144
147
|
y, z, faces, color=brain_color, alpha=0.8, linewidth=linewidth, zorder=100
|
|
145
148
|
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Copyright (c) The nilearn developers.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions
|
|
6
|
+
are met:
|
|
7
|
+
1. Redistributions of source code must retain the above copyright
|
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
10
|
+
notice, this list of conditions and the following disclaimer in the
|
|
11
|
+
documentation and/or other materials provided with the distribution.
|
|
12
|
+
3. Neither the name of the University nor the names of its contributors
|
|
13
|
+
may be used to endorse or promote products derived from this software
|
|
14
|
+
without specific prior written permission.
|
|
15
|
+
|
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
17
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
18
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
19
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
20
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
21
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
22
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
23
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
24
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
25
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
26
|
+
SUCH DAMAGE.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Third-party data: glass-brain schematics (vendored from nilearn)
|
|
2
|
+
|
|
3
|
+
## Source / provenance
|
|
4
|
+
|
|
5
|
+
- **Project:** nilearn — <https://github.com/nilearn/nilearn>
|
|
6
|
+
- **Version:** 0.13.1
|
|
7
|
+
- **Upstream files:** `nilearn/plotting/glass_brain_files/brain_schematics_side.json`,
|
|
8
|
+
`…_back.json`, `…_top.json`
|
|
9
|
+
- **Copyright:** © The nilearn developers. All rights reserved.
|
|
10
|
+
- **Licence:** BSD 3-Clause — reproduced verbatim in `NILEARN_LICENSE` in this
|
|
11
|
+
directory.
|
|
12
|
+
|
|
13
|
+
## What these are and how they are used
|
|
14
|
+
|
|
15
|
+
`brain_schematics_{side,back,top}.json` describe the MNI152 brain outline drawn
|
|
16
|
+
by `bsplot.volume.plot_brain_schematics` (and hence `bsplot.brain.glass_brain`).
|
|
17
|
+
They are redistributed **byte-for-byte unmodified** from the upstream files
|
|
18
|
+
listed above.
|
|
19
|
+
|
|
20
|
+
The loader and patch-building code adapted from nilearn's `glass_brain.py` lives
|
|
21
|
+
in `bsplot/_glass_brain.py`, which retains the nilearn copyright notice as the
|
|
22
|
+
BSD 3-Clause licence requires.
|
|
23
|
+
|
|
24
|
+
## Licence compatibility
|
|
25
|
+
|
|
26
|
+
bsplot as a whole is licensed under the **EUPL-1.2**. The BSD 3-Clause licence
|
|
27
|
+
is a permissive licence whose only obligations are to retain the copyright
|
|
28
|
+
notice and the licence text (both done here, for source and binary
|
|
29
|
+
distributions). BSD-licensed material may be incorporated into and distributed
|
|
30
|
+
as part of an EUPL-licensed work; these specific files remain under their
|
|
31
|
+
original BSD 3-Clause terms.
|
|
32
|
+
|
|
33
|
+
This note is an honest description of provenance and licensing, not legal
|
|
34
|
+
advice. If in doubt, have the licensing reviewed by counsel.
|