nltools 0.6.0.dev2__tar.gz → 0.6.0.dev4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/.gitignore +3 -0
  2. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/PKG-INFO +1 -1
  3. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/alignment/procrustes.py +5 -3
  4. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/signal.py +13 -9
  5. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/designmatrix/regressors.py +4 -1
  6. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/simulator/haxby.py +29 -4
  7. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/models/ridge.py +377 -69
  8. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_algorithms/test_procrustes.py +13 -0
  9. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_algorithms/test_signal.py +9 -1
  10. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/datasets/test_datasets.py +13 -0
  11. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/models/test_ridge.py +360 -0
  12. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/pyproject.toml +4 -4
  13. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/LICENSE +0 -0
  14. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/README.md +0 -0
  15. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/__init__.py +0 -0
  16. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/__init__.py +0 -0
  17. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/alignment/__init__.py +0 -0
  18. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/alignment/srm.py +0 -0
  19. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/backends.py +0 -0
  20. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/corrections.py +0 -0
  21. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/decoding.py +0 -0
  22. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/inference/__init__.py +0 -0
  23. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/inference/bootstrap.py +0 -0
  24. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/inference/correlation.py +0 -0
  25. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/inference/intersubject.py +0 -0
  26. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/inference/isc.py +0 -0
  27. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/inference/matrix.py +0 -0
  28. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/inference/one_sample.py +0 -0
  29. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/inference/random.py +0 -0
  30. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/inference/timeseries.py +0 -0
  31. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/inference/two_sample.py +0 -0
  32. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/inference/utils.py +0 -0
  33. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/inference/validation.py +0 -0
  34. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/neighborhoods.py +0 -0
  35. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/outliers.py +0 -0
  36. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/regression.py +0 -0
  37. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/similarity.py +0 -0
  38. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/algorithms/validation.py +0 -0
  39. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/cross_validation.py +0 -0
  40. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/__init__.py +0 -0
  41. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/adjacency/__init__.py +0 -0
  42. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/adjacency/io.py +0 -0
  43. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/adjacency/modeling.py +0 -0
  44. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/adjacency/plotting.py +0 -0
  45. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/adjacency/state.py +0 -0
  46. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/adjacency/stats.py +0 -0
  47. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/adjacency/utils.py +0 -0
  48. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/atlases/__init__.py +0 -0
  49. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/atlases/labeling.py +0 -0
  50. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/atlases/loading.py +0 -0
  51. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/atlases/registry.py +0 -0
  52. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/atlases/reporting.py +0 -0
  53. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/braindata/__init__.py +0 -0
  54. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/braindata/analysis.py +0 -0
  55. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/braindata/bootstrap.py +0 -0
  56. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/braindata/io.py +0 -0
  57. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/braindata/modeling.py +0 -0
  58. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/braindata/plotting.py +0 -0
  59. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/braindata/prediction.py +0 -0
  60. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/braindata/utils.py +0 -0
  61. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/braindata/validation.py +0 -0
  62. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/braindata/viewer.js +0 -0
  63. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/braindata/viewer.py +0 -0
  64. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/combine.py +0 -0
  65. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/designmatrix/__init__.py +0 -0
  66. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/designmatrix/append.py +0 -0
  67. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/designmatrix/diagnostics.py +0 -0
  68. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/designmatrix/io.py +0 -0
  69. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/designmatrix/plotting.py +0 -0
  70. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/designmatrix/transforms.py +0 -0
  71. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/designmatrix/utils.py +0 -0
  72. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/ownership.py +0 -0
  73. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/results.py +0 -0
  74. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/results_io.py +0 -0
  75. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/roc/__init__.py +0 -0
  76. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/simulator/__init__.py +0 -0
  77. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/data/validation.py +0 -0
  78. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/datasets.py +0 -0
  79. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/io/__init__.py +0 -0
  80. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/io/events.py +0 -0
  81. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/io/h5.py +0 -0
  82. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/mask.py +0 -0
  83. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/models/__init__.py +0 -0
  84. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/models/glm.py +0 -0
  85. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/models/results.py +0 -0
  86. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/models/validation.py +0 -0
  87. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/plotting/__init__.py +0 -0
  88. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/plotting/adjacency.py +0 -0
  89. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/plotting/brain.py +0 -0
  90. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/plotting/decomposition.py +0 -0
  91. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/plotting/prediction.py +0 -0
  92. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/resources/covariates_example.csv +0 -0
  93. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/resources/onsets_example.csv +0 -0
  94. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/templates/__init__.py +0 -0
  95. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/templates/config.py +0 -0
  96. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/templates/fetch.py +0 -0
  97. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/templates/matching.py +0 -0
  98. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/templates/paths.py +0 -0
  99. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/templates/registry.py +0 -0
  100. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/conftest.py +0 -0
  101. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/__init__.py +0 -0
  102. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_algorithms/__init__.py +0 -0
  103. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_algorithms/conftest.py +0 -0
  104. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_algorithms/test_corrections.py +0 -0
  105. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_algorithms/test_decoding.py +0 -0
  106. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_algorithms/test_intersubject.py +0 -0
  107. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_algorithms/test_neighborhoods.py +0 -0
  108. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_algorithms/test_outliers.py +0 -0
  109. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_algorithms/test_regression.py +0 -0
  110. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_algorithms/test_similarity.py +0 -0
  111. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_backends.py +0 -0
  112. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_bootstrap.py +0 -0
  113. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_cross_validation.py +0 -0
  114. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_gpu_policy.py +0 -0
  115. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_hyperalignment.py +0 -0
  116. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_inference/__init__.py +0 -0
  117. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_inference/test_api_conventions.py +0 -0
  118. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_inference/test_correlation.py +0 -0
  119. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_inference/test_cpu_parallelization.py +0 -0
  120. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_inference/test_isc_group.py +0 -0
  121. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_inference/test_isc_vocabulary.py +0 -0
  122. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_inference/test_matrix.py +0 -0
  123. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_inference/test_one_sample.py +0 -0
  124. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_inference/test_progress_bar.py +0 -0
  125. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_inference/test_tail_vocabulary.py +0 -0
  126. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_inference/test_timeseries.py +0 -0
  127. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_inference/test_two_sample.py +0 -0
  128. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_inference/test_utils.py +0 -0
  129. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_isc.py +0 -0
  130. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_mask.py +0 -0
  131. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_srm.py +0 -0
  132. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/core/test_utils.py +0 -0
  133. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/datasets/__init__.py +0 -0
  134. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/io_tests/__init__.py +0 -0
  135. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/io_tests/test_file_reader.py +0 -0
  136. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/io_tests/test_h5.py +0 -0
  137. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/models/__init__.py +0 -0
  138. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/models/conftest.py +0 -0
  139. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/models/test_glm.py +0 -0
  140. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/models/test_glm_warnings.py +0 -0
  141. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/models/test_results.py +0 -0
  142. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/plotting/__init__.py +0 -0
  143. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/plotting/test_adjacency.py +0 -0
  144. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/plotting/test_f123_prediction.py +0 -0
  145. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/plotting/test_surface.py +0 -0
  146. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/pyodide/.gitignore +0 -0
  147. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/pyodide/test_runner.mjs +0 -0
  148. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/support/__init__.py +0 -0
  149. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/support/test_designation.py +0 -0
  150. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/support/test_scripts.py +0 -0
  151. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/templates/__init__.py +0 -0
  152. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/templates/test_brainspace.py +0 -0
  153. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/templates/test_fetch_pyodide.py +0 -0
  154. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/utils/__init__.py +0 -0
  155. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/tests/utils/test_utils.py +0 -0
  156. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/utils.py +0 -0
  157. {nltools-0.6.0.dev2 → nltools-0.6.0.dev4}/nltools/version.py +0 -0
@@ -96,3 +96,6 @@ docs/tutorials/workflows/[0-9]*_*.md
96
96
  # page outputs docs_show replays (pages/). Deliberately not under .cache/, which
97
97
  # is zensical's and which `zensical build -c` wipes whole.
98
98
  /.tutorial-cache/
99
+
100
+ # Local planning artifacts (specs, plans, SDD workspaces)
101
+ .superpowers/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: nltools
3
- Version: 0.6.0.dev2
3
+ Version: 0.6.0.dev4
4
4
  Summary: A Python package to analyze neuroimaging data
5
5
  Project-URL: Homepage, https://nltools.org
6
6
  Author-email: "Luke J. Chang" <luke.j.chang@dartmouth.edu>, Eshin Jolly <eshin.jolly@gmail.com>
@@ -151,8 +151,10 @@ def align(
151
151
  method (str): One of `'probabilistic_srm'`, `'deterministic_srm'`, or
152
152
  `'procrustes'`. Defaults to `'deterministic_srm'`.
153
153
  n_features (int | None): Number of features in the common space (SRM only).
154
- None uses the number of voxels, and may not exceed any subject's
155
- voxel count. Must be None for `'procrustes'`.
154
+ None uses the smallest subject's size along the aligned axis (voxels
155
+ for `axis=0`), the largest value every subject can support; an
156
+ explicit value may not exceed that size for any subject. Must be None
157
+ for `'procrustes'`.
156
158
  axis (int): Axis to align on: 0 aligns timepoints (ISC computed per voxel),
157
159
  1 aligns voxels (ISC computed per timepoint). Defaults to 0.
158
160
  n_iter (int): Number of `_SRM`/`_DetSRM` iterations; ignored by
@@ -235,7 +237,7 @@ def align(
235
237
  out = {}
236
238
  if method in ["deterministic_srm", "probabilistic_srm"]:
237
239
  if n_features is None:
238
- n_features = int(data[0].shape[0])
240
+ n_features = int(min(x.shape[0] for x in data))
239
241
  if method == "deterministic_srm":
240
242
  srm = _DetSRM(
241
243
  n_features=n_features, n_iter=n_iter, random_state=random_state
@@ -214,7 +214,9 @@ def upsample(
214
214
  return upsampled_df
215
215
 
216
216
 
217
- def make_cosine_basis(nsamples, sampling_freq, filter_length, unit_scale=True, drop=0):
217
+ def make_cosine_basis(
218
+ nsamples, sampling_interval, filter_length, unit_scale=True, drop=0
219
+ ):
218
220
  """Create basis functions for a discrete cosine transform.
219
221
 
220
222
  Based on the implementation in ``spm_filter`` and ``spm_dctmtx`` because
@@ -224,11 +226,12 @@ def make_cosine_basis(nsamples, sampling_freq, filter_length, unit_scale=True, d
224
226
 
225
227
  Args:
226
228
  nsamples (int): Number of observations (e.g. TRs).
227
- sampling_freq (float): Sampling *interval* in seconds (the TR), matching
228
- SPM's `RT` — not a frequency, despite the name. The number of bases
229
- is `trunc(2 * nsamples * sampling_freq / filter_length + 1)`, minus
230
- the constant. `DesignMatrix.add_dct_basis` passes
231
- `1 / DesignMatrix.sampling_freq` for this reason.
229
+ sampling_interval (float): Seconds between observations (the TR), SPM's
230
+ `RT`. The number of bases is
231
+ `trunc(2 * nsamples * sampling_interval / filter_length + 1)`, minus
232
+ the constant. `DesignMatrix` stores a sampling frequency, so
233
+ `DesignMatrix.add_dct_basis` inverts it and passes
234
+ `1 / DesignMatrix.sampling_freq`.
232
235
  filter_length (int): Filter length in seconds.
233
236
  unit_scale (bool): Scale the basis functions to the range [-1, 1]. Defaults to True.
234
237
  drop (int): Number of leading (slowest) bases to drop after the constant is
@@ -239,12 +242,13 @@ def make_cosine_basis(nsamples, sampling_freq, filter_length, unit_scale=True, d
239
242
  np.ndarray: Basis matrix of shape (nsamples, n_bases).
240
243
 
241
244
  Note:
242
- The basis count follows `spm_dctmtx`'s `k = fix(2*(n*RT)/HParam + 1)`, so
243
- 100 TRs of 2 s with a 128 s filter give the same four bases SPM gives.
245
+ The basis count follows `spm_dctmtx`'s `k = fix(2*(n*RT)/HParam + 1)` less
246
+ the constant that `spm_filter` drops, so 100 TRs of 2 s under a 128 s
247
+ filter give three bases, the same three SPM uses.
244
248
  """
245
249
 
246
250
  # Figure out number of basis functions to create
247
- order = int(np.trunc(2 * (nsamples * sampling_freq) / filter_length + 1))
251
+ order = int(np.trunc(2 * (nsamples * sampling_interval) / filter_length + 1))
248
252
 
249
253
  n = np.arange(nsamples)
250
254
 
@@ -427,7 +427,10 @@ def _add_dct_basis(
427
427
 
428
428
  # Create DCT basis matrix using stats function
429
429
  basis_mat = make_cosine_basis(
430
- dm.shape[0], 1.0 / dm.sampling_freq, duration, drop=drop
430
+ dm.shape[0],
431
+ sampling_interval=1.0 / dm.sampling_freq,
432
+ filter_length=duration,
433
+ drop=drop,
431
434
  )
432
435
 
433
436
  # Generate column names (.nl_cosine_1, .nl_cosine_2, ...)
@@ -186,7 +186,9 @@ def _simulate_run(dm, rois, n_voxels, rng):
186
186
  return data
187
187
 
188
188
 
189
- def load_haxby_example(n_runs=1, *, space="mni", random_state=42):
189
+ def load_haxby_example(
190
+ n_runs=1, *, space="mni", block_order="independent", random_state=42
191
+ ):
190
192
  """Load a synthetic Haxby-like dataset on the MNI grid, entirely in-memory.
191
193
 
192
194
  The quickest way to try nltools: nothing is downloaded beyond the MNI
@@ -204,7 +206,10 @@ def load_haxby_example(n_runs=1, *, space="mni", random_state=42):
204
206
  fusiform cortex, and scrambled pictures in early visual cortex — with a 3%
205
207
  peak response against 1% white noise. A condition also drives its
206
208
  category-mates' spheres at a third of that, so the eight response patterns
207
- carry an animate / man-made / scene / control similarity structure.
209
+ carry an animate / man-made / scene / control similarity structure. Each run
210
+ draws its own block order by default; pass `block_order='shared'` when the
211
+ runs have to line up TR by TR, as they do for intersubject correlation,
212
+ alignment and anything else that compares runs timepoint against timepoint.
208
213
 
209
214
  Args:
210
215
  n_runs (int): Number of runs to generate. Default 1.
@@ -213,6 +218,10 @@ def load_haxby_example(n_runs=1, *, space="mni", random_state=42):
213
218
  `extract_roi` work on the result. `'grid'` is a 10 x 10 x 5
214
219
  synthetic volume with random condition clusters, for tests that need
215
220
  construction in milliseconds and never plot.
221
+ block_order (str): How the condition order varies across runs.
222
+ `'independent'` (default) draws a fresh order per run; `'shared'`
223
+ draws one order and gives it to every run, so the runs are
224
+ comparable TR by TR. Noise differs per run either way.
216
225
  random_state (int | None): Seed for reproducible output. Default 42.
217
226
 
218
227
  Returns:
@@ -223,7 +232,8 @@ def load_haxby_example(n_runs=1, *, space="mni", random_state=42):
223
232
  `_c0` (HRF-convolved boxcars).
224
233
 
225
234
  Raises:
226
- ValueError: If `space` is not `'mni'` or `'grid'`.
235
+ ValueError: If `space` is not `'mni'` or `'grid'`, or `block_order` is not
236
+ `'independent'` or `'shared'`.
227
237
 
228
238
  Examples:
229
239
  ```python
@@ -258,16 +268,31 @@ def load_haxby_example(n_runs=1, *, space="mni", random_state=42):
258
268
 
259
269
  if space not in ("mni", "grid"):
260
270
  raise ValueError(f"space must be 'mni' or 'grid', got {space!r}")
271
+ if block_order not in ("independent", "shared"):
272
+ raise ValueError(
273
+ f"block_order must be 'independent' or 'shared', got {block_order!r}"
274
+ )
261
275
 
262
276
  rng = np.random.default_rng(random_state)
263
277
  mask_img = _mask_image(space)
264
278
  n_voxels = int((np.asarray(mask_img.dataobj) > 0).sum())
265
279
  rois = _condition_rois(space, mask_img, rng)
266
280
 
281
+ # Drawn once so every run gets the same sequence; 'independent' draws inside
282
+ # the loop instead, leaving the default run's RNG stream untouched.
283
+ shared_order = (
284
+ list(rng.permutation(_HAXBY_CONDITIONS)) if block_order == "shared" else None
285
+ )
286
+
267
287
  brain_data_list = []
268
288
  design_matrix_list = []
269
289
  for run in range(n_runs):
270
- dm, labels = _run_design(list(rng.permutation(_HAXBY_CONDITIONS)))
290
+ order = (
291
+ shared_order
292
+ if shared_order is not None
293
+ else list(rng.permutation(_HAXBY_CONDITIONS))
294
+ )
295
+ dm, labels = _run_design(order)
271
296
  data = _simulate_run(dm, rois, n_voxels, rng)
272
297
  labels_and_run = pl.DataFrame(
273
298
  {