Skip to content

Exploration and Evolution: improvements

Compare
Choose a tag to compare
@caglorithm caglorithm released this 19 May 20:38
· 646 commits to master since this release
6288ba8

Release time 💪🏾!

Version 0.5.1 of neurolib is out and we have some juicy improvements for exploration and evolution!

Evolution:

  • NSGA-2 algorithm implemented (Deb et al. 2002)
  • Preselect complete algorithms (using algorithm="adaptive" or "nsga2")
  • Implement custom operators for all evolutionary operations
  • Keep track of the evolution history using evolution.history
  • Genealogy evolution.tree available from evolution.buildEvolutionTree() that is networkx compatible [1]
  • Continue working: saveEvolution() and loadEvolution() can load an evolution from another session [2]
  • Overview dataframe evolution.dfPop now has all fitness values as well
  • Get scores using getScores()
  • Plot evolution progress with evolutionaryUtils.plotProgress()

Exploration:

  • Use loadResults(all=True) to load all simulated results from disk to memory (available as .results) or use all=False to load runs individually from hdf. Both options populate dfResults.
  • loadResults() has memory cap to avoid filling up RAM
  • loadDfResults() creates the parameter table from a previous simulation
  • explorationUtils.plotExplorationResults() for plotting 2D slices of the explored results with some advanced functions like alpha maps and contours for predefined regions.

devUtils

  • A module that we are using for development and research with some nice features. Please do not rely on this file since there might be breaking changes in the future.
    • plot_outputs() like a true numerical simlord
    • model_fit() to compute the model's FC and FCD fit to the dataset, could be usefull for everyone
    • getPowerSpectrum() does what is says
    • getMeanPowerSpectrum() same
    • a very neat rolling_window() from a numpy PR that never got accepted

Other:

  • Data loading:
    • Dataset can load different SC matrix normalizations: "max", "waytotal", "nvoxel"
    • Can precompute FCD matrices to avoid having to do it later (fcd=True)
  • neurolib/utils/atlas.py added with aal2 region names (thanks @jajcayn) and coordinates of centers of regions (from scans of @caglorithm's brain 🤯)
  • ParameterSpace has .lowerBound and .upperBound.
  • pypet finally doesn't create a billion log files anymore due to a custom log config

[1] Plotting the genealogy tree:

import matplotlib.pyplot as plt
import networkx as nx
from networkx.drawing.nx_pydot import graphviz_layout

G = nx.DiGraph(evolution.tree)
G = G.reverse()     # Make the graph top-down
pos = graphviz_layout(G, prog='dot')
plt.figure(figsize=(8, 8))
nx.draw(G, pos, node_size=50, alpha=0.5, node_color=list(evolution.id_score.values()), with_labels=False)
plt.show()

tree

[2] Loading precomputed evolution

evaluateSimulation = lambda x: x # the funciton can be ommited, that's why we define a lambda here
pars = ParameterSpace(['a', 'b'], # should be same as previously saved evolution
                      [[0.0, 4.0], [0.0, 5.0]])
evolution = Evolution(evaluateSimulation, pars, weightList = [1.0])
evolution = evolution.loadEvolution("data/evolution-results-2020-05-15-00H-24M-48S.dill")