Based on two different 3D movies (20190805_SJR3.2.2_w1_s2.nd2 and 20190805_322_w1_s2.nd2), provided by the Laboratory of the Physics of Biological Systems, our task is to identify and distinguish two parts (the terminal nodule and the central nodule) of a neuron type called AIA.
For our work we considered all frames as different volumes, not taking into account time continuity.
We used a DenseNetFCN-3D with 4 dense blocks of 3 layers per block (mostly because of computation constraints).
DataGenerator.pypython file: Create generator for training and validation, user may apply image augmentation on the fly.DenseNet3D.pypython file: Implementation of the DenseNetFCN-3D from GalDude33.generateFramesMasksFromVideo.ipynbnotebook: Generate frames/masks with desired shape from the video/ground_truth files.Training.ipynbnotebook: Feed the DenseNetFCN-3D with frames/masks pairs.VisualizationPrediction.ipynbnotebook: Predict an example mask with the DenseNetFCN-3D model.ConfusionMatrix.ipynbnotebook: Compute the accuracy and the F1 score for the 'AIA terminal nodule' (class 1) , the 'AIA central nodule'(class 2) and the other cells (class 0).
(keep all the files in the same directory)
We executed the code on Google Colab by following these steps:
- The training samples and their corresponding masks need to be stored as
.npyfiles. Their names should beframe_i.npyandmask_i.npyrespectively (for i going from 0 → maxTime) and frames/masks need to be stored in two different folders. If you gives the good PATHs in the second cell ofgenerateFramesMasksFromVideo.ipynb, this notebook does this steps for you.
P.S: To help our model, we labeled ALL cell parts that were not AIA central/terminal noduls with the same value. Thus, the model only has to distinguish 3 types of cells. - Give the wanted paths and variables values to all the second cell's variables of
Training.ipynbnotebook. Then execute all cells. It will train a DenseNetFCN-3D and save the model. - Once the model has been trained, it is possible to have a visual idea of the prediction with the
VisualizationPrediction.ipynbnotebook. First, change the variables/paths of the second cell and then run all the cells. The last cell shows the image, the mask and finally the predicted mask. - Finally, the
ConfusionMatrix.ipynbnotebook can be used (once the PATHs from cell 2 have been changed) to compute the accuracy and the F1 score for the 'AIA terminal nodule' (class 1) , the 'AIA central nodule'(class 2) and the other cells (class 0).