Android Open Source - Visu Study Data Parser






From Project

Back to project page Visu.

License

The source code is released under:

Apache License

If you think the Android project Visu listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ufavaloro.android.visu.storage;
/*from  w ww.  j  av a 2 s .c  o m*/
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;

import com.ufavaloro.android.visu.storage.datatypes.AcquisitionData;
import com.ufavaloro.android.visu.storage.datatypes.AdcData;
import com.ufavaloro.android.visu.storage.datatypes.PatientData;
import com.ufavaloro.android.visu.storage.datatypes.StudyData;

public class StudyDataParser {
  
  public static StudyData getStudyData(byte[] fileInputBuffer) {
  
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(fileInputBuffer);
    DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
    
    AcquisitionData acquisitionData = null;
    PatientData patientData = null;
    ArrayList<Short> samples = null;
    
    try {
      
    // Leo PatientData
    // Obtengo nombre del paciente
    byte[] patientNameBytes = new byte[50*((Character.SIZE)/8)];
    dataInputStream.read(patientNameBytes);
    char[] patientName = DataConversion.byteArrayToCharArray(patientNameBytes);
    
    // Obtengo apellido del paciente
    byte[] patientSurnameBytes = new byte[50*((Character.SIZE)/8)];
    dataInputStream.read(patientSurnameBytes);
    char[] patientSurname = DataConversion.byteArrayToCharArray(patientSurnameBytes);
    
    // Obtengo nombre del estudio
    byte[] studyNameBytes = new byte[100*((Character.SIZE)/8)];
    dataInputStream.read(studyNameBytes);
    char[] studyName = DataConversion.byteArrayToCharArray(studyNameBytes);
    
    patientData = new PatientData(patientName, patientSurname, studyName);

    // Leo AcquisitionData
    // Obtengo nombre del sensor adquisidor
    byte[] sensorBytes = new byte[50*((Character.SIZE)/8)];
    dataInputStream.read(sensorBytes);
    char[] sensor = DataConversion.byteArrayToCharArray(sensorBytes);
    
    // Obtengo tipo de estudio
    byte[] studyTypeBytes = new byte[50*((Character.SIZE)/8)];
    dataInputStream.read(studyTypeBytes);
    char[] studyType = DataConversion.byteArrayToCharArray(studyTypeBytes);
    
    // Obtengo frecuencia de muestreo
    byte[] fsBytes = new byte[(Double.SIZE)/8];
    dataInputStream.read(fsBytes);
    double fs = DataConversion.byteArrayToDouble(fsBytes);
    
    // Obtengo resoluci?n
    byte[] bitsBytes = new byte[(Integer.SIZE)/8];
    dataInputStream.read(bitsBytes);
    int bits = DataConversion.byteArrayToInt(bitsBytes);
    
    // Obtengo voltaje m?ximo
    byte[] vMaxBytes = new byte[(Double.SIZE)/8];
    dataInputStream.read(vMaxBytes);
    double vMax = DataConversion.byteArrayToDouble(vMaxBytes);
    
    // Obtengo voltaje m?nimo
    byte[] vMinBytes = new byte[(Double.SIZE)/8];
    dataInputStream.read(vMinBytes);
    double vMin = DataConversion.byteArrayToDouble(vMinBytes);
    
    // Obtengo amplitud m?xima
    byte[] aMaxBytes = new byte[(Double.SIZE)/8];
    dataInputStream.read(aMaxBytes);
    double aMax = DataConversion.byteArrayToDouble(aMaxBytes);
    
    // Obtengo amplitud m?nima
    byte[] aMinBytes = new byte[(Double.SIZE)/8];
    dataInputStream.read(aMinBytes);
    double aMin = DataConversion.byteArrayToDouble(aMinBytes);
    
    // Obtengo muestras totales almacenadas
    byte[] totalSamplesBytes = new byte[(Double.SIZE)/8];
    dataInputStream.read(totalSamplesBytes);
    double totalSamples = DataConversion.byteArrayToDouble(totalSamplesBytes);
    
    AdcData adcData = new AdcData(fs, bits, vMax, vMin, aMax, aMin, sensor, -1, -1);
    acquisitionData = new AcquisitionData(adcData);
    acquisitionData.setStudyType(studyType[0]);
  
    // Salteo padding
    int i = 0;
    while(dataInputStream.read() == 0) i++; dataInputStream.read();
    
    
    // Obtengo muestras
    samples = new ArrayList<Short>();
    short sample;
    
    do {
      sample = dataInputStream.readShort();
      if(sample != -1) samples.add(sample);
    }while(sample != -1);
      

    // Cierro
    dataInputStream.close();
    } catch (IOException ioe) {}
    
    // Genero Data y vuelvo
    StudyData studyData = new StudyData();

    studyData.setAcquisitionData(acquisitionData);
    studyData.setPatientData(patientData);
    studyData.setSamplesBuffer(samples);
  
    return studyData;  
  }
  
}




Java Source Code List

com.samsung.sprc.fileselector.FileData.java
com.samsung.sprc.fileselector.FileListAdapter.java
com.samsung.sprc.fileselector.FileOperation.java
com.samsung.sprc.fileselector.FileSelector.java
com.samsung.sprc.fileselector.FileUtils.java
com.samsung.sprc.fileselector.OnHandleFileListener.java
com.samsung.sprc.fileselector.SaveLoadClickListener.java
com.samsung.sprc.fileselector.TextViewWithImage.java
com.ufavaloro.android.visu.UI.ChannelOptionsDialog.java
com.ufavaloro.android.visu.UI.LoadFileFromGoogleDriveDialog.java
com.ufavaloro.android.visu.UI.LoadFileFromLocalStorageDialog.java
com.ufavaloro.android.visu.UI.MainActivity.java
com.ufavaloro.android.visu.UI.MainMenuDialog.java
com.ufavaloro.android.visu.UI.NewStudyDialog.java
com.ufavaloro.android.visu.UI.OfflineChannelPropertiesDialog.java
com.ufavaloro.android.visu.UI.OnlineChannelPropertiesDialog.java
com.ufavaloro.android.visu.UI.StopStudyDialog.java
com.ufavaloro.android.visu.bluetooth.BluetoothProtocolMessage.java
com.ufavaloro.android.visu.bluetooth.BluetoothProtocol.java
com.ufavaloro.android.visu.bluetooth.BluetoothServiceMessage.java
com.ufavaloro.android.visu.bluetooth.BluetoothService.java
com.ufavaloro.android.visu.draw.BitmapManager.java
com.ufavaloro.android.visu.draw.DrawHelper.java
com.ufavaloro.android.visu.draw.RGB.java
com.ufavaloro.android.visu.draw.ReferenceMatrix.java
com.ufavaloro.android.visu.draw.TouchPointer.java
com.ufavaloro.android.visu.draw.channel.ChannelList.java
com.ufavaloro.android.visu.draw.channel.Channel.java
com.ufavaloro.android.visu.draw.channel.DrawBuffer.java
com.ufavaloro.android.visu.draw.channel.InfoBox.java
com.ufavaloro.android.visu.draw.channel.Label.java
com.ufavaloro.android.visu.draw.channel.ScreenElement.java
com.ufavaloro.android.visu.draw.channel.SignalBox.java
com.ufavaloro.android.visu.storage.DataConversion.java
com.ufavaloro.android.visu.storage.SamplesBuffer.java
com.ufavaloro.android.visu.storage.StorageHelperMessage.java
com.ufavaloro.android.visu.storage.StorageHelper.java
com.ufavaloro.android.visu.storage.StudyDataParser.java
com.ufavaloro.android.visu.storage.datatypes.AcquisitionData.java
com.ufavaloro.android.visu.storage.datatypes.AdcData.java
com.ufavaloro.android.visu.storage.datatypes.PatientData.java
com.ufavaloro.android.visu.storage.datatypes.StorageData.java
com.ufavaloro.android.visu.storage.datatypes.StudyData.java
com.ufavaloro.android.visu.storage.googledrive.GoogleDriveClientMessage.java
com.ufavaloro.android.visu.storage.googledrive.GoogleDriveClient.java
com.ufavaloro.android.visu.storage.googledrive.GoogleDriveManagerMessage.java
com.ufavaloro.android.visu.storage.googledrive.GoogleDriveManager.java
com.ufavaloro.android.visu.storage.local.LocalStorageManager.java
com.ufavaloro.android.visu.study.StudyMessage.java
com.ufavaloro.android.visu.study.StudyType.java
com.ufavaloro.android.visu.study.Study.java