A dendritic spine spike persistent learning mapping method and device for two-dimensional two-photon calcium imaging
By combining the SAM basic segmentation large model and the lightweight multi-scale instance segmentation network, the problem of efficient automation of dendritic spine detection and segmentation in two-dimensional two-photon calcium imaging is solved. It achieves high-precision recognition and stable mapping under complex conditions, reduces manual annotation time, and improves the model's generalization ability across experimental conditions.
Patent Information
- Application Number
- CN202610204797.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-12
- Publication Date
- 2026-05-12
- Estimated Expiration
- 2046-02-12
AI Technical Summary
Existing technologies for dendritic spine detection and segmentation in two-dimensional two-photon calcium imaging suffer from problems such as time-consuming manual annotation, insufficient robustness, difficulty in adapting to continuous data accumulation, and performance degradation across batches, especially in low-contrast, unevenly lit, or densely packed small target scenes.
Pseudo-labels are generated using a large SAM-based segmentation model, and interactive correction is performed through a lightweight multi-scale instance segmentation network. A continuous learning model is constructed, and preprocessing steps such as motion correction, quantile contrast stretching, and background correction are combined to achieve high-precision identification and mapping of dendritic spines.
It significantly reduces the workload of manual annotation, improves the model's generalization ability and segmentation performance under different conditions, ensures the consistency of input data, and enables efficient analysis of the spatial distribution and morphological structure of dendritic spines across the entire field of view.
Smart Images

Figure CN121685554B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image recognition technology, specifically to a method and apparatus for continuous learning of dendritic spines in two-dimensional two-photon calcium imaging. Background Technology
[0002] Dendritic spine detection and segmentation technology in two-dimensional two-photon calcium imaging aims to automatically identify, quantify, and spatially map the tiny spine structures on neuronal dendrites for analysis of synaptic plasticity, learning and memory processes, and related disease models. The small size, low contrast, complex morphology, and dense distribution of dendritic spines make manual annotation extremely time-consuming, highlighting the growing need for automated processing.
[0003] Current mainstream methods include threshold-dependent segmentation, edge detection, morphological features, and wavelet / differential filtering operators, which are suitable for scenes with clear contrast, but lack robustness to weak boundaries, uneven lighting, or dense small target data. Convolutional neural network-based detection algorithms, through deep learning techniques and training with large amounts of labeled data, can automatically learn the morphological features of dendritic spines and perform better in noisy environments. However, these methods typically rely on a large amount of high-quality manual annotation and are prone to performance degradation across batches and experimental conditions. Furthermore, most existing models employ static training strategies, making it difficult to automatically adapt to new distributions as data accumulates, and they lack effective continuous learning mechanisms to cope with catastrophic forgetting.
[0004] Further innovation is needed to propose a continuous learning method to reduce the cost of manual annotation, improve the model's generalization in weak contrast, dense spine scenarios and multi-batch data, and achieve high-precision, scalable mapping analysis of dendritic spines. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention proposes a method and apparatus for continuous learning mapping of dendritic spines in two-dimensional two-photon calcium imaging, which solves the aforementioned technical problems.
[0006] Firstly, a method for continuous learning mapping of dendritic spines in two-dimensional two-photon calcium imaging is provided, including:
[0007] Two-photon calcium imaging dendritic spine image data is acquired and preprocessed to obtain a first image dataset. The first dataset is then randomly divided to obtain k second image datasets.
[0008] The basic segmentation model generates pseudo-labels for the second image data in the first second image dataset with single-point cues, thus obtaining the first second-label image dataset. Based on this dataset, the basic segmentation model is trained.
[0009] The remaining j-th second image dataset is predicted by the basic segmentation model, and the j-th second label image dataset is formed by interactive correction through the large model. The second labels of each round are incorporated into incremental training to update the segmentation model, resulting in a continuous learning model. The model is used to perform instance segmentation on the first image dataset and crop the region of interest to obtain a dendritic spine instance image set.
[0010] The dendritic spine instance image set is processed according to the nearest attachment rule of dendritic centerline to obtain a dendritic spine coordinate set, and the dendritic spine instance image set is automatically classified to obtain a dendritic spine classification dataset.
[0011] Based on the dendritic spine coordinate set and the dendritic spine classification dataset, a dendritic spine density and category distribution map is constructed to obtain a full-view dendritic spine density structure mapping.
[0012] Furthermore, the two-photon calcium imaging dendritic spine image data is preprocessed to obtain a first image dataset, and the first dataset is randomly divided to obtain k second image datasets, including:
[0013] Motion correction and information projection of the raw data yield a two-dimensional reference image;
[0014] The two-dimensional reference image is subjected to grayscale normalization and quantile contrast stretching to obtain a contrast-enhanced image.
[0015] The contrast-enhanced image is then subjected to background correction to obtain a background-corrected image;
[0016] The background correction image is denoised by median filtering and Gaussian filtering to obtain a denoised image;
[0017] The denoised image is resampled and interpolated according to the target input size and the imaging calibration ratio, and quantized to a preset bit depth to obtain the first image dataset.
[0018] The first image dataset is divided into k sub-datasets according to a preset random seed;
[0019] Stratified sampling can be optionally performed to ensure that the proportion of different imaging batches / animals / fields of view is basically the same in each subset;
[0020] The fixed validation set and test set are not included in the partitioning of the k second image datasets;
[0021] Each subset has an equal or approximately equal sample size. The source data identifier and full-image coordinate information of each sample are recorded to obtain k second image datasets.
[0022] Furthermore, the step of generating pseudo-labels for the second image data in the first second image dataset using a single-point cue from the basic segmentation model to obtain the first second-labeled image dataset, and training the basic segmentation model based on this dataset, includes:
[0023] A single-point positive cue is given for the dendritic spine region in the first and second datasets, and the basic segmentation large model generates an instance mask in one forward pass.
[0024] The system provides interactive fine-tuning with a few positive / negative prompts at the points of error, outputs a binary mask and instance polygons, and obtains the first second-labeled image dataset.
[0025] Using the first second-label image dataset as supervision, an instance segmentation network is trained to obtain the basic segmentation model.
[0026] Furthermore, the remaining j-th second image dataset is predicted by the basic segmentation model, and the j-th second label image dataset is formed through interactive correction by the large model. The second labels from each round are incorporated into incremental training to update the segmentation model, resulting in a continuous learning model. This model is then used to process the first image dataset on multi-scale feature maps to obtain a dendritic spine instance mask set, including:
[0027] The basic segmentation model is used to perform dendritic spine instance segmentation prediction on the j-th second image dataset to obtain the j-th second mask image dataset;
[0028] Using the aforementioned basic segmentation model with minimal prompting, the j-th second mask image dataset is interactively corrected to generate the j-th second label image dataset;
[0029] The j-th second-label image dataset is incorporated into the incremental training set and retrained together with the weights of the previous model, along with early stopping monitoring, to obtain the updated segmentation model.
[0030] Repeat the above steps until the kth second image dataset is processed to obtain the continuous learning model;
[0031] The first image dataset is processed on multi-scale feature maps using the continuous learning model to obtain a dendritic spine instance mask set.
[0032] Extract the bounding box of the dendritic spine instance mask set and enlarge it according to a preset ratio to obtain the target region set;
[0033] The first image dataset is cropped into regions of interest of fixed size according to the target region set, and normalized and quantized. Each dendritic spine region of interest and its corresponding instance identifier, category information and full-image coordinate position are saved to form a dendritic spine instance image set.
[0034] Furthermore, the dendritic spine instance image set is processed according to the nearest attachment rule of the dendritic centerline to obtain a dendritic spine coordinate set, and the dendritic spine instance image set is automatically classified to obtain a dendritic spine classification dataset, including:
[0035] Extract the centerline of the target dendrites from the first image dataset and discretize it into ordered coordinate points to obtain the dendrite centerline coordinate dataset;
[0036] Calculate the centroid coordinates of the mask for each dendritic spine instance in the dendritic spine instance image set to obtain the dendritic spine centroid coordinate dataset;
[0037] Calculate the shortest Euclidean distance between the dendritic centerline coordinate dataset and the dendritic spine centroid coordinate dataset to obtain the shortest Euclidean distance dataset;
[0038] Based on the preset distance threshold, the above shortest Euclidean distance dataset is processed to determine the attachment relationship between dendritic spines and dendrites. The centroid coordinates of dendritic spines that satisfy the attachment relationship are processed to obtain the dendritic spine coordinate set.
[0039] The dendritic spine instance image set is input into a lightweight classification network, which consists of a multi-layer reversible convolutional module and a coordinate attention mechanism.
[0040] The category to which each instance in the dendritic spine instance image set belongs is determined based on the feature vector and classification confidence score output by the classification network.
[0041] The dendritic spine classification dataset is obtained by outputting the corresponding category label and confidence distribution for each instance.
[0042] Furthermore, the step of constructing a dendritic spine density and category distribution map based on the dendritic spine coordinate set and the full-view dendritic spine coordinate framework to obtain a full-view dendritic spine density structure mapping includes:
[0043] Using the dendrite coordinate set and the dendrite spine classification dataset, the number of dendrite spines on the corresponding dendrites and the proportion of different categories are counted to obtain the dendrite density dataset.
[0044] The dendritic spine density dataset and category information are mapped to a full-view coordinate frame;
[0045] Density heatmaps and category distribution maps are generated using color coding, and the output includes density, category, location and statistical information, resulting in a full-view dendritic spine density structure mapping.
[0046] Secondly, a dendritic spine continuous learning mapping device for two-dimensional two-photon calcium imaging is provided, comprising:
[0047] The data acquisition module is used to acquire two-photon calcium imaging dendritic spine image data, preprocess it to obtain a first image dataset, and randomly divide the first dataset to obtain k second image datasets.
[0048] The segmentation processing module is used to generate pseudo-labels for the second image data in the first second image dataset with single-point cues from the basic segmentation model, to obtain the first second-label image dataset, and to train the basic segmentation model based on it.
[0049] The continuous learning module is used to predict the remaining j-th second image dataset by the base segmentation model, and to form the j-th second label image dataset through interactive correction by the large model. The second labels of each round are incorporated into the incremental training to update the segmentation model, thus obtaining the continuous learning model. The first image dataset is processed on the multi-scale feature map using the model to obtain the dendritic spine instance mask set.
[0050] The center coordinate processing module is used to process the dendritic spine instance image set according to the nearest attachment rule of the dendritic centerline to obtain the dendritic spine coordinate set, and to automatically determine the category of the dendritic spine instance image set to obtain the dendritic spine classification dataset.
[0051] The mapping module is used to construct a dendritic spine density and category distribution map based on the dendritic spine coordinate set and the dendritic spine classification dataset, thereby obtaining a full-view dendritic spine density structure mapping.
[0052] Furthermore, a two-dimensional two-photon calcium imaging dendritic spine continuous learning mapping device includes a processor and a memory storing program instructions, the processor being configured to execute, when running the program instructions, a two-dimensional two-photon calcium imaging dendritic spine continuous learning mapping device as described above.
[0053] Thirdly, an electronic device is provided, including the dendritic spine continuous learning mapping device for two-dimensional two-photon calcium imaging described above.
[0054] The invention employing the above technical solution has the following advantages:
[0055] 1. This invention utilizes the strong generalization capability of the SAM-based large-scale segmentation model to generate high-quality pseudo-labels through single-point or limited interactive prompts. Simultaneously, it combines a lightweight multi-scale instance segmentation network to achieve accurate identification of weak contrast, blurred boundaries, and densely packed small target dendritic spines. This combination approach combines the reliable structural representation capability of a large model with the efficient reasoning capability of a small model, maintaining stable and high-precision segmentation performance even under complex imaging conditions.
[0056] 2. This invention constructs a continuous training model consisting of "prediction-large model correction-integration training-model update," enabling the model to automatically adapt to changes in data distribution under different batches, different animals, and different imaging parameters, significantly improving the model's generalization ability across experimental conditions. Compared with traditional static training methods, this invention greatly reduces the cost of model retraining while ensuring the continuous growth of model performance through long-term experimental data accumulation.
[0057] 3. This invention uses a large model to generate pseudo-labels and obtains highly consistent segmentation supervision signals through minimal interactive correction, significantly reducing the workload of manual dendritic spine annotation. Compared to the traditional fully manual boundary drawing process, it can shorten the annotation time by tens of times, thus making the construction of dendritic spine datasets more lightweight and scalable.
[0058] 4. Through steps such as motion correction, quantile contrast stretching, background correction, and noise suppression, this invention effectively alleviates common problems in two-photon imaging, such as brightness fluctuations, uneven illumination, and noise interference, ensuring the consistency of input data and enabling the segmentation and classification network to maintain stable and reliable performance under multiple experimental conditions.
[0059] 5. This invention covers the complete process of data preprocessing, continuous learning segmentation, instance pruning, centerline attachment calculation, morphological classification and density mapping. Users only need to provide the original image to obtain the spatial distribution, density map and morphological structure statistics of dendritic spines in the whole field of view, which effectively reduces manual intervention, significantly improves scientific research efficiency, and makes large-scale neuroscience research possible.
[0060] 6. This invention, through a unified mapping between the dendritic centerline and dendritic spine coordinates, can output indicators such as dendritic linear density, morphological composition, and local change trends, enabling quantitative analysis of dendritic microstructural changes. This capability can be used for synaptic plasticity research, drug efficacy evaluation, and systematic measurement of dendritic degeneration in disease models, providing a solid quantitative foundation for neuroscience mechanism research. Attached Figure Description
[0061] To more clearly illustrate the specific embodiments of the present invention, the accompanying drawings used in the specific embodiments will be briefly described below. In all the drawings, the elements or parts are not necessarily drawn to scale.
[0062] Figure 1 This is a flowchart of a method for continuous learning and mapping of dendritic spines in two-dimensional two-photon calcium imaging according to the present invention.
[0063] Figure 2 This is a schematic diagram of dendritic spine data preprocessing in a two-photon calcium imaging dendritic spine continuous learning mapping method of the present invention.
[0064] Figure 3 This is a schematic diagram of different dendritic spine labeling methods in a two-dimensional two-photon calcium imaging dendritic spine continuous learning mapping method of the present invention;
[0065] Figure 4 This is a schematic diagram of the dendritic spine segmentation network structure in the dendritic spine continuous learning mapping method for two-dimensional two-photon calcium imaging of the present invention.
[0066] Figure 5 This is a schematic diagram of the continuous learning method in the continuous learning mapping method for dendritic spines in two-dimensional two-photon calcium imaging according to the present invention;
[0067] Figure 6 This is a schematic diagram of the dendritic spine classification network method in the dendritic spine continuous learning mapping method for two-dimensional two-photon calcium imaging of the present invention;
[0068] Figure 7 This is a schematic diagram of the full-field dendritic spine mapping effect in the dendritic spine continuous learning mapping method for two-dimensional two-photon calcium imaging according to the present invention.
[0069] Figure 8 This is a schematic diagram of the two-dimensional maximum projection in the dendritic spine continuous learning mapping method for two-dimensional two-photon calcium imaging according to the present invention.
[0070] Figure 9 This is a schematic diagram of dendritic spine segmentation and classification mapping in a two-dimensional two-photon calcium imaging dendritic spine continuous learning mapping method of the present invention;
[0071] Figure 10 This is a schematic diagram of calcium signal extraction in a dendritic spine continuous learning mapping method for two-dimensional two-photon calcium imaging according to the present invention.
[0072] Figure 11 The flowchart is a method for continuous learning and mapping of dendritic spines in two-dimensional two-photon calcium imaging according to the present invention.
[0073] Figure 12 This is a flowchart of a dendritic spine continuous learning mapping device for two-dimensional two-photon calcium imaging according to the present invention. Detailed Implementation
[0074] The embodiments of the technical solution of the present invention will now be described in detail with reference to the accompanying drawings. These embodiments are merely illustrative of the technical solution of the present invention and are therefore intended to limit the scope of protection of the present invention.
[0075] like Figures 1-12 As shown, the present invention provides a method for continuous learning mapping of dendritic spines in two-dimensional two-photon calcium imaging, comprising:
[0076] Step S01: Acquire two-photon calcium imaging dendritic spine image data, and preprocess it to obtain a first image dataset. Then, randomly divide the first dataset to obtain k second image datasets.
[0077] Step S02: Generate pseudo-labels for the second image data in the first second image dataset with single-point cues using the basic segmentation model to obtain the first second-label image dataset, and train the basic segmentation model accordingly.
[0078] Step S03: The remaining j-th second image dataset is predicted by the basic segmentation model, and the j-th second label image dataset is formed by interactive correction through the large model. The second labels of each round are incorporated into the incremental training to update the segmentation model and obtain the continuous learning model. The first image dataset is processed on the multi-scale feature map using the model to obtain the dendritic spine instance mask set.
[0079] Step S04: Perform coordinate processing on the dendritic spine instance image set according to the nearest attachment rule of dendritic centerline to obtain the dendritic spine coordinate set, and perform automatic category determination on the dendritic spine instance image set to obtain the dendritic spine classification dataset;
[0080] Step S05: Construct a dendritic spine density and category distribution map based on the dendritic spine coordinate set and the dendritic spine classification dataset to obtain a full-view dendritic spine density structure mapping.
[0081] In some embodiments, two-photon calcium imaging dendritic spine image data is acquired and preprocessed to obtain a first image dataset. The first dataset is then randomly divided to obtain k second image datasets, including:
[0082] The experiment used two-photon calcium imaging to acquire fluorescence image data of dendrites and dendritic spines, as well as publicly available datasets, including but not limited to:
[0083] A three-dimensional Z-axis stacked image sequence;
[0084] Continuous three-dimensional time series images containing time series data;
[0085] The two-dimensional dendritic imaging image has already been projected;
[0086] Raw data can be organized by animal number, field of view number, and collection time for subsequent tracking and statistics.
[0087] Drift and deformation corrections are performed on 3D temporal images or 3D Z-axis stacked image sequences, including translation compensation, local deformation correction and inter-frame intensity normalization, to obtain motion-corrected images;
[0088] The motion-corrected 3D image is subjected to maximum intensity projection, and background frames are filtered according to imaging depth or batch information to obtain a 2D reference image;
[0089] A contrast-enhanced image is obtained by performing grayscale normalization and quantile contrast stretching on the two-dimensional reference image.
[0090] Background correction is performed on the contrast-enhanced image, including rolling ball algorithm, morphological opening operation or polynomial surface fitting, and median filtering and Gaussian filtering are used for noise reduction to obtain a denoised image;
[0091] Based on the network input size requirements and imaging calibration ratio, the denoised image is resampled by bilinear or bicubic interpolation and quantized to a preset bit depth of 8 bits to obtain the first image dataset.
[0092] The first image dataset is divided into k subsets according to a preset random seed, where k ≥ 2;
[0093] Stratified sampling can be used to ensure that the proportion of different batches, different animals, different imaging conditions, or different fields of view is roughly the same in each subset.
[0094] The validation and test sets are fixed before the partitioning and do not participate in the construction of the k second image datasets;
[0095] Record metadata such as the original path, animal number, field of view number, and spatial calibration for each image.
[0096] Specifically, this invention uses Python code to automatically preprocess dendritic spine image data, improving data quality and maintaining consistency in their format, size, pixel, and other information, reducing the possibility of errors during network input, and further improving network performance during training.
[0097] like Figure 2 The images show the effects of preprocessing dendritic spine data before and after processing. Image a is the image before low-contrast preprocessing, image b is the result of image a after processing using the method of this invention, image c is a darker image before low-contrast preprocessing, and image d is the result of image c after processing using the method of this invention. Preprocessing can enhance low-contrast areas and improve the consistency of dendritic spine data.
[0098] The preprocessing steps mainly include:
[0099] 1. Motion Correction and Maximum Intensity Projection: Rigid or non-rigid motion correction is performed on continuous 3D time-series images or stacked 3D Z-axis image sequences to reduce displacement errors caused by animal movement and drift. Maximum intensity projection is performed along the Z-axis or time axis to compress the 3D data into a single 2D reference image, preserving the highlight structural information of dendrites and dendritic spines, resulting in a 2D reference image, such as... Figure 2 As shown.
[0100] 2. Gray-level normalization and quantile contrast stretching: Gray-level normalization is performed on the two-dimensional reference image, linearly mapping pixel values to the 0-255 pixel range. Low and high quantiles are calculated and contrast stretching is performed, mapping the main signal range to the full dynamic range, resulting in a contrast-enhanced image that effectively improves the visibility of weak dendritic spine structures.
[0101] 3. Background Correction and Noise Suppression: Smoothing and morphological opening operations are used to estimate the background and perform background subtraction to reduce fluorescence inhomogeneity and slow gradients; median filtering and Gaussian filtering are applied sequentially to the contrast-enhanced image. Median filtering suppresses isolated noise and salt-and-pepper noise, while Gaussian filtering smooths high-frequency noise to obtain a denoised image.
[0102] 4. Spatial Resampling and Bit Depth Quantization: Based on the imaging calibration ratio and the preset network input size (500×500 pixels), the denoised image is interpolated and resampled to unify the spatial resolution; the resampled image is then quantized to a preset bit depth (8 bits) and saved in a unified format (PNG). This results in a first image dataset with unified size, resolution, and grayscale dynamic range.
[0103] Figure 3 The original data to be labeled and three different dendritic spine labeling methods used in this invention are shown. Figure a shows the original data; Figure b shows the traditional manual labeling method, which involves clicking multiple times on the edge of the dendritic spine to form a closed region and complete the labeling of the current dendritic spine; Figure c shows the labeling method using a large model, which only requires clicking once on the target dendritic spine to complete the labeling of a single dendritic spine; Figure d shows the use of a trained model to make predictions on new data, and the use of a large model to correct and fine-tune the prediction results, utilizing model priors to limit manual intervention to areas of missed or false detections.
[0104] In some embodiments, pseudo-labels are generated from the second image data in the first second image dataset using a basic segmentation model with single-point cues, resulting in a first second-labeled image dataset. Based on this dataset, a basic segmentation model is trained, including:
[0105] 1. Single-point cue generation of pseudo-labels: On each image in the first and second image datasets, the annotator provides a single-point positive cue in the target dendritic spine region. The image and the positive cue are input into the base segmentation large model (SAM). A single forward inference operation yields the dendritic spine instance mask and polygon contour, forming the initial pseudo-label, such as... Figure 3 As shown.
[0106] 2. Interactive Misclassified Region Refinement: For clearly misclassified or missed regions, manual evaluation is used to interactively fine-tune the model using a small number of positive / negative points as feedback. The main model automatically updates the instance mask for that region based on the new feedback, outputting a higher-quality binary mask and instance contour. A first-label dataset is constructed, and the base segmentation model is trained.
[0107] 3. Pair the generated instance masks with the corresponding original images to form the first second-label image dataset;
[0108] 4. Using this labeled dataset as a supervision signal, train a lightweight instance segmentation network to obtain the basic segmentation model.
[0109] Specifically, such as Figure 4 As shown, this invention's lightweight instance segmentation network is an improved one-stage instance segmentation network targeting small dendritic spines. Its overall structure includes a backbone feature extraction module, a feature fusion neck module, and a prototype-coefficient decoupled head mask prediction module, used to perform dendritic spine detection and instance segmentation on a single two-dimensional two-photon image.
[0110] The backbone feature extraction module outputs feature maps of multiple scales sequentially from bottom to top. In this invention, a multi-directional windmill convolution module PConvX and a three-way structure-aware downsampling module ADownSPD are introduced into the backbone structure to enhance the feature representation ability of the slender dendritic spine structure and suppress redundant background information.
[0111] 1) The PConvX module divides the input channel into multiple sub-branches, using separable convolution kernels in the horizontal, vertical, and diagonal directions for convolution operations. More convolution directions can be added as needed based on the actual data requirements. The aim is to capture the slender structural features of dendritic trunks and spines in different directions, and then perform multi-directional feature fusion through pointwise convolution, thereby enhancing the details of dendritic spine edges and necks without significantly increasing the number of parameters.
[0112] 2) The ADownSPD module employs three parallel downsampling methods: average pooling, max pooling, and structural pattern description. It concatenates and fuses statistical smoothing information, brightness extremum information, and local structural pattern information, then compresses them using 1×1 convolution and nonlinear activation. This preserves dendritic and dendritic spine structures and suppresses background noise during downsampling, outperforming traditional methods that only use stride convolution or single-path pooling. The concatenated features are then fused via point convolution to obtain more balanced features with higher information density, providing richer texture, contour, and structural information for subsequent multi-scale aggregation, thereby improving the overall accuracy and stability of dendritic spine segmentation.
[0113] The feature fusion neck module employs a bidirectional feature pyramid structure, both top-down and bottom-up, to progressively fuse the multi-scale feature maps output from the backbone. This invention incorporates a context anchor attention module (R4CAA) and a lightweight spatial-channel reconstruction module (R4SC) during the feature fusion stage to further enhance the response in salient dendritic spine regions and reduce interference from unstructured regions.
[0114] 1) The R4CAA module simultaneously encodes the spatial location information of the feature map in both the horizontal and vertical directions, combining it with channel attention to give higher weights to channels containing dendritic trunks and densely packed spine regions, thereby enhancing the network's ability to perceive clustered small spine structures. This module can give higher responses to dendritic spine structures while maintaining the same resolution, suppressing background interference and low-contrast regions near the dendritic trunk, significantly improving the separability of unclear dendritic spine-dendritic trunk boundaries and adjacent adherent regions during segmentation.
[0115] 2) The R4SC module performs lightweight reconstruction of the fused features in both spatial and channel dimensions, suppressing repetitive and redundant features and highlighting key signals related to dendritic spine edges, neck, and head. This allows for the preservation of detailed information beneficial to small targets in both shallower and deeper features. R4SC and R4CAA are complementary, resulting in a fused feature map with higher effective information density, which is more conducive to subsequent instance detection and mask prediction.
[0116] The dendritic spine segmentation network of this invention was tested on a laboratory dataset using existing dendritic spine segmentation networks. Table 1 shows the test results for instance segmentation of a 500×500 two-photon calcium imaging image. The test metrics for the segmentation network include IoU (Intersection over Union), Dice Coefficient, Hausdorff distance, Precision, Recall, and F1 score. The formulas for calculating these metrics are as follows:
[0117]
[0118]
[0119]
[0120] ,
[0121]
[0122] in, and These represent the regions covered by automatic segmentation and the labeled segmented regions, respectively; t and g represent the corresponding boundary coordinate sets (segmentation contours) in Euclidean space, respectively.
[0123]
[0124]
[0125]
[0126] in, This indicates the number of dendritic spines in the ground truth (GT) category. Indicates the number of true positive dendritic spines. This indicates the number of dendritic spines detected.
[0127] The segmentation networks tested included: FCNs (Fully Convolutional Networks), DeepD3 (Deep Dendritic Detection), 2dSpAn-Auto (two-dimensional Spine Analysis-Automatic), Mask R-CNN (MaskRegion-based Convolutional Neural Network for instance segmentation), and YOLOv12 (You Only Look Once for real-time object detection and instance segmentation). The testing process involved dividing the dataset into three subsets: a training dataset (227 images), a validation dataset (33 images), and a test dataset (66 images). Dynamic random flipping and random centering were used to augment the training data. The segmentation networks were trained using the AdamW optimizer with an initial learning rate of 0.0001. A learning rate decay strategy was employed, decreasing the learning rate by 10% every 10 epochs. The optimal model was obtained using an early stopping strategy, with each epoch containing 114 iterations. During the training phase of the segmentation network, the minimum batch size was set to 2. The model with the highest F1 score during the training of each segmentation network was selected as the test model. During the testing phase, the optimal model was loaded and the test dataset was read, resulting in the results shown in the table.
[0128] Table 1. Test Results of the Segmentation Network
[0129]
[0130] In some embodiments, the remaining j-th second image dataset is predicted by the base segmentation model, and the j-th second label image dataset is formed through interactive correction by a large model. The second labels from each round are incorporated into incremental training to update the segmentation model, resulting in a continuous learning model. This model is then used to process the first image dataset on multi-scale feature maps to obtain a dendritic spine instance mask set, including:
[0131] 1. Using the j-th second image dataset as input, the segmentation network initialized with the model weights from the previous round performs forward inference on all images to obtain the corresponding initial instance mask. The predicted feature map is generated by the backbone and the multi-scale feature fusion module, and then passes through the prototype-coefficient combination mask head to generate instance-level segmentation results, resulting in the j-th initial mask result;
[0132] 2. Call the basic segmentation large model to perform interactive correction on the j-th initial mask result set. For false detections, false negatives and boundary adhesion regions, the large model automatically redraws or refines the instance mask with a small number of single-point positive / negative prompts to generate pseudo labels of consistent quality, forming the j-th second label image dataset.
[0133] 3. Combine the j-th second-label image dataset with the label datasets generated in the previous j-1 rounds to form an incremental training set. While keeping the model weights of the previous round as the initial conditions, fine-tune the segmentation network. During the training process, data augmentation, learning rate decay and early stopping strategies are adopted to suppress overfitting and ensure stable performance transfer between different rounds.
[0134] 4. Repeat the above forward prediction, interactive correction and incremental training process for the second to the kth second image datasets in sequence, until the processing of the kth second image dataset is completed, and a continuous learning model integrating incremental information from all rounds is obtained.
[0135] like Figure 5 The diagram illustrates the continuous learning process proposed in this invention. First, an initial dataset is used, comprising two-photon dendritic spine images and masks annotated using a large model. The segmentation module first completes its initial training using this dataset. The resulting model then makes predictions on a new dataset. After obtaining the automatic segmentation results, the large model is used to fine-tune the predictions. The fine-tuned mask is then merged with the automatic segmentation results and used as supervised incremental data to input into the segmentation network for further training, resulting in the next round of model development.
[0136] Specifically, in this invention, the continuous learning module adopts an incremental training framework of "inference-correction-update" to achieve stable learning and performance transfer of dendritic spine data from multiple batches. In the "inference" phase, the current round model performs instance segmentation prediction on the new dataset, fully utilizing previously learned dendritic spine morphological features and multi-scale contextual information. In the "correction" phase, the basic segmentation model interactively corrects the prediction results with minimal prompts, uniformly correcting low-contrast dendritic spines, dendritic spines adjacent to the dendritic trunk, and small targets that are prone to model errors into high-quality pseudo-labels, thereby maintaining the consistency of the supervision signal without significantly increasing the burden of manual annotation. In the "update" phase, the current round pseudo-labels and existing round labels are included in the incremental training set, and short-range fine-tuning is performed starting from the previous round's weights. Early stopping and regularization strategies are used to avoid forgetting old knowledge, while gradually adapting to new data distributions from different animals, batches, or imaging conditions. Through multiple rounds of "reasoning-correction-update" cycles, this invention can continuously absorb new dendritic spine image information while maintaining the basic stability of existing task performance, thereby achieving long-term online expansion and performance enhancement of the two-dimensional two-photon calcium imaging dendritic spine segmentation model.
[0137] The following compares the continuous learning training strategy proposed in this invention with the traditional single-stage training method. Tables 2 and 3 show the results of continuous learning performance evaluation on a 500×500 dendritic spine image. The continuous learning evaluation metrics include BWT (Backward Transfer) and FWT (Forward Transfer). The formulas for calculating these metrics are as follows:
[0138]
[0139]
[0140] in This represents the F1 score on task j after completing the i-th round of continuous learning; while This is the F1 score obtained when learning task j for the first time.
[0141] Testing Process: An initial dataset of 326 images from a laboratory dataset was selected and randomly divided into a fixed validation set (33 images), a fixed test set (66 images), and the remaining 227 images as the training set. The training set was then randomly divided into an initial subset (67 images) and eight incremental subsets (20 images each), constituting an eight-round continuous learning task. A base model was trained on the initial subset; subsequently, inference was performed sequentially on the incremental subsets, and the prediction results were corrected using the SAM (Simultaneous Modeling) to generate pseudo-labels, which were then merged into the next round of training. The model weights from the previous round were then fine-tuned to obtain the next round's model. A total of eight rounds of continuous learning were trained. To verify the impact of training duration on continuous learning performance, this invention set two training modes: 50 epochs and 100 epochs, with other training hyperparameters consistent with the segmentation network. During the testing phase, after each round of training, the model was loaded, inference was performed on the fixed test set, and the F1 score was recorded. Finally, a comprehensive evaluation result of the continuous learning model was obtained.
[0142] Table 2. Continuous Learning Test Results (BWT)
[0143]
[0144]
[0145] Table 3. Results of the Continuous Learning Test (FWT)
[0146]
[0147]
[0148]
[0149] 1. Use a continuous learning model to predict images in the first image dataset, predict dendritic spine candidate regions on multi-scale feature maps, output pixel-level instance masks and corresponding instance identifiers, and summarize them to form a dendritic spine instance mask set;
[0150] 2. Calculate the bounding box of each instance mask for the dendritic spine instance mask set one by one. Expand the bounding box by 1.5 times in the width and height directions according to the preset magnification factor, and perform boundary clipping or filling where it exceeds the image range to obtain the target region set covering the dendritic spine body and its neck neighborhood.
[0151] 3. Using the above target region set as an index, crop the corresponding positions in the first image dataset, resample each target region to a uniform fixed input size, and perform grayscale normalization, bit depth quantization and format standardization processing. At the same time, record the instance identifier, full-image coordinate position and category placeholder information or initial prediction label that can be associated with the subsequent classification module for each region, and finally form a dendritic spine instance image set.
[0152] In some embodiments, the dendritic spine instance image set is processed according to the nearest attachment rule of the dendritic centerline to obtain a dendritic spine coordinate set, and the dendritic spine instance image set is automatically classified to obtain a dendritic spine classification dataset, including:
[0153] 1. Manually label the centerline of the dendritic region in the first image dataset, and sample and discretize the centerline according to a preset step size to obtain a dendritic centerline coordinate dataset composed of ordered coordinate points;
[0154] 2. Perform connected component analysis or polygon contour extraction on the mask of each dendritic spine instance in the dendritic spine instance image set, calculate the centroid coordinates of its instance region, and transform the centroid position from the cropped region of interest coordinate system back to the full image coordinate system, and summarize them to form a dendritic spine centroid coordinate dataset;
[0155] 3. Using the dendritic centerline coordinate dataset as a reference and the dendritic spine centroid coordinate dataset as a query set, calculate the Euclidean distance from the centroid of each dendritic spine to all centerline sampling points one by one, and select the minimum value as the nearest attachment distance of the dendritic spine to obtain the shortest Euclidean distance dataset describing the geometric relationship between dendritic spine and dendritic spine.
[0156] 4. Based on the preset distance threshold and optional projection rules, threshold determination and filtering are performed on the shortest Euclidean distance dataset. Dendritic spines with a distance less than or equal to the threshold and satisfying geometric constraints are considered to have successfully attached to the corresponding dendritic centerline. Based on recording the coordinates of the nearest attachment point, the dendritic branch number, and the dendritic spine number, a structured dendritic spine coordinate set is output.
[0157] Specifically, in the process of determining the nearest attachment relationship, a spatial index of the sampling points on the dendritic centerline is constructed to accelerate the nearest neighbor query from the centroid of the dendritic spine to the centerline. For each dendritic spine centroid, the nearest centerline point and its corresponding shortest Euclidean distance are obtained. When the shortest Euclidean distance is less than or equal to the physical distance threshold τ calculated based on the pixel size, it is marked as "valid attachment," and the dendrite number to which the spine is attached, its projection position index on the centerline, and its global coordinates are recorded. For cases where multiple dendritic centerlines are simultaneously adjacent to a certain dendritic spine centroid, a minimum distance priority strategy is adopted. Dendritic spines that exceed the threshold or have obviously abnormal geometric relationships can be marked as "awaiting manual review" to avoid misjudging free noise or false detections far from the dendrites as valid dendritic spines. The dendritic spine coordinate set generated after processing by the aforementioned nearest attachment rule not only records the spatial position of each dendritic spine in the entire field of view, but also retains its corresponding dendrite, branch, and relative position index along the dendritic direction. This provides a unified and coherent geometric basis for the subsequent construction of density profiles along the dendritic axis, branch-level statistics, and mapping of dendritic spine density and category distribution in the entire field of view.
[0158] 1. Scale and normalize the grayscale of each region of interest in the dendritic spine instance image set according to a uniform input size. Preferably, normalize the dendritic spine region of interest obtained by the segmentation module into a fixed-size two-dimensional image, and retain its corresponding instance number and coordinate information in the full field of view.
[0159] 2. Input the normalized dendritic spine instance images into a lightweight classification network in batches. The classification network consists of a backbone and terminal coordinate attention mechanism composed of multiple layers of reversible convolutional modules. The feature vector representation of each instance and the corresponding multi-class confidence distribution are obtained through forward inference.
[0160] 3. Determine the structural category of each dendritic spine instance based on the maximum confidence score output by the classification network or the preset decision rule, and record the instance identifier, full-image coordinates, category label and complete confidence vector together to form a structured dendritic spine classification dataset. Optionally, the predicted category can be overlaid back onto the corresponding instance mask with different colors.
[0161] like Figure 6 The diagram illustrates the lightweight classification network structure used in this invention. This network accepts the output of a segmentation network, converts the original image into a dendritic spine region of interest (ROI), and inputs it into the classification network. The network structure consists of convolutional layers, six consecutive invertible convolutions, a coordinate attention mechanism, and a global pooling layer. Finally, the classification network categorizes the input dendritic spine ROI into different dendritic spine types.
[0162] Specifically, in this invention, the lightweight classification network preferably adopts a shallow structure with reversible residual convolution modules at its core, which can control the number of parameters and inference latency while maintaining high classification performance. A specific architecture may include:
[0163] 1) Stem convolutional layer: The input dendritic spine region of interest image is first expanded and preliminarily extracted through several layers of 3×3 convolution. After convolution, batch normalization and non-linear activation function are applied to enhance numerical stability and improve the ability to represent local texture.
[0164] 2) MBConv Multi-Layer Reversible Convolutional Backbone Module: Each MBConv module includes an inverse residual structure consisting of "1×1 channel extended convolution; 3×3 depthwise separable convolution; 1×1 channel compressed convolution." Residual connections are introduced when the input and output dimensions are consistent, enabling efficient feature reuse across the channel dimension. The depthwise separable convolution performs spatial convolution on each channel separately, which is beneficial for capturing fine-grained morphological changes in the neck and head of dendritic spines within a small receptive field, while significantly reducing computational cost. By stacking multiple MBConv modules, multi-level representations from local to mesoscale are extracted progressively from the bottom up, enabling the network to focus on both the shape of the dendritic spine head and its relative positional relationship with the dendritic backbone.
[0165] 3) Coordinate Attention Mechanism: A coordinate attention module is introduced at the end of the main branch to perform global aggregation and positional encoding on the feature maps output by MBConv.
[0166] Global aggregation is performed along both the horizontal and vertical directions to obtain a one-dimensional feature representation carrying spatial location information. Spatial coordinate encoding is fused with channel semantics to generate position-sensitive attention weights, which are then reweighted positionally and channel-wise on the original feature map. This allows for highlighting the dendritic spine outline and neck region without reducing spatial resolution, suppressing background interference near the dendritic trunk, and improving separability in low-contrast scenes.
[0167] 4) Global Aggregation and Classification Header: To better distinguish subtle morphological differences, this invention uses generalized mean pooling instead of simple average pooling or max pooling.
[0168] This pooling method adaptively reweights different response intensities of the feature map using a learnable exponential parameter, continuously adjusting between average and extreme responses to simultaneously consider the spine outline, neck details, and background texture. The resulting global feature vector is then mapped sequentially through one or two fully connected layers and a non-linear activation function, finally outputting the probability distribution for each category via a Softmax layer.
[0169] The dendritic spine classification network of this invention was tested on a laboratory dataset using existing classification networks. Table 4 shows the test results for classifying a 50×50 two-dimensional two-photon calcium imaging dendritic spine region of interest image. The test metrics for the classification network include Accuracy, Precision, and Recall, calculated using the following formulas:
[0170]
[0171]
[0172]
[0173] Among them, true positive (TP) refers to the number of dendritic spines that are correctly classified and predicted as positive, true negative (TN) refers to the number of dendritic spines that are correctly classified and predicted as negative, false positive (FP) represents the number of dendritic spines that are misclassified, and false negative (FN) represents the number of dendritic spines that are misclassified.
[0174] The classification networks tested included: EfficientNet (Efficient Neural Network), ResNet18 (Residual Network-18 Layers), Swin Transformer (Shifted Window Transformer), VGG16 (Visual GeometryGroup-16 Layers), and MobileNet (Mobile Neural Network). The testing process involved selecting 959 dendritic spine region-of-interest images collected in the laboratory to form the initial dataset. Labels were provided based on manually calibrated morphological categories (mushroom-shaped and short and stout). The dataset was randomly divided into a training set (767 images) and a test set (192 images), and this random division was repeated 10 times to verify the stability of the classification networks. Each of the six methods, including this invention, was trained for 200 epochs. The classification network of this invention used the AdamW optimizer with an initial learning rate of 0.0001 and a minimum batch size of 32. After each training round, the model with the highest accuracy is selected as the test model. During the testing phase, the model is loaded, the test set is read, various metrics are calculated, and the results in the table are obtained.
[0175] Table 4. Classification Network Test Results
[0176] In some embodiments, a dendritic spine density and category distribution map is constructed based on the dendritic spine coordinate set and the dendritic spine classification dataset to obtain a full-view dendritic spine density structure mapping, including:
[0177] 1. Based on the dendritic centerline coordinate dataset, dendritic spine coordinate dataset, and dendritic spine classification dataset, the number of attached dendritic spines, dendritic spine density per unit length, and proportion of different morphological categories are counted for each target dendrite, resulting in a dendritic spine density dataset organized by dendritic number.
[0178] 2. Map the dendritic spine density dataset and category statistics results back to the full-field dendritic coordinate frame according to the coordinates of the dendritic centerline and the position of the dendritic spine centroid in the original imaging coordinate system. Establish the corresponding spatial index on a plane or voxel grid with the same size as the original imaging to form a full-field statistical frame containing "spatial location - dendritic number - dendritic spine density - category ratio".
[0179] 3. Based on the full-view statistical framework, color coding is used to render dendritic spine density as a continuous or discrete density heatmap, and the main categories or category proportions are visualized by pseudo-color overlay. The output is a dendritic spine density and category distribution map that simultaneously contains density, category, spatial location and statistical information, and the full-view dendritic spine density structure mapping result is obtained. Optionally, it supports exporting the corresponding image and table data by dendrite, by field of view or by region.
[0180] like Figure 7 The figures show the full-field mapping results of dendritic spine data with a single neuron structure using this invention. Figure a shows the original three-dimensional data of cell body-dendritic spine-dendritic spine in the full field of view. Figure b shows the two-dimensional maximum projection map of this data. Figure c shows the classification and segmentation results after analysis using this invention, where the red area represents mushroom-shaped dendritic spines, the green area represents short and thick dendritic spines, the blue area represents other types of dendritic spines, and the yellow dashed line is the dendritic centerline used to determine the dendritic spine's affiliation and calculate its density. Figure d shows the distribution of different types of dendritic spines in this data, and the dendritic spine density analysis on each dendrite.
[0181] Specifically, during the full-view mapping process, the dendritic centerline and segment statistical results can be back-projected onto a two-dimensional coordinate grid consistent with the original image:
[0182] 1) For each length segment of each dendrite, map the centerline coordinate range corresponding to the segment to the original image plane, calculate the coverage area of the segment in the pixel coordinate system, and fill or weight the corresponding density value in the area.
[0183] 2) For category composition, visualization can be achieved using methods such as "dominant category coloring" or "category ratio multi-channel encoding": for example, pre-assigning pseudo-color to each type of dendritic spine, mixing colors according to category ratio within that segment, or using multiple layers to display the density distribution of different categories separately;
[0184] 3) For regions where multiple dendrites may overlap in space, strategies such as maximum value, summation, or weighted fusion can be used to distinguish the dominant dendrites or present cumulative density information, thereby constructing a dendritic spine density heatmap and category distribution map that are continuously distributed on the original imaging field of view.
[0185] like Figure 8 As shown, Figures a and b are two-dimensional maximum projection diagrams of two different sets of dendritic spine data used for time-series functional structure analysis.
[0186] like Figure 9 As shown, Figure a and Figure b are the corresponding figures. Figure 8 Figures a and b show the results of the automatic classification and segmentation of this invention. The red area represents the mushroom-shaped dendritic spines, the green area represents the short and thick dendritic spines, and the blue area represents other types of dendritic spines.
[0187] like Figure 10 As shown, this is the corresponding Figure 9 The results of extracting time-series functional calcium signals using this invention are shown in Figures a and b, respectively. Figure 9 The calcium signals extracted from the two dendritic spines selected by the dashed box in Figure a are shown in Figures c and d, respectively. Figure 9 The calcium signals extracted from the two dendritic spines selected by the dashed box in Figure b are shown in the time scale, which is 5 seconds.
[0188] in, This represents the relative fluorescence change rate, used to characterize the dynamic change in calcium activity intensity of dendritic spines over time. Specifically, it is the baseline fluorescence intensity of each dendritic spine in the time series. ( (The instantaneous fluorescence intensity can be estimated using the resting interval or sliding window quantile as a reference.) Normalization, calculation yields
[0189] This eliminates the initial brightness differences between different cells and improves cross-sample comparability. The curves in the figure correspond to the ΔF / F time series trajectories of different ROIs, with peaks and spikes reflecting calcium transient events.
[0190] Preferably, the present invention further extends the above-mentioned structure mapping to a "structure-function integrated" dendritic spine mapping: for two-photon calcium imaging data with time series, the dendritic spine instance mask output by the segmentation module can be reused as the region of interest, and the fluorescence intensity curve of each dendritic spine in the full time series can be automatically extracted and calculated. Functional readout metrics such as peak amplitude, event frequency, and integral area are used. These functional metrics are aligned with the dendritic spine coordinate set and projected onto the same full-view coordinate frame, enabling joint visualization and statistical analysis of "dendritic spine density-morphological category-functional activity". This structure-function mapping can simultaneously display morphological and functional differences at the dendritic and dendritic spine levels without adding additional annotation costs, significantly improving the interpretability, reproducibility, and scalability of dendritic spine analysis. It provides a unified quantitative comparison framework for subsequent research on differences in dendritic spine reconstruction and plasticity among different dendritic branches, different views, and different conditions.
[0191] Specifically, in the mapping module of this invention, quantitative dendritic spine density analysis is performed on two-dimensional two-photon calcium imaging data. The mapping module of this invention can automatically load an instance segmentation mask that is strictly aligned with the original image, and on this basis, depict the centerline of the target dendrites. The centerline is usually marked manually or semi-automatically along the dendritic axis to ensure the biological accuracy of the results. The method of use is as follows: First, according to the actual physical calibration ratio of the image (e.g., ... (pixels), set the spatial scale factor s, and set the nearest attachment threshold for dendritic spines. (In this embodiment) Usually taken For each detected dendritic spine instance, the system automatically calculates its shortest Euclidean distance to the dendritic centerline. If this distance satisfies... If the dendritic spine is found to be attached to the target dendrite, then it is considered to be attached to the target dendrite. When necessary, the editing mode provided by this invention allows users to manually review and correct the automatically selected dendritic spines, thereby ensuring higher interpretability and reliability of the statistical results. The dendritic spine density is calculated as follows:
[0192]
[0193]
[0194]
[0195]
[0196] in, It is the vertex coordinate of the target dendrite centerline, which is manually drawn, and its piecewise linear curve is represented by C. It is the pixel set of the mask for the i-th dendrite instance. These represent pixels on the dendrites and centerline, respectively. `s` converts the pixel distance to physical units. is the shortest Euclidean distance from the i-th dendrite to the centerline. τ is the nearest attachment threshold, which is set to 2 micrometers in this analysis. N is the value that satisfies... The number of dendritic spines, L is the physical length of the target dendrite centerline, and ρ is the dendritic linear density of the target dendrite.
[0197] In other embodiments, a dendritic spine continuous learning mapping device for two-dimensional two-photon calcium imaging is provided, comprising:
[0198] The data acquisition module is used to acquire two-photon calcium imaging dendritic spine image data, preprocess it to obtain a first image dataset, and randomly divide the first dataset to obtain k second image datasets.
[0199] The segmentation processing module is used to generate pseudo-labels for the second image data in the first second image dataset with single-point cues from the basic segmentation model, to obtain the first second-label image dataset, and to train the basic segmentation model based on it.
[0200] The continuous learning module is used to predict the remaining j-th second image dataset by the basic segmentation model, and form the j-th second label image dataset through interactive correction by the large model. The second labels of each round are incorporated into the incremental training to update the segmentation model, resulting in a continuous learning model. This model is used to process the first image dataset on multi-scale feature maps to obtain a dendritic spine instance mask set.
[0201] The center coordinate processing module is used to process the dendritic spine instance image set according to the nearest attachment rule of the dendritic centerline to obtain the dendritic spine coordinate set, and to automatically determine the category of the dendritic spine instance image set to obtain the dendritic spine classification dataset.
[0202] The mapping module is used to construct a dendritic spine density and category distribution map based on the dendritic spine coordinate set and the dendritic spine classification dataset, thereby obtaining a full-view dendritic spine density structure mapping.
[0203] In some embodiments, a two-dimensional two-photon calcium imaging dendritic spine continuous learning mapping apparatus includes a processor and a memory storing program instructions, the processor being configured to execute a two-dimensional two-photon calcium imaging dendritic spine continuous learning mapping method as described above when the program instructions are executed.
[0204] In other embodiments, an electronic device (e.g., a mobile phone, a computer) is provided, including the dendritic spine continuous learning mapping device for two-dimensional two-photon calcium imaging described above.
[0205] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention, and they should all be covered within the scope of the claims and specification of the present invention.
Claims
1. A method for continuous learning mapping of dendritic spines in two-dimensional two-photon calcium imaging, characterized in that, include: Two-photon calcium imaging dendritic spine image data is acquired and preprocessed to obtain a first image dataset. The first image dataset is then randomly divided to obtain k second image datasets. The basic segmentation model generates pseudo-labels for the second image data in the first second image dataset with single-point cues, thus obtaining the first second-label image dataset. Based on this dataset, the basic segmentation model is trained. The remaining j-th second image dataset is predicted by the basic segmentation model, and the j-th second label image dataset is formed by interactive correction through the large model. The second labels of each round are incorporated into incremental training to update the segmentation model, resulting in a continuous learning model. The continuous learning model is used to process the first image dataset on multi-scale feature maps to obtain a dendritic spine instance image set. The dendritic spine instance image set is processed according to the nearest attachment rule of dendritic centerline to obtain a dendritic spine coordinate set, and the dendritic spine instance image set is automatically classified to obtain a dendritic spine classification dataset. Based on the dendritic spine coordinate set and the dendritic spine classification dataset, a dendritic spine density and category distribution map is constructed to obtain a full-view dendritic spine density structure mapping.
2. The method for continuous learning mapping of dendritic spines in two-dimensional two-photon calcium imaging according to claim 1, characterized in that, The two-photon calcium imaging dendritic spine image data is preprocessed to obtain a first image dataset. The first dataset is then randomly divided to obtain k second image datasets, including: Motion correction and information projection are performed on the original data to obtain a two-dimensional reference image; The two-dimensional reference image is subjected to grayscale normalization and quantile contrast stretching to obtain a contrast-enhanced image; The contrast-enhanced image is then subjected to background correction to obtain a background-corrected image; The background correction image is denoised by median filtering and Gaussian filtering to obtain a denoised image; The denoised image is resampled and interpolated according to the target input size and the imaging calibration ratio, and quantized to a preset bit depth to obtain the first image dataset. The first image dataset is divided into k sub-datasets according to a preset random seed; Stratified sampling was used to ensure that different imaging batches / animals / fields of view had a consistent proportion in each subset; The fixed validation set and test set are not included in the partitioning of the k second image datasets; Each subset has an equal sample size. The source data identifier and full-image coordinate information of each sample are recorded to obtain k second image datasets.
3. The method for continuous learning mapping of dendritic spines in two-dimensional two-photon calcium imaging according to claim 1, characterized in that, The process involves generating pseudo-labels for the second image data in the first second image dataset using a basic segmentation model with single-point cues, resulting in the first second-labeled image dataset. Based on this dataset, a basic segmentation model is trained, including: A single-point positive cue is given for the dendritic spine region in the first second image dataset, and the basic segmentation large model generates an instance mask in one forward pass; The system provides interactive fine-tuning with a few positive / negative prompts at the points of error, outputs a binary mask and instance polygons, and obtains the first second-labeled image dataset. Using the first second-label image dataset as supervision, an instance segmentation network is trained to obtain the basic segmentation model.
4. The method for continuous learning mapping of dendritic spines in two-dimensional two-photon calcium imaging according to claim 1, characterized in that, The remaining j-th second image dataset is predicted by the base segmentation model, and the j-th second label image dataset is formed through interactive correction by the large model. The second labels from each round are incorporated into incremental training to update the segmentation model, resulting in a continuous learning model. This continuous learning model is used to process the first image dataset on multi-scale feature maps to obtain a dendritic spine instance image set, including: The basic segmentation model is used to perform dendritic spine instance segmentation prediction on the j-th second image dataset to obtain the j-th second mask image dataset; Using the aforementioned basic segmentation model with minimal prompting, the j-th second mask image dataset is interactively corrected to generate the j-th second label image dataset; The j-th second-label image dataset is incorporated into the incremental training set and retrained together with the weights of the previous model, along with early stopping monitoring, to obtain the updated segmentation model. Repeat the above steps until the kth second image dataset is processed to obtain the continuous learning model; The first image dataset is processed on multi-scale feature maps using the continuous learning model to obtain a dendritic spine instance mask set. Extract the bounding box of the dendritic spine instance mask set and enlarge it according to a preset ratio to obtain the target region set; The first image dataset is cropped into regions of interest of fixed size according to the target region set, and normalized and quantized. Each dendritic spine region of interest and its corresponding instance identifier, category information and full-image coordinate position are saved to form a dendritic spine instance image set.
5. The method for continuous learning mapping of dendritic spines in two-dimensional two-photon calcium imaging according to claim 1, characterized in that, The dendritic spine instance image set is processed according to the nearest attachment rule of the dendritic centerline to obtain a dendritic spine coordinate set, and the dendritic spine instance image set is automatically classified to obtain a dendritic spine classification dataset, including: Extract the centerline of the target dendrites from the first image dataset and discretize it into ordered coordinate points to obtain the dendrite centerline coordinate dataset; Calculate the centroid coordinates of the mask for each dendritic spine instance in the dendritic spine instance image set to obtain the dendritic spine centroid coordinate dataset; Calculate the shortest Euclidean distance between the dendritic centerline coordinate dataset and the dendritic spine centroid coordinate dataset to obtain the shortest Euclidean distance dataset; Based on the preset distance threshold, the above shortest Euclidean distance dataset is processed to determine the attachment relationship between dendritic spines and dendrites. The centroid coordinates of dendritic spines that satisfy the attachment relationship are processed to obtain the dendritic spine coordinate set. The dendritic spine instance image set is input into a lightweight classification network, which consists of a multi-layer reversible convolutional module and a coordinate attention mechanism. The category to which each instance in the dendritic spine instance image set belongs is determined based on the feature vector and classification confidence score output by the classification network. The dendritic spine classification dataset is obtained by outputting the corresponding category label and confidence distribution for each instance.
6. The method for continuous learning mapping of dendritic spines in two-dimensional two-photon calcium imaging according to claim 1, characterized in that, The process of constructing a dendritic spine density and category distribution map based on the dendritic spine coordinate set and the dendritic spine classification dataset to obtain a full-view dendritic spine density structure mapping includes: Using the dendritic spine coordinate set and dendritic spine classification dataset, the number of dendritic spines on the corresponding dendrites and the proportion of different categories are counted to obtain the dendritic spine density dataset. The dendritic spine density dataset and category information are mapped to a full-view coordinate frame; Density heatmaps and category distribution maps are generated using color coding, and the output includes density, category, location and statistical information, resulting in a full-view dendritic spine density structure mapping.
7. A dendritic spine continuous learning mapping device for two-dimensional two-photon calcium imaging, characterized in that, include: The data acquisition module is used to acquire two-photon calcium imaging dendritic spine image data, preprocess it to obtain a first image dataset, and randomly divide the first image dataset to obtain k second image datasets. The segmentation processing module is used to generate pseudo-labels for the second image data in the first second image dataset with single-point cues from the basic segmentation model, to obtain the first second-label image dataset, and to train the basic segmentation model based on it. The continuous learning module is used to predict the remaining j-th second image dataset by the base segmentation model, and to form the j-th second label image dataset through interactive correction by the large model. The second labels of each round are incorporated into the incremental training to update the segmentation model, thus obtaining the continuous learning model. The continuous learning model is used to process the first image dataset on multi-scale feature maps to obtain the dendritic spine instance image set. The center coordinate processing module is used to process the dendritic spine instance image set according to the nearest attachment rule of the dendritic centerline to obtain the dendritic spine coordinate set, and to automatically determine the category of the dendritic spine instance image set to obtain the dendritic spine classification dataset. The mapping module is used to construct a dendritic spine density and category distribution map based on the dendritic spine coordinate set and the dendritic spine classification dataset, thereby obtaining a full-view dendritic spine density structure mapping.
8. A dendritic spine continuous learning mapping device for two-dimensional two-photon calcium imaging, comprising a processor and a memory storing program instructions, characterized in that, The processor is configured to, when running the program instructions, execute a dendritic spine continuous learning mapping method for two-dimensional two-photon calcium imaging as described in any one of claims 1 to 6.
9. An electronic device, characterized in that, The device includes a dendritic spine continuous learning mapping device for two-dimensional two-photon calcium imaging as described in any one of claims 7 or 8.