@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.
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -0
- package/skills/01_Meta-Skills/contribute-skill/SKILL.md +277 -0
- package/skills/01_Meta-Skills/contribute-skills-via-pr/SKILL.md +163 -0
- package/skills/01_Meta-Skills/paper-to-skill/SKILL.md +435 -0
- package/skills/01_Meta-Skills/paper-to-skill/references/extraction-guide.md +286 -0
- package/skills/01_Meta-Skills/paper-to-skill/references/skill-template.md +250 -0
- package/skills/01_Meta-Skills/repo-to-skill/SKILL.md +289 -0
- package/skills/01_Meta-Skills/share-case/SKILL.md +253 -0
- package/skills/01_Meta-Skills/share-usage/README.md +63 -0
- package/skills/01_Meta-Skills/share-usage/SKILL.md +395 -0
- package/skills/01_Meta-Skills/verify-skill/SKILL.md +331 -0
- package/skills/02_Cross-Domain_Foundation/cogsci-power-analysis/SKILL.md +194 -0
- package/skills/02_Cross-Domain_Foundation/cogsci-power-analysis/references/effect-sizes.md +352 -0
- package/skills/02_Cross-Domain_Foundation/cogsci-power-analysis/references/sample-size-guide.md +407 -0
- package/skills/02_Cross-Domain_Foundation/cogsci-statistics/SKILL.md +361 -0
- package/skills/02_Cross-Domain_Foundation/cogsci-statistics/references/common-analyses.md +517 -0
- package/skills/02_Cross-Domain_Foundation/cogsci-visualization/SKILL.md +292 -0
- package/skills/02_Cross-Domain_Foundation/cogsci-visualization/references/plot-recipes.md +709 -0
- package/skills/02_Cross-Domain_Foundation/research-literacy/SKILL.md +286 -0
- package/skills/02_Cross-Domain_Foundation/research-literacy/references/common-assumptions.md +320 -0
- package/skills/02_Cross-Domain_Foundation/research-literacy/references/planning-template.md +143 -0
- package/skills/03_Cognitive_Psychology/alternative-uses-task-designer/SKILL.md +197 -0
- package/skills/03_Cognitive_Psychology/alternative-uses-task-designer/references/instruction-templates.md +60 -0
- package/skills/03_Cognitive_Psychology/cognitive-paradigm-design/SKILL.md +246 -0
- package/skills/03_Cognitive_Psychology/cognitive-paradigm-design/references/classic-paradigms.md +435 -0
- package/skills/03_Cognitive_Psychology/cognitive-paradigm-design/references/design-principles.md +256 -0
- package/skills/03_Cognitive_Psychology/creativity-self-efficacy-mediation/SKILL.md +270 -0
- package/skills/03_Cognitive_Psychology/creativity-self-efficacy-mediation/references/lavaan-templates.md +172 -0
- package/skills/03_Cognitive_Psychology/divergent-thinking-scoring/SKILL.md +238 -0
- package/skills/03_Cognitive_Psychology/divergent-thinking-scoring/references/scoring-rubric.md +143 -0
- package/skills/03_Cognitive_Psychology/drift-diffusion-model/SKILL.md +203 -0
- package/skills/03_Cognitive_Psychology/drift-diffusion-model/references/fitting-guide.md +571 -0
- package/skills/03_Cognitive_Psychology/drift-diffusion-model/references/model-variants.md +427 -0
- package/skills/03_Cognitive_Psychology/evidence-accumulation-selector/SKILL.md +310 -0
- package/skills/03_Cognitive_Psychology/evidence-accumulation-selector/references/ez-diffusion-formulas.md +137 -0
- package/skills/03_Cognitive_Psychology/signal-detection-analysis/SKILL.md +300 -0
- package/skills/03_Cognitive_Psychology/signal-detection-analysis/references/application-guide.md +278 -0
- package/skills/03_Cognitive_Psychology/signal-detection-analysis/references/sdt-formulas.md +318 -0
- package/skills/03_Cognitive_Psychology/visual-search-array-generator/SKILL.md +283 -0
- package/skills/03_Cognitive_Psychology/visual-search-array-generator/references/array-generation-parameters.yaml +111 -0
- package/skills/04_Psycholinguistics/reading-time-analysis/SKILL.md +301 -0
- package/skills/04_Psycholinguistics/reading-time-analysis/references/measure-computation-guide.md +195 -0
- package/skills/04_Psycholinguistics/self-paced-reading-designer/SKILL.md +257 -0
- package/skills/04_Psycholinguistics/self-paced-reading-designer/references/analysis-guide.md +356 -0
- package/skills/04_Psycholinguistics/self-paced-reading-designer/references/region-segmentation.md +266 -0
- package/skills/04_Psycholinguistics/sentence-stimulus-norming/SKILL.md +346 -0
- package/skills/04_Psycholinguistics/sentence-stimulus-norming/references/lexical-databases-guide.md +184 -0
- package/skills/05_EEG_ERP/eeg-paradigm-designer/SKILL.md +226 -0
- package/skills/05_EEG_ERP/eeg-paradigm-designer/references/component-paradigm-map.md +276 -0
- package/skills/05_EEG_ERP/eeg-paradigm-designer/references/timing-parameters.md +244 -0
- package/skills/05_EEG_ERP/eeg-preprocessing-pipeline-guide/SKILL.md +367 -0
- package/skills/05_EEG_ERP/eeg-preprocessing-pipeline-guide/references/parameter-lookup-tables.md +138 -0
- package/skills/05_EEG_ERP/erp-analysis/SKILL.md +185 -0
- package/skills/05_EEG_ERP/erp-analysis/references/erp-components.md +447 -0
- package/skills/05_EEG_ERP/erp-analysis/references/preprocessing-pipeline.md +277 -0
- package/skills/05_EEG_ERP/erp-analysis/references/statistical-approaches.md +351 -0
- package/skills/05_EEG_ERP/mne-python-guide/SKILL.md +174 -0
- package/skills/05_EEG_ERP/mne-python-guide/references/decoding.md +178 -0
- package/skills/05_EEG_ERP/mne-python-guide/references/io_formats.md +160 -0
- package/skills/05_EEG_ERP/mne-python-guide/references/preprocessing.md +259 -0
- package/skills/05_EEG_ERP/mne-python-guide/references/simulation.md +173 -0
- package/skills/05_EEG_ERP/mne-python-guide/references/source_localization.md +234 -0
- package/skills/05_EEG_ERP/mne-python-guide/references/statistics.md +196 -0
- package/skills/05_EEG_ERP/mne-python-guide/references/time_frequency.md +165 -0
- package/skills/05_EEG_ERP/mne-python-guide/references/visualization.md +175 -0
- package/skills/06_fMRI_Neuroimaging/brain-connectivity-modeler/SKILL.md +317 -0
- package/skills/06_fMRI_Neuroimaging/brain-connectivity-modeler/references/method-implementation-guide.md +116 -0
- package/skills/06_fMRI_Neuroimaging/fmri-glm-analysis-guide/SKILL.md +296 -0
- package/skills/06_fMRI_Neuroimaging/fmri-glm-analysis-guide/references/design-matrix-guide.md +214 -0
- package/skills/06_fMRI_Neuroimaging/fmri-glm-analysis-guide/references/statistical-inference.md +288 -0
- package/skills/06_fMRI_Neuroimaging/fmri-preprocessing-pipeline-guide/SKILL.md +274 -0
- package/skills/06_fMRI_Neuroimaging/fmri-preprocessing-pipeline-guide/references/quality-control.md +336 -0
- package/skills/06_fMRI_Neuroimaging/fmri-preprocessing-pipeline-guide/references/step-by-step-pipeline.md +380 -0
- package/skills/06_fMRI_Neuroimaging/fmri-task-design-guide/SKILL.md +264 -0
- package/skills/06_fMRI_Neuroimaging/fmri-task-design-guide/references/design-optimization-examples.md +114 -0
- package/skills/06_fMRI_Neuroimaging/neural-decoding-analysis/SKILL.md +273 -0
- package/skills/06_fMRI_Neuroimaging/neural-decoding-analysis/references/decoding-methods.md +170 -0
- package/skills/06_fMRI_Neuroimaging/neural-decoding-analysis/references/rsa-guide.md +266 -0
- package/skills/06_fMRI_Neuroimaging/pycortex-guide/SKILL.md +123 -0
- package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/database-subjects.md +179 -0
- package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/dataset-types.md +208 -0
- package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/freesurfer-fmriprep.md +162 -0
- package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/mapping-transforms.md +181 -0
- package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/mni-utils.md +207 -0
- package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/surface-analysis.md +219 -0
- package/skills/06_fMRI_Neuroimaging/pycortex-guide/references/visualization.md +251 -0
- package/skills/07_Computational_Modeling/act-r-model-builder/SKILL.md +297 -0
- package/skills/07_Computational_Modeling/act-r-model-builder/references/model-patterns.md +197 -0
- package/skills/07_Computational_Modeling/act-r-model-builder/references/parameter-table.yaml +204 -0
- package/skills/07_Computational_Modeling/bayesian-cognitive-model-builder/SKILL.md +294 -0
- package/skills/07_Computational_Modeling/bayesian-cognitive-model-builder/references/diagnostics-checklist.md +351 -0
- package/skills/07_Computational_Modeling/bayesian-cognitive-model-builder/references/prior-selection-guide.md +241 -0
- package/skills/07_Computational_Modeling/parameter-recovery-checker/SKILL.md +269 -0
- package/skills/07_Computational_Modeling/parameter-recovery-checker/references/recovery-diagnostics.md +207 -0
- package/skills/08_Computational_Neuroscience/brain-connectivity-modeler/SKILL.md +317 -0
- package/skills/08_Computational_Neuroscience/brain-connectivity-modeler/references/method-implementation-guide.md +116 -0
- package/skills/08_Computational_Neuroscience/neural-decoding-analysis/SKILL.md +273 -0
- package/skills/08_Computational_Neuroscience/neural-decoding-analysis/references/decoding-methods.md +170 -0
- package/skills/08_Computational_Neuroscience/neural-decoding-analysis/references/rsa-guide.md +266 -0
- package/skills/08_Computational_Neuroscience/neural-population-analysis-guide/SKILL.md +305 -0
- package/skills/08_Computational_Neuroscience/neural-population-analysis-guide/references/data-requirements.md +60 -0
- package/skills/08_Computational_Neuroscience/neural-population-analysis-guide/references/method-comparison.md +151 -0
- package/skills/08_Computational_Neuroscience/spiking-network-model-builder/SKILL.md +376 -0
- package/skills/08_Computational_Neuroscience/spiking-network-model-builder/references/hh-parameters.md +117 -0
- package/skills/08_Computational_Neuroscience/spiking-network-model-builder/references/network-regimes.md +130 -0
- package/skills/09_Cellular_Molecular_Neuroscience/calcium-imaging-analysis-guide/SKILL.md +258 -0
- package/skills/09_Cellular_Molecular_Neuroscience/calcium-imaging-analysis-guide/references/indicator-parameters.md +242 -0
- package/skills/09_Cellular_Molecular_Neuroscience/calcium-imaging-analysis-guide/references/pipeline-details.md +211 -0
- package/skills/09_Cellular_Molecular_Neuroscience/optogenetics-protocol-designer/SKILL.md +261 -0
- package/skills/09_Cellular_Molecular_Neuroscience/optogenetics-protocol-designer/references/opsin-catalog.md +124 -0
- package/skills/09_Cellular_Molecular_Neuroscience/optogenetics-protocol-designer/references/stimulation-parameters.md +304 -0
- package/skills/10_Clinical_Neuropsychology/lesion-symptom-mapping-guide/SKILL.md +367 -0
- package/skills/10_Clinical_Neuropsychology/lesion-symptom-mapping-guide/references/disconnection-guide.md +152 -0
- package/skills/10_Clinical_Neuropsychology/lesion-symptom-mapping-guide/references/vlsm-pipeline.md +182 -0
- package/skills/10_Clinical_Neuropsychology/neuropsych-battery-selector/SKILL.md +250 -0
- package/skills/10_Clinical_Neuropsychology/neuropsych-battery-selector/references/deficit-profiles.md +302 -0
- package/skills/10_Clinical_Neuropsychology/neuropsych-battery-selector/references/test-catalog.md +304 -0
- package/skills/11_Developmental_Cognition/infant-looking-time-designer/SKILL.md +345 -0
- package/skills/11_Developmental_Cognition/infant-looking-time-designer/references/age-parameters.yaml +186 -0
- package/skills/12_Social_Cognition/tom-task-selector/SKILL.md +379 -0
- package/skills/12_Social_Cognition/tom-task-selector/references/task-database.md +317 -0
- package/skills/13_Visualization/nature-figure/README.md +442 -0
- package/skills/13_Visualization/nature-figure/SKILL.md +60 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-01-bar-charts.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-02-line-trends.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-03-heatmaps.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-04-scatter-bubble.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-05-radar-polar.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-06-distributions.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-07-forest-interval.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-08-area-stacked.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-09-image-plates.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/chart-atlas/atlas-10-network-matrix.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/Dispersion_motivation.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/Dispersion_observation.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/Dispersion_observation_distillation.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/ImmunoStruct_contrastive.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/ImmunoStruct_results_CEDAR.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/ImmunoStruct_results_IEDB.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/ImmunoStruct_schematic.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/assets/RNAGenScape_schematic.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_CellSpliceNet/figures/ablation.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_CellSpliceNet/figures/comparison.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_CellSpliceNet/plot_ablation.py +86 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_CellSpliceNet/plot_comparison.py +109 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/diffusion_swiss_roll.py +97 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/diffusion_swiss_roll.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/fig2_comparison_GeneRegulatory.pdf +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/fig2_comparison_GeneRegulatory.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/fig2_comparison_Trajectory.pdf +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/fig2_comparison_Trajectory.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/figX_comparison_Ablation.pdf +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/figures/figX_comparison_Ablation.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/plot_comparison_Ablation.py +64 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/plot_comparison_GeneRegulatory.py +74 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Cflows/plot_comparison_Trajectory.py +74 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Dispersion/figures/idea.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Dispersion/figures/illustration.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Dispersion/plot_idea.py +76 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_Dispersion/plot_illustration.py +404 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_FPGM/figures/freq_prior.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_FPGM/plot_freq_prior.py +146 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/figures/bars_ablation_Cancer.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/figures/bars_ablation_IEDB.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/figures/bars_comparison_Cancer.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/figures/bars_comparison_IEDB.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/plot_bars.py +216 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ImmunoStruct/raw_data.py +125 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/manifold.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/manifold_holes.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/results_comparison_optimization.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/results_comparison_speed.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/figures/results_sweep.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/plot_comparison.py +228 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/plot_hole_manifold.py +82 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/plot_manifold.py +61 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_RNAGenScape/plot_sweep.py +77 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_VIGIL/figures/comparison_posttraining.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_VIGIL/figures/comparison_radar.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_VIGIL/plot_comparison_radar.py +173 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_VIGIL/plot_posttraining.py +82 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/brute_force.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/correctness_by_category.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/correctness_by_subcategory.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/rewriting.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/figures/selfcorrection_math.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_brute_force.py +248 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_correctness_by_category.py +132 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_correctness_by_subcategory.py +131 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_rewriting.py +105 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_brainteaser/plot_selfcorrection_math.py +99 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ophthal_review/figures/composition_heatmap.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ophthal_review/figures/trend_by_month.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ophthal_review/plot_composition.py +81 -0
- package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_ophthal_review/plot_trend.py +125 -0
- package/skills/13_Visualization/nature-figure/assets/gallery/fig1-material-mechanism-rich.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/gallery/fig2-spatial-imaging-rich.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/gallery/fig3-in-vivo-efficacy-rich.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/gallery/fig4-single-cell-systems-rich.png +0 -0
- package/skills/13_Visualization/nature-figure/assets/gallery/fig5-validation-perturbation-rich.png +0 -0
- package/skills/13_Visualization/nature-figure/evals/evals.json +37 -0
- package/skills/13_Visualization/nature-figure/manifest.yaml +57 -0
- package/skills/13_Visualization/nature-figure/references/api.md +428 -0
- package/skills/13_Visualization/nature-figure/references/backend-selection.md +100 -0
- package/skills/13_Visualization/nature-figure/references/chart-types.md +281 -0
- package/skills/13_Visualization/nature-figure/references/common-patterns.md +350 -0
- package/skills/13_Visualization/nature-figure/references/demos.md +65 -0
- package/skills/13_Visualization/nature-figure/references/design-theory.md +436 -0
- package/skills/13_Visualization/nature-figure/references/figure-contract.md +93 -0
- package/skills/13_Visualization/nature-figure/references/nature-2026-observations.md +112 -0
- package/skills/13_Visualization/nature-figure/references/qa-contract.md +119 -0
- package/skills/13_Visualization/nature-figure/references/r-template-index.md +66 -0
- package/skills/13_Visualization/nature-figure/references/r-workflow.md +161 -0
- package/skills/13_Visualization/nature-figure/references/tutorials.md +251 -0
- package/skills/13_Visualization/nature-figure/static/core/contract.md +29 -0
- package/skills/13_Visualization/nature-figure/static/core/stance.md +37 -0
- package/skills/13_Visualization/nature-figure/static/fragments/backend/python.md +37 -0
- package/skills/13_Visualization/nature-figure/static/fragments/backend/r.md +44 -0
- package/skills/14_Writing/markdown-report-writing/SKILL.md +306 -0
- package/skills/14_Writing/markdown-report-writing/references/compatibility-matrix.md +72 -0
- package/skills/14_Writing/markdown-report-writing/references/templates.md +299 -0
- package/skills/15_Others/neuroimaging-power-guide/SKILL.md +324 -0
- package/skills/15_Others/neuroimaging-power-guide/references/effect-size-lookup-tables.md +102 -0
- package/skills/15_Others/neuroimaging-sample-size-calculator/SKILL.md +330 -0
- package/skills/15_Others/neuroimaging-sample-size-calculator/references/worked-examples.md +220 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# RSA Analysis Guide: Step-by-Step Workflow
|
|
2
|
+
|
|
3
|
+
This reference document supplements `SKILL.md` with a complete step-by-step workflow for representational similarity analysis (RSA), including RDM construction, model specification, noise ceiling computation, and visualization.
|
|
4
|
+
|
|
5
|
+
## Step-by-Step RSA Workflow
|
|
6
|
+
|
|
7
|
+
### Step 1: Estimate Condition-Specific Activity Patterns
|
|
8
|
+
|
|
9
|
+
**For fMRI:**
|
|
10
|
+
1. Run a general linear model (GLM) with one regressor per condition (beta-series or least-squares-separate approach)
|
|
11
|
+
2. Each condition yields a beta-weight map across voxels in an ROI
|
|
12
|
+
3. Use **least-squares-separate (LSS)** for single-trial estimates when computing trial-wise RDMs (Mumford et al., 2012)
|
|
13
|
+
4. Use **least-squares-all (LSA)** when you have a small number of conditions with many trials each
|
|
14
|
+
|
|
15
|
+
> **Domain judgment**: For single-trial estimation, LSS produces less biased estimates than LSA when trials are closely spaced in time, because including all regressors simultaneously leads to collinearity in the design matrix (Mumford et al., 2012).
|
|
16
|
+
|
|
17
|
+
**For EEG/MEG:**
|
|
18
|
+
1. Epoch data around stimulus onset; average trials within each condition
|
|
19
|
+
2. Use the spatial pattern at a specific time point, or average over a time window
|
|
20
|
+
3. For time-resolved RSA: compute RDM at each time point separately
|
|
21
|
+
|
|
22
|
+
### Step 2: Extract Patterns for the ROI or Brain Region
|
|
23
|
+
|
|
24
|
+
- **ROI approach**: Extract voxel/channel values for each condition from a predefined region
|
|
25
|
+
- **Searchlight RSA**: Compute RDMs in a local sphere around each voxel (same radius considerations as decoding searchlight: **3-4 voxels** for fMRI; Kriegeskorte et al., 2006)
|
|
26
|
+
- **Whole-brain RSA**: Use parcellation (e.g., Glasser atlas with 360 parcels) and compute one RDM per parcel
|
|
27
|
+
|
|
28
|
+
### Step 3: Construct the Neural RDM
|
|
29
|
+
|
|
30
|
+
#### Choosing a Distance Metric
|
|
31
|
+
|
|
32
|
+
| Metric | Formula | Bias | Scale | Best For |
|
|
33
|
+
|---|---|---|---|---|
|
|
34
|
+
| **Correlation distance** | 1 - Pearson(pattern_a, pattern_b) | Positively biased by noise | 0 to 2 | Exploratory RSA; comparing pattern shape |
|
|
35
|
+
| **Euclidean distance** | sqrt(sum((a - b)^2)) | Positively biased by noise | 0 to inf | When amplitude matters |
|
|
36
|
+
| **Crossnobis (cross-validated Mahalanobis)** | Multiply pattern differences across independent data partitions, with multivariate noise normalization | **Unbiased** (expected value = 0 under null) | -inf to inf | **Inferential statistics; model comparison** |
|
|
37
|
+
|
|
38
|
+
(Walther et al., 2016; Kriegeskorte & Diedrichsen, 2019)
|
|
39
|
+
|
|
40
|
+
#### Computing the Crossnobis Distance
|
|
41
|
+
|
|
42
|
+
The crossnobis estimator requires data from multiple independent partitions (e.g., fMRI runs):
|
|
43
|
+
|
|
44
|
+
1. Estimate condition-specific patterns separately for each run
|
|
45
|
+
2. Compute the residual covariance matrix from the GLM residuals (for noise normalization)
|
|
46
|
+
3. For each pair of conditions (i, j):
|
|
47
|
+
- Compute the pattern difference (beta_i - beta_j) in each run
|
|
48
|
+
- Multiply the pattern differences from different runs (cross-validated: never multiply a run's data with itself)
|
|
49
|
+
- Apply multivariate noise normalization (whiten using the residual covariance)
|
|
50
|
+
4. Average across all cross-validated run pairs
|
|
51
|
+
|
|
52
|
+
> **Domain judgment**: The cross-validation step ensures the estimator is unbiased. Without it, noise in the patterns inflates all pairwise distances by a positive amount proportional to the noise variance divided by the number of voxels. This bias makes it impossible to test whether two conditions are truly distinguishable (Walther et al., 2016).
|
|
53
|
+
|
|
54
|
+
#### Noise Normalization (Multivariate Whitening)
|
|
55
|
+
|
|
56
|
+
- Estimate the noise covariance matrix Sigma from GLM residuals
|
|
57
|
+
- Apply Sigma^(-1/2) to the pattern differences before computing distances
|
|
58
|
+
- This weights informative voxels (low noise correlation) more heavily than noisy or correlated voxels
|
|
59
|
+
- Improves reliability of RDMs substantially, especially for large ROIs (Walther et al., 2016)
|
|
60
|
+
|
|
61
|
+
### Step 4: Construct Model RDMs
|
|
62
|
+
|
|
63
|
+
Model RDMs encode your theoretical predictions about representational structure.
|
|
64
|
+
|
|
65
|
+
#### Common Model RDM Types
|
|
66
|
+
|
|
67
|
+
| Model Type | Construction | Example |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| **Categorical** | Binary: 0 for same category, 1 for different category | "Face vs. object" model: 0 within faces, 0 within objects, 1 between |
|
|
70
|
+
| **Feature-based** | Continuous distances from computational features | DNN layer activations; Gabor filter responses; semantic embedding distances |
|
|
71
|
+
| **Behavioral** | Distances derived from human similarity judgments | Multi-arrangement task (Kriegeskorte & Mur, 2012); pairwise similarity ratings |
|
|
72
|
+
| **Hierarchical** | Graded distances reflecting taxonomic depth | 0 within species, 0.5 within class, 1 across kingdoms |
|
|
73
|
+
| **Computational model** | Distances from the internal representations of a model | CNN layer RDMs; RNN hidden state RDMs; reinforcement learning value RDMs |
|
|
74
|
+
|
|
75
|
+
#### Constructing Model RDMs from Theoretical Predictions
|
|
76
|
+
|
|
77
|
+
1. **Define your stimulus set**: List all conditions (N conditions)
|
|
78
|
+
2. **For each pair of conditions**: Assign a predicted dissimilarity value
|
|
79
|
+
3. **Organize into an N x N symmetric matrix** with zeros on the diagonal
|
|
80
|
+
4. **Vectorize the lower triangle**: Extract the N*(N-1)/2 unique pairwise distances
|
|
81
|
+
|
|
82
|
+
> **Domain judgment**: Model RDMs should be constructed BEFORE looking at neural data. Constructing models post-hoc to match observed neural RDMs is circular (Kriegeskorte et al., 2009). Pre-register your model RDMs when possible.
|
|
83
|
+
|
|
84
|
+
### Step 5: Compare Neural RDMs to Model RDMs
|
|
85
|
+
|
|
86
|
+
#### Comparison Methods
|
|
87
|
+
|
|
88
|
+
| Method | Use When | Formula | Source |
|
|
89
|
+
|---|---|---|---|
|
|
90
|
+
| **Spearman rank correlation** | Default; robust to outliers and nonlinear monotonic relationships | rho(vectorized_brain_RDM, vectorized_model_RDM) | Nili et al., 2014 |
|
|
91
|
+
| **Pearson correlation** | When the linear relationship between model and brain distances is theoretically motivated | r(vectorized_brain_RDM, vectorized_model_RDM) | Kriegeskorte et al., 2008 |
|
|
92
|
+
| **Kendall tau-a** | For RDMs with many tied values (e.g., binary categorical models) | tau_a(vectorized_brain_RDM, vectorized_model_RDM) | Nili et al., 2014 |
|
|
93
|
+
| **Partial correlation** | When controlling for a confound model (e.g., low-level visual similarity) | partial_rho(brain, model_A \| model_B) | Kriegeskorte & Diedrichsen, 2019 |
|
|
94
|
+
| **Weighted regression** | Fitting multiple models simultaneously; estimating relative contributions | beta = (X'X)^{-1} X'y on vectorized RDMs | Kriegeskorte & Diedrichsen, 2019 |
|
|
95
|
+
|
|
96
|
+
#### Choosing Between Spearman and Pearson
|
|
97
|
+
|
|
98
|
+
- **Spearman** (default): Does not assume linearity between model and brain distances; only assumes a monotonic relationship. More robust to the arbitrary scaling of model predictions (Nili et al., 2014)
|
|
99
|
+
- **Pearson**: Appropriate when the model makes quantitative predictions about the magnitude of distances, not just their rank order
|
|
100
|
+
|
|
101
|
+
### Step 6: Statistical Inference
|
|
102
|
+
|
|
103
|
+
#### Permutation Test for Individual Model Significance
|
|
104
|
+
|
|
105
|
+
1. Permute condition labels **of the neural data** (not the model) to generate null RDMs
|
|
106
|
+
2. Recompute the correlation between each permuted neural RDM and the model RDM
|
|
107
|
+
3. Repeat **10,000 times** (Nili et al., 2014)
|
|
108
|
+
4. p-value = proportion of null correlations >= observed correlation
|
|
109
|
+
|
|
110
|
+
> **Domain judgment**: You must permute the condition labels (rows and columns of the RDM simultaneously), NOT individual entries of the RDM. Permuting entries destroys the distance-matrix structure and produces an invalid null distribution (Nili et al., 2014).
|
|
111
|
+
|
|
112
|
+
#### Noise Ceiling Computation
|
|
113
|
+
|
|
114
|
+
The noise ceiling bounds the best possible model fit given between-subject variability.
|
|
115
|
+
|
|
116
|
+
**Upper bound:**
|
|
117
|
+
1. For each subject, compute the correlation between that subject's RDM and the group-average RDM (including that subject)
|
|
118
|
+
2. Average across subjects
|
|
119
|
+
|
|
120
|
+
**Lower bound (preferred -- cross-validated):**
|
|
121
|
+
1. For each subject, compute the correlation between that subject's RDM and the group-average RDM **excluding** that subject
|
|
122
|
+
2. Average across subjects
|
|
123
|
+
|
|
124
|
+
(Nili et al., 2014)
|
|
125
|
+
|
|
126
|
+
**Interpretation:**
|
|
127
|
+
- A model whose fit falls within the noise ceiling explains as much representational variance as is possible given the noise in the data
|
|
128
|
+
- A model below the lower bound leaves systematic, explainable variance unaccounted for
|
|
129
|
+
- The gap between upper and lower bound reflects the degree of between-subject variability
|
|
130
|
+
|
|
131
|
+
#### Comparing Two Models
|
|
132
|
+
|
|
133
|
+
1. For each subject, compute the correlation of the brain RDM with Model A and with Model B
|
|
134
|
+
2. Compute the difference (corr_A - corr_B) for each subject
|
|
135
|
+
3. Test the group-level difference with a paired t-test or Wilcoxon signed-rank test
|
|
136
|
+
4. Alternatively, use a bootstrap test: resample subjects and test whether the difference in model fit is consistently positive or negative (Nili et al., 2014)
|
|
137
|
+
|
|
138
|
+
### Step 7: Visualize Results
|
|
139
|
+
|
|
140
|
+
#### RDM Visualization
|
|
141
|
+
|
|
142
|
+
- Display as a **color-coded matrix** (conditions x conditions) with an appropriate colormap (diverging for crossnobis, sequential for correlation distance)
|
|
143
|
+
- Order conditions meaningfully: group by category, sort by a relevant feature dimension
|
|
144
|
+
- Always include a **colorbar** with the distance metric labeled
|
|
145
|
+
- For crossnobis RDMs: use a diverging colormap centered at zero (e.g., blue-white-red) to highlight that negative values are meaningful
|
|
146
|
+
|
|
147
|
+
#### Multidimensional Scaling (MDS)
|
|
148
|
+
|
|
149
|
+
- Apply classical (metric) MDS to the RDM to project conditions into a 2D or 3D space
|
|
150
|
+
- Useful for visualizing cluster structure and gradients in the representation
|
|
151
|
+
- Report the stress value or proportion of variance explained by the MDS solution
|
|
152
|
+
- **Caution**: MDS is a visualization aid, not a statistical test. Do not draw inferential conclusions from MDS plots alone (Kriegeskorte et al., 2008)
|
|
153
|
+
|
|
154
|
+
#### Model Comparison Bar Plots
|
|
155
|
+
|
|
156
|
+
- Plot the correlation between each model RDM and the brain RDM (one bar per model)
|
|
157
|
+
- Include error bars (SEM across subjects or bootstrap confidence intervals)
|
|
158
|
+
- Overlay the noise ceiling as a shaded band
|
|
159
|
+
- Mark significant models and significant model differences
|
|
160
|
+
|
|
161
|
+
## Category-Level vs. Exemplar-Level RSA
|
|
162
|
+
|
|
163
|
+
### Category-Level Analysis
|
|
164
|
+
|
|
165
|
+
- Conditions represent categories (e.g., faces, houses, tools, animals)
|
|
166
|
+
- Typically **4-20 categories** with multiple exemplars per category
|
|
167
|
+
- RDM captures between-category representational distances
|
|
168
|
+
- Appropriate for: testing categorical organization (e.g., animate vs. inanimate distinction)
|
|
169
|
+
- **Limitation**: Cannot distinguish whether a region encodes the category boundary or continuous features that correlate with category membership
|
|
170
|
+
|
|
171
|
+
### Exemplar-Level Analysis
|
|
172
|
+
|
|
173
|
+
- Each condition is a unique stimulus (e.g., 96 individual object images)
|
|
174
|
+
- RDM captures fine-grained representational geometry
|
|
175
|
+
- Appropriate for: comparing neural representations to computational model layer representations (e.g., DNN layers)
|
|
176
|
+
- **Requirement**: Many more conditions (typically **48-96+**); each shown multiple times
|
|
177
|
+
- **Challenge**: Single-trial beta estimates are noisier; crossnobis estimator is essential to avoid bias (Walther et al., 2016)
|
|
178
|
+
|
|
179
|
+
> **Domain judgment**: Category-level RSA with few categories (e.g., 4) has very few unique distances in the RDM (only 6 for 4 categories), making model comparisons statistically weak. Exemplar-level designs with many conditions provide much more statistical power for RSA because the number of unique distances grows as N*(N-1)/2 (Kriegeskorte et al., 2008).
|
|
180
|
+
|
|
181
|
+
## Multi-Arrangement for Behavioral RDMs
|
|
182
|
+
|
|
183
|
+
### The Method
|
|
184
|
+
|
|
185
|
+
The multi-arrangement task (Kriegeskorte & Mur, 2012) efficiently measures perceived similarity among stimuli:
|
|
186
|
+
|
|
187
|
+
1. Participants view all stimuli on a computer screen and arrange them by perceived similarity (drag-and-drop)
|
|
188
|
+
2. Similar items are placed close together; dissimilar items far apart
|
|
189
|
+
3. The procedure adaptively selects subsets of stimuli for additional arrangements to improve estimation
|
|
190
|
+
4. Pairwise distances between stimulus positions are extracted and combined across arrangements
|
|
191
|
+
|
|
192
|
+
### Practical Parameters
|
|
193
|
+
|
|
194
|
+
- **Number of stimuli**: Works well with **12-96** stimuli (fewer than 12: too few distances; more than 96: too many items to arrange simultaneously)
|
|
195
|
+
- **Number of arrangements**: Typically **10-30** per participant; the algorithm adaptively selects informative subsets
|
|
196
|
+
- **Subset size per arrangement**: **6-12 stimuli** per arrangement screen (participant fatigue increases with larger subsets)
|
|
197
|
+
- **Duration**: Approximately **20-60 minutes** depending on stimulus set size
|
|
198
|
+
|
|
199
|
+
### When to Use Behavioral RDMs
|
|
200
|
+
|
|
201
|
+
- To test whether neural representations predict perceived similarity
|
|
202
|
+
- To bridge neural and behavioral levels of description (Kriegeskorte et al., 2008)
|
|
203
|
+
- As a model RDM alongside computational models to test which better explains neural data
|
|
204
|
+
|
|
205
|
+
## Using the RSA Toolbox (Python: rsatoolbox)
|
|
206
|
+
|
|
207
|
+
### Basic Workflow
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
import rsatoolbox
|
|
211
|
+
import numpy as np
|
|
212
|
+
|
|
213
|
+
# 1. Create dataset objects (one per subject/session)
|
|
214
|
+
# data: n_conditions x n_channels/voxels
|
|
215
|
+
# descriptors: condition labels
|
|
216
|
+
dataset = rsatoolbox.data.Dataset(
|
|
217
|
+
measurements=beta_patterns, # conditions x voxels
|
|
218
|
+
obs_descriptors={'stimulus': condition_labels}
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
# 2. Compute RDM
|
|
222
|
+
rdm = rsatoolbox.rdm.calc_rdm(
|
|
223
|
+
dataset,
|
|
224
|
+
method='crossnobis', # preferred for inference
|
|
225
|
+
descriptor='stimulus',
|
|
226
|
+
noise=noise_covariance # from GLM residuals
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
# 3. Define model RDMs
|
|
230
|
+
model_rdm = rsatoolbox.rdm.RDMs(
|
|
231
|
+
dissimilarities=model_distances, # vectorized lower triangle
|
|
232
|
+
rdm_descriptors={'name': 'my_model'}
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
# 4. Compare
|
|
236
|
+
result = rsatoolbox.rdm.compare(
|
|
237
|
+
rdm, model_rdm,
|
|
238
|
+
method='spearman' # or 'corr', 'kendall'
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
# 5. Noise ceiling
|
|
242
|
+
ceiling = rsatoolbox.inference.eval_fixed(
|
|
243
|
+
model_rdm, subject_rdms,
|
|
244
|
+
method='spearman'
|
|
245
|
+
)
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Key Function Parameters
|
|
249
|
+
|
|
250
|
+
| Function | Key Parameter | Recommended Value | Rationale |
|
|
251
|
+
|---|---|---|---|
|
|
252
|
+
| `calc_rdm` | `method` | `'crossnobis'` | Unbiased estimator (Walther et al., 2016) |
|
|
253
|
+
| `calc_rdm` | `noise` | GLM residual covariance | Multivariate noise normalization improves reliability |
|
|
254
|
+
| `compare` | `method` | `'spearman'` | Robust to nonlinear monotonic transforms (Nili et al., 2014) |
|
|
255
|
+
| `eval_fixed` | `method` | `'spearman'` | Consistent with comparison method |
|
|
256
|
+
|
|
257
|
+
## References
|
|
258
|
+
|
|
259
|
+
- Kriegeskorte, N., Goebel, R., & Bandettini, P. (2006). Information-based functional brain mapping. *PNAS*, 103(10), 3863-3868.
|
|
260
|
+
- Kriegeskorte, N., Mur, M., & Bandettini, P. (2008). Representational similarity analysis. *Front. Syst. Neurosci.*, 2, 4.
|
|
261
|
+
- Kriegeskorte, N., et al. (2009). Circular analysis in systems neuroscience. *Nat. Neurosci.*, 12(5), 535-540.
|
|
262
|
+
- Kriegeskorte, N., & Mur, M. (2012). Inverse MDS: Inferring dissimilarity structure from multiple item arrangements. *Front. Psychol.*, 3, 245.
|
|
263
|
+
- Kriegeskorte, N., & Diedrichsen, J. (2019). Peeling the onion of brain representations. *Annu. Rev. Neurosci.*, 42, 407-432.
|
|
264
|
+
- Mumford, J. A., Turner, B. O., Ashby, F. G., & Poldrack, R. A. (2012). Deconvolving BOLD activation in event-related designs for multivoxel pattern classification analyses. *NeuroImage*, 59(3), 2636-2643.
|
|
265
|
+
- Nili, H., et al. (2014). A toolbox for representational similarity analysis. *PLoS Comput. Biol.*, 10(4), e1003553.
|
|
266
|
+
- Walther, A., et al. (2016). Reliability of dissimilarity measures for multi-voxel pattern analysis. *NeuroImage*, 137, 188-200.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "pycortex-guide"
|
|
3
|
+
description: "Domain-validated guidance for cortical surface visualization and brain surface rendering of fMRI data using pycortex: data types (Volume, Vertex, Dataset), 2D cortical flatmaps, 3D WebGL brain viewers, volume-to-surface mapping, FreeSurfer/fMRIPrep integration, ROI management, and surface analysis. Use this skill whenever the user mentions pycortex, `import cortex`, cortical surfaces, brain flatmaps, WebGL brain viewers, cortical surface mapping, or wants to visualize neuroimaging data on the cortex, even if they don't explicitly name pycortex."
|
|
4
|
+
version: "1.0.0"
|
|
5
|
+
authors:
|
|
6
|
+
- "Claude (AI-assisted)"
|
|
7
|
+
review_status: "ai-generated"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Pycortex Guide
|
|
11
|
+
|
|
12
|
+
## Purpose
|
|
13
|
+
|
|
14
|
+
Encodes domain knowledge for using pycortex — a Python library for visualizing fMRI and volumetric neuroimaging data on cortical surfaces. Covers data creation, 2D flatmap rendering, interactive 3D WebGL viewers, volume-to-surface mapping, subject database management, FreeSurfer/fMRIPrep integration, and surface geometry analysis.
|
|
15
|
+
|
|
16
|
+
## When to Use This Skill
|
|
17
|
+
|
|
18
|
+
Activate when the user:
|
|
19
|
+
- Wants to visualize fMRI data on cortical surfaces
|
|
20
|
+
- Mentions pycortex, `import cortex`, flatmaps, or cortical surface visualization
|
|
21
|
+
- Needs to create Volume, Vertex, or Dataset objects for brain data
|
|
22
|
+
- Wants to generate 2D flatmaps or 3D interactive brain viewers
|
|
23
|
+
- Needs to import FreeSurfer or fMRIPrep subjects into pycortex
|
|
24
|
+
- Works with volume-to-surface mapping or cortical ROIs
|
|
25
|
+
- Needs to align functional data to anatomical surfaces
|
|
26
|
+
- Wants to compute surface properties (curvature, thickness, geodesic distance)
|
|
27
|
+
|
|
28
|
+
## Reference Files
|
|
29
|
+
|
|
30
|
+
| Topic | File | When to Read |
|
|
31
|
+
|-------|------|--------------|
|
|
32
|
+
| Data types | `references/dataset-types.md` | User creates Volume, Vertex, RGB, 2D, or Dataset objects |
|
|
33
|
+
| Visualization | `references/visualization.md` | User wants flatmaps, WebGL viewers, exports, or screenshots |
|
|
34
|
+
| Database & subjects | `references/database-subjects.md` | User manages subjects, surfaces, transforms, or masks |
|
|
35
|
+
| Mapping & transforms | `references/mapping-transforms.md` | User maps volume↔surface, aligns data, or works with transforms |
|
|
36
|
+
| FreeSurfer & fMRIPrep | `references/freesurfer-fmriprep.md` | User imports subjects from FreeSurfer or fMRIPrep |
|
|
37
|
+
| Surface analysis | `references/surface-analysis.md` | User computes curvature, geodesic distance, ROIs, or distortion |
|
|
38
|
+
| MNI & utilities | `references/mni-utils.md` | User transforms to/from MNI space or uses volume utilities |
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install -U setuptools wheel numpy cython
|
|
44
|
+
pip install -U pycortex
|
|
45
|
+
# With headless rendering support:
|
|
46
|
+
pip install -U 'pycortex[headless]'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Requirements: Python 3.10+, Linux/macOS only. Key dependencies: numpy, scipy, matplotlib, nibabel, h5py, tornado, shapely, lxml.
|
|
50
|
+
|
|
51
|
+
## Overview Pipeline
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
1. Import subject (FreeSurfer/fMRIPrep) → stored in cortex.db
|
|
55
|
+
2. Create data objects (Volume/Vertex) → wrap arrays with metadata
|
|
56
|
+
3. Visualize (quickflat / webgl / export) → 2D flatmaps or 3D viewers
|
|
57
|
+
4. Analyze surfaces (curvature, ROIs) → surface geometry tools
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Quick Start
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
import cortex
|
|
64
|
+
|
|
65
|
+
# Create a random volume for demo subject "S1" with transform "fullhead"
|
|
66
|
+
vol = cortex.Volume.random("S1", "fullhead")
|
|
67
|
+
|
|
68
|
+
# 2D flatmap
|
|
69
|
+
fig = cortex.quickshow(vol, with_curvature=True, with_rois=True)
|
|
70
|
+
fig.savefig("flatmap.png")
|
|
71
|
+
|
|
72
|
+
# Interactive 3D viewer
|
|
73
|
+
cortex.webshow(vol)
|
|
74
|
+
|
|
75
|
+
# Create volume from your own data (3D numpy array)
|
|
76
|
+
import numpy as np
|
|
77
|
+
data = np.random.randn(31, 100, 100) # must match transform shape
|
|
78
|
+
vol = cortex.Volume(data, "S1", "fullhead", cmap="RdBu_r", vmin=-2, vmax=2)
|
|
79
|
+
cortex.quickshow(vol)
|
|
80
|
+
|
|
81
|
+
# Save/load datasets
|
|
82
|
+
ds = cortex.Dataset(my_map=vol)
|
|
83
|
+
ds.save("results.hdf")
|
|
84
|
+
ds_loaded = cortex.load("results.hdf")
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Key Data Types
|
|
88
|
+
|
|
89
|
+
| Class | Description | Key Args |
|
|
90
|
+
|-------|-------------|----------|
|
|
91
|
+
| `Volume` | Volumetric data (3D/4D) | `data, subject, xfmname, cmap, vmin, vmax` |
|
|
92
|
+
| `Vertex` | Surface vertex data (1D/2D) | `data, subject, cmap, vmin, vmax` |
|
|
93
|
+
| `VolumeRGB` | RGB per voxel | `red, green, blue, subject, xfmname, alpha` |
|
|
94
|
+
| `VertexRGB` | RGB per vertex | `red, green, blue, subject, alpha` |
|
|
95
|
+
| `Volume2D` | Two volumes, 2D colormap | `dim1, dim2, subject, xfmname, vmin, vmax, vmin2, vmax2` |
|
|
96
|
+
| `Vertex2D` | Two vertex maps, 2D colormap | `dim1, dim2, subject, vmin, vmax, vmin2, vmax2` |
|
|
97
|
+
| `Dataset` | Container for multiple views | `**named_dataviews` |
|
|
98
|
+
|
|
99
|
+
## Key Visualization Functions
|
|
100
|
+
|
|
101
|
+
| Function | Description |
|
|
102
|
+
|----------|-------------|
|
|
103
|
+
| `cortex.quickshow(data, ...)` | 2D flatmap → matplotlib Figure |
|
|
104
|
+
| `cortex.quickflat.make_png(fname, data, ...)` | Save flatmap as PNG |
|
|
105
|
+
| `cortex.quickflat.make_svg(fname, data, ...)` | Save flatmap as SVG |
|
|
106
|
+
| `cortex.quickflat.make_gif(fname, volumes, ...)` | Animated GIF from volumes |
|
|
107
|
+
| `cortex.webshow(data, ...)` | Interactive 3D WebGL viewer |
|
|
108
|
+
| `cortex.webgl.make_static(path, data, ...)` | Static HTML 3D viewer |
|
|
109
|
+
| `cortex.export.save_3d_views(vol, ...)` | Multi-angle PNG exports |
|
|
110
|
+
| `cortex.export.plot_panels(vol, panels, ...)` | Multi-panel figure |
|
|
111
|
+
|
|
112
|
+
## Common Pitfalls
|
|
113
|
+
|
|
114
|
+
1. Volume data shape must match the transform dimensions in the database. Use `cortex.db.get_xfm(subject, xfmname)` to check expected shape.
|
|
115
|
+
2. Subject and transform names must exist in `cortex.db` before creating Volume objects. Import from FreeSurfer first.
|
|
116
|
+
3. `cortex.quickshow` is an alias for `cortex.quickflat.make_figure` — they are the same function.
|
|
117
|
+
4. Vertex data length must match total vertex count (left + right hemisphere). Single-hemisphere data is auto-padded with zeros.
|
|
118
|
+
5. `vmin`/`vmax` default to 1st/99th percentile of data. Always set explicitly for consistent colorbars across subjects.
|
|
119
|
+
6. WebGL viewer (`webshow`) starts a Tornado server — it blocks in scripts. Use in IPython/Jupyter or set `autoclose=True`.
|
|
120
|
+
7. The pycortex filestore path is set in `cortex.options.config`. Check with `cortex.database.default_filestore`.
|
|
121
|
+
8. For headless rendering (no display), install with `pip install 'pycortex[headless]'` and use `cortex.export.save_3d_views(..., headless=True)`.
|
|
122
|
+
9. `cortex.db` is a singleton — all operations share the same database instance.
|
|
123
|
+
10. When saving datasets with `pack=True`, subject geometry and transforms are embedded in the HDF5 file for portability.
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# Database & Subjects Reference
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
1. [Database Singleton (cortex.db)](#database-singleton)
|
|
5
|
+
2. [Subject Management](#subject-management)
|
|
6
|
+
3. [Surfaces](#surfaces)
|
|
7
|
+
4. [Transforms](#transforms)
|
|
8
|
+
5. [Masks](#masks)
|
|
9
|
+
6. [ROI Storage](#roi-storage)
|
|
10
|
+
7. [Configuration](#configuration)
|
|
11
|
+
|
|
12
|
+
## Database Singleton
|
|
13
|
+
|
|
14
|
+
`cortex.db` is the singleton `Database` object providing access to all stored subjects, surfaces, transforms, and masks.
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
import cortex
|
|
18
|
+
|
|
19
|
+
# Check filestore location
|
|
20
|
+
print(cortex.database.default_filestore)
|
|
21
|
+
|
|
22
|
+
# List subjects
|
|
23
|
+
print(dir(cortex.db))
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Database File Structure
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
filestore/
|
|
30
|
+
└── {subject}/
|
|
31
|
+
├── surfaces/
|
|
32
|
+
│ ├── {name}_{hemisphere}.npz # Surface geometry files
|
|
33
|
+
│ └── ...
|
|
34
|
+
├── transforms/
|
|
35
|
+
│ └── {xfmname}/
|
|
36
|
+
│ ├── matrices.xfm # Affine transform
|
|
37
|
+
│ └── reference.nii.gz # Reference volume
|
|
38
|
+
├── rois.svg # ROI definitions
|
|
39
|
+
├── overlays.svg # Overlay definitions
|
|
40
|
+
└── warning.txt # Optional subject notes
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Subject Management
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
# Access subject database
|
|
47
|
+
subj_db = cortex.db.get_paths("S1")
|
|
48
|
+
# Returns dict with keys: 'surfs', 'xfms', 'anatomicals', etc.
|
|
49
|
+
|
|
50
|
+
# SubjectDB provides attribute access
|
|
51
|
+
subj = cortex.database.SubjectDB("S1")
|
|
52
|
+
subj.transforms # XfmDB object
|
|
53
|
+
subj.surfaces # SurfaceDB object
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Surfaces
|
|
57
|
+
|
|
58
|
+
### get_surf
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
cortex.db.get_surf(subject, type, hemisphere="both", merge=False, nudge=False)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
| Parameter | Type | Default | Description |
|
|
65
|
+
|-----------|------|---------|-------------|
|
|
66
|
+
| `subject` | str | required | Subject name |
|
|
67
|
+
| `type` | str | required | Surface type |
|
|
68
|
+
| `hemisphere` | str | "both" | "left", "right", or "both" |
|
|
69
|
+
| `merge` | bool | False | Merge hemispheres into single array |
|
|
70
|
+
| `nudge` | bool | False | Nudge hemispheres apart for display |
|
|
71
|
+
|
|
72
|
+
Surface types: `"fiducial"`, `"inflated"`, `"flat"`, `"pial"`, `"wm"`, `"pia"`
|
|
73
|
+
|
|
74
|
+
Returns: `(pts, polys)` — vertices array `(N, 3)` and faces array `(F, 3)`.
|
|
75
|
+
If `hemisphere="both"` and `merge=False`, returns `((left_pts, left_polys), (right_pts, right_polys))`.
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
# Get both hemispheres merged
|
|
79
|
+
pts, polys = cortex.db.get_surf("S1", "fiducial", merge=True)
|
|
80
|
+
|
|
81
|
+
# Get left hemisphere only
|
|
82
|
+
left_pts, left_polys = cortex.db.get_surf("S1", "fiducial", "left")
|
|
83
|
+
|
|
84
|
+
# Get inflated surface
|
|
85
|
+
pts, polys = cortex.db.get_surf("S1", "inflated", merge=True, nudge=True)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Transforms
|
|
89
|
+
|
|
90
|
+
### get_xfm
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
cortex.db.get_xfm(subject, xfmname, xfmtype="coord")
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
| Parameter | Type | Default | Description |
|
|
97
|
+
|-----------|------|---------|-------------|
|
|
98
|
+
| `xfmtype` | str | "coord" | Transform type: "coord", "magnet", "raw" |
|
|
99
|
+
|
|
100
|
+
Returns a `Transform` object.
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
xfm = cortex.db.get_xfm("S1", "fullhead")
|
|
104
|
+
print(xfm.shape) # Expected volume shape
|
|
105
|
+
|
|
106
|
+
# Save a new transform
|
|
107
|
+
xfm.save("S1", "my_new_xfm")
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### save_xfm
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
cortex.db.save_xfm(subject, name, xfm, xfmtype="coord", reference=None)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Masks
|
|
117
|
+
|
|
118
|
+
Masks define which voxels are included in analyses. Stored per subject/transform.
|
|
119
|
+
|
|
120
|
+
### get_mask
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
cortex.db.get_mask(subject, xfmname, type="thick")
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
| Type | Description |
|
|
127
|
+
|------|-------------|
|
|
128
|
+
| `"thick"` | Thick cortical ribbon mask (default) |
|
|
129
|
+
| `"thin"` | Thin cortical ribbon mask |
|
|
130
|
+
| `"nearest"` | Nearest-neighbor mask |
|
|
131
|
+
|
|
132
|
+
Returns: 3D boolean array matching transform shape.
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
mask = cortex.db.get_mask("S1", "fullhead", "thick")
|
|
136
|
+
n_voxels = mask.sum()
|
|
137
|
+
# Use mask with Volume
|
|
138
|
+
masked_data = np.random.randn(n_voxels)
|
|
139
|
+
vol = cortex.Volume(masked_data, "S1", "fullhead", mask=mask)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## ROI Storage
|
|
143
|
+
|
|
144
|
+
ROIs are stored as SVG files in the subject directory.
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
# Get ROI vertices
|
|
148
|
+
roi_verts = cortex.db.get_overlay("S1")
|
|
149
|
+
# Returns SVGOverlay object
|
|
150
|
+
|
|
151
|
+
# Get specific ROI vertex indices
|
|
152
|
+
from cortex.utils import get_roi_verts
|
|
153
|
+
roi_dict = get_roi_verts("S1", roi="V1") # dict: {"V1": array_of_vertex_indices}
|
|
154
|
+
|
|
155
|
+
# Get all ROIs
|
|
156
|
+
all_rois = get_roi_verts("S1") # dict of all ROI names → vertex arrays
|
|
157
|
+
|
|
158
|
+
# Get ROI masks for volume data
|
|
159
|
+
from cortex.utils import get_roi_mask
|
|
160
|
+
roi_masks = get_roi_mask("S1", "fullhead", roi="V1")
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Configuration
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
import cortex
|
|
167
|
+
|
|
168
|
+
# View current config
|
|
169
|
+
print(cortex.options.config.get("basic", "filestore"))
|
|
170
|
+
|
|
171
|
+
# Config file location
|
|
172
|
+
print(cortex.options.usercfg)
|
|
173
|
+
|
|
174
|
+
# Key config sections:
|
|
175
|
+
# [basic] filestore = path to subject database
|
|
176
|
+
# [webgl] colormaps = path to colormap files
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Default config is at `cortex/defaults.cfg`. User overrides in `~/.config/pycortex/options.cfg`.
|