brainglobe / brainglobe-heatmap

Rendering anatomical heatmaps with brainrender and matplotlib
https://brainglobe.info
MIT License
34 stars 10 forks source link

Separating slicing from plotting #3

Closed vigji closed 2 years ago

vigji commented 2 years ago

I'm checking out the API of the package, and I see that at the moment a single class heatmap (I'd suggest renaming to Heatmap) is taking care of both the slicing and the plotting. In this way there's no easy way for the user to just use the package to get a plottable slice, and not use the default matplotlib visualisation.

I would suggest conceptually splitting the slicing from the plotting. Maybe there could be a Slicer class, that performs what now is in self.slice() and can be used to just return the coordinates to be plot, and a Heatmap class with the features of the current one?

FedeClaudi commented 2 years ago

Done, have a look!

FedeClaudi commented 2 years ago

You can now use this code just to get the coordinates in the 2D plane:


regions = ['TH', 'RSP', 'AI', 'SS', 'MO', 'PVZ', 'LZ', 'VIS', 'AUD', 'RHP', 'STR', 'CB', 'FRP', 'HIP', 'PA']

coordinates = bgh.get_plane_coordinates(
    regions,
    position=(
        8000,
        5000,
        5000,
    ),  # displacement along the AP axis relative to midpoint
    orientation="frontal",  # 'frontal' or 'sagittal', or 'top' or a tuple (x,y,z)
)

Should it return the coordinates in 3D space as well?

vigji commented 2 years ago

awesome! No, would no really see now an application for that.

If I can just suggest a naming change, bgh.get_plane_coordinates feels like you're getting the coordinates that define the plane. Maybe Something along the lines of get_slice_coordinates or slice_structures or get_structures_slice_coords?

FedeClaudi commented 2 years ago

Fair, done