def process_distributed_sm_measurement(directory):
    from topo.command.basic import load_snapshot
    import cPickle as pickle
    data_dict = {}
    
    load_snapshot('snapshot.typ')
    
    for a in os.listdir(directory):
        b = os.path.join(directory,a);
        b = os.path.join(b,'dict.dat');
        f = open(b,'r')
        d = pickle.load(f)
        data_dict.update(d)
        
    sa = surround_analysis()
    
    for (x,y) in data_dict.keys():
            sa.plot_size_tunning(x,y)
            sa.plot_orientation_contrast_tuning_abs(x,y)
    
    self.plot_histograms_of_measures()
    #lhi = compute_local_homogeneity_index(self.sheet.sheet_views['OrientationPreference'].view()[0]*pi,0.5)                
    #self.plot_map_feature_to_surround_modulation_feature_correlations(lhi,"Local Homogeneity Index")
    #self.plot_map_feature_to_surround_modulation_feature_correlations(self.sheet.sheet_views['OrientationSelectivity'].view()[0],"OrientationSelectivity")
    #self.plot_map_feature_to_surround_modulation_feature_correlations(self.sheet.sheet_views['OrientationPreference'].view()[0]*numpy.pi,"OrientationPreference")
	
Ejemplo n.º 2
0
def compare_with_and_without_snapshot_LoadSnapshot(script="examples/lissom.ty"):
    data_filename=os.path.split(script)[1]+"_PICKLETEST"
    snapshot_filename=os.path.split(script)[1]+"_PICKLETEST.typ_"

    locn = resolve_path(os.path.join('tests',data_filename))
    print "Loading pickle from %s"%locn
    try:
        data = pickle.load(open(locn,"rb"))
    except IOError:
        print "\nData file '"+data_filename+"' could not be opened; run _A() first"
        raise

    # retrieve parameters used when script was run
    run_for=data['run_for']
    break_at=data['break_at']
    look_at=data['look_at']

#    # CEBALERT: shouldn't need to re-list - should be able to read from data!
#    cortex_density=data['cortex_density']
#    lgn_density=data['lgn_density']
#    retina_density=data['retina_density']
#    dims=data['dims']
#    dataset=data['dataset']
    
    from topo.command.basic import load_snapshot

    locn = resolve_path(os.path.join('tests',snapshot_filename))
    print "Loading snapshot at %s"%locn

    try:
        load_snapshot(locn)
    except IOError:
        print "\nPickle file '"+snapshot_filename+"' could not be opened; run _B() first."
        raise

    assert topo.sim.time()==break_at
    assert_array_equal(data[topo.sim.time()],topo.sim[look_at].activity,
                       err_msg="\nAt topo.sim.time()=%d"%topo.sim.time())
    print "Match at %s after loading snapshot"%topo.sim.time()

    topo.sim.run(run_for-break_at)
                
    assert_array_equal(data[topo.sim.time()],topo.sim[look_at].activity,
                       err_msg="\nAt topo.sim.time()=%d"%topo.sim.time())

    print "Match at %s after running loaded snapshot"%topo.sim.time()
Ejemplo n.º 3
0
def loadModelSnapshot(saveSnapshotTime, 
                      LGNRingNo=5, V1RingNo=5, basename='snapshot'): 
    # LGNRingNo and V1RingNo are paramters that change the model structure
    typPath = '../models/snapshots/'

    loadSnapshot = "%s-LGN%s-V1%s-T%s.typ" % (basename, str(LGNRingNo), str(V1RingNo), str(saveSnapshotTime))
    if saveSnapshotTime is not None:
        fullTypPath = typPath+loadSnapshot
        snapshotExists = os.path.exists(fullTypPath)
        # Load snapshot and return
        if snapshotExists:
            print "Loading snapshot %s" % loadSnapshot
            load_snapshot(typPath+loadSnapshot)
            print ("Snapshot %s loaded." % loadSnapshot)
            return False
        else:
            # saveSnapshotFlag. True indicates a snapshot is needed as it is desired but doesn't exist.
            return True 
    else: 
        return False
def process_distributed_sm_measurement(directory):
    from topo.command.basic import load_snapshot
    import cPickle as pickle
    data_dict = {}
    
    load_snapshot('snapshot.typ')
    
    for a in os.listdir(directory):
        b = os.path.join(directory,a);
        b = os.path.join(b,'dict.dat');
        f = open(b,'r')
        d = pickle.load(f)
        data_dict.update(d)
        
    sa = surround_analysis()
    
    for (x,y) in data_dict.keys():
            sa.plot_size_tunning(x,y)
            sa.plot_orientation_contrast_tuning_abs(x,y)
    
    self.plot_histograms_of_measures()
Ejemplo n.º 5
0
def GCALTemporal(stimulus = None,
                 timestep=0.5,
                 ringParams = ('MAX','MAX'),
                 saveSnapshotTime = None,
                 plastic=True,

                 LGN_TC = None,
                 LGNFFStrength = 2.33,
                 GCStrength=0.6,
                 GCDelay=0.01,
                 LGNDistanceDelay=None,

                 # V1 Settings
                 V1_TC = None,
                 V1FFStrength=1.5,
                 ExcStrength=1.7,
                 InhStrength=-1.4,
                 LateralDelay=0.01,
                 V1DistanceDelay=None,

                 HomeoFactor=1.0, 
                 HomeoPlastic = False ): 

    VSDSheetFlag = True;  saveSnapshotFlag = False; LOAD = None

    ###################################################
    # Modifying sheets #
    ####################
                           
    modelName = 'fit-LGN-V1.py'
    (LGNRingNo,V1RingNo) = ringParams

    if LOAD is not None:
        typPath = '../models/snapshots/'
        load_snapshot(typPath+LOAD)
    else:   
        print "Modifying model loaded in memory"          
    
    ########################
    # Sheets Modifications #
    ########################

        p = gcal_vanilla.makeParams()
        gcal_vanilla.makeSheets(p)
        # Switch out the LISSOM sheets for continuous ones
        switchAllSheets(VSDSheetFlag)
        # Setup the input generator
        setupRetina(stimulus, timestep)
        # Connecting with original GCAL connections
        gcal_vanilla.connectGCAL(p,LGNRingNo,V1RingNo)
                             

    ############################
    # Connection Modifications #
    ############################
                             
    'Alternatively, could use topo.sheet[<name>].projection(<name>)'
    conns = dict([(el.name,el) for el in topo.sim.connections()])

    ''' AfferentToLGNOn, AfferentToLGNOff, LGNOnAfferent, LGNOffAfferent,
        GCLGNOn-*,  GCLGNOff-*, LateralInhibitory-*, LateralExcitatory-*
    '''

    #######
    # LGN #
    #######

    # FEEDFORWARD DELAY IS ABOUT 15MS FOR BOTH STAGES

    # Afferent from Retina to LGNOn/Off. Delay and strength.
    setConnDelay('AfferentToLGNOn',15.0,conns)
    setConnDelay('AfferentToLGNOff',15.0,conns)
    setConnStrength('AfferentToLGNOn', LGNFFStrength,conns)
    setConnStrength('AfferentToLGNOff', LGNFFStrength,conns)

    assert GCStrength > 0
    modifyLateralConnections(conns, 'GCLGNOn', GCStrength, GCDelay, LGNDistanceDelay)
    modifyLateralConnections(conns, 'GCLGNOff', GCStrength, GCDelay, LGNDistanceDelay)

    ######
    # V1 #
    ######
                             
    setConnDelay('LGNOnAfferent',15.0,conns)
    setConnDelay('LGNOffAfferent',15.0,conns)
    setConnStrength('LGNOnAfferent', V1FFStrength,conns)
    setConnStrength('LGNOffAfferent' ,V1FFStrength,conns)

    assert ExcStrength > 0;  assert InhStrength < 0
    modifyLateralConnections(conns, 'LateralExcitatory', ExcStrength, LateralDelay, V1DistanceDelay)
    modifyLateralConnections(conns, 'LateralInhibitory', InhStrength, LateralDelay, V1DistanceDelay)

    ##########################
    # Sheet output functions #
    ##########################

    setLGNOutputFns(LGN_TC)
    setV1OutputFns(V1_TC, HomeoFactor, HomeoPlastic) 

    ###############################
    # Plasticity and snapshotting #
    ###############################
    
    if saveSnapshotFlag:
        setSheetPlasticity(plastic=True) # No point making snapshot if plasticity if off                                
        saveSnapShot(saveSnapshotTime)

    setSheetPlasticity(plastic)      # Set as desired
import numpy

from contrib.jacommands import LateralOrientationAnnisotropy

from topo.analysis.featureresponses import MeasureResponseCommand, FeatureMaps, SinusoidalMeasureResponseCommand, FeatureCurveCommand
FeatureMaps.num_orientation=16
MeasureResponseCommand.scale=1.0
MeasureResponseCommand.duration=4.0
SinusoidalMeasureResponseCommand.frequencies=[2.4]
FeatureCurveCommand.num_orientation=16
FeatureCurveCommand.curve_parameters=[{"contrast":15},{"contrast":50},{"contrast":90}]
from topo.command.basic import load_snapshot


#load_snapshot('./DATA/LESI/LESI-NEW-SMALL/CCSimple_010000.00_ormap.typ')
load_snapshot('./DATA/LESI/LESI-NEW-LARGE-LargeRegion/CCSimple_010000.00_with_map.typ')
    
from topo.command.basic import wipe_out_activity, clear_event_queue
wipe_out_activity()
clear_event_queue()

from topo.pattern.basic import SineGrating, Disk
class SineGratingDiskTemp(SineGrating):
      mask_shape = param.Parameter(default=Disk(smoothing=0,size=1.0))

def set_parameters(a,b,c,d,e,f,g,h,i,j,k,l,m):
    print a,b,c,d,e,f,g,h,i,j,k,l,m
    
    topo.sim["V1Simple"].projections()["V1SimpleFeedbackExc1"].strength=b
    topo.sim["V1Simple"].projections()["V1SimpleFeedbackInh"].strength=c
    topo.sim["V1Complex"].projections()["LongEE"].strength=d
from topo.numbergen import UniformRandom, BoundedNumber, ExponentialDecay
from topo.command.basic import pattern_present
from param import normalize_path
import numpy

from topo.analysis.featureresponses import MeasureResponseCommand, FeatureMaps, SinusoidalMeasureResponseCommand, FeatureCurveCommand
FeatureMaps.num_orientation=16
MeasureResponseCommand.scale=1.0
MeasureResponseCommand.duration=4.0
SinusoidalMeasureResponseCommand.frequencies=[2.4]
FeatureCurveCommand.num_orientation=16
FeatureCurveCommand.curve_parameters=[{"contrast":15},{"contrast":50},{"contrast":90}]
from topo.command.basic import load_snapshot


load_snapshot('CCSimple_010005_new_or_map.00.typ')
    
from topo.command.basic import wipe_out_activity, clear_event_queue
wipe_out_activity()
clear_event_queue()

from topo.pattern.basic import SineGrating, Disk
class SineGratingDiskTemp(SineGrating):
      mask_shape = param.Parameter(default=Disk(smoothing=0,size=1.0))

def set_parameters(a,b,c,d,e,f,g,h,i,j,k,l):
    print a,b,c,d,e,f,g,h,i,j,k,l
    
    topo.sim["V1Simple"].projections()["V1SimpleFeedbackExc1"].strength=b
    topo.sim["V1Simple"].projections()["V1SimpleFeedbackInh"].strength=c
    topo.sim["V1Complex"].projections()["LongEE"].strength=d