I have two classes, MainActivity and HjorthClass.
Please direct your attention to the TestSeizureDetected() at the bottom of MainActivity. Everything else is working fine. When I run testValue.returnVal() I only get the value 1.0. That number does not change regardless the numbers in the string. I have already verified that finalSeizureData is accurate by printing out values at different positions.
String huge is composed of 7681 separate values, and is not included in this. The issue lies in my Hjorthclass, but I cannot figure out where it is or why returnVal only returns 1.0.
*EDIT:*Only relevant code is showing. Since code has been edited and cut down in size, do not point out Syntax errors in MainActivity. Thank you.
public class MainActivity extends Activity implements LocationListener{
public double[][] finalSeizureData= new double[7681][1];
public HjorthClass testValue;
public void TestSeizureDetected()
{
String[] temp = huge.split("\\s+");
double[] convert = new double[temp.length];
for(int y = 0; y<convert.length; y++)
{
convert[y]= Double.parseDouble(temp[y]);
}
for(int i = 0; i<convert.length;i++)
{
for(int j = 0; j<1;j++)
{
finalSeizureData[i][j] = convert[i];
}
}
testValue = new HjorthClass(finalSeizureData);
textResult.setText("Value"+ testValue.returnVal());
if(testValue.returnSum()== true)
{
textResult.setText("Seizure has been detected in Text File");
}
}
}
Hjorth Class
public class HjorthClass extends Activity{
public double [][]Active;
public int height;
public int width;
public double [][] m0;
public double [][] threshold;
public double sum;
public double []temp;
//check length of height
public HjorthClass (double [][]Active)
{
height = Active[0].length;
width = Active[1].length;
m0 = new double[height][width];
threshold= new double[height][width];
sum = 0;
for(int i = 0; i<height; i++)// Original moving average - is used for Activity
{
if(i == 0)
{
m0[0][0] = Active[i][i];
}
else
{
for(int j =0; j < width; j++)
{
m0[i][j] = Active[i][j];
}
}
}
for(int i = 0; i<height; i++)
{
for(int j =0; j < width; j++)
{
if(m0[i][j] >= 1 )
{
threshold[i][j] = 1;
}
else
{
threshold[i][j]=0;
}
}
}
for(int i = 0; i<height; i++)// Sum of all the values
{
for(int j =0; j < width; j++)
{
sum = sum + threshold[i][j];
}
}
}
public boolean returnSum()
{
if(sum >= 300)
{
return true;
}
else
return false;
}
public double returnVal()
{
return sum;
}
}
height = Active[0].length;should beheight = Active.length;heightin your Hjorth class. Try changing it toheight = Active.length.