Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fMRI generator #16

Open
Seanny123 opened this issue Jun 27, 2016 · 0 comments
Open

Add fMRI generator #16

Seanny123 opened this issue Jun 27, 2016 · 0 comments

Comments

@Seanny123
Copy link
Contributor

Seanny123 commented Jun 27, 2016

Terry used the code below in Nengo 1.4 to generate fMRI signals. It should be converted to Nengo 2.0. The basic flow of the code, is to toss a probe on the spiking output, and then multiply the spiking output by the absolute value of the connection weight matrix (i.e. to get the total amount of neurotransmitter used). For the hemodynamic function, just take it from this ACT-R paper.

class FMRI(nef.SimpleNode):
    def __init__(self,name,filename,ensembles,terminations):
        self.spikes=0
        self.synapses=0
        nef.SimpleNode.__init__(self,name)
        self.ensembles=ensembles
        self.encoders={}
        for t in terminations:
            while hasattr(t,'wrappedTermination'):
                t=t.wrappedTermination
            self.encoders[t]=numeric.array(t.node.encoders).__abs__()


        self.filename=filename

    def tick(self):
        self.spikes=0
        for n in self.ensembles:
            total=0
            for v in n.getOrigin('AXON').getValues().getValues():
                total+=v
            self.spikes+=total

        self.synapses=0
        for t,encoders in self.encoders.items():
            x=t.output
            enc=self.encoders[t]
            self.synapses+=sum(numeric.dot(enc,x))

        f=file(self.filename,'a')
        f.write('%g,%g,%g\n'%(self.t_start,self.spikes,self.synapses))
        f.close()

    def origin_spikes(self):
        return [self.spikes]
    def origin_synpases(self):
        return [self.synapses]

I figured I'd make an issue for this, so people could have access to this code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant