Metadata-Version: 2.1
Name: shapeaxi
Version: 0.6.9
Summary: Shape Analysis Exploration and Interpretability
Project-URL: Source Code, https://github.com/DCBIA-OrthoLab/ShapeAXI/
Author-email: juanprietob <juanprietob@gmail.com>, FlorianDAVAUX <florian.davaux@cpe.fr>
License-Expression: MIT
License-File: LICENSE
Keywords: Shape Analysis
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: GPU :: NVIDIA CUDA :: 11.7
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.8
Requires-Dist: absl-py==1.3.0
Requires-Dist: aiohttp==3.8.3
Requires-Dist: aiosignal==1.3.1
Requires-Dist: antlr4-python3-runtime==4.12.0
Requires-Dist: async-timeout==4.0.2
Requires-Dist: attrs==22.2.0
Requires-Dist: autopep8==2.0.2
Requires-Dist: cachetools==5.2.0
Requires-Dist: certifi==2023.7.22
Requires-Dist: charset-normalizer==2.1.1
Requires-Dist: cmake==3.27.4.1
Requires-Dist: contourpy==1.0.7
Requires-Dist: cycler==0.11.0
Requires-Dist: decorator==5.1.1
Requires-Dist: einops==0.6.1
Requires-Dist: filelock==3.12.2
Requires-Dist: fire==0.5.0
Requires-Dist: fonttools==4.38.0
Requires-Dist: frozenlist==1.3.3
Requires-Dist: fslpy==3.15.2
Requires-Dist: fsspec==2022.11.0
Requires-Dist: future==0.18.3
Requires-Dist: fvcore==0.1.5.post20221221
Requires-Dist: google-auth-oauthlib==0.4.6
Requires-Dist: google-auth==2.15.0
Requires-Dist: grad-cam==1.4.6
Requires-Dist: grpcio==1.51.1
Requires-Dist: idna==3.4
Requires-Dist: imageio==2.24.0
Requires-Dist: importlib-metadata==6.8.0
Requires-Dist: importlib-resources==6.0.1
Requires-Dist: iopath==0.1.10
Requires-Dist: ipython==8.16.1
Requires-Dist: itk-core==5.3.0
Requires-Dist: itk-filtering==5.3.0
Requires-Dist: itk-io==5.3.0
Requires-Dist: itk-numerics==5.3.0
Requires-Dist: itk-registration==5.3.0
Requires-Dist: itk-segmentation==5.3.0
Requires-Dist: itk==5.3.0
Requires-Dist: jinja2==3.1.2
Requires-Dist: joblib==1.2.0
Requires-Dist: kaleido==0.2.1
Requires-Dist: kiwisolver==1.4.4
Requires-Dist: lightning-bolts==0.7.0
Requires-Dist: lightning-utilities==0.5.0
Requires-Dist: lit==16.0.6
Requires-Dist: mako==1.2.4
Requires-Dist: markdown==3.4.1
Requires-Dist: markupsafe==2.1.1
Requires-Dist: matplotlib==3.7.1
Requires-Dist: medcam==0.1.21
Requires-Dist: monai==1.2.0
Requires-Dist: mpmath==1.3.0
Requires-Dist: multidict==6.0.4
Requires-Dist: networkx==3.0
Requires-Dist: nibabel==5.0.0
Requires-Dist: nptyping==2.4.1
Requires-Dist: numpy==1.24.2
Requires-Dist: nvidia-cublas-cu11==11.10.3.66
Requires-Dist: nvidia-cuda-cupti-cu11==11.7.101
Requires-Dist: nvidia-cuda-nvrtc-cu11==11.7.99
Requires-Dist: nvidia-cuda-runtime-cu11==11.7.99
Requires-Dist: nvidia-cudnn-cu11==8.5.0.96
Requires-Dist: nvidia-cufft-cu11==10.9.0.58
Requires-Dist: nvidia-curand-cu11==10.2.10.91
Requires-Dist: nvidia-cusolver-cu11==11.4.0.1
Requires-Dist: nvidia-cusparse-cu11==11.7.4.91
Requires-Dist: nvidia-nccl-cu11==2.14.3
Requires-Dist: nvidia-nvtx-cu11==11.7.91
Requires-Dist: oauthlib==3.2.2
Requires-Dist: opencv-python==4.7.0.68
Requires-Dist: packaging==23.0
Requires-Dist: pandas==1.5.2
Requires-Dist: pillow==9.4.0
Requires-Dist: plotly==5.14.1
Requires-Dist: portalocker==2.6.0
Requires-Dist: protobuf==3.20.1
Requires-Dist: pyarrow==12.0.0
Requires-Dist: pyasn1-modules==0.2.8
Requires-Dist: pyasn1==0.4.8
Requires-Dist: pycodestyle==2.10.0
Requires-Dist: pyensae==1.3.967
Requires-Dist: pynrrd==1.0.0
Requires-Dist: pyparsing==3.0.9
Requires-Dist: pyquickhelper==1.12.3806
Requires-Dist: pyquicksetup==0.2.4
Requires-Dist: python-dateutil==2.8.2
Requires-Dist: pytorch-lightning==1.8.6
Requires-Dist: pytz==2022.7
Requires-Dist: pywavelets==1.4.1
Requires-Dist: pyyaml==6.0
Requires-Dist: requests-oauthlib==1.3.1
Requires-Dist: requests==2.28.1
Requires-Dist: rsa==4.9
Requires-Dist: scikit-image==0.19.3
Requires-Dist: scikit-learn==1.2.0
Requires-Dist: scipy==1.9.3
Requires-Dist: simpleitk==2.2.1
Requires-Dist: six==1.16.0
Requires-Dist: sympy==1.12
Requires-Dist: tabulate==0.9.0
Requires-Dist: tenacity==8.2.2
Requires-Dist: tensorboard-data-server==0.6.1
Requires-Dist: tensorboard-plugin-wit==1.8.1
Requires-Dist: tensorboard==2.11.0
Requires-Dist: tensorboardx==2.5.1
Requires-Dist: termcolor==2.1.1
Requires-Dist: threadpoolctl==3.1.0
Requires-Dist: tifffile==2022.10.10
Requires-Dist: tomli==2.0.1
Requires-Dist: torch==2.0.1
Requires-Dist: torchaudio==2.0.2
Requires-Dist: torchmetrics==0.11.4
Requires-Dist: torchvision==0.15.2
Requires-Dist: tqdm==4.64.1
Requires-Dist: triton==2.0.0
Requires-Dist: ttach==0.0.3
Requires-Dist: typing-extensions==4.4.0
Requires-Dist: urllib3==1.26.13
Requires-Dist: vtk==9.2.6
Requires-Dist: werkzeug==2.2.2
Requires-Dist: yacs==0.1.8
Requires-Dist: yarl==1.8.2
Requires-Dist: zipp==3.16.2
Description-Content-Type: text/markdown

# ShapeAXI

Welcome to the official documentation for **ShapeAXI**. Dive into the cutting-edge framework designed for comprehensive shape analysis.  

---
If you want, you can have access to another documentation to run an executable called **dentalmodelseg** :


[DentalModelSeg](DentalModelSeg.md)
---

## Table of Contents
- [Introduction](#introduction)
- [Installation](#installation)
- [Usage](#usage)
- [Experiments & Results](#experiments--results)
- [Explainability](#explainability)
- [Contribute](#contribute)
- [FAQs](#faqs)
- [License](#license)

---

## Introduction

**ShapeAXI** is a state-of-the-art shape analysis framework that harnesses a multi-view approach. This approach is adept at capturing 3D objects from a variety of viewpoints and analyzing them through 2D Convolutional Neural Networks (CNNs).

---

## Installation (python 3.8 or 3.9 are required, no other versions)

### Installation of shapeaxi
```bash
pip install shapeaxi
```

### Installation of pytorch3d 

For this installation, we are going to use a variable, {YOURVERSION}, because this installation is specific to each computer configuration.
- First, you need to install ipython :
```bash
pip install ipython
```
Then, you can run **ipython** in the terminal (or **python -m IPython** if it is not working).  
You can now add paste these lines :
```bash
import sys
import torch
pyt_version_str=torch.__version__.split("+")[0].replace(".", "")
version_str="".join([
    f"py3{sys.version_info.minor}_cu",
    torch.version.cuda.replace(".",""),
    f"_pyt{pyt_version_str}"
])
print(version_str)
```
It will print something like this : **py39_cu117_pyt201**.  
This is the content of your variable {YOURVERSION}.
- Finally, exit of ipython and in your terminal you can run this line by adding your editing {YOURVERSION}, 
```bash
pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{YOURVERSION}/download.html
```

Finally, check the installation,
```bash
pip show pytorch3d
```
---

## Usage

### Basic Usage:

To get started with **ShapeAXI**, follow the steps below:


#### Example CSV File

Your input CSV file should be structured as follows:

| surf                                 | class  |
|--------------------------------------|--------|
| path/to/shape1.vtk                   | class1 |
| path/to/shape2.stl                   | class2 |
| path/to/shape3.obj                   | class1 |
| ...                                  | ...    |


- **surf**: This column holds the file paths to the 3D shape objects. The tool supports the formats `.vtk`, `.stl`, and `.obj`.
- **class**: This column indicates the class of the 3D object.

### Running ShapeAXI

To use ShapeAXI, execute the `saxi_folds.py` script:

```bash
python saxi_folds.py --csv your_data.csv --compute_scale_factor 1 --surf_column surf --class_column class --subdivision_level 2 --batch_size 8 --out output_dir/
```

Ensure you replace `your_data.csv` with the correct path to your specific CSV file. 

```
usage: saxi_folds.py [-h] --csv CSV [--folds FOLDS] [--valid_split VALID_SPLIT] [--group_by GROUP_BY] [--nn NN] [--surf_column SURF_COLUMN] [--class_column CLASS_COLUMN] [--compute_scale_factor COMPUTE_SCALE_FACTOR] [--mount_point MOUNT_POINT]
                     [--num_workers NUM_WORKERS] [--base_encoder BASE_ENCODER] [--base_encoder_params BASE_ENCODER_PARAMS] [--hidden_dim HIDDEN_DIM] [--radius RADIUS] [--subdivision_level SUBDIVISION_LEVEL] [--image_size IMAGE_SIZE] [--lr LR] [--epochs EPOCHS]
                     [--batch_size BATCH_SIZE] [--patience PATIENCE] [--log_every_n_steps LOG_EVERY_N_STEPS] [--tb_dir TB_DIR] [--tb_name TB_NAME] [--neptune_project NEPTUNE_PROJECT] [--neptune_tags NEPTUNE_TAGS] [--target_layer TARGET_LAYER] [--fps FPS] [--out OUT]

Automatically train and evaluate a N fold cross-validation model for Shape Analysis Explainability and Interpretability

options:
  -h, --help            show this help message and exit

Split:
  --csv CSV             CSV with columns surf,class
  --folds FOLDS         Number of folds
  --valid_split VALID_SPLIT
                        Number of folds
  --group_by GROUP_BY   GroupBy criteria in the CSV. For example, SubjectID in case the same subjects has multiple timepoints/data points and the subject must belong to the same data split

Train:
  --nn NN               Type of neural network for training
  --surf_column SURF_COLUMN
                        Surface column name
  --class_column CLASS_COLUMN
                        Class column name
  --compute_scale_factor COMPUTE_SCALE_FACTOR
                        Compute a global scale factor for all shapes in the population.
  --mount_point MOUNT_POINT
                        Dataset mount directory
  --num_workers NUM_WORKERS
                        Number of workers for loading
  --base_encoder BASE_ENCODER
                        Base encoder for the feature extraction
  --base_encoder_params BASE_ENCODER_PARAMS
                        Base encoder parameters that are passed to build the feature extraction
  --hidden_dim HIDDEN_DIM
                        Hidden dimension for features output. Should match with output of base_encoder. Default value is 512
  --radius RADIUS       Radius of icosphere
  --subdivision_level SUBDIVISION_LEVEL
                        Subdivision level for icosahedron
  --image_size IMAGE_SIZE
                        Image resolution size
  --lr LR, --learning-rate LR
                        Learning rate
  --epochs EPOCHS       Max number of epochs
  --batch_size BATCH_SIZE
                        Batch size
  --patience PATIENCE   Patience for early stopping
  --log_every_n_steps LOG_EVERY_N_STEPS
                        Log every n steps
  --tb_dir TB_DIR       Tensorboard output dir
  --tb_name TB_NAME     Tensorboard experiment name
  --neptune_project NEPTUNE_PROJECT
                        Neptune project
  --neptune_tags NEPTUNE_TAGS
                        Neptune tags

Explainability group:
  --target_layer TARGET_LAYER
                        Target layer for explainability
  --fps FPS             Frames per second

Output:
  --out OUT             Output
```

#### Workflow:

1. On running `saxi_folds.py`, the tool will:
   - Generate the necessary N folds.
   - Handle the training, validation, and testing.

2. The tool then produces:
   - A confusion matrix.
   - ROC curves.
   - Explainability maps for each shape in the dataset.

## Experiments & Results

**ShapeAXI** has been rigorously tested across multiple domains. Below is a summary of our key experiments:

### Condyles Classification

- **Categories**: Healthy vs. Degenerative states
- **Accuracy**: ~79.78%

![Condyles Classification Results Placeholder](doc/images/Deg_classification_aggregate_long_exists_aggregate_prediction_norm_confusion.png)
![Condyles Classification ROC](doc/images/Deg_classification_aggregate_long_exists_aggregate_prediction_roc.png)

### Cleft Patients Severity Classification

- **Classes**: Severity levels 0 to 3
- **Accuracy**: ~81.58%

![Cleft Patients Severity Classification Results Placeholder](doc/images/01.Final_ClassificationALLfold_test_prediction_norm_confusion.png)
![Cleft Patients Severity Classification ROC](doc/images//01.Final_ClassificationALLfold_test_prediction_roc.png)
---

## Explainability

In **ShapeAXI**, we prioritize transparency and understanding. The explainability feature of our framework offers heat-maps which grant insights into its classification rationale.

https://github.com/DCBIA-OrthoLab/ShapeAXI/assets/7086191/120b0095-5f2d-4f0d-b650-a0587a33e067

https://github.com/DCBIA-OrthoLab/ShapeAXI/assets/7086191/2c635250-624f-4cce-b150-4d5507b398b4

---

## Contribute

We welcome community contributions to **ShapeAXI**. For those keen on enhancing this tool, please adhere to the steps below:

1. **Fork** the repository.
2. Create your **feature branch** (`git checkout -b feature/YourFeature`).
3. Commit your changes (`git commit -am 'Add some feature'`).
4. Push to the branch (`git push origin feature/YourFeature`).
5. Open a **pull request**.

For a comprehensive understanding of our contribution process, consult our [Contribution Guidelines](path/to/contribution_guidelines.md).

---

Of course! Here are some general FAQ entries tailored for a tool/framework like ShapeAXI:

## FAQs

### What is ShapeAXI?

**Answer:** ShapeAXI is an innovative shape analysis framework that employs a multi-view approach, rendering 3D objects from varied perspectives and analyzing them using 2D Convolutional Neural Networks (CNNs).

---

### How do I install and set up ShapeAXI?

**Answer:** Detailed installation and setup instructions can be found in the 'Installation' section of our documentation. Simply follow the steps mentioned, and you should have ShapeAXI up and running in no time.

---

### Can I use ShapeAXI for my own datasets?

**Answer:** Absolutely! ShapeAXI is designed to be versatile. You can use it on a wide variety of shape datasets. Ensure your data is in the required format as outlined in the 'Usage' section.

---

### How does ShapeAXI handle explainability?

**Answer:** ShapeAXI offers a unique approach to explainability, providing heat-maps for each class across every shape. These visualizations provide insights into the underlying object characteristics and the classification rationale.

---

### Are there any known limitations of ShapeAXI?

**Answer:** Like all models and frameworks, ShapeAXI has its constraints. It is optimized for the datasets and tasks it has been trained and tested on. While it offers versatility across a range of datasets, results may vary based on the quality and type of data. We continually work on refining and improving ShapeAXI to overcome any limitations.

---

### How can I contribute to ShapeAXI's development?

**Answer:** We welcome contributions! Please refer to the 'Contribute' section of our documentation for guidelines on how you can contribute.

---

### Who do I contact for technical support or questions about ShapeAXI?

**Answer:** For technical support or any questions, please create a new issue in our GitHub repository.

---

### Will there be future updates to ShapeAXI?

**Answer:** Yes, we plan on continuously improving and expanding ShapeAXI based on user feedback, new research, and technological advancements. Stay tuned to our repository for updates.

---

## License

**ShapeAXI** is under the [APACHE 2.0](LICENSE) license.

---

**ShapeAXI Team**: For further details, inquiries, or suggestions, feel free to [contact us](mailto:juan_prieto@med.unc.edu).
