Automated segmentation of the median nerve in patients with carpal tunnel syndrome

Subject inclusionPatients with CTS were recruited from the orthopedic department St. Olavs hospital, Trondheim (Norway). All patients scheduled for surgery with carpal tunnel release were defined as established CTS. Exclusion criteria were previous fracture, previous CTS operation, and patients with established inflammatory arthritis. The result from the ultrasound exam did not interfere with the decision to treat by surgical release. Patients waiting for the operation were asked to do the ultrasound before the operation. The healthy controls were recruited from the rheumatologic department and SINTEF, the exclusion criteria were symptoms of CTS, former surgery or severe trauma of the wrist. Approval by the Regional Committees for Medical and Health Research Ethics (Regionale komiteer for medisinsk og helsefaglig forskningsetikk in Norwegian) was granted based on detailed consideration of our experimental protocol (application ID 373038). The research was performed in accordance with national and EU guidelines and regulations, written informed consent was obtained from all participants, and our research was performed in accordance with the WMA Declaration of Helsinki—Ethical principles for medical research involving human subjects.Ground truth or gold standard for the diagnosis of CTS: The diagnosis of CTS was defined as established when the patient was accepted for surgery. But not all patients were diagnosed with electrophysiological tests, in some cases the patient was accepted for surgery only after a clinical evaluation and a history of a successful decompression of the contralateral hand.From all participants, age, sex, self-reported weight and height were recorded. For the ultrasound scanning the participant was sitting in front of the operator with the arm in a supine position on a table with a slight flexion of the fingers. From the wrist crease was measured a distance of 15 cm up the forearm where ultrasound was taken. The reason to scan such a large aspect of the median nerve was to secure enough data for future studies on 3D visualisation of the nerve and for the possibility to calculate ratios of the CSA at different levels.From the healthy controls only the left forearm and wrist were scanned with ultrasound. From the patients only the arm that was planned for operation was scanned (in patients with bilateral CTS both hands were scanned). All ultrasound images were taken by a rheumatologist with more than 5 years of experience in musculoskeletal ultrasound (F.M.) To guarantee visualization of the median nerve in the middle of the forearm, a GE Logiq 10 scanner was used with a 6–15 MHz probe in a MSK mode with a depth of 3.5–4.0 cm was used. Three similar recordings were taken from each participant. Each video-loop of the ultrasound consisted of about 500 frames, depending on how fast the probe was moved down the forearm.SegmentationThe ultrasound videos were manually segmented by an experienced rheumatologist using Annotation Web22 to delineate the median nerve by a polygon in 30–40 ultrasound images per participant. Each anatomical structure that was segmented, a different colour was assigned to (Fig. 1b). The epineurium (nerve sheath) of the median nerve was not included in the segmentation or outlining (Fig. 1). The images selected for segmentation were selected from all parts of the ultrasound scans, not only close to the wrist. Images were chosen according to their quality, so in areas with very blurry images segmentation was dropped, but in areas with good quality in the sense of distinguishability of the structures, images were segmented in close succession.Figure 1(a) Wrist flexor side, transverse at the crease without segmentation, (b) same frame as in A, but outlined the scaphoid bone to the left (orange), the pisiform on the right side (white), and the median nerve (blue).Measurement of the median nerveFor the measurement of the cross-sectional area (CSA) of the median nerve, only images taken to the very inlet of the carpal tunnel with visualization of both the scaphoid and the pisiform were used. The CSA of the median nerve was manually traced at the inside of the high echogenic epineurium from each participant. We performed three manual measurements from each participant and copied the CSA calculated by the scanner. Additionally, a similar measurement was taken further proximally at the level of the pronator quadratus muscle. The trained AI algorithm was used to automatically calculate the CSA from the same image that were used for the first manual CSA measurement for each patient.Inter-observer variabilityIn a minor sample of the patients (n = 8), manual segmentation of the median nerve was performed by F.M. and I.S. separately for inter-observer testing. From each participant 30 frames were randomly picked by a non-expert, so both operators were annotating identical frames.Algorithm trainingThe images used to train the segmentation AI-models were exported from the GE Logic scanner with minimal noise filtering and processing. The images were downscaled to fit a network input size of 256 \(\times\) 256 pixels. For the algorithm training the ultrasound images were used in their unprocessed form without any augmentation of contrast The CNN architecture used in this study was a fully-convolutional encoder–decoder U-net type network23. This architecture has six levels with cross-over connections and uses 2 \(\times\) 2 max pooling in the encoder and 2 \(\times\) 2 repeat upsampling in the decoder. Two 3 \(\times\) 3 convolution layers are used at each level, together with ReLU activation. The output is a segmentation of the same size as the input image.The neural networks were trained using Keras with 10-fold cross-validation, Adam optimizer, 150 epochs and a Dice loss function. The patients were randomly divided into 10 groups with 4–5 patients in each group. For each of the cross-validation folds, data from one group was set aside for testing of the trained model, one group was used as a validation set during training and 8 groups were used as a training set. The test results from each fold were averaged for the final test result. Random augmentations were used during training to reduce overfitting19. The following augmentations were used:

Gamma intensity transformation.

Rotation with a maximum angle of 10 degrees.

Gaussian shadows: Dark shadows applied to the image at random locations and with random sizes.

Depth: Cuts the image bottom at random depths.

JPEG compression: Compresses the image with a random quality setting.

Elastic image deformation.

Diagnostic power of cross-sectional areaA secondary branch of our study, independently from machine learning-based segmentation of the median nerve, was to assess the relationship between the cross-sectional area (CSA) of the median nerve and the patient being diagnosed with carpal tunnel syndrome. This was done using the CSA measured manually by delineating the nerve using a dedicated function of the ultrasound scanner, and a second time using the CSA predicted by the machine learning model to compare if the diagnostic power was comparable to that of the first method.Manually measured cross-sectional areaThe data was preprocessed by averaging the three repeated measurements and removing outliers of cross-sectional area (CSA) of the median nerve, following the criteria of 1.5 times interquartile range. Variables were normalized using a standard scaler, to achieve a mean of zero, and standard deviation of one. A preliminary linear regression was fitted to the CSA as a function of height, weight, age, and gender. Variables were further binned to improve parsimony of the following models. A logistic regression was fitted to the diagnostic status of the subject as dependent variable, using a generalized linear model with logit link. All analyses were performed using R Statistical Software (v4.3.3; R Core Team 2024). Independent variables, or predictors, were the manually measured CSAs of the median nerve, as well as height, weight, age, and gender of the patients. The model was weighted to compensate for any uneven distribution of patients versus control. The model was built incrementally from a null model to a set of independent variables so that the marginal goodness of fit overcomes the additional degrees of freedom measured by maximum likelihood and chi squared test.$$\begin{aligned} Diagnosis \sim CSA_s + height_s \end{aligned}$$where Diagnosis is the binary dependent variable of the logistic regression, and \(CSA_s\) and \(height_s\) are the scaled or normalised version of CSA of the median nerve and subject height, respectively.Though this method balances goodness of fit and parsimony, we combined the predictive value of the model for final selection of the model. The latter was calculated by letting the logistic regression predict the classes (standard probability cut-off of 0.5) and building a confusion matrix from results and reference classes of diagnosis. Additional standard metrics of accuracy, sensitivity and specificity are also reported. Reproducibility of the three repeated measurements was tested using the test-retest reliability (intraclass correlation coefficient—ICC).Machine learning-estimated cross-sectional areaThe machine learning-simulated cross-sectional areas were compared to the manually measured ones in paired t-test and Wilcoxon paired samples test to determine systematic bias of estimation. Additionally, the diagnostic value of the simulated CSAs was tested using the same logistic regression as for the manual ones. The classification as healthy or carpal tunnel syndrome with the standard metrics allows for comparison of diagnostic powers.

Hot Topics

Related Articles