# Surface Mapping & Deep Learning Tutorial
## Authors
- Martin Styner, Beatriz Paniagua, Connor Bowley
- Mathieu Leclercq, Juan Carlos Prieto, Tom Bigonneau
---



## Overview
This tutorial combines two modules for surface-based analysis in 3D Slicer and SlicerSALT:
1. **SurfacePlaneMapper**: Flattens 3D surfaces (e.g., brain or hippocampus) into regular 2D images using geometry image techniques.
2. **SlicerSurfaceLearner**: Enables training of deep learning models (e.g., ResNet, EfficientNet) directly from the flattened images, without writing any code.
### Installation
You can install the module either via **SlicerSALT** or **3D Slicer**:
- **Using SlicerSALT**:
Download the application from [http://salt.slicer.org](http://salt.slicer.org), launch it, and the module will be ready to use.


- **Using 3D Slicer**:
Download 3D Slicer from [http://www.slicer.org](http://www.slicer.org). Open the **Extension Manager**, search for **SlicerSurfaceLearner**, click **Install**, and restart Slicer.


---
## 1. SurfacePlaneMapper
### Description
The **SurfacePlaneMapper** module flattens a 3D surface into a 2D image using the "Geometry Image" method by Gu et al. ([link](https://hhoppe.com/gim.pdf)):
- Cuts the surface into a disk using a predefined cut path network.
- Maps the boundary of this disk to a square.
- Geometry and feature data are stored in 2D grids with implicit correspondence.


### Module Parameters
- **Input Directory**
Choose the folder containing your surfaces, organized according to one of the supported directory structures explained below. This is where the module will look for your surface data.
- **File Type and Output Resolution**
Select the format of your input files (e.g., `.txt` or `.vtk`) and specify the desired resolution for the output images.
**Note:** The geometry image will initially occupy only one-quarter of the specified resolution. It will then be tiled 4 times to fill the full output image dimensions.
- **Sphere Template**
Choose the sphere template file used for mapping your surfaces. This file should be a `.vtk` or `.obj` file representing a subdivided icosahedral sphere.
- **Output Directory**
Select the folder where the results will be saved. The module will replicate your input folder structure and output flattened geometry images in both **PNG** (normalized) and **NIFTI** (raw) formats.
### Input Directory Structure
Two supported formats:
#### Option 1: `.txt` Feature Files
```
| ---- subject_id
| ---- session
| ---- modality
| ---- *.txt
```
Each `.txt` file contains features per surface point.
#### Option 2: `.vtk` Feature Files
```
| ---- subject_id
| ---- session
| ---- modality
| ---- *.vtk
```
### Sphere Template
A `.vtk` or `.obj` file representing a spherical icosahedral mesh (e.g., subdivision template).
### Output Directory Structure
```