MATLAB code for "How one brain substrate generates many ideas. A Geometro-Diffusion Theory model" (E. Estrada).

REQUIREMENTS
  MATLAB R2020b or later, Optimization Toolbox (linprog, intlinprog, lsqcurvefit) and
  Statistics and Machine Learning Toolbox (corr, tiedrank, prctile, signrank, binocdf, pdist).

DATA (not included; public sources, see Data availability in the article). Put the files in the folder data/:
  sc_weighted.npy (or sc_weighted.csv)      Schaefer-100 group-consensus weighted structural connectome of
                                            Hansen et al., 100 x 100 (the .npy file of that study is read directly).
  strucMatrix_with_sctx_schaefer_100.csv    HCP connectome with 14 subcortical regions (ENIGMA toolbox).
  strucMatrix_ctx_glasser_360.csv, strucLabels_ctx_glasser_360.csv
                                            HCP connectome, HCP-MMP1 parcellation (ENIGMA toolbox).
  probability.csv, amplitude.csv, peak_latency.csv, euclidian_distance.csv
                                            F-TRACT atlas v2112, patients older than 15 years, HCP-MMP1 (Zenodo).

USE
  run_all runs every analysis in order; each script can also be run on its own (Supplementary Information
  section in brackets). Random numbers are seeded, but MATLAB and the original computation use different
  random generators, so quantities obtained from random inputs (counts, medians) agree with the article
  statistically, not digit by digit; quantities without random inputs (t*, whole-substrate I_sig^max,
  F-TRACT correlations of the model) agree to numerical precision.

  common/          coupling (diffusion) model derived from the DMF, t*, diffusion distances, I_sig, inputs,
                   effective networks, degree-preserving rewiring, operator learning
  S2_repertoire/   effnet          repertoire, repeated networks, connectivity, saturation        [S2]
                   effnet_isig     geometric richness of every effective network                  [S2]
                   actual_conn     connectivity of the activity at t*                             [S2]
                   norm_check      normalization of the connectome                                [S9]
  S3_origins/      imagine_lp      inputs of another origin, linear program                       [S3]
                   imagine_actual  the same with the activity at t* only                          [S3]
                   imagine_exhaustive  exhaustive search over all crossing times (per-region bound
                                   and mixed-integer program)                                     [S3]
                   shared          shared repertoire of different origins                         [S3]
                   mtl             visual and auditory inputs, substrate with subcortex           [S3]
  S4_reader/       reader_test, reader_geom, reader_relations, reader_rsa   reader of items       [S4]
  S5_states/       states          effective networks along the coupling axis                     [S5]
  S6_reading/      readA, readAB, readID   reading the geometry, learning by repetition,
                                   identification                                                 [S6]
  S7_ftract/       ftract, ftract_cmp, ftract_amplitude, ftract_overlap, ftract_dice
                                   comparison with F-TRACT                                        [S7]
  S8_rivalry/      rivalry, rivalry_same   full dynamic mean-field model with two inputs          [S8]
                   run_queue       serial reader with a weighted queue                            [S8]

  The figures of the article are not drawn by these codes.
  The exhaustive search (S3) and the full DMF simulations (S8) are the long computations (hours).
