Exemplo n.º 1
0
 def test_compare_w_neurolib_native_model(self):
     """
     Compare with neurolib's native Hopf model.
     """
     # run this model - default is diffusive coupling
     hopf_multi = HopfNetwork(self.SC, self.DELAYS, seed=SEED)
     multi_result = hopf_multi.run(DURATION,
                                   DT,
                                   ZeroInput(DURATION, DT).as_array(),
                                   backend="numba")
     # run neurolib's model
     hopf_neurolib = HopfModel(Cmat=self.SC, Dmat=self.DELAYS, seed=SEED)
     hopf_neurolib.params["duration"] = DURATION
     hopf_neurolib.params["dt"] = DT
     # there is no "global coupling" parameter in MultiModel
     hopf_neurolib.params["K_gl"] = 1.0
     # delays <-> length matrix
     hopf_neurolib.params["signalV"] = 1.0
     hopf_neurolib.params["coupling"] = "diffusive"
     hopf_neurolib.params["sigma_ou"] = 0.0
     hopf_neurolib.params[
         "xs_init"] = hopf_multi.initial_state[::2][:, np.newaxis]
     hopf_neurolib.params["ys_init"] = hopf_multi.initial_state[
         1::2][:, np.newaxis]
     hopf_neurolib.run()
     for var in NEUROLIB_VARIABLES_TO_TEST:
         corr_mat = np.corrcoef(hopf_neurolib[var],
                                multi_result[var].values.T)
         self.assertTrue(np.greater(corr_mat, CORR_THRESHOLD).all())
Exemplo n.º 2
0
    def test_model_imports(self):
        from neurolib.models.hopf import HopfModel

        hopf = HopfModel()
        from neurolib.models.aln import ALNModel

        aaln = ALNModel()
        from neurolib.models.fhn import FHNModel
Exemplo n.º 3
0
    def test_single_node(self):
        logging.info("\t > Hopf: Testing single node ...")
        start = time.time()
        hopf = HopfModel()
        hopf.params["duration"] = 2.0 * 1000
        hopf.params["sigma_ou"] = 0.03

        hopf.run()

        end = time.time()
        logging.info("\t > Done in {:.2f} s".format(end - start))
Exemplo n.º 4
0
    def test_network(self):
        logging.info("\t > Hopf: Testing brain network (chunkwise integration and BOLD" " simulation) ...")
        start = time.time()
        ds = Dataset("gw")
        hopf = HopfModel(Cmat=ds.Cmat, Dmat=ds.Dmat)
        hopf.params["w"] = 1.0
        hopf.params["signalV"] = 0
        hopf.params["duration"] = 10 * 1000
        hopf.params["sigma_ou"] = 0.14
        hopf.params["K_gl"] = 0.6

        hopf.run(chunkwise=True, bold=True, append_outputs=True)

        end = time.time()
        logging.info("\t > Done in {:.2f} s".format(end - start))
Exemplo n.º 5
0
 def test_compare_w_neurolib_native_model(self):
     """
     Compare with neurolib's native Hopf model.
     """
     # run this model
     hopf_multi = self._create_node()
     multi_result = hopf_multi.run(DURATION,
                                   DT,
                                   ZeroInput(DURATION, DT).as_array(),
                                   backend="numba")
     # run neurolib's model
     hopf_neurolib = HopfModel(seed=SEED)
     hopf_neurolib.params["duration"] = DURATION
     hopf_neurolib.params["dt"] = DT
     hopf_neurolib.run()
     for var in NEUROLIB_VARIABLES_TO_TEST:
         corr_mat = np.corrcoef(hopf_neurolib[var],
                                multi_result[var].values.T)
         self.assertTrue(np.greater(corr_mat, CORR_THRESHOLD).all())
Exemplo n.º 6
0
 def test_chunksize(self):
     model = HopfModel()
     chunksize = 100
     model.run(chunksize=chunksize)
     self.assertEqual(model.output.shape[1], chunksize)