Package: oneat
oneatAction classification for TZYX shaped images, Static classification for TYX shaped imagesThiscapedpackage was generated withCookiecutterusing@caped'scookiecutter-templatetemplate.InstallationYou can installoneatviapip:pip install oneatTo install latest development version :pip install git+https://github.com/Kapoorlabs-CAPED/caped-ai-oneat.gitContributingContributions are very welcome. Tests can be run withtox, please ensure
the coverage at least stays the same before you submit a pull request.LicenseDistributed under the terms of theBSD-3license,
"oneat" is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.Algorithm and Code for finding mitotic cells in TZYX datasetsProgram structureWe use hydra library to separate the parameters of the code from the actual file that contains the runnable code. We do so to minimize the interaction with the actual script/file/interactive code where the users do not have to change any lines to specify the paths/filenames/parameters. Theconfiguration file to modify the parameters.The params_train contains the training parameters for the hyperparameters of the network, these parameters are set once and for all and are not learned during the training process, hence the name hyperparameters.The params_predict contains the parameters needed for model prediction such as the number of tiles, event threshold and confidence to veto the events below the threshold.The trainclass contains the training class used by oneat and is input as a string. For VollNet (Resnet based) the training class is NEATVollNet, for DenseVollNet (Densenet based) the training class is DenseVollNet.The defaults provides the filename and the paths, depending on where the data is you only have to select the path file which is supplied for local paths/ovh server paths/aws paths. This maybe a bit of gymnastics in the beginning but once the paths, files are set only parameters need to be changed during regular usage of the scripts and interactive programs.The training dataThe training data for 3D + time dataset was made by clicking on the location in ZYX of the mitotic (blue points layer) and non-mitotic cell (red points layer) using an interactiveNapari widget.We also have the segmentation image for the raw data that we use to create the clicks and we use the segmentation labels at the click location to refine the location of the clicked cell, get it's height, width and depth that we use to create the training label.Using acustom training data creating scriptThe training data consists of 1 timeframe before and after the division/mitosis splitting of the cell, 4 Z planes before and 4 Z planes after the click Z location and 32 pixels in XY around the click location in X and Y. In this fashion the non-mitotic and mitotic cells are always in the center, spatially and temporally making the task of learning easier. The shape of the training data TZYX hence is (3,8,64,64) and the training label consists of class label + 0.5,0.5,0.5,0.5,Height,Width,Depth,confidence. The 0.5 signifies the spatial and temporal centering of the cell.ResNet and DenseNet based VollNet and DenseVollNet architecturesAfter the training data is saved as an npz file, the training can be done using a Resnet or a Densenet architecture based network. We see a better performance using    architecture. See theResnet implementation, see theDensnet implementation.We have fully convolutional implementation of both these architectures, hence the training can be done on the data of our chosen size and shape but at the prediction stage we benifit from convolutionalization of the sliding window operation where the network finds the location of the mitotic cells using the indices that the prediction function provides to map the predictions to their proper spatial and temporal locations in the input data of arbitrary size/shape.Program to train the model on a GPU based machineUsingthis scriptand setting the training parameters in the configuration file we train the model with the chosen hyperparameters.Visualizing training loss and accuracy with TensorboardOneat supports visualization of the training loss, accuracy and other training metrics using tensorboard.Tensorboard can be started from the same directory from where you launched the training script/interactive program for training. Inside that folder you will find anoutputsdirectory, inside it is a timestamped directory of logs for the tensorboard, for example the directory is named 08-21-02/ then launch tensorboard with the following command from inside the outputs directory:tensorboard --logdir 08-21-02/.Tensorboard will print a localhost url to copy and paste in the browser for examplehttp://localhost:6007/, clicking on the menu item of scalars shows the loss and accuracy plots for the training epochs. You can refresh the page to update the curves if it does not happen automatically.Model Evaluation and PredictionOnce the model has been trained, we can evaluate the performance of the model with metrics. The metrics measure the model performance on ground truth data which consists of the raw ground truth image, its corresponding segmentation image and the csv file containing the ground truth locations of the mitotic cells as TZYX columns.For evaluating the model performance we have to run the model prediction on the ground truth raw image using its segmentation image inthis script. The prediction program generates a csv file containing the location of mitotic cells and also the probability, confidence scores and radius of the cell to create bounding boxes around the cell location.Using the ground truth and the predictions csv file we compute the tru positive, false positive and false negative rate of detection usingthis script.