Skip to content

Perform skin stress-strain curve regression on SHG images using deep learning

License

Notifications You must be signed in to change notification settings

siemdejong/skinstression

Repository files navigation

Skinstression

Skin stretch regression using deep learning or Skinstression is a deep learning framework to predict the stress-strain curve of skin tissue. A convolutional neural network is trained on second harmonic generation images of skin tissue, matched with stretch measurements as targets.

Training data is not made publicly available.

Quick start

A common CLI workflow includes:

Task Terminal
Login to wandb wandb login
Initializing a sweep wandb sweep sweep.yaml
Running a wandb sweep agent wandb agent
Training a model python train.py
Predicting using a model python predict.py

For logging to wandb, it is required to login to wandb.

NOTE: please take a look at train.py or predict.py when training or predicting. They contain settings you may need to change before launching scripts. Some settings are consumed by Pytorch Lightning (docs).

Training

Training with python train.py will make a tmp directory containing the splits. Subsequent runs will reuse the splits. Users can modify the splits. Users can modify training parameters in train.py.

Predicting

Predict with python predict.py, will make use of the tmp directory containing the splits, or make the splits if they don't exist yet. Data is read sequentially. If save_plots=True, plots are save to the tmp directory. Lines are color coded by slice index (which is not necessarily depth first, depending on the scanning protocol).

Hyperparameter optimization

Running hyperparameter optimization can be done with Wandb Sweep. First initialize the orchestrator with wandb sweep sweep.yaml. Then, on agent devices, run wandb agent <sweep id>, where the sweep id given at initialization should be given. Hyperparameter ranges can be configured with sweep.yaml.

Data

stacks.zarr

The SkinstressionDataset and SkinstressionDataModule rely on the iamges to be written to a zarr store. Every 3D image should be saved separately in a zarr store. This allows for easy migration to 3D models, which are currently not implemented, because they require a lot of GPU memory, not always available. Use notebooks/13-sj-tozarr.ipynb as a starting point to achieve conversion to Zarr.

params.csv

This is the target file. The first column indicates the sample. Subsequent columns indicate the target parameters.

sample_to_person.csv

File mapping samples (sample_id) to person identifiers (person_id).

curves/

This directory contains curves with <sample_id>.csv and has columns strain and stress, making up the stress-strain curves. params.csv was calculated using these curves.

Extension possibilities

Any user can contribute their own models and datasets by modifying skinstression/dataset.py or skinstression/model.py.

Installation

Do below steps in a python environment. Skinstression is tested with python 3.11.

Install pytorch for your system. See pytorch.org.

Clone this repository and install the needed dependencies.

git clone https://github.com/siemdejong/skinstression
cd skinstression
pip install .

If you would like to make changes, install as editable with pip install -e ..

Contributing

Contributions are welcome.

  1. Create an issue.
  2. Fork this repository.
  3. Clone the fork.
  4. Make a new branch.
  5. Commit changes.
  6. Push the new branch to the fork.
  7. Make a pull request to this repository.

About

Perform skin stress-strain curve regression on SHG images using deep learning

Topics

Resources

License

Stars

Watchers

Forks