*****************************************************************

Mesh Generator for Neurons 
Author:		Rogene M. Eichler West
Version: 	2.9.3
Dated:		21 February 1997 

******************************************************************
	
Copyright @ 1995-7 Rogene M. Eichler West
All Rights Reserved

******************************************************************

NEW:	Surface area is conserved from the original morphology
	files and the simulation output files.

Synopsis:

	This code converts cell morphology descriptions in 
	Eutectic NTS format into files suitable for numerical 
	simulations. The output can be formatted for custom 
	simulators, or the popular public domain neural simulators 
	GENESIS and NEURON. The mesh size, or number of compart-
	ments, is determined by the electrotonic criteria specified
	by the user at run time. The compartments are numbered 
	according to the methods of Hines (1984) and Eichler West 
	and Wilcox (1996).

Compilation:
	
	To compile:
		cc -O mesh*c -o mesh -lm

	To run:
		mesh

	The code has been tested with the cc and gcc compilers and 
	on SGI, SUN, and Cray computing platforms.

Input Arguments:

	File:
		Type the full file name. The file should reside 
		in the same directory as the mesh executable code. 
		Wild card characters (ie *) in the file name will 
		not be recognized. 

		The mesh generator reads datafiles in Eutectic NTS 
		format. The x,y,z coordinates and diameters are 
		given in microns. The data is organized in a depth-
		first tree structure.  

		These point types are recognized: 
			SOS, SCP, SOE, MTO, TTO, BTO, BAE, MAE, 
			TAE, NE, BP, CP

		These point types are converted: 
			ES -> NE, FS -> CP, SB -> CP
       
		These point types are ignored: 
			OS, OCP, OE, DS, DCP, DE 

		The datafiles should be "merged" using the Eutectic
		software before using this mesher. This software 
		will attempt to match up *TO with *AE ends, but 
		will only be successful if they fall within 10 
		microns of each other's coordinates.

		If the datafile is edited, one should take care 
		that the edit retains a complete tree structure. 
		The soft ware will check for the condition that 
		*TO + BP = NE. (See Eichler West and Wilcox 1996) 

		The number of Eutectic points is grabbed from the 
		first line in the Eutectic file. If you alter the 
		file by adding or deleting points, it is necessary
		to also change the number in this header.

	Rm:
		The membrane resistance (Ohm*cm2). Typical values 
		range from 5,000 - 50,000. 

	Ri:
		The internal (axial) resistance (Ohm*cm). Typical 
		values range from 50 - 250. 

	The maximum intracompartment radius range (microns):
		This criterion establishes a maximum on how much 
		the radius can vary from one end of the compartment
		to the other. Typical values range from 0.1 - 1.0.
		Smaller values of RCrit produce more compartments.
 
	The maximum electrotonic length per compartment: 
		This criterion sets a maximum on the electrotonic 
		length (L) per compartment. Typical values range 
		from 0.01 - 0.1 (Segev et al 1989), but should be 
		selected based on the convergence behavior of the 
		particular structure being simulated. It has been 
		shown that structures with an overall L of 1.0 
		numerically converge sufficiently with compartments
		having an L of 0.1. Longer structures require 
		smaller values of LCrit per compartment (Perkel and
		Mulloney 1978). Smaller values of LCrit produce 
		more compartments. 

	Choice of output format:
		Custom Code -
                	radii.dat:
                        	a list of compartment radii 
				(units cm)
                	length.dat:
                        	a list of compartment lengths 
				(units cm)
                	connect.dat:
                        	a connectivity matrix
                        	1.0 where neighboring region
                        	0.0 else (including the diagonal)
                            	The matrix is written:
                                	do i = 1, comp_no
                                        	do j = 1, comp_no
                                               	write G(i,j)
                                        	end do
                                	end do
		GENESIS -
			The cell file is named genesis-script.p 
			and the units are microns.

		NEURON -	
			The cell file is named neuron-script.dat 
			and the units are microns.
			
	Choice of additional file options:
		SGI objects - 				graph.dat
			Used to create objects in OpenGL to animate
			simulations. 

		Individual electrotonic lengths -	compL.dat
			Contains the electrotonic length of each 
			individual compartment.

		Electrotonic length from soma - 	LfS.dat
			The total electrotonic distance away from 
			the soma is listed for each compartment.
 
		Distance from soma -			DfS.dat
                        The total distance away from the soma is 
			listed in cm for each compartment.

General comments:

        The resulting compartments will not be of uniform electro-
	tonic length. The soma compartment may exceed the LCrit. 
	The radius criterium may result in compartments much 
	smaller than LCrit.

	There are *much* more CPU efficient ways this code could 
	be written. I have opted for readability so that future 
	changes could be easily incorporated. This program will 
	only need to be run once for each dataset presumably, so 
	efficiency in time is not an important issue.

Development:

	Several users have requested an option to output the soma 
	as a stack of disks, rather than a sphere. This will be 
	included in the next release.

	Also, Neurolucida files will be supported in the new release.

	NEURON formatting (see BUGS NOTE).
	
BUGS NOTE:

	NEURONS users: I have not implemented the output formatting
	in 3-D coordinates! Electrotonically, I assume you will 
	generate the correct solution but I am told that the 
	graphics will not be pretty. I am not a NEURON user, so 
	Beta test volunteers are appreciated and will increase the 
	priority of further development.

	If your results are suspicious, please mail me a copy of
	the Eutectic file and the parameters that produced the
	questionable outputs. I will be happy to investigate the
	cause of the problem.
 
References:

                Eichler West, R.M. and Wilcox G.L. (1996) "A renum-
	bering method to decrease matrix banding in equations des
	cribing branched neuron-like structures." J Neuroscience
        Methods. (In Press.) {Minnesota Supercomputer Institute
        Research Report UMSI 95/167}

        	Hines, M. (1984) "Efficient computation of branched
	nerve equations." Int. J. Biomed. Comp. 15:69-76.
 
        	Perkel, D.H. and Mulloney, B. (1978) "Electrotonic
	properties of neurons: steady-state compartmental model."
	J Neurophysiol. 41:627-639.
        
		Segev, I., Fleshman, J.W., and Burke, E. (1989)
	"Compartmental models of complex neurons." In: C. Koch
	and I. Segev (eds) Methods in Neuronal Modeling. (pp 63-
	96). MIT Press, Cambridge, Massachusetts.

Acknowledgements:

	Thanks first and foremost to Dr. George L. Wilcox (Univer-
	sity of Minnesota) for his vision of hackers taking over 
	the world of biology and his support towards making it 
	happen!

        I appreciate the help of Dave Beeman and Nathan Urban with
        formatting and beta testing the GENESIS outputs. Erik 
	De Schutter suggested that the surface area should be 
	conserved from the original morphology files.  

	1995-1996:

	Computing facilities were provided by the Minnesota Super-
	computer Institute, the Laboratory for Computational 
	Sciences and Engineering (LCS&E) at the University of 
	Minnesota, the Computer Science Department at the Univer-
	sity of Minnesota, the Army High Performance Computing
	Research Center, and West Research.

	I received financial support at various intervals during 
	the course of the code development from a Minnesota Super-
	computer Institute / Cray Research grant, the Graduate 
	Program in Neuroscience at the University of Minnesota, the
	Army High Performance Computing Research Center, and West 
	Research. 

	1996-1997:

	Computing facilities were provided by the Born Bunge 
	Foundation, Universitaire Instelling Antwerpen (Belgium).

	I received financial support from a joint postdoctoral
	appointment between the labs of Erik De Schutter (UIA)
	and Jim Bower (Caltech).


******************************************************************

For more information, the author can be contacted at:

	rogene@med.umn.edu
	rogene@bbf.uia.ac.be
	rogene@bbb.caltech.edu

	Address during original development:
		Graduate Program in Neuroscience
		University of Minnesota
		Minneapolis, Minnesota 55455
		USA

	Current addresses (starting Aug 1996):
  	     1. Theoretical Neurobiology
		Born Bunge Foundation
		Universitaire Instelling Antwerpen - UIA
           	Universiteitsplein 1
           	B2610 Antwerp
           	BELGIUM

	     2. Division of Biology 216-76 
		California Institute of Technology
		Pasadena, CA 91125
		USA

