/** * */ package analyze; /** * @author John H. Krantz * summarizes the data from the Gabor Model */ public class Summarize { private double [][][] columns; // the raw data // values to determine private double maxActivity = 0; private double maxNegActivity = 0; private double meanAct = 0; private double stdAct = 0; private double meanPosAct = 0; private double stdPosAct = 0; private double meanNegAct = 0; private double stdNegAct = 0; public static final int ALL = 0; public static final int POS = 1; public static final int NEG = 2; // flags for types of means and standard deviations // to compute // flags ffor point summary public static final int MEAN = 0; public static final int STDEV = 1; public static final int MAX = 2; public static final int MIN = 3; public static final int RANGE = 4; public static final int MAXORIENT = 5; public static final int MINORIENT = 6; public Summarize(){ // empty constructor } // set methods /** * give the data to be analyzed to the object * @param double [][][] col the column data * indexes are in order of y, x, and orientation */ public void setColumns(double [][][] col){ columns = col; } // get methods /** * get the maximum firing rate of all of the cells * @return double maximum Activity */ public double getMaxAct(){ maxActivity = 0; for (int y = 0; y < columns.length; y ++){ for (int x = 0; x < columns[0].length; x ++){ for (int o = 0; o < columns[0][0].length; o ++){ if (columns[y][x][o] > maxActivity){ maxActivity = columns[y][x][o]; }// check if greater than current max } // end of orientation loop } // end of x axis loop } // end of y axis loop return maxActivity; } /** * get the maximum negative firing rate of all of the cells * @return double maximum negative Activity */ public double getMaxNegAct(){ maxNegActivity = 0; for (int y = 0; y < columns.length; y ++){ for (int x = 0; x < columns[0].length; x ++){ for (int o = 0; o < columns[0][0].length; o ++){ if (columns[y][x][o] < maxNegActivity & columns[y][x][o] < 0){ maxNegActivity = columns[y][x][o]; }// check if more negative than current max } // end of orientation loop } // end of x axis loop } // end of y axis loop return maxNegActivity; } /** * Determine the mean level of activity * @return double mean level of activity */ public double getMeanAct(){ meanAct = getMeanStd(ALL)[0]; return meanAct; } /** * Return the standard deviation of the overal activity * @return double standard deviation */ public double getStdAct() { stdAct = getMeanStd(ALL)[1]; return stdAct; } /** * Determine the mean level of positive activity (zeros do not count) * @return double mean level of positive activity */ public double getMeanPosAct(){ meanPosAct = getMeanStd(POS)[0]; return meanPosAct; } /** * Return the standard deviation of the positive activity * @return double standard deviation */ public double getStdPosAct() { stdPosAct = getMeanStd(POS)[1]; return stdPosAct; } /** * Determine the mean level of negative activity (zeros do not count) * @return double mean level of negative activity */ public double getMeanNegAct(){ meanNegAct = getMeanStd(NEG)[0]; return meanNegAct; } /** * Return the standard deviation of the negative activity * @return double standard deviation */ public double getStdNegAct() { stdNegAct = getMeanStd(NEG)[1]; return stdNegAct; } /** * Return the summary for a particular location at all orientations * @param int y the y location of the receptive field * @param int x the x location of the receptive field * @return double [] the summary values in the following order * mean, standard deviation, max, min, range. */ public double [] getPointSummary(int y, int x){ double [] temp = new double[7]; // values to determine double mean = 0, stdev = 0, max = columns[y][x][0], min = columns[y][x][0], range = 0; double count = columns[y][x].length; double sumSq = 0; double sumsSq = 0; // get summaries for (int o = 0; o < count; o ++){ mean += columns[y][x][o]; sumSq += (columns[y][x][o]*columns[y][x][o]); if (columns[y][x][o] > max) max = columns[y][x][o]; if (columns[y][x][o] < min) min = columns[y][x][o]; } sumsSq = mean*mean; // find the orientation of the max and min double maxOr = 0; double minOr = 0; for (int o = 0; o < count; o ++){ if (columns[y][x][o] == max){ maxOr = o; } if (columns[y][x][o] == min){ minOr = o; } } double orS = 180.0/(double)count; // // deterine the orientation step size // finish summary mean = mean/count; range = max-min; stdev = Math.sqrt((sumSq-sumsSq/count)/(count-1)); // put in temp temp[0] = mean; temp[1] = stdev; temp[2] = max; temp[3] = min; temp[4] = range; temp[5] = maxOr*orS; temp[6] = minOr*orS; return temp; } /** * Return the Mean [0] and Standard deviation[1] * for the data set of different types * @param int type 0 = all, 1 = pos, 2 = neg * @return double [2] mean [0] and standard deviation [1] */ public double [] getMeanStd(int type){ double sum = 0; double sumSq = 0; double count = 0; double temp [] = new double [2]; // sum the values for (int y = 0; y < columns.length; y ++){ for (int x = 0; x < columns[0].length; x ++){ for (int o = 0; o < columns[0][0].length; o ++){ // sum depending on the type to get switch (type){ case (ALL) : sum += columns[y][x][o]; sumSq += columns[y][x][o]*columns[y][x][o]; count ++; break; case (POS) : if (columns[y][x][o] > 0){ sum += columns[y][x][o]; sumSq += columns[y][x][o]*columns[y][x][o]; count ++; } break; case (NEG) : if (columns[y][x][o] < 0){ sum += columns[y][x][o]; sumSq += columns[y][x][o]*columns[y][x][o]; count ++; } break; } } // end of orientation loop } // end of x axis loop } // end of y axis loop // convert to average temp[0] = sum/count; temp[1] = Math.sqrt((sumSq-((sum*sum))/count) /(count-1)); return temp; } }