From 122c4f1d6a5fe14962fbf6eae491579ef53e6a5a Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 12 Sep 2024 09:43:14 +0100 Subject: [PATCH 1/4] update description to reflect new brainmapper widget --- examples/brainmapper.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/brainmapper.py b/examples/brainmapper.py index c8891a00..6880d650 100644 --- a/examples/brainmapper.py +++ b/examples/brainmapper.py @@ -1,9 +1,13 @@ """ -Visualise the output from brainmapper. Cells transformed to atlas space can -be found at brainmapper_output/points/points.npy. +Visualise the output from brainmapper. +Cells transformed to atlas space can be found at +brainmapper_output/points/points.npy or exported by the brainmapper +napari +widget For more details on brainmapper, please see: -https://brainglobe.info/documentation/brainglobe-workflows/brainmapper/index.html +- https://brainglobe.info/documentation/brainglobe-workflows/brainmapper/index.html +- https://brainglobe.info/documentation/brainglobe-utils/transform-widget.html """ from pathlib import Path From ca0fbc278f955ab1f8a4247d15dbe2577dbceb8f Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 12 Sep 2024 09:43:34 +0100 Subject: [PATCH 2/4] Add new example plotting cells from brainmapper only in specific regions --- examples/brainmapper_regions.py | 62 +++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 examples/brainmapper_regions.py diff --git a/examples/brainmapper_regions.py b/examples/brainmapper_regions.py new file mode 100644 index 00000000..e6809dd5 --- /dev/null +++ b/examples/brainmapper_regions.py @@ -0,0 +1,62 @@ +""" +Visualise the output from brainmapper in some specific brain regions. +Cells transformed to atlas space can be found at +brainmapper_output/points/points.npy or exported by the brainmapper napari +widget + +For more details on brainmapper, please see: +- https://brainglobe.info/documentation/brainglobe-workflows/brainmapper/index.html +- https://brainglobe.info/documentation/brainglobe-utils/transform-widget.html +""" + +from pathlib import Path + +from myterial import orange +from rich import print + +from brainrender.scene import Scene +from brainrender.actors import Points +from brainrender import settings + +import numpy as np +settings.SHADER_STYLE = "plastic" +settings.SHOW_AXES = False + +cells_path = Path(__file__).parent.parent / "resources" / "points.npy" + +# Define regions of interest (easier to define all at the +# terminal/finest level of the hierarchy) +regions = ["VISp1", "VISp4", "VISp5"] + +print(f"[{orange}]Running example: {Path(__file__).name}") + +def get_cells_in_regions(scene, cells_path, regions): + cells = np.load(cells_path) + new_cells = [] + + + for cell in cells: + if scene.atlas.structure_from_coords(cell, as_acronym=True, microns=True) in regions: + if cell[0] > 0: + new_cells.append(cell) + + new_cells = np.asarray(new_cells) + + return new_cells + +# Create a brainrender scene +scene = Scene(title=f"brainmapper cells in {regions}", inset=False) + +cells_points = get_cells_in_regions(scene, cells_path, regions) + +# Create points actor +cells = Points(cells_points, radius=45, colors="palegoldenrod", alpha=0.8) + +# Add specific regions +for region in regions: + scene.add_brain_region(region, color="mediumseagreen", alpha=0.2) + +# Add cells +scene.add(cells) + +scene.render() From c0a521b3bc04a2a030adfe3f68f3ef3fcdb49d8a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 08:44:52 +0000 Subject: [PATCH 3/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- examples/brainmapper_regions.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/brainmapper_regions.py b/examples/brainmapper_regions.py index e6809dd5..f8528389 100644 --- a/examples/brainmapper_regions.py +++ b/examples/brainmapper_regions.py @@ -19,6 +19,7 @@ from brainrender import settings import numpy as np + settings.SHADER_STYLE = "plastic" settings.SHOW_AXES = False @@ -30,13 +31,18 @@ print(f"[{orange}]Running example: {Path(__file__).name}") + def get_cells_in_regions(scene, cells_path, regions): cells = np.load(cells_path) new_cells = [] - for cell in cells: - if scene.atlas.structure_from_coords(cell, as_acronym=True, microns=True) in regions: + if ( + scene.atlas.structure_from_coords( + cell, as_acronym=True, microns=True + ) + in regions + ): if cell[0] > 0: new_cells.append(cell) @@ -44,6 +50,7 @@ def get_cells_in_regions(scene, cells_path, regions): return new_cells + # Create a brainrender scene scene = Scene(title=f"brainmapper cells in {regions}", inset=False) From 2ca5a9cf626b13795ba8c63b6ccbfbddd8a70f68 Mon Sep 17 00:00:00 2001 From: Adam Tyson Date: Thu, 12 Sep 2024 10:27:17 +0100 Subject: [PATCH 4/4] Update examples/brainmapper.py Co-authored-by: Igor Tatarnikov <61896994+IgorTatarnikov@users.noreply.github.com> --- examples/brainmapper.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/brainmapper.py b/examples/brainmapper.py index 6880d650..376a401b 100644 --- a/examples/brainmapper.py +++ b/examples/brainmapper.py @@ -2,8 +2,7 @@ Visualise the output from brainmapper. Cells transformed to atlas space can be found at brainmapper_output/points/points.npy or exported by the brainmapper -napari -widget +napari widget For more details on brainmapper, please see: - https://brainglobe.info/documentation/brainglobe-workflows/brainmapper/index.html