@brainpilot/skills 0.0.6

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 (229) hide show
  1. package/dist/index.d.ts +6 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +28 -0
  4. package/dist/index.js.map +1 -0
  5. package/package.json +35 -0
  6. package/skills/01_Meta-Skills/contribute-skill/SKILL.md +277 -0
  7. package/skills/01_Meta-Skills/contribute-skills-via-pr/SKILL.md +163 -0
  8. package/skills/01_Meta-Skills/paper-to-skill/SKILL.md +435 -0
  9. package/skills/01_Meta-Skills/paper-to-skill/references/extraction-guide.md +286 -0
  10. package/skills/01_Meta-Skills/paper-to-skill/references/skill-template.md +250 -0
  11. package/skills/01_Meta-Skills/repo-to-skill/SKILL.md +289 -0
  12. package/skills/01_Meta-Skills/share-case/SKILL.md +253 -0
  13. package/skills/01_Meta-Skills/share-usage/README.md +63 -0
  14. package/skills/01_Meta-Skills/share-usage/SKILL.md +395 -0
  15. package/skills/01_Meta-Skills/verify-skill/SKILL.md +331 -0
  16. package/skills/02_Cross-Domain_Foundation/cogsci-power-analysis/SKILL.md +194 -0
  17. package/skills/02_Cross-Domain_Foundation/cogsci-power-analysis/references/effect-sizes.md +352 -0
  18. package/skills/02_Cross-Domain_Foundation/cogsci-power-analysis/references/sample-size-guide.md +407 -0
  19. package/skills/02_Cross-Domain_Foundation/cogsci-statistics/SKILL.md +361 -0
  20. package/skills/02_Cross-Domain_Foundation/cogsci-statistics/references/common-analyses.md +517 -0
  21. package/skills/02_Cross-Domain_Foundation/cogsci-visualization/SKILL.md +292 -0
  22. package/skills/02_Cross-Domain_Foundation/cogsci-visualization/references/plot-recipes.md +709 -0
  23. package/skills/02_Cross-Domain_Foundation/research-literacy/SKILL.md +286 -0
  24. package/skills/02_Cross-Domain_Foundation/research-literacy/references/common-assumptions.md +320 -0
  25. package/skills/02_Cross-Domain_Foundation/research-literacy/references/planning-template.md +143 -0
  26. package/skills/03_Cognitive_Psychology/alternative-uses-task-designer/SKILL.md +197 -0
  27. package/skills/03_Cognitive_Psychology/alternative-uses-task-designer/references/instruction-templates.md +60 -0
  28. package/skills/03_Cognitive_Psychology/cognitive-paradigm-design/SKILL.md +246 -0
  29. package/skills/03_Cognitive_Psychology/cognitive-paradigm-design/references/classic-paradigms.md +435 -0
  30. package/skills/03_Cognitive_Psychology/cognitive-paradigm-design/references/design-principles.md +256 -0
  31. package/skills/03_Cognitive_Psychology/creativity-self-efficacy-mediation/SKILL.md +270 -0
  32. package/skills/03_Cognitive_Psychology/creativity-self-efficacy-mediation/references/lavaan-templates.md +172 -0
  33. package/skills/03_Cognitive_Psychology/divergent-thinking-scoring/SKILL.md +238 -0
  34. package/skills/03_Cognitive_Psychology/divergent-thinking-scoring/references/scoring-rubric.md +143 -0
  35. package/skills/03_Cognitive_Psychology/drift-diffusion-model/SKILL.md +203 -0
  36. package/skills/03_Cognitive_Psychology/drift-diffusion-model/references/fitting-guide.md +571 -0
  37. package/skills/03_Cognitive_Psychology/drift-diffusion-model/references/model-variants.md +427 -0
  38. package/skills/03_Cognitive_Psychology/evidence-accumulation-selector/SKILL.md +310 -0
  39. package/skills/03_Cognitive_Psychology/evidence-accumulation-selector/references/ez-diffusion-formulas.md +137 -0
  40. package/skills/03_Cognitive_Psychology/signal-detection-analysis/SKILL.md +300 -0
  41. package/skills/03_Cognitive_Psychology/signal-detection-analysis/references/application-guide.md +278 -0
  42. package/skills/03_Cognitive_Psychology/signal-detection-analysis/references/sdt-formulas.md +318 -0
  43. package/skills/03_Cognitive_Psychology/visual-search-array-generator/SKILL.md +283 -0
  44. package/skills/03_Cognitive_Psychology/visual-search-array-generator/references/array-generation-parameters.yaml +111 -0
  45. package/skills/04_Psycholinguistics/reading-time-analysis/SKILL.md +301 -0
  46. package/skills/04_Psycholinguistics/reading-time-analysis/references/measure-computation-guide.md +195 -0
  47. package/skills/04_Psycholinguistics/self-paced-reading-designer/SKILL.md +257 -0
  48. package/skills/04_Psycholinguistics/self-paced-reading-designer/references/analysis-guide.md +356 -0
  49. package/skills/04_Psycholinguistics/self-paced-reading-designer/references/region-segmentation.md +266 -0
  50. package/skills/04_Psycholinguistics/sentence-stimulus-norming/SKILL.md +346 -0
  51. package/skills/04_Psycholinguistics/sentence-stimulus-norming/references/lexical-databases-guide.md +184 -0
  52. package/skills/05_EEG_ERP/eeg-paradigm-designer/SKILL.md +226 -0
  53. package/skills/05_EEG_ERP/eeg-paradigm-designer/references/component-paradigm-map.md +276 -0
  54. package/skills/05_EEG_ERP/eeg-paradigm-designer/references/timing-parameters.md +244 -0
  55. package/skills/05_EEG_ERP/eeg-preprocessing-pipeline-guide/SKILL.md +367 -0
  56. package/skills/05_EEG_ERP/eeg-preprocessing-pipeline-guide/references/parameter-lookup-tables.md +138 -0
  57. package/skills/05_EEG_ERP/erp-analysis/SKILL.md +185 -0
  58. package/skills/05_EEG_ERP/erp-analysis/references/erp-components.md +447 -0
  59. package/skills/05_EEG_ERP/erp-analysis/references/preprocessing-pipeline.md +277 -0
  60. package/skills/05_EEG_ERP/erp-analysis/references/statistical-approaches.md +351 -0
  61. package/skills/05_EEG_ERP/mne-python-guide/SKILL.md +174 -0
  62. package/skills/05_EEG_ERP/mne-python-guide/references/decoding.md +178 -0
  63. package/skills/05_EEG_ERP/mne-python-guide/references/io_formats.md +160 -0
  64. package/skills/05_EEG_ERP/mne-python-guide/references/preprocessing.md +259 -0
  65. package/skills/05_EEG_ERP/mne-python-guide/references/simulation.md +173 -0
  66. package/skills/05_EEG_ERP/mne-python-guide/references/source_localization.md +234 -0
  67. package/skills/05_EEG_ERP/mne-python-guide/references/statistics.md +196 -0
  68. package/skills/05_EEG_ERP/mne-python-guide/references/time_frequency.md +165 -0
  69. package/skills/05_EEG_ERP/mne-python-guide/references/visualization.md +175 -0
  70. package/skills/06_fMRI_Neuroimaging/brain-connectivity-modeler/SKILL.md +317 -0
  71. package/skills/06_fMRI_Neuroimaging/brain-connectivity-modeler/references/method-implementation-guide.md +116 -0
  72. package/skills/06_fMRI_Neuroimaging/fmri-glm-analysis-guide/SKILL.md +296 -0
  73. package/skills/06_fMRI_Neuroimaging/fmri-glm-analysis-guide/references/design-matrix-guide.md +214 -0
  74. package/skills/06_fMRI_Neuroimaging/fmri-glm-analysis-guide/references/statistical-inference.md +288 -0
  75. package/skills/06_fMRI_Neuroimaging/fmri-preprocessing-pipeline-guide/SKILL.md +274 -0
  76. package/skills/06_fMRI_Neuroimaging/fmri-preprocessing-pipeline-guide/references/quality-control.md +336 -0
  77. package/skills/06_fMRI_Neuroimaging/fmri-preprocessing-pipeline-guide/references/step-by-step-pipeline.md +380 -0
  78. package/skills/06_fMRI_Neuroimaging/fmri-task-design-guide/SKILL.md +264 -0
  79. package/skills/06_fMRI_Neuroimaging/fmri-task-design-guide/references/design-optimization-examples.md +114 -0
  80. package/skills/06_fMRI_Neuroimaging/neural-decoding-analysis/SKILL.md +273 -0
  81. package/skills/06_fMRI_Neuroimaging/neural-decoding-analysis/references/decoding-methods.md +170 -0
  82. package/skills/06_fMRI_Neuroimaging/neural-decoding-analysis/references/rsa-guide.md +266 -0
  83. package/skills/06_fMRI_Neuroimaging/pycortex-guide/SKILL.md +123 -0
  84. package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/database-subjects.md +179 -0
  85. package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/dataset-types.md +208 -0
  86. package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/freesurfer-fmriprep.md +162 -0
  87. package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/mapping-transforms.md +181 -0
  88. package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/mni-utils.md +207 -0
  89. package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/surface-analysis.md +219 -0
  90. package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/visualization.md +251 -0
  91. package/skills/07_Computational_Modeling/act-r-model-builder/SKILL.md +297 -0
  92. package/skills/07_Computational_Modeling/act-r-model-builder/references/model-patterns.md +197 -0
  93. package/skills/07_Computational_Modeling/act-r-model-builder/references/parameter-table.yaml +204 -0
  94. package/skills/07_Computational_Modeling/bayesian-cognitive-model-builder/SKILL.md +294 -0
  95. package/skills/07_Computational_Modeling/bayesian-cognitive-model-builder/references/diagnostics-checklist.md +351 -0
  96. package/skills/07_Computational_Modeling/bayesian-cognitive-model-builder/references/prior-selection-guide.md +241 -0
  97. package/skills/07_Computational_Modeling/parameter-recovery-checker/SKILL.md +269 -0
  98. package/skills/07_Computational_Modeling/parameter-recovery-checker/references/recovery-diagnostics.md +207 -0
  99. package/skills/08_Computational_Neuroscience/brain-connectivity-modeler/SKILL.md +317 -0
  100. package/skills/08_Computational_Neuroscience/brain-connectivity-modeler/references/method-implementation-guide.md +116 -0
  101. package/skills/08_Computational_Neuroscience/neural-decoding-analysis/SKILL.md +273 -0
  102. package/skills/08_Computational_Neuroscience/neural-decoding-analysis/references/decoding-methods.md +170 -0
  103. package/skills/08_Computational_Neuroscience/neural-decoding-analysis/references/rsa-guide.md +266 -0
  104. package/skills/08_Computational_Neuroscience/neural-population-analysis-guide/SKILL.md +305 -0
  105. package/skills/08_Computational_Neuroscience/neural-population-analysis-guide/references/data-requirements.md +60 -0
  106. package/skills/08_Computational_Neuroscience/neural-population-analysis-guide/references/method-comparison.md +151 -0
  107. package/skills/08_Computational_Neuroscience/spiking-network-model-builder/SKILL.md +376 -0
  108. package/skills/08_Computational_Neuroscience/spiking-network-model-builder/references/hh-parameters.md +117 -0
  109. package/skills/08_Computational_Neuroscience/spiking-network-model-builder/references/network-regimes.md +130 -0
  110. package/skills/09_Cellular_Molecular_Neuroscience/calcium-imaging-analysis-guide/SKILL.md +258 -0
  111. package/skills/09_Cellular_Molecular_Neuroscience/calcium-imaging-analysis-guide/references/indicator-parameters.md +242 -0
  112. package/skills/09_Cellular_Molecular_Neuroscience/calcium-imaging-analysis-guide/references/pipeline-details.md +211 -0
  113. package/skills/09_Cellular_Molecular_Neuroscience/optogenetics-protocol-designer/SKILL.md +261 -0
  114. package/skills/09_Cellular_Molecular_Neuroscience/optogenetics-protocol-designer/references/opsin-catalog.md +124 -0
  115. package/skills/09_Cellular_Molecular_Neuroscience/optogenetics-protocol-designer/references/stimulation-parameters.md +304 -0
  116. package/skills/10_Clinical_Neuropsychology/lesion-symptom-mapping-guide/SKILL.md +367 -0
  117. package/skills/10_Clinical_Neuropsychology/lesion-symptom-mapping-guide/references/disconnection-guide.md +152 -0
  118. package/skills/10_Clinical_Neuropsychology/lesion-symptom-mapping-guide/references/vlsm-pipeline.md +182 -0
  119. package/skills/10_Clinical_Neuropsychology/neuropsych-battery-selector/SKILL.md +250 -0
  120. package/skills/10_Clinical_Neuropsychology/neuropsych-battery-selector/references/deficit-profiles.md +302 -0
  121. package/skills/10_Clinical_Neuropsychology/neuropsych-battery-selector/references/test-catalog.md +304 -0
  122. package/skills/11_Developmental_Cognition/infant-looking-time-designer/SKILL.md +345 -0
  123. package/skills/11_Developmental_Cognition/infant-looking-time-designer/references/age-parameters.yaml +186 -0
  124. package/skills/12_Social_Cognition/tom-task-selector/SKILL.md +379 -0
  125. package/skills/12_Social_Cognition/tom-task-selector/references/task-database.md +317 -0
  126. package/skills/13_Visualization/nature-figure/README.md +442 -0
  127. package/skills/13_Visualization/nature-figure/SKILL.md +60 -0
  128. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-01-bar-charts.png +0 -0
  129. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-02-line-trends.png +0 -0
  130. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-03-heatmaps.png +0 -0
  131. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-04-scatter-bubble.png +0 -0
  132. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-05-radar-polar.png +0 -0
  133. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-06-distributions.png +0 -0
  134. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-07-forest-interval.png +0 -0
  135. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-08-area-stacked.png +0 -0
  136. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-09-image-plates.png +0 -0
  137. package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-10-network-matrix.png +0 -0
  138. package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/Dispersion_motivation.png +0 -0
  139. package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/Dispersion_observation.png +0 -0
  140. package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/Dispersion_observation_distillation.png +0 -0
  141. package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/ImmunoStruct_contrastive.png +0 -0
  142. package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/ImmunoStruct_results_CEDAR.png +0 -0
  143. package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/ImmunoStruct_results_IEDB.png +0 -0
  144. package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/ImmunoStruct_schematic.png +0 -0
  145. package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/RNAGenScape_schematic.png +0 -0
  146. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_CellSpliceNet/figures/ablation.png +0 -0
  147. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_CellSpliceNet/figures/comparison.png +0 -0
  148. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_CellSpliceNet/plot_ablation.py +86 -0
  149. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_CellSpliceNet/plot_comparison.py +109 -0
  150. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/diffusion_swiss_roll.py +97 -0
  151. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/diffusion_swiss_roll.png +0 -0
  152. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/fig2_comparison_GeneRegulatory.pdf +0 -0
  153. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/fig2_comparison_GeneRegulatory.png +0 -0
  154. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/fig2_comparison_Trajectory.pdf +0 -0
  155. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/fig2_comparison_Trajectory.png +0 -0
  156. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/figX_comparison_Ablation.pdf +0 -0
  157. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/figX_comparison_Ablation.png +0 -0
  158. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/plot_comparison_Ablation.py +64 -0
  159. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/plot_comparison_GeneRegulatory.py +74 -0
  160. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/plot_comparison_Trajectory.py +74 -0
  161. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Dispersion/figures/idea.png +0 -0
  162. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Dispersion/figures/illustration.png +0 -0
  163. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Dispersion/plot_idea.py +76 -0
  164. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Dispersion/plot_illustration.py +404 -0
  165. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_FPGM/figures/freq_prior.png +0 -0
  166. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_FPGM/plot_freq_prior.py +146 -0
  167. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/figures/bars_ablation_Cancer.png +0 -0
  168. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/figures/bars_ablation_IEDB.png +0 -0
  169. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/figures/bars_comparison_Cancer.png +0 -0
  170. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/figures/bars_comparison_IEDB.png +0 -0
  171. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/plot_bars.py +216 -0
  172. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/raw_data.py +125 -0
  173. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/manifold.png +0 -0
  174. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/manifold_holes.png +0 -0
  175. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/results_comparison_optimization.png +0 -0
  176. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/results_comparison_speed.png +0 -0
  177. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/results_sweep.png +0 -0
  178. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/plot_comparison.py +228 -0
  179. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/plot_hole_manifold.py +82 -0
  180. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/plot_manifold.py +61 -0
  181. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/plot_sweep.py +77 -0
  182. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_VIGIL/figures/comparison_posttraining.png +0 -0
  183. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_VIGIL/figures/comparison_radar.png +0 -0
  184. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_VIGIL/plot_comparison_radar.py +173 -0
  185. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_VIGIL/plot_posttraining.py +82 -0
  186. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/brute_force.png +0 -0
  187. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/correctness_by_category.png +0 -0
  188. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/correctness_by_subcategory.png +0 -0
  189. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/rewriting.png +0 -0
  190. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/selfcorrection_math.png +0 -0
  191. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_brute_force.py +248 -0
  192. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_correctness_by_category.py +132 -0
  193. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_correctness_by_subcategory.py +131 -0
  194. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_rewriting.py +105 -0
  195. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_selfcorrection_math.py +99 -0
  196. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ophthal_review/figures/composition_heatmap.png +0 -0
  197. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ophthal_review/figures/trend_by_month.png +0 -0
  198. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ophthal_review/plot_composition.py +81 -0
  199. package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ophthal_review/plot_trend.py +125 -0
  200. package/skills/13_Visualization/nature-figure/assets/gallery/fig1-material-mechanism-rich.png +0 -0
  201. package/skills/13_Visualization/nature-figure/assets/gallery/fig2-spatial-imaging-rich.png +0 -0
  202. package/skills/13_Visualization/nature-figure/assets/gallery/fig3-in-vivo-efficacy-rich.png +0 -0
  203. package/skills/13_Visualization/nature-figure/assets/gallery/fig4-single-cell-systems-rich.png +0 -0
  204. package/skills/13_Visualization/nature-figure/assets/gallery/fig5-validation-perturbation-rich.png +0 -0
  205. package/skills/13_Visualization/nature-figure/evals/evals.json +37 -0
  206. package/skills/13_Visualization/nature-figure/manifest.yaml +57 -0
  207. package/skills/13_Visualization/nature-figure/references/api.md +428 -0
  208. package/skills/13_Visualization/nature-figure/references/backend-selection.md +100 -0
  209. package/skills/13_Visualization/nature-figure/references/chart-types.md +281 -0
  210. package/skills/13_Visualization/nature-figure/references/common-patterns.md +350 -0
  211. package/skills/13_Visualization/nature-figure/references/demos.md +65 -0
  212. package/skills/13_Visualization/nature-figure/references/design-theory.md +436 -0
  213. package/skills/13_Visualization/nature-figure/references/figure-contract.md +93 -0
  214. package/skills/13_Visualization/nature-figure/references/nature-2026-observations.md +112 -0
  215. package/skills/13_Visualization/nature-figure/references/qa-contract.md +119 -0
  216. package/skills/13_Visualization/nature-figure/references/r-template-index.md +66 -0
  217. package/skills/13_Visualization/nature-figure/references/r-workflow.md +161 -0
  218. package/skills/13_Visualization/nature-figure/references/tutorials.md +251 -0
  219. package/skills/13_Visualization/nature-figure/static/core/contract.md +29 -0
  220. package/skills/13_Visualization/nature-figure/static/core/stance.md +37 -0
  221. package/skills/13_Visualization/nature-figure/static/fragments/backend/python.md +37 -0
  222. package/skills/13_Visualization/nature-figure/static/fragments/backend/r.md +44 -0
  223. package/skills/14_Writing/markdown-report-writing/SKILL.md +306 -0
  224. package/skills/14_Writing/markdown-report-writing/references/compatibility-matrix.md +72 -0
  225. package/skills/14_Writing/markdown-report-writing/references/templates.md +299 -0
  226. package/skills/15_Others/neuroimaging-power-guide/SKILL.md +324 -0
  227. package/skills/15_Others/neuroimaging-power-guide/references/effect-size-lookup-tables.md +102 -0
  228. package/skills/15_Others/neuroimaging-sample-size-calculator/SKILL.md +330 -0
  229. package/skills/15_Others/neuroimaging-sample-size-calculator/references/worked-examples.md +220 -0
@@ -0,0 +1,296 @@
1
+ ---
2
+ name: "fmri-glm-analysis-guide"
3
+ description: "Domain-validated guidance for fMRI General Linear Model specification: HRF modeling, design matrix construction, contrast definition, confound regression, and statistical inference"
4
+ domain: "cognitive-neuroscience"
5
+ version: "1.0.0"
6
+ authors:
7
+ - "awesome_cognitive_and_neuroscience_skills contributors"
8
+ papers:
9
+ - "Poldrack, Mumford, & Nichols, 2011"
10
+ - "Poline & Brett, 2012"
11
+ - "Lindquist, 2008"
12
+ - "Eklund, Nichols, & Knutsson, 2016"
13
+ - "Friston et al., 1996"
14
+ dependencies:
15
+ required:
16
+ - research-literacy
17
+ review_status: "ai-generated"
18
+ ---
19
+
20
+ # fMRI GLM Analysis Guide
21
+
22
+ ## Purpose
23
+
24
+ The General Linear Model (GLM) is the standard statistical framework for task-based fMRI analysis. It models the observed BOLD time series as a linear combination of expected signal components (task regressors convolved with the hemodynamic response function) plus confound regressors plus noise (Poline & Brett, 2012; Poldrack et al., 2011, Ch. 4).
25
+
26
+ This skill encodes the domain-specific judgment needed to correctly specify a GLM for fMRI data. A competent programmer without neuroimaging training would get many of these decisions wrong -- choosing the wrong HRF model, setting an inappropriate high-pass filter cutoff, omitting critical confound regressors, or applying invalid statistical thresholds. Each decision described here requires understanding the biophysics of BOLD signal, the noise characteristics of fMRI data, and the statistical assumptions of the model.
27
+
28
+ ## When to Use This Skill
29
+
30
+ - Specifying a first-level (single-subject) GLM for task fMRI
31
+ - Choosing HRF models, confound regressors, and temporal filtering parameters
32
+ - Defining contrasts to test experimental hypotheses
33
+ - Setting up second-level (group) analyses
34
+ - Selecting appropriate multiple comparison correction methods
35
+ - Reviewing or troubleshooting an existing fMRI analysis pipeline
36
+
37
+ ## Research Planning Protocol
38
+
39
+ Before executing the domain-specific steps below, you MUST:
40
+
41
+ 1. **State the research question** — What specific brain-behavior hypothesis is this GLM testing?
42
+ 2. **Justify the method choice** — Why task fMRI with GLM? What alternatives (resting-state, EEG, behavior-only) were considered?
43
+ 3. **Declare expected outcomes** — Which regions/contrasts do you expect to show effects, and in what direction?
44
+ 4. **Note assumptions and limitations** — What does the GLM assume? Where could it mislead?
45
+ 5. **Present the plan to the user and WAIT for confirmation** before proceeding.
46
+
47
+ For detailed methodology guidance, see the `research-literacy` skill.
48
+
49
+
50
+ ## ⚠️ Verification Notice
51
+
52
+ This skill was generated by AI from academic literature. All parameters, thresholds, and citations require independent verification before use in research. If you find errors, please [open an issue](https://github.com/HaoxuanLiTHUAI/awesome_cognitive_and_neuroscience_skills/issues).
53
+
54
+ ## First-Level Analysis Decision Tree
55
+
56
+ ### Step 1: HRF Model Selection
57
+
58
+ The hemodynamic response function (HRF) models the neurovascular coupling delay between neural activity and the measured BOLD signal. The canonical HRF peaks at approximately **5-6 seconds** post-stimulus (Glover, 1999).
59
+
60
+ | HRF Model | When to Use | Trade-off |
61
+ |---|---|---|
62
+ | Canonical (double-gamma) | Default for most task designs when timing is well-established | Assumes fixed HRF shape; highest statistical power (1 parameter per condition) (Lindquist et al., 2009) |
63
+ | Canonical + temporal derivative | When peak latency may vary by ~1 s across conditions or regions | Captures timing shifts; 2 parameters per condition (Friston et al., 1998; Henson et al., 2002) |
64
+ | Canonical + temporal + dispersion derivatives | When both latency and width of HRF may vary | Maximum flexibility with basis functions; 3 parameters per condition, reduced power (Henson et al., 2002) |
65
+ | Finite Impulse Response (FIR) | When HRF shape is unknown or expected to deviate substantially from canonical form | No shape assumption; many parameters (one per time bin); requires many trials for stable estimation (Glover, 1999; Dale, 1999) |
66
+
67
+ **Decision logic:**
68
+
69
+ ```
70
+ Is the HRF shape well-established for your task and population?
71
+ |
72
+ +-- YES --> Is timing precision critical to your hypothesis?
73
+ | |
74
+ | +-- YES --> Canonical + temporal derivative
75
+ | |
76
+ | +-- NO --> Canonical HRF (default)
77
+ |
78
+ +-- NO --> Do you have enough trials (>40 per condition) for stable estimation?
79
+ |
80
+ +-- YES --> FIR model (exploratory) or canonical + derivatives
81
+ |
82
+ +-- NO --> Canonical + temporal derivative (safest compromise)
83
+ ```
84
+
85
+ **Domain warning**: When using derivative basis functions, the contrast for the main condition should weight only the canonical regressor (not the derivatives). An F-test across all basis functions tests whether any component differs from zero (Calhoun et al., 2004). See `references/design-matrix-guide.md` for details.
86
+
87
+ ### Step 2: High-Pass Filter Cutoff
88
+
89
+ Low-frequency drifts from scanner instability, subject physiology, and slow head motion must be removed. This is implemented as a discrete cosine transform (DCT) basis set added to the design matrix (Poldrack et al., 2011, Ch. 5).
90
+
91
+ - **Default cutoff period**: **128 seconds** (0.0078 Hz) -- the SPM default, appropriate for most event-related and block designs (Poldrack et al., 2011, Ch. 5)
92
+ - **Rule**: The cutoff period must be at least **2x the longest interval** between events of the same condition type (Poldrack et al., 2011, Ch. 5)
93
+ - **Block designs**: For a block design with 30-second blocks alternating between two conditions, the full cycle is 60 seconds. A 128-second cutoff safely preserves this signal
94
+ - **Slow event-related designs**: If trials of the same condition occur every 90 seconds, a 128-second cutoff is too aggressive. Use at least **180 seconds** (2 x 90)
95
+
96
+ **Domain warning**: Setting the cutoff too low (long period) leaves drift in the data, inflating noise. Setting it too high (short period) attenuates your experimental signal. Always verify that your design's fundamental frequency is preserved by the filter.
97
+
98
+ ### Step 3: Confound Regression
99
+
100
+ Confound regressors model variance from non-neural sources. Omitting them inflates false positive rates; including too many reduces statistical power.
101
+
102
+ #### Motion Parameters
103
+
104
+ Head motion is the single largest source of structured artifact in fMRI (Power et al., 2012).
105
+
106
+ | Model | Parameters | When to Use | Source |
107
+ |---|---|---|---|
108
+ | Standard 6-parameter | 3 translation + 3 rotation | Minimum acceptable model | Friston et al., 1996 |
109
+ | 24-parameter (Friston) | 6 current + 6 prior timepoint + 12 squared terms | Recommended default for task fMRI | Friston et al., 1996 |
110
+ | 6-parameter + derivatives | 6 current + 6 temporal derivatives | Intermediate model | Satterthwaite et al., 2013 |
111
+
112
+ **Domain insight**: The 24-parameter model (Friston et al., 1996) captures both linear and nonlinear motion effects, including spin-history artifacts from previous-timepoint head positions. The squared terms model the nonlinear relationship between motion and BOLD signal changes.
113
+
114
+ #### Framewise Displacement and Spike Regressors
115
+
116
+ - Calculate framewise displacement (FD) as the sum of absolute values of the six motion derivatives, with rotations converted to mm on a 50-mm radius sphere (Power et al., 2012)
117
+ - Flag volumes with FD > **0.5 mm** as motion spikes (Power et al., 2012); for more stringent control, use FD > **0.2 mm** (Power et al., 2014)
118
+ - Model each spike as a separate indicator regressor (one column per flagged volume). This is mathematically equivalent to censoring/scrubbing but preserves the temporal structure of the design matrix
119
+
120
+ #### Physiological Noise: CompCor
121
+
122
+ When physiological recordings (pulse, respiration) are unavailable:
123
+
124
+ - **aCompCor** (anatomical CompCor): Extract top **5-6 principal components** from white matter and CSF masks (Behzadi et al., 2007; Muschelli et al., 2014)
125
+ - **tCompCor** (temporal CompCor): Extract components from high-temporal-variance voxels (Behzadi et al., 2007)
126
+ - aCompCor is generally preferred because it uses anatomically defined noise ROIs and is less susceptible to removing neural signal (Ciric et al., 2017)
127
+
128
+ **Domain warning -- global signal regression**: Regressing out the global mean signal is controversial. It improves motion artifact removal but introduces artifactual anticorrelations in functional connectivity analyses (Murphy & Fox, 2017). For task-based GLM, global signal regression is generally not recommended unless specifically justified.
129
+
130
+ ### Step 4: Serial Autocorrelation Correction
131
+
132
+ fMRI time series exhibit temporal autocorrelation due to hemodynamic smoothing and physiological noise. Ignoring this inflates t-statistics and false positive rates (Woolrich et al., 2001).
133
+
134
+ | Method | Implementation | Software |
135
+ |---|---|---|
136
+ | AR(1) prewhitening | Models autocorrelation as first-order autoregressive process | SPM (default), Nilearn |
137
+ | ARMA(1,1) | Autoregressive moving-average; more flexible | AFNI (3dREMLfit) |
138
+ | Tukey taper prewhitening | Nonparametric spectral smoothing of autocorrelation | FSL FILM (Woolrich et al., 2001) |
139
+
140
+ **Domain insight**: Recent work has shown that AR(1) may be insufficient for modern multiband acquisitions with short TRs (< 1 s), where higher-order autocorrelation structure is present (Olszowy et al., 2019). For short-TR data, consider ARMA(1,1) or FSL's FILM approach.
141
+
142
+ ### Step 5: Construct and Verify the Design Matrix
143
+
144
+ Before fitting the model:
145
+
146
+ 1. **Visualize the design matrix** -- Check for empty or near-empty columns, which indicate conditions with no events or events lost to the high-pass filter
147
+ 2. **Check condition-regressor correlation** -- Correlation > **0.5** between task regressors indicates collinearity, reducing power and making contrasts uninterpretable (Mumford et al., 2015)
148
+ 3. **Verify the high-pass filter preserves signal** -- Overlay the filter cutoff on the power spectrum of each task regressor
149
+ 4. **Inspect the variance inflation factor (VIF)** -- VIF > **5** for any regressor indicates problematic multicollinearity (Poldrack et al., 2011, Ch. 4)
150
+
151
+ See `references/design-matrix-guide.md` for detailed guidance on design matrix construction.
152
+
153
+ ## Contrast Specification
154
+
155
+ Contrasts define the specific hypotheses you test within the fitted GLM.
156
+
157
+ ### t-Contrasts (Directional)
158
+
159
+ A t-contrast is a single row vector of weights applied to the parameter estimates. It tests a directional hypothesis.
160
+
161
+ | Contrast Type | Weight Vector Example | Tests |
162
+ |---|---|---|
163
+ | Activation vs. baseline | [1 0 0 ...] | Is condition A > 0? |
164
+ | Condition difference | [1 -1 0 ...] | Is condition A > condition B? |
165
+ | Linear trend | [-1 0 1 ...] | Does activation increase linearly across 3 levels? |
166
+ | Interaction (2x2) | [1 -1 -1 1 ...] | Does the difference A1-A2 differ from B1-B2? |
167
+
168
+ **Rules for valid t-contrasts** (Poline & Brett, 2012):
169
+ - Weights must sum to zero for difference contrasts
170
+ - Only task regressors should receive non-zero weights (never confound regressors)
171
+ - When using derivative basis functions, contrast only the canonical regressor
172
+
173
+ ### F-Contrasts (Omnibus)
174
+
175
+ An F-contrast tests whether any of several effects are non-zero. It is specified as a matrix (multiple rows).
176
+
177
+ | Use Case | When to Use |
178
+ |---|---|
179
+ | Main effect of factor | Testing whether any level of a factor differs from any other |
180
+ | HRF model with derivatives | Testing whether the canonical + derivative basis set captures any response |
181
+ | Any-difference test | Testing whether any condition differs from baseline |
182
+
183
+ **Domain insight**: An F-test for the full basis set (canonical + derivatives) tests whether there is any evoked response, regardless of its exact timing or shape. This is more sensitive than a t-test on the canonical regressor alone when the true HRF deviates from canonical form (Calhoun et al., 2004).
184
+
185
+ ## Second-Level Analysis (Group Inference)
186
+
187
+ First-level contrast maps (one per subject) serve as input to the group model.
188
+
189
+ ### Fixed Effects vs. Mixed Effects
190
+
191
+ | Approach | Models | Generalizability | When to Use | Source |
192
+ |---|---|---|---|---|
193
+ | Fixed effects (FFX) | Within-subject variance only | Only to the scanned subjects | Multiple runs within one subject | Poldrack et al., 2011, Ch. 8 |
194
+ | Mixed effects (MFX) | Within- + between-subject variance | To the population | Group inference across subjects | Mumford & Nichols, 2009 |
195
+ | OLS (summary statistics) | Between-subject variance only | To the population (if homogeneity holds) | Standard group analysis; valid and near-optimal under moderate variance heterogeneity | Mumford & Nichols, 2009 |
196
+
197
+ **Decision logic:**
198
+
199
+ ```
200
+ Are you combining runs within one subject?
201
+ |
202
+ +-- YES --> Fixed effects (concatenation or run-by-run with FFX)
203
+ |
204
+ +-- NO --> Are you making group-level inferences?
205
+ |
206
+ +-- YES --> Mixed effects (FLAME in FSL) or OLS summary statistics
207
+ OLS is valid and near-optimal for balanced designs
208
+ (Mumford & Nichols, 2009)
209
+ ```
210
+
211
+ **Domain warning**: Using a fixed-effects analysis for group inference treats between-subject variability as zero, dramatically inflating false positive rates. Results would apply only to the specific subjects scanned, not to the population (Friston et al., 2005; Mumford & Nichols, 2009).
212
+
213
+ ### Common Second-Level Designs
214
+
215
+ - **One-sample t-test**: Design matrix = intercept only (column of ones). Tests group mean activation against zero
216
+ - **Two-sample t-test**: Compares two groups (e.g., patients vs. controls). Include group-mean confounds (age, motion) as covariates
217
+ - **Paired t-test**: Within-subject comparison of two conditions at the group level
218
+ - **ANOVA / Flexible factorial**: Multiple factors; requires careful specification of variance components
219
+
220
+ ## Multiple Comparison Correction
221
+
222
+ With approximately **100,000 voxels** tested simultaneously, correction for multiple comparisons is essential. See `references/statistical-inference.md` for detailed guidance.
223
+
224
+ ### Quick Reference
225
+
226
+ | Method | Controls | Recommended Threshold | When to Use |
227
+ |---|---|---|---|
228
+ | Voxelwise FWE (RFT) | Family-wise error | p < 0.05 FWE | Highly localized effects expected (Worsley et al., 1996) |
229
+ | FDR (Benjamini-Hochberg) | False discovery rate | q < 0.05 | Distributed effects; moderate correction (Genovese et al., 2002) |
230
+ | Cluster-based (RFT) | Cluster-level FWE | CDT p < 0.001, then cluster p < 0.05 FWE | Standard approach; use CDT of p < 0.001 (Eklund et al., 2016) |
231
+ | TFCE | Voxelwise FWE via permutation | p < 0.05 FWE-corrected | No arbitrary CDT; good sensitivity (Smith & Nichols, 2009) |
232
+ | Permutation testing | FWE (nonparametric) | p < 0.05 FWE | Gold standard; no distributional assumptions (Nichols & Holmes, 2002) |
233
+
234
+ **Critical domain knowledge**: Cluster-based inference with a cluster-defining threshold (CDT) of p < 0.01 produces inflated false positive rates (up to 70% instead of the nominal 5%). Always use CDT of **p < 0.001** or stricter (Eklund et al., 2016). For permutation tests, use at least **5,000-10,000 permutations** for publication-quality results (Nichols & Holmes, 2002).
235
+
236
+ ## Common Pitfalls
237
+
238
+ 1. **Double-dipping / circular analysis**: Selecting voxels or ROIs based on the effect of interest, then testing that same effect in the selected data. This inflates effect sizes and produces invalid statistics (Kriegeskorte et al., 2009). Use independent data for selection and testing, or use a priori ROIs
239
+ 2. **Collinear regressors**: Highly correlated task regressors make individual contrasts uninterpretable. Check the correlation matrix of the design matrix; correlations > **0.5** between task regressors are problematic (Mumford et al., 2015)
240
+ 3. **HRF misspecification**: Using the canonical HRF when the true response deviates substantially (e.g., in pediatric or clinical populations) produces biased estimates and reduced power (Lindquist et al., 2009). Consider adding temporal derivatives or using FIR
241
+ 4. **High-pass filter too aggressive**: If the filter cutoff period is shorter than the longest inter-event interval, the task signal is attenuated. Always verify cutoff against your experimental timing
242
+ 5. **Ignoring temporal autocorrelation**: Using ordinary least squares (OLS) without prewhitening inflates t-statistics and false positive rates (Woolrich et al., 2001)
243
+ 6. **Omitting motion regressors**: Motion artifacts are the largest source of false positives in fMRI. At minimum, include 6 rigid-body parameters; the 24-parameter model is preferred (Power et al., 2012; Friston et al., 1996)
244
+ 7. **Using uncorrected thresholds for inference**: p < 0.001 uncorrected is insufficient for publication. Always apply FWE, FDR, or permutation-based correction (Eklund et al., 2016)
245
+ 8. **Fixed-effects for group inference**: Treats between-subject variance as zero; results do not generalize beyond the scanned sample (Mumford & Nichols, 2009)
246
+
247
+ ## Minimum Reporting Checklist
248
+
249
+ Based on the OHBM COBIDAS guidelines (Nichols et al., 2017) and Poldrack et al. (2008):
250
+
251
+ - [ ] Software package and version used for GLM estimation
252
+ - [ ] HRF model (canonical, derivatives, FIR) and any assumed parameters
253
+ - [ ] High-pass filter cutoff (in seconds or Hz) and implementation (DCT, Butterworth)
254
+ - [ ] Motion regressors included (6-parameter, 24-parameter, spike regressors)
255
+ - [ ] Additional confound regressors (CompCor components, global signal, etc.)
256
+ - [ ] Serial autocorrelation model (AR(1), ARMA(1,1), prewhitening approach)
257
+ - [ ] Contrast specification (weight vectors for each contrast tested)
258
+ - [ ] Second-level model type (fixed effects, mixed effects, OLS) and covariates
259
+ - [ ] Multiple comparison correction method, thresholds, and software
260
+ - [ ] For cluster-based inference: cluster-defining threshold and cluster-level threshold
261
+ - [ ] Smoothing kernel FWHM applied before group analysis (typically **6-8 mm** for standard 2-mm voxels; Poldrack et al., 2011, Ch. 5)
262
+
263
+ ## References
264
+
265
+ - Behzadi, Y., Restom, K., Liau, J., & Liu, T. T. (2007). A component based noise correction method (CompCor) for BOLD and perfusion based fMRI. *NeuroImage*, 37(1), 90-101.
266
+ - Calhoun, V. D., Stevens, M. C., Pearlson, G. D., & Kiehl, K. A. (2004). fMRI analysis with the general linear model: Removal of latency-induced amplitude bias by incorporation of hemodynamic derivative terms. *NeuroImage*, 22(1), 252-257.
267
+ - Ciric, R., Wolf, D. H., Power, J. D., et al. (2017). Benchmarking of participant-level confound regression strategies for the control of motion artifact in studies of functional connectivity. *NeuroImage*, 154, 174-187.
268
+ - Dale, A. M. (1999). Optimal experimental design for event-related fMRI. *Human Brain Mapping*, 8(2-3), 109-114.
269
+ - Eklund, A., Nichols, T. E., & Knutsson, H. (2016). Cluster failure: Why fMRI inferences for spatial extent have inflated false-positive rates. *PNAS*, 113(28), 7900-7905.
270
+ - Friston, K. J., Fletcher, P., Josephs, O., Holmes, A., Rugg, M. D., & Turner, R. (1998). Event-related fMRI: Characterizing differential responses. *NeuroImage*, 7(1), 30-40.
271
+ - Friston, K. J., Stephan, K. E., Lund, T. E., Morcom, A., & Kiebel, S. (2005). Mixed-effects and fMRI studies. *NeuroImage*, 24(1), 244-252.
272
+ - Friston, K. J., Williams, S., Howard, R., Frackowiak, R. S. J., & Turner, R. (1996). Movement-related effects in fMRI time-series. *Magnetic Resonance in Medicine*, 35(3), 346-355.
273
+ - Genovese, C. R., Lazar, N. A., & Nichols, T. (2002). Thresholding of statistical maps in functional neuroimaging using the false discovery rate. *NeuroImage*, 15(4), 870-878.
274
+ - Glover, G. H. (1999). Deconvolution of impulse response in event-related BOLD fMRI. *NeuroImage*, 9(4), 416-429.
275
+ - Henson, R. N. A., Price, C. J., Rugg, M. D., Turner, R., & Friston, K. J. (2002). Detecting latency differences in event-related BOLD responses. *NeuroImage*, 15(1), 83-97.
276
+ - Kriegeskorte, N., Simmons, W. K., Bellgowan, P. S., & Baker, C. I. (2009). Circular analysis in systems neuroscience: The dangers of double dipping. *Nature Neuroscience*, 12(5), 535-540.
277
+ - Lindquist, M. A. (2008). The statistical analysis of fMRI data. *Statistical Science*, 23(4), 439-464.
278
+ - Lindquist, M. A., Loh, J. M., Atlas, L. Y., & Wager, T. D. (2009). Modeling the hemodynamic response function in fMRI: Efficiency, bias and mis-modeling. *NeuroImage*, 45(1 Suppl), S187-S198.
279
+ - Mumford, J. A., & Nichols, T. E. (2009). Simple group fMRI modeling and inference. *NeuroImage*, 47(4), 1469-1475.
280
+ - Mumford, J. A., Poline, J. B., & Poldrack, R. A. (2015). Orthogonalization of regressors in fMRI models. *PLoS ONE*, 10(4), e0126255.
281
+ - Murphy, K., & Fox, M. D. (2017). Towards a consensus regarding global signal regression for resting state functional connectivity MRI. *NeuroImage*, 154, 169-173.
282
+ - Muschelli, J., Nebel, M. B., Caffo, B. S., et al. (2014). Reduction of motion-related artifacts in resting state fMRI using aCompCor. *NeuroImage*, 96, 22-35.
283
+ - Nichols, T. E., Das, S., Eickhoff, S. B., et al. (2017). Best practices in data analysis and sharing in neuroimaging using MRI (COBIDAS). *Nature Neuroscience*, 20(3), 299-303.
284
+ - Nichols, T. E., & Holmes, A. P. (2002). Nonparametric permutation tests for functional neuroimaging: A primer with examples. *Human Brain Mapping*, 15(1), 1-25.
285
+ - Olszowy, W., Aston, J., Rua, C., & Williams, G. B. (2019). Accurate autocorrelation modeling substantially improves fMRI reliability. *Nature Communications*, 10, 1220.
286
+ - Poldrack, R. A., Fletcher, P. C., Henson, R. N., Worsley, K. J., Brett, M., & Nichols, T. E. (2008). Guidelines for reporting an fMRI study. *NeuroImage*, 40(2), 409-414.
287
+ - Poldrack, R. A., Mumford, J. A., & Nichols, T. E. (2011). *Handbook of Functional MRI Data Analysis*. Cambridge University Press.
288
+ - Poline, J. B., & Brett, M. (2012). The general linear model and fMRI: Does love last forever? *NeuroImage*, 62(2), 871-880.
289
+ - Power, J. D., Barnes, K. A., Snyder, A. Z., Schlaggar, B. L., & Petersen, S. E. (2012). Spurious but systematic correlations in functional connectivity MRI networks arise from subject motion. *NeuroImage*, 59(3), 2142-2154.
290
+ - Power, J. D., Mitra, A., Laumann, T. O., Snyder, A. Z., Schlaggar, B. L., & Petersen, S. E. (2014). Methods to detect, characterize, and remove motion artifact in resting state fMRI. *NeuroImage*, 84, 320-341.
291
+ - Satterthwaite, T. D., Elliott, M. A., Gerraty, R. T., et al. (2013). An improved framework for confound regression and filtering for control of motion artifact in the preprocessing of resting-state functional connectivity data. *NeuroImage*, 64, 240-256.
292
+ - Smith, S. M., & Nichols, T. E. (2009). Threshold-free cluster enhancement: Addressing problems of smoothing, threshold dependence and localisation in cluster inference. *NeuroImage*, 44(1), 83-98.
293
+ - Woolrich, M. W., Ripley, B. D., Brady, M., & Smith, S. M. (2001). Temporal autocorrelation in univariate linear modeling of FMRI data. *NeuroImage*, 14(6), 1370-1386.
294
+ - Worsley, K. J., Marrett, S., Neelin, P., Vandal, A. C., Friston, K. J., & Evans, A. C. (1996). A unified statistical approach for determining significant signals in images of cerebral activation. *Human Brain Mapping*, 4(1), 58-73.
295
+
296
+ See `references/` for detailed design matrix construction guide and statistical inference methods.
@@ -0,0 +1,214 @@
1
+ # Design Matrix Construction Guide
2
+
3
+ ## Overview
4
+
5
+ The design matrix is the core of the fMRI GLM. Each column represents a regressor (expected signal component or confound), and each row corresponds to one acquired volume (time point). Correct construction is essential: errors in the design matrix directly produce incorrect statistical results.
6
+
7
+ This reference expands on the design matrix topics introduced in `../SKILL.md`.
8
+
9
+ ## Experimental Design Types
10
+
11
+ ### Block Designs
12
+
13
+ In a block design, stimuli of the same condition are presented in sustained epochs (typically **15-30 seconds**; Poldrack et al., 2011, Ch. 3).
14
+
15
+ **Advantages:**
16
+ - Maximum detection power for sustained activations (Liu et al., 2001)
17
+ - Simple GLM specification: one boxcar regressor per condition, convolved with HRF
18
+ - Robust to HRF misspecification because the sustained signal is easily detected
19
+
20
+ **Disadvantages:**
21
+ - Cannot estimate HRF shape (hemodynamic responses overlap and saturate)
22
+ - Cannot separate individual trial types within a block
23
+ - Susceptible to habituation, anticipation, and strategy effects
24
+
25
+ **Design matrix specification:**
26
+ - One regressor per block condition: onset = block start, duration = block length (e.g., 20 s)
27
+ - Convolved with the chosen HRF model
28
+ - Recommended block duration: **15-30 seconds** (shorter blocks sacrifice power; longer blocks increase habituation; Poldrack et al., 2011, Ch. 3)
29
+
30
+ ### Event-Related Designs
31
+
32
+ In an event-related design, individual trials are modeled as brief events (typical duration **0.5-4 seconds**; Dale, 1999).
33
+
34
+ **Advantages:**
35
+ - Can estimate HRF shape via deconvolution or FIR models
36
+ - Can separate individual trial types (e.g., correct vs. incorrect trials)
37
+ - Can randomize trial order, reducing anticipation effects
38
+ - Can jitter inter-trial intervals for optimal statistical efficiency
39
+
40
+ **Disadvantages:**
41
+ - Lower detection power per unit time compared to block designs (Liu et al., 2001)
42
+ - Requires more trials for stable estimation
43
+ - More sensitive to HRF model specification
44
+
45
+ **Design matrix specification:**
46
+ - One regressor per condition: onset times for each trial, duration = stimulus presentation time (or 0 for impulse events)
47
+ - Convolved with the chosen HRF model
48
+
49
+ ### Mixed (Hybrid) Designs
50
+
51
+ Combine block and event-related elements. For example, blocks of a task with individual trial onsets modeled within each block (Petersen & Dubis, 2012).
52
+
53
+ **Design matrix specification:**
54
+ - Separate sustained (block) and transient (event) regressors
55
+ - The sustained regressor models the tonic state; the transient regressor models trial-by-trial variation within that state
56
+
57
+ ## Optimal Inter-Stimulus Interval (ISI)
58
+
59
+ The spacing between events critically affects statistical efficiency.
60
+
61
+ ### Fixed vs. Jittered ISI
62
+
63
+ | Design | Efficiency for Detection | Efficiency for Estimation | Source |
64
+ |---|---|---|---|
65
+ | Fixed ISI (long, > 12 s) | Moderate | High (individual HRFs separable) | Buckner et al., 1996 |
66
+ | Fixed ISI (short, 2-4 s) | Low (responses overlap predictably) | Low (cannot deconvolve) | Dale, 1999 |
67
+ | Jittered ISI (random, mean 4-8 s) | High | Moderate to High | Dale, 1999 |
68
+ | Jittered ISI with null events | Highest | High | Friston et al., 1999 |
69
+
70
+ **Key result**: For jittered designs, efficiency improves monotonically with decreasing mean ISI. Jittered designs can be **>10x more efficient** than fixed ISI designs with the same mean interval (Dale, 1999).
71
+
72
+ ### Practical ISI Recommendations
73
+
74
+ - **Minimum mean ISI**: **2 seconds** to allow hemodynamic responses to partially separate (Dale, 1999)
75
+ - **Include null events**: Insert **20-33%** null trials (fixation-only periods) distributed randomly throughout the experiment. This provides baseline estimation and temporal jitter (Friston et al., 1999; Josephs & Henson, 1999)
76
+ - **ISI distribution**: Sample ISIs from a truncated exponential or uniform distribution. The exponential distribution provides more short ISIs (higher efficiency) while including occasional long ISIs (better HRF estimation) (Hagberg et al., 2001)
77
+ - **Minimum ISI**: At least **2 seconds** even for jittered designs to avoid severe nonlinear saturation of the hemodynamic response (Glover, 1999)
78
+ - **Maximum ISI**: Keep below half the high-pass filter cutoff period to avoid signal attenuation
79
+
80
+ ### Design Optimization Tools
81
+
82
+ - **optseq2** (FreeSurfer): Optimizes event ordering and null event placement for maximum efficiency (Dale, 1999)
83
+ - **NeuroDesign** (Python): Genetic algorithm-based optimization for detection and estimation efficiency (Durnez et al., 2017)
84
+ - **fMRI Power**: Power calculations for fMRI designs (Mumford & Nichols, 2008)
85
+
86
+ ## Design Efficiency Calculation
87
+
88
+ Design efficiency quantifies how well a given design matrix allows estimation of the effects of interest.
89
+
90
+ ### Detection Efficiency
91
+
92
+ For a contrast vector **c** and design matrix **X**, the efficiency of detecting the contrast is:
93
+
94
+ ```
95
+ efficiency = 1 / trace(c' * (X'X)^(-1) * c)
96
+ ```
97
+
98
+ Higher values indicate more statistical power for detecting the contrast (Dale, 1999; Liu et al., 2001).
99
+
100
+ ### Detection vs. Estimation Trade-off
101
+
102
+ - **Detection power**: Ability to detect whether an effect exists (e.g., is this region activated?). Maximized by block designs and rapid event-related designs with jittered ISI (Liu et al., 2001)
103
+ - **Estimation efficiency**: Ability to accurately estimate the shape of the HRF. Maximized by designs with long ISIs or well-jittered rapid designs (Liu et al., 2001)
104
+ - These are inherently in tension: optimizing for one reduces the other. Choose based on your primary research question
105
+
106
+ ## Parametric Modulators
107
+
108
+ Parametric modulators allow continuous trial-by-trial variables (e.g., reaction time, stimulus intensity, subjective rating) to modulate the expected BOLD response.
109
+
110
+ ### Implementation
111
+
112
+ 1. Create a standard onset regressor for the condition (convolved with HRF)
113
+ 2. Create an additional regressor with the same onsets but amplitude scaled by the parametric variable (mean-centered)
114
+ 3. Both regressors are convolved with the HRF
115
+ 4. The parametric regressor captures variance linearly related to the modulating variable, after removing the main effect of the condition
116
+
117
+ ### Practical Considerations
118
+
119
+ - **Mean-center the parametric variable** to make the unmodulated and modulated regressors more orthogonal (Mumford et al., 2015)
120
+ - **Orthogonalization**: Some software (SPM) automatically orthogonalizes parametric modulators with respect to the main condition regressor. This means the main regressor captures all shared variance, and the parametric regressor captures only the residual. Be aware of this behavior -- it can affect interpretation (Mumford et al., 2015)
121
+ - **Order of entry matters in SPM**: When multiple parametric modulators are entered, later ones are orthogonalized with respect to earlier ones (unless serial orthogonalization is turned off). In FSL and AFNI, regressors are not orthogonalized by default (Mumford et al., 2015)
122
+ - **Polynomial expansion**: For nonlinear relationships, include quadratic (and occasionally cubic) terms as additional parametric modulators
123
+
124
+ ### Common Parametric Modulators in Cognitive Neuroscience
125
+
126
+ | Modulator | Domain | Interpretation | Source |
127
+ |---|---|---|---|
128
+ | Reaction time | Decision-making | Regions whose activity scales with decision difficulty | Grinband et al., 2008 |
129
+ | Prediction error | Reinforcement learning | Regions encoding reward prediction error signals | O'Doherty et al., 2003 |
130
+ | Stimulus intensity | Perception | Regions with graded response to stimulus strength | Buchel et al., 1998 |
131
+ | Memory confidence | Memory | Regions tracking retrieval strength | Kim & Cabeza, 2007 |
132
+ | Working memory load | Executive function | Regions sensitive to cognitive demand | Braver et al., 1997 |
133
+
134
+ ## Temporal Derivatives
135
+
136
+ ### What They Model
137
+
138
+ Adding a temporal derivative to the canonical HRF allows the model to capture small shifts (+/- approximately **1 second**) in the peak latency of the hemodynamic response (Friston et al., 1998; Henson et al., 2002).
139
+
140
+ The dispersion derivative additionally captures variations in the width (duration) of the response.
141
+
142
+ ### Contrast Specification with Derivatives
143
+
144
+ **Critical domain knowledge**: When using temporal and dispersion derivatives, standard t-contrasts should weight only the canonical HRF regressor. The derivative regressors serve as nuisance parameters that soak up variance from timing variability, improving the fit of the canonical regressor.
145
+
146
+ ```
147
+ Example with canonical + temporal derivative + dispersion derivative:
148
+ Condition A regressors: [A_canonical, A_temporal_deriv, A_dispersion_deriv]
149
+ Condition B regressors: [B_canonical, B_temporal_deriv, B_dispersion_deriv]
150
+
151
+ t-contrast (A > B): [1 0 0 -1 0 0 ...]
152
+ F-contrast (any response to A): [[1 0 0 ...], [0 1 0 ...], [0 0 1 ...]]
153
+ ```
154
+
155
+ The F-test across all three basis functions tests whether there is any hemodynamic response to the condition, regardless of its exact shape (Calhoun et al., 2004).
156
+
157
+ ### When to Add Derivatives
158
+
159
+ - **Always consider temporal derivatives** when: analyzing data from clinical populations, pediatric/elderly subjects, or when comparing groups that may differ in neurovascular coupling (Handwerker et al., 2004)
160
+ - **Do not add derivatives** when: you have very few trials per condition (< 20), as the additional parameters reduce degrees of freedom without compensating benefit
161
+
162
+ ## Confound Regressor Details
163
+
164
+ ### fMRIPrep Confound Outputs
165
+
166
+ When using fMRIPrep (Esteban et al., 2019), the confounds TSV file contains many potential regressors. A recommended selection strategy:
167
+
168
+ **Minimal model** (task fMRI with low motion):
169
+ - 6 motion parameters
170
+ - aCompCor: top 5 WM + CSF components
171
+
172
+ **Standard model** (recommended default):
173
+ - 24 motion parameters (Friston model)
174
+ - aCompCor: top 5 WM + CSF components
175
+ - High-motion spike regressors (FD > 0.5 mm)
176
+
177
+ **Aggressive model** (high motion or connectivity analysis):
178
+ - 24 motion parameters (Friston model)
179
+ - aCompCor: top 5 WM + CSF components
180
+ - Spike regressors (FD > 0.2 mm)
181
+ - Cosine regressors for high-pass filtering (provided by fMRIPrep)
182
+
183
+ ### Non-Steady-State Volumes
184
+
185
+ The first few volumes of each fMRI run may not have reached steady-state magnetization. These should be either:
186
+ - Excluded from the analysis (remove the first **3-5 volumes**, depending on the TR and flip angle; Poldrack et al., 2011, Ch. 2)
187
+ - Modeled with indicator regressors (one regressor per excluded volume)
188
+
189
+ fMRIPrep identifies these automatically and provides `non_steady_state_outlier_XX` columns in the confounds file.
190
+
191
+ ## References
192
+
193
+ - Braver, T. S., Cohen, J. D., Nystrom, L. E., et al. (1997). A parametric study of prefrontal cortex involvement in human working memory. *NeuroImage*, 5(1), 49-62.
194
+ - Buchel, C., Holmes, A. P., Rees, G., & Friston, K. J. (1998). Characterizing stimulus-response functions using nonlinear regressors in parametric fMRI experiments. *NeuroImage*, 8(2), 140-148.
195
+ - Buckner, R. L., Bandettini, P. A., O'Craven, K. M., et al. (1996). Detection of cortical activation during averaged single trials of a cognitive task using functional magnetic resonance imaging. *PNAS*, 93(25), 14878-14883.
196
+ - Calhoun, V. D., Stevens, M. C., Pearlson, G. D., & Kiehl, K. A. (2004). fMRI analysis with the general linear model: Removal of latency-induced amplitude bias. *NeuroImage*, 22(1), 252-257.
197
+ - Dale, A. M. (1999). Optimal experimental design for event-related fMRI. *Human Brain Mapping*, 8(2-3), 109-114.
198
+ - Durnez, J., Blair, R., & Poldrack, R. A. (2017). NeuroDesign: Optimal experimental designs for task fMRI. *bioRxiv*, 119594.
199
+ - Esteban, O., Markiewicz, C. J., Blair, R. W., et al. (2019). fMRIPrep: A robust preprocessing pipeline for functional MRI. *Nature Methods*, 16(1), 111-116.
200
+ - Friston, K. J., Fletcher, P., Josephs, O., et al. (1998). Event-related fMRI: Characterizing differential responses. *NeuroImage*, 7(1), 30-40.
201
+ - Friston, K. J., Zarahn, E., Josephs, O., Henson, R. N. A., & Dale, A. M. (1999). Stochastic designs in event-related fMRI. *NeuroImage*, 10(5), 607-619.
202
+ - Glover, G. H. (1999). Deconvolution of impulse response in event-related BOLD fMRI. *NeuroImage*, 9(4), 416-429.
203
+ - Grinband, J., Wager, T. D., Lindquist, M., Ferrera, V. P., & Hirsch, J. (2008). Detection of time-varying signals in event-related fMRI designs. *NeuroImage*, 43(3), 509-520.
204
+ - Hagberg, G. E., Zito, G., Patria, F., & Sanes, J. N. (2001). Improved detection of event-related functional MRI signals using probability functions. *NeuroImage*, 14(5), 1193-1205.
205
+ - Handwerker, D. A., Ollinger, J. M., & D'Esposito, M. (2004). Variation of BOLD hemodynamic responses across subjects and brain regions and their effects on statistical analyses. *NeuroImage*, 21(4), 1639-1651.
206
+ - Henson, R. N. A., Price, C. J., Rugg, M. D., Turner, R., & Friston, K. J. (2002). Detecting latency differences in event-related BOLD responses. *NeuroImage*, 15(1), 83-97.
207
+ - Josephs, O., & Henson, R. N. A. (1999). Event-related functional magnetic resonance imaging: Modelling, inference and optimization. *Philosophical Transactions of the Royal Society B*, 354(1387), 1215-1228.
208
+ - Kim, H., & Cabeza, R. (2007). Trusting our memories: Dissociating the neural correlates of confidence in veridical versus illusory memories. *Journal of Neuroscience*, 27(45), 12190-12197.
209
+ - Liu, T. T., Frank, L. R., Wong, E. C., & Buxton, R. B. (2001). Detection power, estimation efficiency, and predictability in event-related fMRI. *NeuroImage*, 13(4), 759-773.
210
+ - Mumford, J. A., & Nichols, T. E. (2008). Power calculation for group fMRI studies accounting for arbitrary design and temporal autocorrelation. *NeuroImage*, 39(1), 261-268.
211
+ - Mumford, J. A., Poline, J. B., & Poldrack, R. A. (2015). Orthogonalization of regressors in fMRI models. *PLoS ONE*, 10(4), e0126255.
212
+ - O'Doherty, J. P., Dayan, P., Friston, K., Critchley, H., & Dolan, R. J. (2003). Temporal difference models and reward-related learning in the human brain. *Neuron*, 38(2), 329-337.
213
+ - Petersen, S. E., & Dubis, J. W. (2012). The mixed block/event-related design. *NeuroImage*, 62(2), 1177-1184.
214
+ - Poldrack, R. A., Mumford, J. A., & Nichols, T. E. (2011). *Handbook of Functional MRI Data Analysis*. Cambridge University Press.