Masticatory muscle (brown) and cross-section plane (green)
This software expects a (mostly isotropic) 3D image of the head covering the masticatory muscle. It is based on a machine-learning (ConvNet) model trained on 3D T1-weighted MRIs of a cohort of subjects aged 50+, although it should work well on any population.
More detail about the model and training approach (will be) described in Liu et al.
The input should be in nifti format. If you have DICOM data, you can convert it to nifti using dcm2niix
The program needs to run on a PyTorch python environment. A CPU version of Pytorch is sufficient.
If you have the uv packaging tool ( https://docs.astral.sh/uv/ ), you can simply run
uv sync
in this repository, and it should take care of downloading and installing the dependencies.
Otherwise, you'll need to configure a python 3 environment on your machine. For e.g. to install using pip3 (works both Linux and MacOS)
pip3 install scipy nibabel pillow
pip3 install torch
Note that on Linux this may download the unnecessary CUDA version of PyTorch, refers to https://pytorch.org/get-started/locally/ for more precise control.
You can run the segmentation of a single image simply by calling
./masseter_run.sh example_t1wi.nii.gz
The script masseter_run.sh, or a symlink to it, can safely be made available in the $PATH for convenience.
Multiple images can be analysed with the script:
./masseter_run_all.sh *.nii.gz
In this case, the script will creates (in the current working directory) a index.html page for easy visualization of all the segmentation masks, and a summary csv table with the volume of the muscle (left and right) and the interesection with the plane.
For each file, the output files example_t1wi_slab_roiL.nii.gz are example_t1wi_slab_roiR.nii.gz, each containing the muscle on its respective side, as well as a cross-section plane mask mapping 2.5cm to 3cm below the estimated Camper plane. For quick visualization purpose and quality checks, some animation similar to the one above are generated in .webp format.
