Skip to content

Commit

Permalink
Added code and test case for window baseline normalization.
Browse files Browse the repository at this point in the history
  • Loading branch information
upibhalla committed Apr 11, 2024
1 parent 535d336 commit ee974e9
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 3 deletions.
82 changes: 82 additions & 0 deletions TestJson/epsc_window_baseline_norm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"Metadata": {
"transcriber": "Upi",
"organization": "NCBS",
"email": "[email protected]",
"source": {
"sourceType": "other",
"doi": "0",
"authors": "None",
"journal": "None. This is a purely fictional _experiment_ for the purposes of testing findSim",
"year": 0,
"figure": ""
},
"testModel": "models/loadGABAR.py",
"testMap": "models/loadGABAR.json"
},
"Experiment": {
"design": "TimeSeries",
"species": "rat",
"cellType": "hippocampal CA1 pyramidal neuron",
"notes": "Test removal of baseline in voltage clamp peak estimate"
},
"Stimuli": [
{
"timeUnits": "sec",
"quantityUnits": "Hz",
"entity" : {
"name": "synInput",
"alias": "synInput"
},
"field": "rate",
"data": [
[0,5]
]
},
{
"timeUnits": "sec",
"quantityUnits": "mV",
"entity" : {
"name": "soma",
"alias": "soma"
},
"field": "Vclamp",
"data": [
[0,-65.0],
[0.001,0.0],
[0.3,-65.0]
]
}
],
"Readouts": {
"timeUnits": "sec",
"quantityUnits": "ratio",
"entity" : {
"name": "vclamp",
"alias": "vclamp"
},
"field": "current",
"window": {"startt": -0.010, "endt": 0.005, "dt": 0.0005,
"operation": "max", "baseline": "min"
},
"normalization": {
"entity" : {
"name": "vclamp",
"alias": "vclamp"
},
"sampling": "start"
},
"data": [
[0.21, 1, 0],
[0.23, 1.2, 0],
[0.25, 1.2, 0],
[0.27, 1.2, 0],
[0.29, 1.2, 0]
]
},
"Modifications": {
"subset": [
{"name":"all"}
]
}
}
9 changes: 6 additions & 3 deletions findSim.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ def putStimsInQ( q, stims, pauseHsolve ):
val = float(j[1]) * i.quantityScale
t = float(j[0])*i.timeScale
heapq.heappush( q, Qentry( t, i, val ) )
if isElec:
if isElec and pauseHsolve.optimizeElec:
# Below we tell the Hsolver to turn off or on for elec calcn.
if val == 0.0:
heapq.heappush( q, Qentry(t+pauseHsolve.stimSettle, pauseHsolve, 0) )
Expand Down Expand Up @@ -1135,6 +1135,9 @@ def parseAndRun( model, stims, readouts, getPlots = False ):
qe = heapq.heappop( q )
currt = sw.getCurrentTime()
if ( qe.t > currt ):
print( "currt={:.4f}, qt={:.4f}".format( currt, qe.t) )
if qe.t > 1.5:
print( qe.entry )
sw.advanceSimulation( qe.t - currt, doPlot = getPlots )
if isinstance( qe.entry, Stimulus ):
sw.deliverStim( qe )
Expand Down Expand Up @@ -1176,12 +1179,12 @@ def parseAndRun( model, stims, readouts, getPlots = False ):
if readouts.useNormalization and readouts.normMode == "each":
if len( [ y for y in readouts.ratioData if abs(y) < eps ] ) > 0:
#raise SimError( "runDoser: Normalization1 failed due to zero denominator: " + str( min( readouts.ratioData ) ) )
print( "parseAndRun: Normalization1 denom={:.3g} for {}.{}".format(min( readouts.ratioData ), readouts.entities[0], readouts.field ) )
print( "parseAndRun: Normalization1 denom={:.3g} for {}.{}".format(min( readouts.ratioData ), readouts.entities, readouts.field ) )
readouts.simData = [ x/y if abs(y)>= eps else 0.0 for x, y in zip(readouts.simData, readouts.ratioData) ]
else:
if abs(norm) < eps:
#raise SimError( "runDoser: Normalization2 failed due to zero denominator: " + str( norm ) )
print( "parseAndRun: Normalization2 denom={:.3g} for {}.{}".format( norm, readouts.entities[0], readouts.field ) )
print( "parseAndRun: Normalization2 denom={:.3g} for {}.{}".format( norm, readouts.entities, readouts.field ) )
readouts.simData = [0.0] *len( readouts.simData )
else:
readouts.simData = [ x/norm for x in readouts.simData ]
Expand Down
7 changes: 7 additions & 0 deletions models/loadGABAR.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"all":["all"],
"soma":["elec/soma"],
"synInput":["elec/soma/gabaR/sh/synapse/synInput_rs"],
"synapse":["elec/soma/gabaR/sh/synapse"]
}

16 changes: 16 additions & 0 deletions models/loadGABAR.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import moose
import rdesigneur as rd
def load( scaleParam, chemFile ):
rdes = rd.rdesigneur(
turnOffElec = True,
elecDt = 5e-5,
chanProto = [['make_GABA()', 'gabaR']],
chanDistrib = [
['gabaR', 'soma', 'Gbar', '1' ]],
stimList = [['soma', '1','gabaR', 'periodicsyn', '50 * (t > 0.1)']],
)
return rdes

def build( rdes ):
rdes.buildModel()
#moose.le( '/model/elec/soma/gabaR/sh/synapse/synInput_rs' )

0 comments on commit ee974e9

Please sign in to comment.