Skip to main content

Plotting functions for hippocampal surface maps from HippUnfold

Project description

🧠 hippunfold_surf

This package provides plotting functions for hippocampal surface maps from HippUnfold (https://github.com/khanlab/hippunfold), wrapping the Nilearn (https://nilearn.github.io) plotting functions (matplotlib engine) to achieve this.

Note: these plotting functions are distinct from those in HippoMaps (https://github.com/MICA-MNI/hippomaps), which use VTK wrappers and have a number of limitations therein.

This package is new and still under active development so suggestions and pull-requests are welcome!

📦 Installation

To install the package, simply run:

pip install hippunfold_plot

🚀 Usage

Here are some examples of how to use the plot_hipp_surf function to visualize hippocampal surface maps.

Example 1: Plot Both Hemispheres

from hippunfold_plot.plotting import plot_hipp_surf
from hippunfold_plot.utils import get_resource_path

#get subfields for demonstrating plotting
label_gii = get_resource_path('tpl-avg_label-hippdentate_density-{density}_subfields.label.gii')
density = '1mm'

# Plot dorsal view
fig = plot_hipp_surf(label_gii.format(density=density), hemi=None, density=density, view='dorsal')

# Plot ventral view
fig = plot_hipp_surf(label_gii.format(density=density), hemi=None, density=density, view='ventral')

png png

Example 2: Plot Left and Right Hemispheres Separately

from hippunfold_plot.plotting import plot_hipp_surf
from hippunfold_plot.utils import get_resource_path

#get subfields for demonstrating plotting
label_gii = get_resource_path('tpl-avg_label-hippdentate_density-{density}_subfields.label.gii')
density = '1mm'

# Plot left hemisphere
fig = plot_hipp_surf(label_gii.format(density=density), hemi='left', density=density, view='dorsal')

# Plot right hemisphere
fig = plot_hipp_surf(label_gii.format(density=density), hemi='right', density=density, view='dorsal')

png png

Example 3: Plot unfolded and canonical space separately

from hippunfold_plot.plotting import plot_hipp_surf
from hippunfold_plot.utils import get_resource_path

#get subfields for demonstrating plotting
label_gii = get_resource_path('tpl-avg_label-hippdentate_density-{density}_subfields.label.gii')
density = '1mm'

# Plot left hemisphere in unfolded space
fig = plot_hipp_surf(label_gii.format(density=density), space='unfold', density=density, view='dorsal')

# Plot left hemisphere in canonical space
fig = plot_hipp_surf(label_gii.format(density=density), space='canonical', density=density, view='dorsal')

png png

🛠️ Functions

plot_hipp_surf

def plot_hipp_surf(surf_map: Union[str, list], 
                   density: str = '0p5mm', 
                   hemi: str = 'left', 
                   space: Optional[str] = None, 
                   figsize: Tuple[int, int] = (12, 8), 
                   dpi: int = 300, 
                   vmin: Optional[float] = None, 
                   vmax: Optional[float] = None, 
                   colorbar: bool = False, 
                   colorbar_shrink: float = 0.25, 
                   cmap: Optional[Union[str, plt.cm.ScalarMappable]] = None, 
                   view: str = 'dorsal', 
                   avg_method: str = 'median', 
                   bg_on_data: bool = True, 
                   alpha: float = 0.1, 
                   darkness: float = 2, 
                   **kwargs) -> plt.Figure:
    """
    This function plots a surface map of the hippocampus, which can be a label-hippdentate shape.gii, func.gii, or a Vx1 array 
    (where V is the number of vertices in the hippocampus and dentate). Any arguments that can be supplied to nilearn's plot_surf() 
    can also be applied here, overriding the defaults set below.    """

🧪 Testing

To run the tests, including unit tests and docstring tests, use the following command:

python -m unittest discover -s . -p "test_*.py"

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

🙌 Contributing

We welcome contributions! Please see our CONTRIBUTING guidelines for more details.

📞 Contact

If you have any questions or feedback, feel free to reach out or post an issue!


Happy plotting! 🎉

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hippunfold_plot-0.1.0.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hippunfold_plot-0.1.0-py3-none-any.whl (2.3 MB view details)

Uploaded Python 3

File details

Details for the file hippunfold_plot-0.1.0.tar.gz.

File metadata

  • Download URL: hippunfold_plot-0.1.0.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.1

File hashes

Hashes for hippunfold_plot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cbc80d9250b812b7deff61f37326c50e033239e65d12681e50c88fb5ba469706
MD5 13e6672dcb7ca9392874fa6677676653
BLAKE2b-256 9a6df7eaeddd4c10d35dd043259ebd5a65af8046c6fb49e9d47e5219a0b64240

See more details on using hashes here.

File details

Details for the file hippunfold_plot-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hippunfold_plot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97b66745fb99cb36205b53f43229ddb0017abc62b8b95b2a6dab69a6721bd90c
MD5 f09dce9f1f2479449f987b648ece60af
BLAKE2b-256 83f75e9ffceef0b11a4f0f5e98afddf8e739c918e7ff7efbc1339fb8b3e567a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page