# DeepMFA: Deep-learning-based Morphological Feature Analysis of a migrating cell
This is the method about how to analyze deep-learning-based morphological feature analysis of a migrating cell.

# Features
For systematic extraction of cell morphology features from microscopy data, a convolutional neural network was trained to classify snapshot mask images of: Dictyostelium (aggregation-stage; ‘agg’), neutrophil-like HL-60 and fish keratocytes.  Image masks of these isolated single cells were normalized in size and orientation.  Hyper-parameters for deep-learning were chosen for relative high-accuracy for various network structures.  The extracted features were well trained as judged by the high validation accuracy; 97.9% and 89.7%, for the training and the validation data respectively.  The classification accuracy of the validation data of Dictyostelium, HL-60, and keratocyte is 94.6%, 96.0%, and 87.8%, respectively.  The three nodes F = (F1, F2, F3) that constituted the second to last layer of the network showed good representation of the three data classes: Dictyoselium, HL-60 and keratocyte, which were further reduced to two by principal component analysis (PCA).  PC1 highlights keratocyte-like shapes while penalizing features common to Dictyostelium and HL-60, and PC2 favors Dictyostelium-like features not found in HL-60.  The three datasets were well separated in the PCA space  compared to classification based on hand-crafted features.  The keratocyte and Dictyostelium (agg) dataset were found in the high PC1 and high PC2 regions, respectively.  The HL-60 dataset were mapped to a low PC1 low PC2 region.

# Installation
Setup NVIDIA Graphics Driver and NVIDIA CUDA.
Install anaconda python (https://www.anaconda.com).
create environment
	$ conda env create -n DeepMFA -f DeepMFA.yml
activate environment
	$ conda activate DeepMFA

# Note
- The procedure consists of 4 steps.
[Step1] Mask image needs to be created from a cell image sequence. Since speed direction estimation is performed in preprocessing (Step 2), it is important that there is no positional deviation.  Also, at this stage, it is necessary to create a mask image of the target cell only with the same image size as the original data, and it is necessary not to pay attention the other cells at all even.
[Step2] The 64x64 pre-processed mask images are prepared as follows: (i) the migration direction is estimated from two mask images of five (or one) frame apart, (ii) the mask image is rotated so that the velocity direction and the centroid position is equal to the y direction and is the image center, respectively, (iii) the image was rescaled so as that the cell area is equal to area of circles with 25 pixel diameter.
[Step3] Extract features by deep-learning pre-trained model.
[Step4] Calculate the mean value of feature quantities and map to the PCA space.

# Requirement
python, keras, tensorflow

# Usage
Samples
- The sample data is a mask image sequence from 100 DIC images of keratocyte cells ([/data/video1.mp4]).
- Requirements of python environment is written in requirements.txt.
[Step1] Create time series of mask images, and create movie files using ffmpeg etc.
[Step2] Execute the matlab program "Step2_Preprocess.m".  Then, pre-processed mask images are made in the result folder [/result].
[Step3] Execute the python program "Step3_predict-value.py".  The program needs keras library with tensorflow backend, so you need to check that the keras-backend is tensorflow ($HOME/.keras/keras.json).  Then, the extracted deep-learning-based shape features are written in the txt file [/result/Features.txt].
[Step4] Execute the matlab program "Step4_Visualize.m".  Then, the results are made in the result folder [/result].　The file "figure_timeseries.png" indicates time-series of feature values of the sample cell.  The file "figure1.png" indicates the average feature score of the cell (blue *) is mapped on the real-cell average features of a single-cell.  The file "figure2.png" indicates the score of the cell (blue *) is mapped on the simulation features (black circles).  One point of the simulation indicate a parameter condition (N=170).

# Author
Daisuke Imoto
Copyright : 12th May 2021 Daisuke Imoto
The author got Ph.D. in Sawai laboratory (https://sawailab.c.u-tokyo.ac.jp) of the University of Tokyo.

# License
CC BY-NC-SA (https://creativecommons.org/licenses/by-nc-sa/4.0/)