{'fraction_non_alphanumeric': 0.03234055354993983, 'fraction_numerical': 0.014891696750902527, 'mean_word_length': 4.771267361111111, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
An Adaptive Space-Filling Curve Trajectory for Ordering 3D Datasets to 1D: Application to Brain Magnetic Resonance Imaging Data for Classification

In this work, we develop an adaptive, near-optimal, 3-Dimensional (3D) to 1D ordering methodology for brain magnetic resonance imaging (MRI) data, using a space-filling curve (SFC) trajectory, which is adaptive to brain’s shape as captured by MRI. We present the pseudocode of the heuristics for developing the SFC trajectory. We apply this trajectory to functional MRI brain activation maps from a schizophrenia study, compress the data, obtain features, and perform classification of schizophrenia patients vs. normal controls. We compare the classification results with those of a linear ordering trajectory, which has been the traditional method for ordering 3D MRI data to 1D. We report that the adaptive SFC trajectory-based classification performance is superior than the linear ordering trajectory-based classification.


Introduction
Magnetic resonance imaging (MRI) is a widely used tomography technology which is used to capture the structure of the brain in three dimensions (3D) of space. A specific modality of MRI technology, known as functional MRI (fMRI), can capture hemodynamic response signals from the brain within the order of s, in a repeated manner, albeit in lower spatial resolution. FMRI therefore includes in time-series data for each volume element (voxel) of the brain. Datasets of both structural and functional MRI, which are 3D spatial matrices (e.g. a 64 × 64 × 64 matrix), generally have to be converted to vector arrays of a single dimension (1D), for further analyses (Fig. 1), such as analyses with general linear models, regression, and independent component analysis. Traditionally, a linear ordering/mapping of data from 3D to 1D have been used for this purpose, i.e. 3D data are scanned consecutively along the first, second, third spatial dimensions in order to obtain a 1D ordering of volumes. Linear ordering introduces large 'jumps' or 'discontinuities' of the recorded signal; for example, if it is applied to structural MRI datasets, it does not preserve the structure of the brain in 1D.
In [1], using a least-squares signal-difference approach which uses sum of squared signal intensity differences (TSSID) was proposed as a cost function and measure of how adaptive an SFC was to the data/signal being traversed. Since the cost function is the sum of signal 'jumps', the goal is to minimize the cost function to find the most adaptive trajectory. In the context of 3D brain imaging, by traversing 3D volumes using a space-filling curve (SFC) that is adaptive to brain's shape, a 3D MRI image can be ordered into 1D space (e.g. into a 64 3 × 1 vector from a 64 × 64 × 64 volume), which can better preserve the brain's structure in 1D. Although this idea was suggested in [1], it was noted that this was inherently a Hamiltonian path problem which also can be formulated as a modified traveling salesman problem (TSP), which is an NP-hard problem to solve. With as many nodes as number of voxels, which is on the order of thousands for fMRI brain activation datasets, it makes the problem computationally intractable [1]. If an approximation of an adaptive SFC could be found and applied for 3D to 1D ordering of the dataset, any dimensionality reduction, smoothing, down-sampling, compression, and Fig. 1. Three views of a structural T1 MRI dataset (a), and an fMRI brain activation map (b), which is computed from fMRI volumes taken at multiple time-points. Conventionally, fMRI dataset voxels are ordered using linear ordering trajectory into rows of a matrix, as a result, a matrix of time × voxels is generated for further analyses (c). feature selection/reduction in 1D could benefit from better preservation of information, when compared with linear ordering, or other predefined orderings such as the Hilbert curve ordering.
In this work, we computed an SFC adaptive to brain's shape (as recorded in a T1 MRI canonical/template image as an example) and developed an algorithm pipeline which uses the computed SFC for ordering of fMRI activation maps from 3D to 1D, obtains features from the 1D orderings, and performs classification of participants; we applied the pipeline to an fMRI study of two groups of participants: schizophrenia patients (SP) and healthy controls (HC), and performed classification of a given brain activation map belonged to SP or HC.

Data and Participants
95 schizophrenia patients (SP) and 89 healthy control (HC) participants were scanned using 3T Siemens Trio MRI scanners at four different research sites in the USA. Research protocol was reviewed and approved by the institutional review board of the local institutions where scans were performed, and written consent was obtained from each participant. The parameters for the functional scan were: TR/TE = 2 s/30 ms, BW = ±100 kHz = 3126 Hz/pixel, FA = 90°, slice thickness 4 mm, slice gap 1 mm, voxel size = 3.4 mm × 3.4 mm × 4 mm, FOV = 22 cm, PACE-enabled, single shot, single-echo EPI pulse sequence, oblique axial slice plane; 64 × 64 acquisition matrix, 27 slices in ascending sequential acquisition. Participants performed a sensorimotor (SM) task during the scan. After standard pre-processing, MRI volumes were warped to Montreal Neurological Institute (MNI) standard canonical/template T1 MRI volume [7]. The fMRI activation maps computed as standard parametric maps of t-value with the SM task, were resampled to the 3 mm × 3 mm × 3 mm standard MNI volume, which resulted in 53 × 63 × 46 data matrix. An adaptive space-filling curve (SFC) using the 53 × 63 × 46 T1 MRI template volume was computed using a graphical processing unit using a greedy search algorithm developed in-house.

The Adaptive Space-Filling Curve Algorithm for 3D MRI Data
The algorithm proceeds as follows. At any voxel, the signal values of its 26 immediate neighbors in 3D is retrieved and sorted based on their signal intensity difference with the current voxel. The next voxel along the adaptive SFC is selected as the voxel with the minimum absolute signal difference that is not already included in the adaptive SFC. The algorithm traverses back in the list of voxels selected for the adaptive SFC until one voxel to be included in the SFC is found. Using the list for backtracking in the worst case requires a time proportional to the length of the list and hence in the worst case is of O(n) where n is the length of the list. Instead, a hash table is used with key value 1 if a voxel is included in the SFC, otherwise the value is zero. A snapshot of the SFC obtained from the T1 image is presented in Fig. 2 and Table 1.
To make the algorithm faster and reduce memory consumption we remove voxels with zero signal intensity in a preprocessing step before applying the algorithm, since zero signal voxels provide no useful information for feature selection for classification. In a predefined SFC, such as the Hilbert SFC, voxels with zero signal intensity are not consecutive and they are scattered over the SFC, and their indexes have to be traced. In the adaptive SFC, these voxels are consecutive and either at the beginning or at the end of the curve and they can be easily trimmed reducing the number of useless signals in the data. Figure 3 presents this effect. Using a pre-defined space-filling curve such as Hilbert curve results in tracing the full volume ( Fig. 3(a)), versus, the adaptive space  filling curve results in voxels with only non-zero signal values, a 57% reduction in the number of voxels (Fig. 3(b)).

Using SFC-Ordered FMRI Activation Data as Features for Classification
The 3D fMRI maps from each participant were converted to 1D with linear ordering and also with the computed adaptive SFC. The 1D arrays were down-sampled by a bin size of 100, values were averaged across each bin ("binning"), which constituted raw features. Features were further reduced to 100, and also to 30, by using and support vector machine based sequential forward search feature reduction algorithm [8]. The reduced features were used to train the classification algorithm by using a random 70% of the dataset and were tested on the remaining 30%. The training-testing process was repeated 100 times by using new random selection of training and testing datasets. Average classification accuracies were computed. The results are presented in the next section.

Results
To make the algorithm faster and reduce memory consumption we remove voxels with zero signal intensity in a preprocessing step before applying the algorithm. As an example, around 57% of voxels in one of the 3D T1 MRI brain were zero. The impact of removing zero signal voxels is clearly visible in Fig. 3. Figure 4 presents a sample progression snapshots of the adaptive SFC at the end of the trajectory, where the SFC is traversing mostly along the outer surface of the brain. Part of the SFC with length of 1000, 3000, 5000, and 7000 (in red color) are overlaid on the full-length adaptive SFC (in gray color). Traversal of the MRI signal along the brain's shape, hence adaptive to the brain's shape, is visible.
The signal intensities and absolute signal intensity differences along the Hilbert and adaptive SFCs are shown in Fig. 5. The adaptive SFC results in less signal intensity difference along successive voxels along the trajectory than Hilbert SFC, and hence it results in less total squared signal intensity difference (TSSID). The impact on the total squared signal difference between successive voxels along the SFC and the SFC length is shown in Table 2. Relative total TSSID between successive voxels along the SFC and the relative length of the SFC is computed for the adaptive and the Hilbert SFCs for our data, the canonical 3D T1 MRI image. The adaptive SFC has 50.5 times less relative TSSID than the Hilbert SFC, and it is 34% shorter. Figure 6 (a) shows a 1D-ordered signal array from a participant's fMRI activation map, not by using an SFC, but by using linear ordering, which is the commonly used, traditional ordering method of 3D signals to 1D. A zoomed version (b) and a binned version (c) are also presented in Fig. 6. Large discontinuities along the slices are visible, and further discontinuities inherent in the scheme are visible in the zoomed version, hence the result of binning includes many signals of zero-values. Figure 7 shows results of the adaptive SFC trajectory-based 1D-ordered signal array. Large clusters can be seen in the adaptive SFC trajectory-based array, whereas linear ordering resulted in a highly disconnected or un-clustered brain activation signal. Large clusters are also visible in the zoomed portion (b), and the binning includes no voxels with zero-values (c); in general, the binned adaptive SFC array includes only few such voxels.
Using the SFC trajectory-based ordering, an SVM classification algorithm resulted in 72.1% (74.6%) average accuracy in classification of SP vs. HC participants, whereas the linear ordering resulted in around 49.9% (50.0%) classification accuracy, using 30 (100) features, employing a sequential forward search algorithm for the reduction of features. SFC-based ordering resulted in significantly higher accuracy, whereas linear ordering resulted in just about chance accuracy of 50%. Performing a 4 × 4 × 4 down-sampling of the brain activation maps directly in 3D, and then ordering the resulting down-sampled brain with linear ordering, using the resulting signal as features, resulted also with chance accuracy of around 50% for participant classification. Overall, SFC-based classification results were significantly higher.

Conclusions and Discussions
An adaptive space-filling curve (SFC) trajectory which is adaptive to brain's shape can be utilized for 1D ordering of 3D MRI data, such as brain activation maps in fMRI, and this ordering proves to be better than using the traditional linear ordering or predefined ordering such as Hilbert ordering. We have shown that it reduces the amount of discontinuities and results in shorter signal with less redundancy. In this work, we used the adaptive SFC for feature reduction in classification using fMRI brain activation maps and we showed that SFC ordering resulted in better features from the activation maps, which resulted in higher classification accuracy of two groups of participants, schizophrenia patients and healthy controls.
The results her need to be replicated with larger sample sizes and with other fMRI studies. In addition to using a canonical T1 MRI image, adaptive SFCs can be obtained using T2, DTI, echo-planar imaging (EPI) and many more kinds of different canonical MRI images in the standard imaging space such as MNI space, and they can be applied to traverse participants' brain imaging data in the standard imaging space, and the traversed data can be subsequently compressed, binned, features extracted, and many more applications can be done.
Potential future work also involves using different feature reduction methods and different classification algorithms, and compression of fMRI data based on SFCs.
Overall, data-adaptive SFCs have great potential in adaptive compression of datasets as well, in order to minimize information loss in compression.