[Pybrainsim-activity] SF.net SVN: pybrainsim:[146] trunk/src
Status: Planning
Brought to you by:
rgoj
From: <rg...@us...> - 2010-08-05 17:36:07
|
Revision: 146 http://pybrainsim.svn.sourceforge.net/pybrainsim/?rev=146&view=rev Author: rgoj Date: 2010-08-05 17:35:58 +0000 (Thu, 05 Aug 2010) Log Message: ----------- * Minor corrections so that lead field is calculated only once Modified Paths: -------------- trunk/src/Head.py trunk/src/HeadModelDipoleSphere.py Modified: trunk/src/Head.py =================================================================== --- trunk/src/Head.py 2010-06-30 08:42:36 UTC (rev 145) +++ trunk/src/Head.py 2010-08-05 17:35:58 UTC (rev 146) @@ -80,7 +80,7 @@ recording = [] for i in range(len(self.registrationSiteList)): recording.append([]) - + # Preparing a variable where the output of each of the generators will # be stored generatorOutput = [] Modified: trunk/src/HeadModelDipoleSphere.py =================================================================== --- trunk/src/HeadModelDipoleSphere.py 2010-06-30 08:42:36 UTC (rev 145) +++ trunk/src/HeadModelDipoleSphere.py 2010-08-05 17:35:58 UTC (rev 146) @@ -67,7 +67,7 @@ # How many generators and electrodes do we have? nGenerators = len(self.head.generatorSiteList) nElectrodes = len(self.head.registrationSiteList) - + # Assuming ideal conductivity sigma = 1.0 @@ -79,6 +79,7 @@ for iElectrode in range(nElectrodes): # Calculating the coordinates of the electrode in the Cartesian coordinates associated with the head + # The X axis points towards the right ear, while the Y axis points towards the front electrodeTheta = self.head.registrationSiteList[iElectrode][0] electrodePhi = self.head.registrationSiteList[iElectrode][1] xyzElectrodeHead = zeros(3); @@ -204,30 +205,37 @@ self.leadFieldFrank1952[iElectrode, iGenerator] = cosPsi * (( 1-pow(f,2.0) )/pow( 1+pow(f,2.0)-2*f*cosTheta, 3/2)-1) self.leadFieldFrank1952[iElectrode, iGenerator] += sinPsi*cosPhi/sinTheta* ( ( 3*f - 3*pow(f,2.0)*cosTheta + pow(f,3.0) - cosTheta )/pow(1+pow(f,2.0)-2*f*cosTheta,3/2) + cosTheta ) self.leadFieldFrank1952[iElectrode, iGenerator] = self.leadFieldFrank1952[iElectrode, iGenerator] / 4 /pi / sigma / self.radius / b + + # This is a nasty trick to make runHeadModel aware that the lead field has already been calculated + self.leadField = 1 def runHeadModel(self, generatorOutput, recording): # Calculating the lead field - self.calculateLeadField() + if self.leadField == 0: + self.calculateLeadField() # Calculating the recording by multyplying the lead field by the generator output - newRecording = dot(self.leadField, (array([generatorOutput])).transpose()) - newRecordingInfinite = dot(self.leadFieldInfinite, (array([generatorOutput])).transpose()) - newRecordingBrody1973 = dot(self.leadFieldBrody1973, (array([generatorOutput])).transpose()) - newRecordingFrank1952 = dot(self.leadFieldFrank1952, (array([generatorOutput])).transpose()) + #newRecording = dot(self.leadField, (array([generatorOutput])).transpose()) + #newRecordingInfinite = dot(self.leadFieldInfinite, (array([generatorOutput])).transpose()) + newRecordingBrody1973 = dot( self.leadFieldBrody1973, (array([generatorOutput])).transpose()) + #newRecordingFrank1952 = dot(self.leadFieldFrank1952, (array([generatorOutput])).transpose()) # Converting the new recording to list format for compatibility with rest of the code - newRecording = list(newRecording[:,0]) - newRecordingInfinite = list(newRecordingInfinite[:,0]) + #newRecording = list(newRecording[:,0]) + #newRecordingInfinite = list(newRecordingInfinite[:,0]) newRecordingBrody1973 = list(newRecordingBrody1973[:,0]) - newRecordingFrank1952 = list(newRecordingFrank1952[:,0]) + #newRecordingFrank1952 = list(newRecordingFrank1952[:,0]) - for i in range(len(newRecording)): + # Brody1973 rules, see comments below... + newRecording = newRecordingBrody1973 + + #for i in range(len(newRecording)): # All three of the lead field calculation methods implemented above can be used, however # only Brody1973 and Frank1952 give results in a bounded homogeneous conducting sphere, # and of these only Brody1973 gives results for all combinations of angles, etc. # Additionally, due to and arccos in my implementation above, Frank1952 for now gives even # worse results than it should for many angles... - newRecording[i] = newRecordingBrody1973[i] + #newRecording[i] = newRecordingBrody1973[i] #newRecording[i] = newRecordingFrank1952[i] #newRecording[i] = newRecordingInfinite[i] #newRecording[i] = (newRecordingBrody1973[i])/(newRecordingFrank1952[i]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |