package model; import util.Defaults; /** *

Title:SimpleCell.java

*

Description: The Gabor Model of a Simple Cell

*

Copyright: Copyright (c) 2007

*

Company: Hanover College

* @author John H. Krantz, Ph.D. * @version 0.5 */ //import java.awt.*; //import javax.swing.*; public class SimpleCell { // cell parameters private double cellTilt; // orientation of the bar in units of // 10 degrees private double cellBarWidth = 2; // bar width in standard deviation. private double phase = 0; private double phaseRad = 0; // bar width setting parameters used when random bar widths // are being selected private double maxRelW = 3.0; // max relative width 1/maxRelW // bar widths over this range. private double sf_X = 0; private double sf_Y = 0; // a column of cells private int numOrient = Defaults.NUM_ORIENT; private double [][][] cells = new double[numOrient][][]; public SimpleCell() { setupCell(); } public SimpleCell(double stdDev_Ctr){ cellBarWidth = (stdDev_Ctr > 0 ? stdDev_Ctr : cellBarWidth); setupCell(); } // set methods /** * Set the width of the bar of the simple cell * @param double w width of bar in standard deviation */ public void setBarWidth(double w){ cellBarWidth = (w >= 1 ? w : cellBarWidth); // setupCell(); } /** * set up the number of orientations to be in * the model. Must be more than 1. * @param int orients the number of orientations */ public void setNumOrientations(int orients){ numOrient = (orients > 1 ? orients : numOrient); } /** * set the phase of the cosine part of the Gabor function * 0 is excitatory center bar * 180 is inhibitory center bar * others are of center. * @param double deg phase in degrees */ public void setPhase(double deg){ phase = deg; phaseRad = Math.PI*phase/180.0; // convert to radians // setupCell(); } public void setupCell(){ double angle; int cellRadius = (int)(Math.round(cellBarWidth*maxRelW)); cells = new double[numOrient][2*cellRadius+1] [2*cellRadius+1]; double ctr = cellRadius+1.0; double s = cellBarWidth; for (int i = 0; i < numOrient; i ++){ // determine the angel of the cell tilt in deg cellTilt = ((double)i/(double)numOrient)*180.0; // angle of cell in radians angle = (double)cellTilt*Math.PI/180.0; sf_X = 2.0*Math.cos(angle)/s; sf_Y = 2.0*Math.sin(angle)/s; for (double x = 0; x < cells[0].length; x ++){ for (double y = 0; y < cells[0][0].length; y ++){ cells[i][(int)x][(int)y] = Math.exp(-((x-ctr)*(x-ctr) + (y-ctr)*(y-ctr))/ (2.0*s*s))* Math.cos(sf_X*(x-ctr)+ sf_Y*(y-ctr)+phaseRad); } } } } // get methods public double [][] getCell(int orient) { return cells[orient]; } public double [][][] getAllCells() { return cells; } public double getTilt() { return cellTilt; } public double getCellWidth() { return cellBarWidth; } public double getPhase() { return phase; } }