SPHARM-Net: Spherical Harmonics-based Convolutional Neural Network
SPHARM-Net: Spherical Harmonics-based Convolutional Neural Network
SPHARM-Net is a spherical harmonics-based convolutional neural network for vertex-wise inference (spherical data segmentation).
A rotation-equivariant convolutional filter can avoid rigid data augmentation, and rotational equivariance can be achieved in spectral convolution without a specific neighborhood definition. Nevertheless, the limited resources of a modern machine enable only band-limited spectral components that might lose geometric details.
SPHARM-Net seeks (1) a constrained spherical convolutional filter that supports an infinite set of spectral components and (2) an end-to-end framework without rigid data augmentation. The proposed filter encodes all the spectral components without the full harmonic expansion to capture geometric details. Thanks to rotational equivariance, the training time can be drastically reduced while improving segmentation accuracy. The proposed convolution is fully composed of matrix transformations, which offers efficient, fast spectral processing. Although SPHARM-Net was tested on brain data, it can be extended to any spherical data segmentation.
git clone https://github.com/Shape-Lab/SPHARM-Net.gitThe proposed convolution is independent of spherical tessellation. However, it tends to achieve better performance as the triangle area becomes uniform. We recommend an icosahedral mesh for SPHARM-Net. An icosahedral sphere at level 6 (40,962 vertices) can be obtained by the following command line:
mkdir sphere && wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=16JPochuVpaUqnumLW34uh7pRxUWrcEF_' -O ./sphere/ico6.vtkDepending on the NVIDIA GPU architectures, the package version numbers vary. For the Ampere architecture, run:
conda create --name spharm-net python=3.7
conda activate spharm-net
conda install pytorch==1.8.0 cudatoolkit=11.1 -c pytorch -c conda-forgeFor the Turing or earlier architectures, run:
conda create --name spharm-net python=3.7
conda activate spharm-net
conda install pytorch==1.1.0 cudatoolkit=10.0 -c pytorchTo install the required packages, run:
pip install .Two public parcellation datasets were used in this work (thank the authors for sharing their datasets!):
We assume a standard FreeSurfer's directory structure with manual label files (*.annot).
$SUBJECTS_DIR
├── subj_1
│ ├── surf
│ │ ├── lh.curv
│ │ ├── lh.inflated.H
│ │ ├── lh.sulc
│ │ └── lh.sphere
│ └── label
│ └── lh.manual.annot
.
.
└── subj_N
├── surf
│ ├── lh.curv
│ ├── lh.inflated.H
│ ├── lh.sulc
│ └── lh.sphere
└── label
└── lh.manual.annotFor training, spherical data need to be re-tessellated by a reference sphere (e.g., ./sphere/ico6.vtk in Step 0). The training samples follow a binary format (features: double, labels: int16). The naming convention should follow the predefined pattern: subjectID.?h.aug0.*.dat if the default loader is used. To generate re-tessellated mesh files, run the following command line:
python ./scripts/prep.py --data-dir $SUBJECTS_DIR --hemi lh --annot manualBy default, the training samples will be generated in ./dataset/ using ./sphere/ico6.vtk, and curv, sulc, inflated.H are re-tessellated. Use --in-ch to include/exclude input channels. You can further accelerate the file creation with multi-threading (use --threads). The script can also generate the left and right hemispheres together (use --hemi lh rh). If registered spheres are preferred, use --native-sphere to specify the registered sphere (e.g., sphere.reg). Once generated, you will see something like:
./dataset
├── features
│ ├── subj_1.lh.aug0.curv.dat
│ ├── subj_1.lh.aug0.inflated.H.dat
│ ├── subj_1.lh.aug0.sulc.dat
. .
. .
│ ├── subj_N.lh.aug0.curv.dat
│ ├── subj_N.lh.aug0.inflated.H.dat
│ └── subj_N.lh.aug0.sulc.dat
├── labels
│ ├── subj_1.lh.aug0.label.dat
. .
. .
│ └── subj_N.lh.aug0.label.dat
└── label_csv
├── subj_1.lh.csv
.
.
└── subj_N.lh.csvYou may want to verify how the
annotfiles are converted inlabel_csv.
To train SPHARM-Net, you will need to supply flags properly. Here are some popular flags:
--sphere : path to the sphere mesh file used for the re-tessellation in Step 0--hemi : hemisphere (lh or rh or lh rh)--n-splits : k-fold cross-validation (default: 5)--fold : cross-validation fold ($fold=1, ..., k)--classes : Labels of interest. It does not necessarily contain all the labels; the excluded label IDs become zero. Check out the generated label IDs in label_csv (see Step 1) . In our experiments, we used0 2 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 34 350 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34--ckpt-dir : path to checkpoint (pth) at the best accuracy (default: ./logs/best_model_fold$fold.py)--resume : path to checkpoint to resume (if paused in past training), e.g., ./logs/best_model_fold$fold.pth.See also more options in ./scripts/train.py.
Overall, you can train the model using the following command line (Mindboggle-101 example):
fold=1
python ./scripts/train.py \
--data-dir ./dataset \
--classes 0 2 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 34 35 \
--fold $fold \
--hemi lh \
--sphere ./sphere/ico6.vtkIf successful, you will see
…python ./scripts/parc.py --subj_dir $SUBJECTS_DIR/subj_1 --hemi lh
…@article{Ha2022:SPHARMNet, author = {Ha, Seungbo and Lyu, Ilwoo}, journal = {IEEE Transactions on Medical Imaging}, title = {SPHARM-Net: Spherical Harmonics-Based Convolution for Cortical Parcellation}, year = {2022}, volume = {41}, number = {10}, pages = {2739-2751}, doi = {10.1109/TMI.2022.3168670}, publisher = {IEEE} }
No open issues yet, or sync has not completed.