2. Creation of manually segmented images using CELLPOSE 2 GUI application
Training set of cortical images was created by first running of pre-trained model in CELLPOSE 2 GUI application. The “Cyto2” model was used to create preliminary segmented images, created in GUI, running “Cyto2” model on 33 images 480×480 pixels size, < 1 mkm resolution, selected randomly from much larger set of fragments of 6 different cortical areas of human cortex (with average size of approximately 3000×4000 pixels). The initial images were obtained by downloading Nissl-stained frontal sections of entire human brain from Allen’s Reference Human Brain Atlas (https://atlas.brain-map.org/).
Segmentation results were visually investigated, and corrected according to visual analysis of initial images. CELLPOSE GUI application allows for manual selection and de-selection of each individual segmentation masks, and, in case of errors, correction of outlines obtained after automatic processing. This procedure was repeated several times on all images, selected for training the custom model, until satisfactory segmentation results were creates. Manually corrected segmentation images were saved as “masks” and later used for training of custom model.
Fig. 2. Cortical image before (left) and after (right) automatic segmentation using pre-trained “Cyto2” model. Segmentation result is overlapped to initial image and each mask is color-coded. Initial value of model radius (size parameter) is set to 30, so small cell’ fraction (nuclei of glia and endothelial cells, r<=10) is rejected.
We have to emphasize, that manual segmentation of cortical images is a tedious and extremely difficult task, which is usually not only time-consuming, but error-prone as well. Due to very thoughtful and convenient design of GUI application, CELLPOSE made this task doable in a reasonable time-frame of several days.
3. Training custom model using manually corrected segmentation images
For training the new model it was necessary to collect all training images and corrected segmentation results in the same folder and apply “train” method from the library. Again, “Cyto2” built-in model was selected as initial model for training. Parameters used for training were: learning_rate = 0.1, weight_decay =0.0001, n_epoch = 1000, cell diameter = 30. Number of images for training was 33. On Titan RTX GPU with compute capability 7.5 one training cycle (10 epochs) took 10 seconds. At the epoch 1000 loss value decreased from 3.5 to 0.35.
Fig.3: Training custom model. Loss value decrease after 1000 epochs.