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.1.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.1-py3-none-any.whl (2.4 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hippunfold_plot-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 a6d3966b06f412a3b46257f2d89d393910f51c53fd910ee7030f99e563c44db8
MD5 26147a2068f02892961755edcfa1c7e0
BLAKE2b-256 662315b438efe17aac6f699a4ea49fbc5da128d55c928aaa1f6fc453b0bbd5d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hippunfold_plot-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 41926650e363d4947e6aadcdbed6345ee98a58f215e4d7ab056a4db5c3542ffa
MD5 a616da96e5c682d3bf286a5fb421c5c0
BLAKE2b-256 21c2ea788a731fff28ba357cb016f7687440a32ac2c2675aa2c126851e298f5b

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