Deep Learning Methods On Neutron Scattering Data

Recently, by using deep learning methods, a computer is able to surpass or come close to matching human performance on image analysis and recognition. This advanced methods could also help extracting features from neutron scattering experimental data. Those data contain rich scientific information about structure and dynamics of materials under investigation. Deep learning could help researchers better understand the link between experimental data and materials properties. Moreover,it could also help to optimize neutron scattering experiment by predicting the best possible instrument configuration. Among all possible experimental methods, we begin our study on the small-angle neutron scattering (SANS) data and by predicting the structure geometry of the sample material at an early stage. This step is a keystone to predict the experimental parameters to properly setup the instrument as well as the best measurement strategy. In this paper, we propose to use transfer learning to retrain a convolutional neural networks (CNNs) based pretrained model to adapt the scattering images classification, which could predict the structure of the materials at an early stage in the SANS experiment. This deep neural network is trained and validated on simulated database, and tested on real scattering images.


I. INTRODUCTION
The fundamental properties of the neutron make it a powerful tool to investigate atomic-scale structure and dynamics of materials. Compared to other scattering techniques such as x-ray or light, neutron has advantages such as negligible radiation damage, exceptional penetration power and ability to selectively highlight specific parts of materials via isotope labelling [1]. However, because the flux of neutrons is lower than the flux of the photons at modern light sources, long measurement time (even tens of hours) is required for a highquality data collection. In this case, early decision becomes a critical component in the experimental work flow. On the other hand, the instrument settings of neutron scattering experiments are manually decided by scientists according to their experiences and knowledges. Due to large differences in the level of experience of the different users, high quality data could become difficult to obtain and quite time consuming. Hence, we propose to use recent advanced machine learning methods to help interpreting experimental data in order to optimize effective use of limited beam time and ence increasing science productivity.
Small-angle neutron scattering (SANS) is an increasingly popular method in structural biology that usefully complements high-resolution structural techniques such as x-ray crystallography or nuclear magnetic resonance spectroscopy [2]. Over time, many methods have been developed to extract relevant information directly from the experimental scattering intensities, working exclusively with the experimentally obtained data. Inthi work, we consider the application of machine learning methods to extract sample structural information from SANS data.
Deep learning has become one of the most active research field in the machine learning community since it was presented in 2006 [3]. Recently, it impacted deeply data science, and its popularity has grown exponentially, especially in computer vision related tasks [4]. Convolutional neural networks (CNNs) is a well-known deep learning architecture inspired by the natural visual perception mechanism of the living creatures. In recent years, CNNs have been widely adopted for a variety of applications in image classification [5] [6], video analysis [7] and natural language processing [8]. CNNs are widely used in image related tasks since they present several advantages. Firstly, CNNs decompose images into multiple patches that are partially overlapped. In this case, each cortex neuron only corresponds to a single patch, which enables the network to classify images with little data pre-processing [9]. Secondly, CNNs are weight sharing, which enable CNNs share learned features from a single sample via back-propagation with other samples. It efficiently decreases the necessary required input sample size and quantity. [10].
In practices, large amount of data is required to train the CNNs from scratch. Due to limited calculation power and lack of labeled big data set for relevant problems, the concept of transfer learning has been introduced. When applying transfer learning, a network is trained on a new dataset of samples using the stored weights for some or all layers from a pretrained network as an initialization, rather than initializing weights randomly. The selection of the pre-trained model in transfer learning is influenced by two factors : problem size and similarity [11]. The selection of the pre-trained model is made on the basis of the associated problem which is relevant to the target problem. If the size of the target data set is smaller and similar to the source training data set then the chance of over fitting is high. Similarly, if the size of the target data is larger and similar to the source data sets then the chance of over fitting is low and it requires only the fine tuning of the pre-trained model [12].
In this paper, we applied transfer learning method on a CNNs architecture based pre-trained model, to analyze and classify neutron scattering image from SANS experiment. This model named Inception-v3 is pre-trained on ImageNet database. With fine-tuning, this model is first retrained and validated by simulated scattering images, then verified on real SANS experimental data collected at the Institut Laue-Langevin (ILL).

A. Data simulation
To generate two-dimensional Small-Angle Neutron Scattering (SANS) images we use the data reduction and simulation code GRASP [13] . GRASP is a MatlabTM script application designed for the graphical inspection, analysis and reduction of position sensitive detector(PSD) data produced by the 3 SANS instruments of the ILL. GRASP is using a mixed analitical and Monte-Carlo approach for the neutron event generetion and can include the real intrument resolution function, the measured backgrounds from a variety of different samples and the influence of the sample environment. By using GRASP, we could generate simulated SANS 2D detector images with variable sets of parameters. We could select different materials' structures and also freely change the instrument configuration. In this work we have choosen D22 SANS instrument and its schematic layout is presented in  Starting from a cold neutron beam arising from the H512 neutron guide, the desired neutron wavelength can be selected through a mechanical velocity selector in a range between 4.6 and 40Å. The wavelength spread ∆λ/λ is 10% (FWHM). The virtual source-to-sample distance is chosen by a collimation system consisting of eight sections. Each section comprises three tubes, any one of which can be positioned on the beam axis. One tube contains a neutron guide of 40 x 55 mm; the second is equipped with an antiparasitic aperture; the third tube bears fixations for future neutron-optical equipment. D22 possesses a large 3 He multidetector with an active area of 1 m 2 . The detector is subdivided in pixels with a size of 8 x 8 mm. The detector consists of 128 linear sensitive Reuter-Stokes tubes arranged vertically with a spacing of 8 mm. Each tube has a dead time of about 1 s roughly corresponding to the analog pulse shaping time. It moves inside a 2.5 m wide and 20 m long vacuum tube providing sample-to-detector distances from 1.1 m to 17.6 m. D22 thus covers a total q range of 4 x 10 −4 to 0.44Å −1 (no detector offset) or 0.85Å −1 (with detector offset) in standard conditions.
A large amounts of SANS diffusion patterns were obtained from samples with geometrical structure and uniform scattering length density such as spheres, cylinders, core-shell spheres, ellipsoid and flux line bragg peak. The corresponding dimensions of the geometric bodies, i.e., inner and outer radius, length, width, height etc., were respectively randomly and independently sampled in ranges from 10 to 800Å. Each instrument configuration of D22 such as sample to detector distance, collimation distance, wavelength bands introduces unique features in the resulting detector images. In our simulation, the sample is inserted in an empty cell filled with background liquid: water (H 2 O) or heavy water (D 2 O).

B. Neural Network Model
In this paper, we have adopted transfer learning using the pre-trained CNNs based Inception-v3 [14] architecture to classify the 2-D neutron scattering images. Instead of creating a model from scratch, we have started from a previously trained model able to solve a similar classification problem. This model was known to classify an image across 1000 categories supplied by the ImageNet academic competition with an error rate that approached human performance. The Inception deep convolutional architecture was introduced as GoogLeNet (Inception-v1) [15]. Since Inception networks are fully convolutional, each weight corresponds to one multiplication per activation. Therefore, by introducing factorizing convolutions in this model, Inception-v3 is able to reduce the number of connections/parameters (42-layer deep learning network) and similar complexity as VGGNet [16], without decreasing the network efficiency. Inception-v3 is a commonly used architecture for deep learning tasks. This model is a stateof-the-art CNNs and it is widly use in the field of computer vision. It consists of two parts: • Feature extraction part with a CNN. • Classification part with fully-connected and softmax layers. The pre-trained Inception-v3 model achieves state-of-the-art accuracy for recognizing general objects with 1000 classes. The model extracts general features from input images in the first part and classifies them based on those features in the second part. The model itself is made up of symmetric and asymmetric building blocks, including convolutions, average pooling, max pooling, concats, dropouts, and fully connected layers. BatchNorm is used extensively throughout the model and applied to activation inputs. Loss is computed via Softmax.
In transfer learning, when we build a new model to classify our original dataset, we reuse the feature extraction part and re-train the classification part with our dataset. Since we don't have to train the feature extraction part, which is the most complex part of the model, we can train the model with less

III. EXPERIMENTAL RESULTS
The small angle neutron scattering instrument D22 is used to investigate a wide range of samples, to identify their atomic structure and composition. Hence, we classify the samples with a 2-D scattering image at an early stage and then, we tried to predict its structure. We have started to consider four different geometrical structures: sphere, core-shell sphere, cylinder and ellipsoid, which procuce a quite similar scattering patterns. All the simulations are performed on a Linux Server (Ubuntu 16.04.5) with two NVIDIA Tesla P100 GPUs.

A. Experiment I: sphere vs. flux line bragg peak
Spheres and flux-line bragg peak produce quite different images on the detector. Unfortunately, in real experiments, the instrument parameters are set according to a "guess" of the structure type and sample parameters, which sometimes are far away from the real structure. Hence,we first try to recognize the scattering image at an early stage without any priori knowledge. 1) Dataset: By using GRASP, we have generated 2000 sample images are generated respectively for the sphere and flux line bragg peak model. The corresponding dimensions of the geometric bodies, i.e., radius for sphere, rocking angle for flux line bragg peak etc. are generated in a certain range randomly and independently. Fig.3 shows some examples in this database, and a square beam stop is applied in the center of detector. As shown in Fig.3, because of data collection time is not long enough or the parameters setting of the instrument are not always perfect, to obtain a high quality scattering images is not easy for further analysis.
2) Result: We begin the training trail with the pre-trained model Inception-v3. The initial weights are taken from the pretrained weights based on ImageNet. Only the weights of the It means all layers are set to frozen except the last dense layer. The model is compiled with binary cross-entropy loss function for the training and validation sets. The initial learning rate is randomly set to 0.01 and the model is trained for 300 epochs, which means the network examined each image 300 times. For each training trail, 80% data are selected randomly for training, 10% data are used for testing and 10% data are used for validation. Fig.4 shows the average accuracy of classification and loss of cross-entropy. After 200 epochs, the average accuracy is stable to 100%, which indicates all the simulated samples in the dataset are corrected classified by current classifier.
Then this classifier is tested on nine scattering image of  The four models: sphere, core-shell sphere, cylinder and ellipsoid geometrically are similar to each other under some particular parameters in the structure. For example, if the model cylinder with length 0, it becomes a sphere model. Recognizing these four structures only from scattering image is a challenge task.
1) Dataset: 10000 simulated scattering images are generated by GRASP,for each individual sample structure. The corresponding dimensions of the geometric bodies, i.e., length, inner and outer radius etc. are generated randomly and independently. The dataset contains complex situation of the models, including monodispersity, polydispersity, low resolution, centralized scattering images etc...

2) Result:
The same pre-trained model as experiment I is applied. Fig.6 shows the results of average accuracy and loss of cross entropy. As a result of an average accuracy of 73%, the most incorrect and correct classification images are shown in Fig.7. We have employed data augmentation and fine-tuning methods to improve the recognition accuracy. The model is optimized by stochastic gradient descent optimizer [17], which restarts techniques to find an optimal learning rate. Optimal learning rate finder is basically boosts the learning rate until the validation loss stops to decrease. Because of limited field of view of the instrument, in real experiment, sometimes we choose to make the neutron beam arrival at the detector with a certain bias from the center, to obtain a larger field of view of the material structure. 2000 simulated scattering images with beam stream arrival with certain bias from the center are added respectively to each class. Fig.8 shows two scattering samples in this kind of scattering data. Table. I shows the average precision, sensitivity (recall), and F1-Score of the model with fine-tuning and augmented database. The average accuracy of this model is 79.8%, which is better than the performance of the model without finetuning. Except class unknown, the other four classes have proximity F1-score (between 75% and 80%). This unknown class is consisted of scattering images generated from simulated program, without or less recording useful scattering information by improper instrument parameters setting. For cylinder, the precision is high 90%, which is the ratio of correctly predicted positive observations to the total predicted positive observations, meanwhile the sensitivity is low 65%, which is the ratio of correctly predicted positive observations  to the all observations in actual class, turns out similar F1score with other classes. Then, this classifier is tested on 9 silica sphere scattering image, 9 cylinder scattering image, 2 ellipsoid scattering image and 1 core-shell sphere scattering image from real experiment. The scattering images from real experiment are raw data, without any pre-process. The most incorrect and correct classification images are shown in Fig.9. In 9 silica sphere real scattering images, 8 image are recognized as sphere with an average confidence value of 92%. As shown in Fig.9e, the incorrect classification happened on the image with less scattering information comparing to correct classifications. For cylinder class, only 3 images are correctly recognized with an average confidence 63%. In the rest 6 images with misclassification, 5 images are similar to Fig.9f. It seems with scattering images which contain the scattering information from the whole directions, that means the neutron beam arrived in the center of detector obtain higher recognition rate than scattering images with center bias of neutron beam arrivals. And for the images which contain only little information around beam stop, it seems difficult to recognize among these four structures.

IV. DISCUSSION & CONCLUSIONS
In this article, we introduced a deep learning based method to recognize material's structure category by its 2-D neutron scattering image. The performance of accuracy is quite depending on the similarity among the material's structure. As shown in experiment I (secton. III-A), the classifier is able to separate structure model with high accuracy between sphere and flux line bragg peaks even in low resolution, less scattering information, and low neutron beam intensity scattering images. However to predict the scattering images from close geometrical structures, such as sphere, core-shell sphere, cylinder and ellipsoid, the accuracy of our classifier decreased. From observation, the accuracy is influenced by the quality and type of scattering images. For example, the classifier could get higher accuracy on high resolution rather than low resolution scattering images. Also it performs better on scattering images with neutron beam arrival at the center of detector which contain scattering information in all directions rather than with center bias scattering images for which part of the information is missing.
The training trail of deep CNNs is done on simulated database. And the trained classifier is tested on several raw scattering images from real experiments. With this small (a) correct sphere recognition with 98% confidence (b) correct cylinder recognition with 65% confidence (c) correct ellipsoid recognition with 45% confidence (d) correct core-shell sphere recognition with 67% confidence (e) incorrect sphere recognition (f) incorrect cylinder recognition Fig. 9: Display of scattering images from real experiment with correct and incorrect recognitions. among of scattering images from real experiment, we couldn't get solid conclusion about the performance of our classifier. However, the result indicates the tendency that our classifier is able to correctly recognize real scattering images without any training samples from real scattering data, it could work equally on simulated and real images.