<commit_before>/* BSD 2-Clause (c) 2014: A.Doherty (Oxford), <NAME> (Oxford)
 *
 * Code for extracting features from raw triaxial acceleration measurements.
 * The features are derived from four papers:
 *
 * Hip and Wrist Accelerometer Algorithms for Free-Living Behavior
 * Classification. <NAME>, <NAME>, <NAME>, <NAME>, <NAME>.
 *
 * A universal, accurate intensity-based classification of different
 * physical activities using raw data of accelerometer. <NAME>,
 * <NAME>, <NAME>, <NAME> and <NAME>
 *
 * Physical Activity Classification using the GENEA Wrist Worn
 * Accelerometer <NAME>, <NAME>, <NAME>, <NAME>
 *
 * Activity recognition using a single accelerometer placed at the wrist or ankle.
 * <NAME>, <NAME>, <NAME>, <NAME>, <NAME>.
 *
 */
import org.jtransforms.fft.DoubleFFT_1D;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
public class Features {

    public static double[] getFeatures(
            double[] x,
            double[] y,
            double[] z,
            double[] filteredVM,
            int sampleRate,
            int numFFTbinsPerChannel){

        // get San Diego (Ellis) features
        double[] sanDiegoFeats = calculateSanDiegoFeatures(x, y, z, sampleRate, 
                                                            numFFTbinsPerChannel);

        // get arm angel features
        double[] armFeats = calculateArmFeatures(x, y, z, sampleRate);

        // get MAD features
        double[] madFeats = calculateMADFeatures(x, y, z);

        // get Unilever (Zhang/Rowlands) features
        double[] uniFeats = unileverFeatures(filteredVM, sampleRate);

        // get Fourier bins for each of the channels
        double[] xFFTfeats = getFFT(x, numFFTbinsPerChannel);
        double[] yFFTfeats = getFFT(y, numFFTbinsPerChannel);
        double[] zFFTfeats = getFFT(z, numFFTbinsPerChannel);
        double[] vmFFTfeats = getFFT(filteredVM, numFFTbinsPerChannel);

        // construct final output array
        // don't forget to change header method immediately below !!!
        double[] output = AccStats.combineArrays(sanDiegoFeats, madFeats);
        output = AccStats.combineArrays(output, uniFeats);
        output = AccStats.combineArrays(output, armFeats);
        output = AccStats.combineArrays(output, xFFTfeats);
        output = AccStats.combineArrays(output, yFFTfeats);
        output = AccStats.combineArrays(output, zFFTfeats);
        output = AccStats.combineArrays(output, vmFFTfeats);

        return output;
        // todo method to write header line order (use static class variables )
    }

    public static String getFeaturesHeader(int numFFTbins){
        String header = getSanDiegoFeaturesHeader(numFFTbins);
        header += "," + getMADFeaturesHeader();
        header += "," + getArmFeaturesHeader();
        header += "," + getUnileverFeaturesHeader();<commit_msg>fix ordering<commit_after>/* BSD 2-Clause (c) 2014: A.Doherty (Oxford), <NAME> (Oxford)
 *
 * Code for extracting features from raw triaxial acceleration measurements.
 * The features are derived from four papers:
 *
 * Hip and Wrist Accelerometer Algorithms for Free-Living Behavior
 * Classification. <NAME>, <NAME>, <NAME>, <NAME>, <NAME>.
 *
 * A universal, accurate intensity-based classification of different
 * physical activities using raw data of accelerometer. <NAME>,
 * <NAME>, <NAME>, <NAME> and <NAME>
 *
 * Physical Activity Classification using the GENEA Wrist Worn
 * Accelerometer <NAME>, <NAME>, <NAME>, <NAME>
 *
 * Activity recognition using a single accelerometer placed at the wrist or ankle.
 * <NAME>, <NAME>, <NAME>, <NAME>, <NAME>.
 *
 */
import org.jtransforms.fft.DoubleFFT_1D;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
public class Features {

    public static double[] getFeatures(
            double[] x,
            double[] y,
            double[] z,
            double[] filteredVM,
            int sampleRate,
            int numFFTbinsPerChannel){

        // get San Diego (Ellis) features
        double[] sanDiegoFeats = calculateSanDiegoFeatures(x, y, z, sampleRate, 
                                                            numFFTbinsPerChannel);

        // get arm angel features
        double[] armFeats = calculateArmFeatures(x, y, z, sampleRate);

        // get MAD features
        double[] madFeats = calculateMADFeatures(x, y, z);

        // get Unilever (Zhang/Rowlands) features
        double[] uniFeats = unileverFeatures(filteredVM, sampleRate);

        // get Fourier bins for each of the channels
        double[] xFFTfeats = getFFT(x, numFFTbinsPerChannel);
        double[] yFFTfeats = getFFT(y, numFFTbinsPerChannel);
        double[] zFFTfeats = getFFT(z, numFFTbinsPerChannel);
        double[] vmFFTfeats = getFFT(filteredVM, numFFTbinsPerChannel);

        // construct final output array
        // don't forget to change header method immediately below !!!
        double[] output = AccStats.combineArrays(sanDiegoFeats, madFeats);
        output = AccStats.combineArrays(output, armFeats);
        output = AccStats.combineArrays(output, uniFeats);
        output = AccStats.combineArrays(output, xFFTfeats);
        output = AccStats.combineArrays(output, yFFTfeats);
        output = AccStats.combineArrays(output, zFFTfeats);
        output = AccStats.combineArrays(output, vmFFTfeats);

        return output;
        // todo method to write header line order (use static class variables )
    }

    public static String getFeaturesHeader(int numFFTbins){
        String header = getSanDiegoFeaturesHeader(numFFTbins);
        header += "," + getMADFeaturesHeader();
        header += "," + getArmFeaturesHeader();
        header += "," + getUnileverFeaturesHeader();
{'fraction_non_alphanumeric': 0.10358565737051793, 'fraction_numerical': 0.0020786419539234368, 'mean_word_length': 2.927891156462585, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6842656', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1587, 'n_words': 478}