Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small formatting fixes #42

Merged
merged 5 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ The position of the center of the plane is given by a set of `(x, y, z)` coordin
Whe using one of the named orientation, you don't need to pass a whole set of `(x, y, z)` coordinates for the plane center. A single value is sufficient as the other two won't affect the plane position:

```python
f = bgh.heatmap(
f = bgh.Heatmap(
values,
position=1000,
orientation="sagittal", # 'frontal' or 'sagittal', or 'horizontal' or a tuple (x,y,z)
orientation="sagittal",
# 'frontal' or 'sagittal', or 'horizontal' or a tuple (x,y,z)
thickness=1000,
atlas_name="allen_cord_20um",
format='2D',
Expand All @@ -83,11 +84,13 @@ f = bgh.heatmap(
```

Also, you can create a slice with a plane centered in the brain by passing `position=None`:

```python
f = bgh.heatmap(
f = bgh.Heatmap(
values,
position=None,
orientation="sagittal", # 'frontal' or 'sagittal', or 'horizontal' or a tuple (x,y,z)
orientation="sagittal",
# 'frontal' or 'sagittal', or 'horizontal' or a tuple (x,y,z)
thickness=1000,
atlas_name="mpin_zfish_1um",
format='2D',
Expand All @@ -100,14 +103,15 @@ Once happy with the position of the slicing planes, creating a visualization is

```python

bgh.heatmap(
bgh.Heatmap(
values,
position=(
8000,
5000,
5000,
),
orientation="horizontal", # 'frontal' or 'sagittal', or 'horizontal' or a tuple (x,y,z)
orientation="horizontal",
# 'frontal' or 'sagittal', or 'horizontal' or a tuple (x,y,z)
title="horizontal view",
vmin=-5,
vmax=3,
Expand Down
2 changes: 1 addition & 1 deletion brainglobe_heatmap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
# package is not installed
pass

from brainglobe_heatmap.heatmaps import heatmap
from brainglobe_heatmap.heatmaps import Heatmap

Check warning on line 9 in brainglobe_heatmap/__init__.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_heatmap/__init__.py#L9

Added line #L9 was not covered by tests
from brainglobe_heatmap.planner import plan
from brainglobe_heatmap.slicer import get_structures_slice_coords
2 changes: 1 addition & 1 deletion brainglobe_heatmap/heatmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
return vmax, vmin


class heatmap:
class Heatmap:

Check warning on line 51 in brainglobe_heatmap/heatmaps.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_heatmap/heatmaps.py#L51

Added line #L51 was not covered by tests
def __init__(
self,
values: Dict,
Expand Down
39 changes: 2 additions & 37 deletions brainglobe_heatmap/planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from rich.table import Table
from vedo import Arrow, Sphere

from brainglobe_heatmap.heatmaps import heatmap
from brainglobe_heatmap.heatmaps import Heatmap

Check warning on line 19 in brainglobe_heatmap/planner.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_heatmap/planner.py#L19

Added line #L19 was not covered by tests
from brainglobe_heatmap.plane import Plane

settings.BACKGROUND_COLOR = amber_lighter
Expand Down Expand Up @@ -47,7 +47,7 @@
)


class plan(heatmap):
class plan(Heatmap):

Check warning on line 50 in brainglobe_heatmap/planner.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_heatmap/planner.py#L50

Added line #L50 was not covered by tests
def __init__(
self,
regions: Union[dict, list],
Expand Down Expand Up @@ -116,38 +116,3 @@

self.scene.render(interactive=self.interactive, zoom=self.zoom)
return self.scene


if __name__ == "__main__":
regions = dict( # scalar values for each region
TH=1,
RSP=0.2,
AI=0.4,
SS=-3,
MO=2.6,
PVZ=-4,
LZ=-3,
VIS=2,
AUD=0.3,
RHP=-0.2,
STR=0.5,
CB=0.5,
FRP=-1.7,
HIP=3,
PA=-4,
)

plan(
regions,
# position of the center point of the plane
position=(
8000,
5000,
5000,
),
# or 'sagittal', or 'horizontal' or a tuple (x,y,z)
orientation="frontal",
# thickness of the slices used for rendering (in microns)
thickness=2000,
arrow_scale=750,
).show()
2 changes: 1 addition & 1 deletion brainglobe_heatmap/slicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
Slices the meshes in a 3D brainrender scene using the gien planes
"""
# slice the scene
for n, plane in enumerate((self.plane0, self.plane1)):
for _, plane in enumerate((self.plane0, self.plane1)):

Check warning on line 139 in brainglobe_heatmap/slicer.py

View check run for this annotation

Codecov / codecov/patch

brainglobe_heatmap/slicer.py#L139

Added line #L139 was not covered by tests
scene.slice(plane, actors=regions, close_actors=True)

scene.slice(self.plane0, actors=scene.root, close_actors=False)
Expand Down
8 changes: 6 additions & 2 deletions examples/cellfinder_cell_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
density (count/volume) of cells in each brain region
"""

from pathlib import Path

import pandas as pd
from brainglobe_atlasapi.bg_atlas import BrainGlobeAtlas
from brainrender._io import load_mesh_from_file

import brainglobe_heatmap as bgh

# get the number of cells for each region
data = pd.read_hdf("examples/cell_counts_example.h5")
cells_path = Path(__file__).parent / "cell_counts_example.h5"

data = pd.read_hdf(cells_path)
cell_counts = data.groupby("region").count()

# get regions two levels up the hierarchy
Expand Down Expand Up @@ -39,7 +43,7 @@
print(cell_counts)


f = bgh.heatmap(
f = bgh.Heatmap(
cell_counts.density.to_dict(),
position=(
8000,
Expand Down
2 changes: 1 addition & 1 deletion examples/heatmap_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)


f = bgh.heatmap(
f = bgh.Heatmap(
values,
# when using a named orientation, you can pass a single value!
position=5000,
Expand Down
2 changes: 1 addition & 1 deletion examples/heatmap_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)


scene = bgh.heatmap(
scene = bgh.Heatmap(
values,
position=(8000, 5000, 5000),
orientation="frontal", # or 'sagittal', or 'horizontal' or a tuple (x,y,z)
Expand Down
2 changes: 1 addition & 1 deletion examples/heatmap_human_brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
values = dict(SFG=1, PrCG=2, Ca=4, Pu=10) # scalar values for each region


scene = bgh.heatmap(
scene = bgh.Heatmap(
values,
position=(100000, 100000, 100000),
thickness=1000,
Expand Down
2 changes: 1 addition & 1 deletion examples/heatmap_spinal_cord.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}


f = bgh.heatmap(
f = bgh.Heatmap(
values,
position=1000,
# 'frontal' or 'sagittal', or 'horizontal' or a tuple (x,y,z)
Expand Down
2 changes: 1 addition & 1 deletion examples/heatmap_zebrafish.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"cerebellum": 0.5,
}

f = bgh.heatmap(
f = bgh.Heatmap(
values,
position=175,
# 'frontal' or 'sagittal', or 'horizontal' or a tuple (x,y,z)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ exclude = ["__init__.py", "build", ".eggs"]
fix = true

[tool.ruff.lint]
select = ["I", "E", "F"]
select = ["I", "E", "F", "B"]

[tool.tox]
legacy_tox_ini = """
Expand Down
Loading