Skip to content

Example

This example demonstrates how to use the cardiotensor package with the example provided in the repository. This example will help you understand how to process input data, compute fiber orientations, and visualize results.

Example Directory Overview

The ./examples/ directory contains:

  • Datasets: Cropped 3D volumes and binary masks for testing and experimentation.
  • Configuration File: A pre-filled parameters_example.conf file for running the workflows.

Data

  1. Heart Volume:

    • Path: ./data/635.2um_LADAF-2021-17_heart_overview_/
    • Description: A downsampled 3D heart image volume designed for testing. The full-resolution dataset is available at the Human Organ Atlas.
  2. Binary Mask:

    • Path: ./data/mask/
    • Description: A binary mask used for segmenting the heart from the background.

Running the Examples

Installation

Note

See Installation

  1. Clone the repository and install the package:

    $ git clone https://github.com/JosephBrunet/cardiotensor.git
    $ cd cardiotensor
    $ pip install .
    

  2. Navigate to the examples directory:

    $ cd examples
    

Processing a Test Slice

  1. Open parameters_example.conf and set TEST = True in the [TEST] section.

Note

For information about conf file see the section Configuration file

  1. Run the following command:
    $ cardio-tensor ./parameters_example.conf
    
  2. The output will be displayed as a plot for a single slice:
Test Slice Result
Result from processing a single test slice.

Processing the Entire Volume

  1. Set TEST = False in parameters_example.conf.

Note

For information about conf file see the section Configuration file

  1. Run the command:
    $ cardio-tensor ./parameters_example.conf
    
  2. Outputs will be saved in the ./output directory with the following structure:
    ./output
    ├── HA          # Helix angle results
    ├── IA          # Intrusion angle results
    ├── FA          # Fractional anisotropy results
    └── eigen_vec   # 3rd Eigenvectors
    

Visualizing Transmural Profiles

  1. Use the cardio-analysis command:

    $ cardio-analysis ./parameters_example.conf 150
    
    Replace 150 with the slice number you wish to analyze.

  2. The GUI will appear, allowing you to:

    • Define a transmural profile line.
    • Adjust parameters like Angle range and Number of lines.
    • Plot and export the profile.
      Analyse GUI
      Graphical interface for defining transmural profiles.

    The generated profile will resemble:

    Transmural profile
    Example of a generated transmural profile.

Visualizing Vector field

Note

WRITE_VECTORS must be equal to True in the Configuration file

Once the structure tensor and eigenvectors have been calculated on the whole volume.

  1. Use the cardio-visualize-vector command:

    $ cardio-visualize-vector parameters_example.conf --start 120 --stride 6
    

    • --start : Show vectors only from slice 120 to the last slice.

    • --stride 6 : Show only 1 vector out of every 6.

  2. The plot will appear and you will be able to rotate it by dragging left click

    Vector visualization
    Vector field visualization from computed structure tensors using Fury.

Generating and visualizing streamlines

  1. Use the cardio-visualize-vector command to generate the streamlines:

    $ cardio-generate-streamlines parameters_example.conf --seeds 10000 --start 150
    

    • --start : Show vectors only from slice 120 to the last slice.

    • --seeds : Number of seeds to start streamlines

    Note

    The streamlines are generated in output/streamlines.npz

  2. Use the cardio-visualize-streamlines command to plot the streamlines:

    $ cardio-visualize-streamlines parameters_example.conf --line-width 1
    

    • --line-width : The width of the streamline in the plot.
streamline visualization
Streamline visualization using Fury.

Notes

  • The provided dataset is for demonstration purposes only.
  • Modify parameters in parameters_example.conf (e.g., SIGMA, RHO) to suit your data.