Skip to content

Commit

Permalink
Merge pull request #42 from brainglobe/class-capitalise
Browse files Browse the repository at this point in the history
Small formatting fixes
  • Loading branch information
alessandrofelder authored May 21, 2024
2 parents 55a698b + 18b0f2b commit a2d04d6
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 54 deletions.
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
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 @@ def check_values(values: dict, atlas: Atlas) -> Tuple[float, float]:
return vmax, vmin


class heatmap:
class Heatmap:
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
from brainglobe_heatmap.plane import Plane

settings.BACKGROUND_COLOR = amber_lighter
Expand Down Expand Up @@ -47,7 +47,7 @@ def fmt_array(x: np.ndarray) -> str:
)


class plan(heatmap):
class plan(Heatmap):
def __init__(
self,
regions: Union[dict, list],
Expand Down Expand Up @@ -116,38 +116,3 @@ def show(self):

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 @@ def slice_scene(self, scene: Scene, regions: List[Actor]):
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)):
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

0 comments on commit a2d04d6

Please sign in to comment.