Optical plasma boundary detection and its reconstruction on EAST tokamak

Plasma boundary detection and reconstruction are important not only for plasma operation but also for plasma facing materials. Traditional methods, for example, EFIT code, which is constrained by electromagnetic measurement, and is very challenging for detecting the plasma boundary in long-pulse burning plasma devices such as ITER. A novel algorithm for the reconstruction of the plasma boundary using one visible camera has been developed on experimental advanced superconducting tokamak (EAST) for fusion reactors. A U-Net convolutional neural network was used to identify the plasma boundary and the pixel coordinates of the boundary points were fitted with EFIT via the XGBoost model. This algorithm can transform the boundary from the image plane to the poloidal plane of the Tokamak based on machine learning without traditional spatial calibration, and then the reconstruction of the plasma configuration shall be realized based on a monocular visible light camera. The reconstruction accuracy of this algorithm is relatively high. The average error on the test set was only 7.36 mm (<1 cm) and satisfied the accuracy requirements of control for EAST tokamak. This result can contribute to the development of the plasma boundary reconstruction and operation based on one visible camera.


Introduction
In magnetic fusion devices, the detection and further reconstruction of plasma shape is of great significance not only for the optimization of operating parameters, but also for controlling the heat load and particle deposition on the vacuum * Author to whom any correspondence should be addressed.
Original content from this work may be used under the terms of the Creative Commons Attribution 4.0 licence. Any further distribution of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI. chamber wall and the target plate of divertor. In present tokamaks, the EFIT code constrained by magnetic measurement is widely used to estimate the position and shape of plasma. Although this method is widely accepted on almost all tokamaks, there are situations in which applicability of the magnetic measurements is limited [1]. Since measurable quantities are acquired via time integration procedure, in future fusion devices especially demonstration reactor (DEMO), the burning plasma condition shall prevent us from accessing plasma parameters via traditional direct diagnostics systems such as probes [2]. It necessitates the development of a new plasma boundary reconstruction algorithm to meet the needs of plasma shape diagnostics in long-pulse plasma operation for larger size tokamak devices in the future.
Machine learning and especially the variant deep learning has proven to be a powerful tool in automations and control [3]. Multiple deep learning architectures have been designed with a same fundamental idea that to train a computer algorithm for predicting or finding patterns in a complicated system [4].
Early in the field of machine learning supported fusion research, neural network was first applied in the prediction of disruptions in multiple fusion devices including TEXT-U [5], DIIID [6], JT-60U [7]. With the limit of computing power and maximum data storage at that time, only a few layers were available in neural network and thus, only able to predict some classes of disruption [8]. However, these efforts revealed great potential of machine learning aided fusion research. Today, disruption prediction still remains one of the most active topics in machine learning aided fusion research [8][9][10][11][12][13][14][15], while another one is machine learning involved plasma control [16][17][18]. Applications in electron temperature profile estimation [19], plasma tomography [20], radiated power estimation [21], discharge prediction [22,23], instabilities identifications [24], heat load pattern estimation [25], equilibrium reconstruction [26][27][28][29][30] all showed promising results. The potential of machine learning in fusion research is beyond the scope of present paper, readers may refer to [31] for further information, where a rather thorough discussion over various deep learning techniques and their possible workflows are outlined.
For machine learning based equilibrium reconstruction, there are mainly two research paradigms [8], which are data driven and physics driven. For physics driven modeling of machine learning, one may seek for a neural network involved Grad-Shafranov solver [32][33][34]. While for data driven modeling, the technical approach is mainly based on computer vision [35]. Luo et al [36] proposed a boundary reconstruction method without camera calibration. The algorithm aims to minimize the deviations between optical reconstruction results and EFIT data, and the error is about 1-2 cm in experimental advanced superconducting tokamak (EAST) discharge experiment and EFIT data. However, its edge extraction algorithm requires manual setting of the region of interest (ROI) area, which cannot detect the outer plasma boundary and the reconstructed boundary may have a horizontal drift, a special method may be required for corrections. The plasma boundary is visible from the images taken by the visible camera on EAST. The problem of magnetic measurement can be avoided by extracting the plasma boundary in the image and reconstructing its shape and positions.
Since 2015, U-Net has made major breakthroughs in the medical image segmentation. It adopts a fully convolutional neural network and with its unique encoding and decoding procedure, the data required by training set can be quite small, enabling it to be a low weight yet efficient computer vision technique.
In this paper, a boundary extraction algorithm using the image segmentation method based on U-Net is proposed in [37]. Reference [37] includes a detailed explanation of the application of U-Net to image segmentation problems, understandable to non-neural network experts. Plasma boundary can be extracted from the whole image without manually setting ROI area, and the optical reconstruction algorithm based on XGBoost [38] obtains an average error of 7.36 mm. This paper presents a plasma boundary reconstruction algorithm based on a visible camera, which is suitable for future long-pulse plasma operation of larger size Tokamak devices. This paper is organized as follows: after introduction of the advantages of plasma boundary reconstruction using visible cameras, the plasma boundary extraction method based on the U-Net are described in section 2. Section 3 presents the plasma boundary reconstruction algorithm based on the XGBoost. Finally, a summary is drawn in section 4.

Plasma boundary detection
Previously, in terms of plasma boundary extraction algorithm, EAST-related teams used adaptive Canny algorithm [39]. However, the experimental results show that the algorithm can only perform the extraction of plasma edge for the dark vacuum chamber. When the vacuum chamber is bright, a large number of erroneous edges appear. Although the edge detection algorithm based on global contrast by Luo et al works well [36], it requires manual setting of the ROI area and cannot identify the outer plasma. During the plasma discharge, the plasma boundary is moving, and some boundaries will disappear occasionally, which makes it difficult to manually select the appropriate ROI area. In order to better extract the plasma boundary during operation, the image segmentation method based on deep learning was developed, in which the U-Net network is used to extract the plasma boundary.
The overall structure of the U-Net network is to encode (down sampling) and then decode (up sampling) to obtain pixel classification with the same size as the original image. In this paper, the size of the feature map of each layer of the U-Net network has been properly modified to make the size of the output image identical to that of the input image, which is convenient for us to analyze and study the experimental results. The modified structure of the U-Net network is shown in figure 1.
The loss function adopts cross entropy loss, and the formula is as follows: where M is the number of categories, and M is taken as 2 to decide whether it belongs to the plasma boundary. The value of y c is either 0 or 1. When the predicted category is the same as the true category, the value is chosen to be 1. Otherwise, it is 0. p c is the predicted value, indicating the probability that the sample belongs to category c. The plasma boundary region is selected as the true segmented image during network training by manually labeling the image. The image size is adjusted to 512 × 512 before model training, and data enhancement processing is conducted to prevent over fitting. The size of U-Net feature map is adjusted but its structure is not different from that of the original paper. The adjustment has little impact on the results. Horizontal and  vertical flipping and distortions are applied in our model for mainly two reasons. One is for correction of images captured from cameras, and the other one is for data augmentation. Data augmentation is a common strategy applied in machine learning that one can generate massive amount of training data by applying distortions, flipping, artificial noise and image contrast to limited amount of input training images. Although data augmentation add no further information to the input data, epoch from Pytorch treats it differently and recognizes them as independent training images, which can train the algorithm equally well. If the image to be identified has no flipping requirements, this step may not be required. The artificial noise we appended to our model is about 0.1 and less, the factor is defined by Pytorch. Removal of artificial noise does not change much of the reliability and performance of our model. The model we obtained has predicted the image data outside the training set. Figure 2 shows the results of U-Net network recognition.
The experimental results show that the image segmentation algorithm based on U-Net can still recognize the plasma boundary when the vacuum chamber is bright. The error boundary is almost absent, and the recognition accuracy is relatively high. The algorithm has high robustness. It can accurately identify the plasma boundary of EAST in different discharge stages, as shown in figure 3. In order to facilitate the subsequent plasma boundary reconstruction, several central points of the plasma boundary region are selected as the data for subsequent boundary reconstructions.

Boundary reconstruction
Plasma boundary reconstruction aims to find a functional relationship between the image plane and the tokamak poloidal plane. Machine learning can fit the functional model of boundary reconstruction from the data. The XGBoost model is used for fitting here.
XGBoost is composed of multiple classification and regression trees, where multiple decision trees make decisions together and all the results are accumulated to get the final result. It adopts the idea of boosting integration to integrate multiple weak learners into a strong learner, so as to improve the effectiveness of the whole model.

XGBoost principle
XGBoost model can be defined as: where f k (x) represents the kth decision tree, x i represents the input eigenvector,ŷ i represents the predicted value, and the model includes K trees. The objective function Obj of the model consists of the loss function L and the regularization term Ω. L is used to evaluate the error between the predicted value and the real value. Ω is used to control the complexity of the model and prevent over fitting. (2) Ω is defined as: where γ and λ are the user-defined parameters, T is the number of leaves, ω is the weight score of the leaf node. In this work, the mean square error is used as a loss function, the tree depth is set to 6 and the number of trees to 100. The γ and λ parameters of the regularization term are set to 0 and 1 respectively." At iteration rounds, the model can be defined as: where f (x i ) is determined by minimizing the objective function. Rewrite target function Obj: + Ω ( f s ) , + Ω ( f s ) , (6) where g i and h i are the first and second derivatives of the loss function, respectively. Since the constant term L does not affect the optimization of the objective function, it can be removed. The objective function Obj can be written as: in which I j refers to all samples falling on leaf node j.
where G j = ∑ iϵIj g i , H j = ∑ iϵIj h i . The value of ω j is determined by setting the partial derivation of Obj (s) to zero. Then we can split the sample data according to the objective function Obj (s) of the optimal solution.

Experimental results
The data of #110790, #110792 and #110793 was selected for processing and analysis. Firstly, the plasma image captured by the camera is boundary identified, and the image is segmented by U-Net network to obtain the plasma boundary. To label the (u, v) coordinates of the plasma boundary with their respective (r, z) values in the poloidal plane, the following procedure is done. First, the (u, v) coordinates of the pixels are translated into the poloidal plane in such a way that the geometric center of the pixels, recognized as the plasma boundary, coincides with the geometric center of the points forming the last closed flux surface (LCFS) of the respective EFIT data. Second, the translated (u, v) coordinates are scaled in such a way that all pixels, recognized as the plasma boundary, lie inside the LCFS. Translation and scaling give the (u ′ , v ′ ) coordinates of the plasma boundary. Third, straight lines from the geometric center are drawn to points on the LCFS through points of the plasma boundary. The intersection of these lines with the LCFS gives the labels, while the intersection with the plasma boundary gives the (u ′ , v ′ ) to be labeled. Figure 4 illustrates this procedure. The lines are drawn with a certain step in angular direction to reduce the number of calculations. Note that the plasma boundary can be a few pixels thick, therefore a single line can cross multiple (u ′ , v ′ ) points/pixels. When this happens, all pixels crossed by this line are sorted by the projection of their (u ′ , v ′ ) coordinates onto the line, and the pixel lying in the middle of this distribution is labeled.
The center point was connected with the pixel coordinates (u ′ , v ′ ), and the straight line was extended to intersect the EFIT fitting curve to obtain the intersection point coordinates (r, z) as the label value. The selection of tag values can be seen as a functional mapping relationship with pixel coordinates, while XGBoost model can be trained to fit this relationship. The EFIT data and image data of all shot numbers at the same time are processed the same way. The (u ′ , v ′ ), (r, z) sets obtained from #110792 and #110793 are used as training sets, and the (u ′ , v ′ ), (r, z) sets obtained from shot numbers #110790 are used as test sets.
Two XGBoost models (model_R,model_Z) were trained to fit the r and z values respectively. The input value of model_R is the (u ′ , v ′ ) set of the training set, and the true value is the r coordinate under the training set. The input value of model_Z is the (u ′ , v ′ ) set of the training set, and the true value is the z coordinate under the training set. On the training set, the mean square error of model_R and model_Z are 3.5149 × 10 −5 m 2 and 1.4034 × 10 −5 m 2 respectively. On the test set, the mean square error of model_R and model_Z are 3.7119 × 10 −5 m 2 and 1.7045 × 10 −5 m 2 respectively. Therefore, the average distance error between the predicted (r, z) coordinate point on the test set and the label value is 7.36 mm. In the study of optical boundary reconstruction of EAST, the error is required to be less than 1 cm, which can meet the feedback of EAST operation. On TCV Tokamak, compared with the magnetic measurement, the error of the boundary reconstruction results with It should be noted that the error analysis is a complex and relatively independent work, and the analysis will be presented detailed in a separate paper in the future. Comparison between the predicted value of the model and the EFIT data was shown in figure 5.
This method needs to learn from a large number of data sets, so the accuracy of model prediction significantly depends on the training set. In order to obtain higher accuracy and wider applicability, the training set is required to be comprehensive and sufficient. Therefore, for different tokamak devices, the data results may be slightly different.

Conclusions and discussions
A novel algorithm of optical plasma boundary reconstruction is presented. U-Net network was successfully applied to extract the plasma boundary using the image from visible camera on EAST. Based on XGBoost model, the boundary reconstruction has been achieved. As the image segmentation algorithm based on the U-Net network does not need to preprocess the original image and manually set the ROI area, this algorithm has strong robustness and can more accurately extract the boundary without a large number of false boundaries, compared with the traditional edge detection algorithm. In the absence of camera calibration, the selection of the label value of pixel coordinates was proposed, and the boundary reconstruction of plasma based on XGBoost to convert the image plane to the tokamak poloidal plane was realized. The average reconstruction error on the test set is experimentally 7.36 mm. Compared with the algorithm of Hao Luo et al, the proposed algorithm has higher accuracy and no horizontal drift problem. As it avoids the random disturbance of magnetic field line and integral drift in magnetic measurement, it is suitable for the long-pulse operation of the tokamak device in the future.
The possible application of diagnosing plasma shape during the current ramp up and ramp down phase is solid and further effort is surely required. In our case, the training data comes from sampling the equilibrium state in shot #110790 and #110792. Since the plasma shape varies accordingly to diversified heating and ionization procedures, a decision tree may be employed to our present model to handle various circumstances during the ramp up or ramp down phase to treat various discharge conditions and plasma configurations including traditional limiter, up/lower/double null divertor configurations. Therefore, further training data is required and a decision tree may be employed to upgrade our model.

Data availability statement
The data that support the findings of this study are available upon reasonable request from the authors.