// File for generating Parasol RGC at the correct position

load_file("Parameters.hoc")
load_file("Human_Parasol_RGC_template.hoc")
/* load_file("nrngui.hoc") */

num_gang = 1
RGC_cell_type = 2   // 1 for ON, 2 for OFF
dendritic_radius = 91
max_num_dendrites = 10000 // Maximum number of dendtrites in each RGC

objref Dend_x, Dend_y, Dend_z, ONOFF_type, RGC_dend_radius, num_dends
objref Ganglion[num_gang] 

// object for storing dendrite centres
objref Dend_centres_x[num_gang], Dend_centres_y[num_gang], Dend_centres_z[num_gang]


proc generate_RGC_cells() {
    ONOFF_type = new Matrix(num_gang, 1)
    RGC_dend_radius = new Matrix(num_gang, 1)

    Dend_x = new Matrix(num_gang, 1)
    Dend_y = new Matrix(num_gang, 1)
    Dend_z = new Matrix(num_gang, 1)

    Ganglion[0] = new Human_Parasol_RGC(-3000, 0, 0)
    ONOFF_type.x[0][0] = RGC_cell_type
    RGC_dend_radius.x[0][0] = dendritic_radius

    Dend_x.x[0][0] = Eccentricity_x*1000
    Dend_y.x[0][0] = 0
    Dend_z.x[0][0] = 0

}

// Function for calculating the centre points of each dendrite for synapse use
proc calc_dendrite_centre() {
    
    num_dends = new Vector(num_gang)
    for i = 0, num_gang - 1 {
        Dend_centres_x[i] = new Vector(max_num_dendrites)
        Dend_centres_y[i] = new Vector(max_num_dendrites)
        Dend_centres_z[i] = new Vector(max_num_dendrites)
        k = 0
        forsec Ganglion[i].basal {
            Dend_centres_x[i].x[k] = x3d(1) + Eccentricity_x*1000    //- (x3d(1) - x3d(0))/2
            Dend_centres_y[i].x[k] = y3d(1)         //- (y3d(1) - y3d(0))/2
            Dend_centres_z[i].x[k] = z3d(1)         //- (z3d(1) - z3d(0))/2
            k = k + 1
        }
        num_dends.x[i] = k
        Dend_centres_x[i].resize(k)
        Dend_centres_y[i].resize(k)
        Dend_centres_z[i].resize(k)
    }

    //print num_dends.x[0]

}