@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,259 @@
|
|
|
1
|
+
# Preprocessing Reference
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
1. [Filtering](#filtering)
|
|
5
|
+
2. [ICA Artifact Removal](#ica-artifact-removal)
|
|
6
|
+
3. [Automated Artifact Detection](#automated-artifact-detection)
|
|
7
|
+
4. [Bad Channel Handling](#bad-channel-handling)
|
|
8
|
+
5. [Re-referencing](#re-referencing)
|
|
9
|
+
6. [Maxwell Filtering (MEG)](#maxwell-filtering-meg)
|
|
10
|
+
7. [Current Source Density (CSD)](#current-source-density)
|
|
11
|
+
8. [EOG/ECG Processing](#eogecg-processing)
|
|
12
|
+
9. [fNIRS Preprocessing](#fnirs-preprocessing)
|
|
13
|
+
10. [iEEG Preprocessing](#ieeg-preprocessing)
|
|
14
|
+
11. [Eye-tracking Preprocessing](#eye-tracking-preprocessing)
|
|
15
|
+
12. [Annotations](#annotations)
|
|
16
|
+
|
|
17
|
+
## Filtering
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
# Bandpass
|
|
21
|
+
raw.filter(l_freq=0.1, h_freq=40.) # ERP standard (Luck, 2014)
|
|
22
|
+
raw.filter(l_freq=1., h_freq=100.) # time-frequency / ICA fitting
|
|
23
|
+
|
|
24
|
+
# Highpass only
|
|
25
|
+
raw.filter(l_freq=1., h_freq=None)
|
|
26
|
+
|
|
27
|
+
# Lowpass only
|
|
28
|
+
raw.filter(l_freq=None, h_freq=40.)
|
|
29
|
+
|
|
30
|
+
# Notch filter (line noise)
|
|
31
|
+
raw.notch_filter(freqs=[50, 100, 150]) # 50 Hz regions
|
|
32
|
+
raw.notch_filter(freqs=[60, 120, 180]) # 60 Hz regions
|
|
33
|
+
|
|
34
|
+
# Key parameters
|
|
35
|
+
raw.filter(l_freq=0.1, h_freq=40.,
|
|
36
|
+
method='fir', # 'fir' (default) or 'iir'
|
|
37
|
+
fir_design='firwin', # 'firwin' (default) or 'firwin2'
|
|
38
|
+
phase='zero', # 'zero' (default), 'zero-double', 'minimum'
|
|
39
|
+
l_trans_bandwidth=0.1, # transition bandwidth (Hz)
|
|
40
|
+
h_trans_bandwidth=10.)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## ICA Artifact Removal
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
# Initialize
|
|
47
|
+
ica = mne.preprocessing.ICA(
|
|
48
|
+
n_components=20, # int or float (0-1 for variance explained)
|
|
49
|
+
method='fastica', # 'fastica' (default), 'picard', 'infomax'
|
|
50
|
+
random_state=97,
|
|
51
|
+
max_iter=800 # or 'auto'
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
# Fit (on 1 Hz highpass filtered data)
|
|
55
|
+
filt_raw = raw.copy().filter(l_freq=1., h_freq=None)
|
|
56
|
+
ica.fit(filt_raw)
|
|
57
|
+
# or: ica.fit(epochs) # can also fit on epochs
|
|
58
|
+
|
|
59
|
+
# Automatic artifact detection
|
|
60
|
+
eog_idx, eog_scores = ica.find_bads_eog(raw)
|
|
61
|
+
ecg_idx, ecg_scores = ica.find_bads_ecg(raw, method='correlation', threshold='auto')
|
|
62
|
+
muscle_idx, muscle_scores = ica.find_bads_muscle(raw)
|
|
63
|
+
|
|
64
|
+
# Visual inspection
|
|
65
|
+
ica.plot_components() # topographies of all components
|
|
66
|
+
ica.plot_sources(raw) # time courses
|
|
67
|
+
ica.plot_properties(raw, picks=eog_idx) # detailed per-component view
|
|
68
|
+
ica.plot_scores(eog_scores) # correlation scores
|
|
69
|
+
ica.plot_overlay(raw, exclude=eog_idx) # before/after overlay
|
|
70
|
+
|
|
71
|
+
# Apply
|
|
72
|
+
ica.exclude = eog_idx + ecg_idx
|
|
73
|
+
ica.apply(raw) # modifies in-place
|
|
74
|
+
|
|
75
|
+
# Save/load
|
|
76
|
+
ica.save('my-ica.fif')
|
|
77
|
+
ica = mne.preprocessing.read_ica('my-ica.fif')
|
|
78
|
+
|
|
79
|
+
# Cross-subject template matching
|
|
80
|
+
from mne.preprocessing import corrmap
|
|
81
|
+
corrmap(icas_list, template=(0, eog_idx[0]), threshold=0.9, label='blink')
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Automated Artifact Detection
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
# Annotate high-amplitude segments
|
|
88
|
+
annot, bads = mne.preprocessing.annotate_amplitude(
|
|
89
|
+
raw, peak=dict(eeg=200e-6), flat=dict(eeg=1e-6))
|
|
90
|
+
raw.set_annotations(raw.annotations + annot)
|
|
91
|
+
|
|
92
|
+
# Annotate muscle artifacts
|
|
93
|
+
annot, scores = mne.preprocessing.annotate_muscle_zscore(
|
|
94
|
+
raw, threshold=5, ch_type='eeg')
|
|
95
|
+
|
|
96
|
+
# Annotate breaks in recording
|
|
97
|
+
annot = mne.preprocessing.annotate_break(raw, min_break_duration=15.)
|
|
98
|
+
|
|
99
|
+
# Annotate movement (MEG with cHPI)
|
|
100
|
+
annot = mne.preprocessing.annotate_movement(raw, pos, rotation_velocity_limit=5.)
|
|
101
|
+
|
|
102
|
+
# Detect bad channels (Local Outlier Factor)
|
|
103
|
+
bads, scores = mne.preprocessing.find_bad_channels_lof(raw)
|
|
104
|
+
|
|
105
|
+
# Detect bad channels (Maxwell filtering, MEG only)
|
|
106
|
+
noisy, flat = mne.preprocessing.find_bad_channels_maxwell(raw)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Bad Channel Handling
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
# Mark bad channels
|
|
113
|
+
raw.info['bads'] = ['EEG 053', 'MEG 2443']
|
|
114
|
+
raw.info['bads'].extend(['EEG 001'])
|
|
115
|
+
|
|
116
|
+
# Interpolate
|
|
117
|
+
raw.interpolate_bads() # spherical spline for EEG, field interpolation for MEG
|
|
118
|
+
|
|
119
|
+
# Detect bridged electrodes
|
|
120
|
+
bridged, ed_matrix = mne.preprocessing.compute_bridged_electrodes(raw)
|
|
121
|
+
mne.preprocessing.interpolate_bridged_electrodes(raw, bridged)
|
|
122
|
+
|
|
123
|
+
# Equalize bad channels across subjects (for group analysis)
|
|
124
|
+
mne.preprocessing.equalize_bads(raws_list)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Re-referencing
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
# Average reference
|
|
131
|
+
raw.set_eeg_reference('average')
|
|
132
|
+
|
|
133
|
+
# Specific channels
|
|
134
|
+
raw.set_eeg_reference(['M1', 'M2']) # mastoid reference
|
|
135
|
+
raw.set_eeg_reference(['TP9', 'TP10']) # linked earlobes
|
|
136
|
+
|
|
137
|
+
# REST reference (Reference Electrode Standardization Technique)
|
|
138
|
+
raw.set_eeg_reference('REST', forward=fwd)
|
|
139
|
+
|
|
140
|
+
# Projection-based (add as projector, don't modify data)
|
|
141
|
+
raw.set_eeg_reference('average', projection=True)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Maxwell Filtering (MEG)
|
|
145
|
+
|
|
146
|
+
Signal Space Separation for MEG denoising:
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
raw_sss = mne.preprocessing.maxwell_filter(
|
|
150
|
+
raw,
|
|
151
|
+
origin='auto', # head origin
|
|
152
|
+
int_order=8, # internal expansion order
|
|
153
|
+
ext_order=3, # external expansion order
|
|
154
|
+
st_duration=10., # tSSS buffer duration (None for SSS only)
|
|
155
|
+
st_correlation=0.98, # tSSS correlation threshold
|
|
156
|
+
coord_frame='head', # coordinate frame
|
|
157
|
+
calibration=cal_fname, # fine calibration file
|
|
158
|
+
cross_talk=ct_fname # cross-talk correction file
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
# Prepare empty room data for noise covariance
|
|
162
|
+
raw_er = mne.preprocessing.maxwell_filter_prepare_emptyroom(raw_er, raw)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Current Source Density
|
|
166
|
+
|
|
167
|
+
Surface Laplacian for EEG:
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
raw_csd = mne.preprocessing.compute_current_source_density(raw)
|
|
171
|
+
epochs_csd = mne.preprocessing.compute_current_source_density(epochs)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## EOG/ECG Processing
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
# Create artifact epochs
|
|
178
|
+
eog_epochs = mne.preprocessing.create_eog_epochs(raw, ch_name='EOG 061')
|
|
179
|
+
ecg_epochs = mne.preprocessing.create_ecg_epochs(raw)
|
|
180
|
+
|
|
181
|
+
# Find events
|
|
182
|
+
eog_events = mne.preprocessing.find_eog_events(raw)
|
|
183
|
+
ecg_events = mne.preprocessing.find_ecg_events(raw)
|
|
184
|
+
|
|
185
|
+
# SSP projectors
|
|
186
|
+
projs_eog, _ = mne.preprocessing.compute_proj_eog(raw, n_eeg=1)
|
|
187
|
+
projs_ecg, _ = mne.preprocessing.compute_proj_ecg(raw, n_eeg=1)
|
|
188
|
+
raw.add_proj(projs_eog + projs_ecg)
|
|
189
|
+
raw.apply_proj()
|
|
190
|
+
|
|
191
|
+
# EOG regression (alternative to ICA)
|
|
192
|
+
model = mne.preprocessing.EOGRegression(picks='eeg', picks_artifact='eog')
|
|
193
|
+
model.fit(raw)
|
|
194
|
+
raw_clean = model.apply(raw)
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## fNIRS Preprocessing
|
|
198
|
+
|
|
199
|
+
```python
|
|
200
|
+
from mne.preprocessing.nirs import (
|
|
201
|
+
optical_density, beer_lambert_law, scalp_coupling_index,
|
|
202
|
+
short_channel_regression, temporal_derivative_distribution_repair
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
# Convert to optical density
|
|
206
|
+
raw_od = optical_density(raw)
|
|
207
|
+
|
|
208
|
+
# Scalp coupling index (quality metric)
|
|
209
|
+
sci = scalp_coupling_index(raw_od)
|
|
210
|
+
raw_od.info['bads'] = [ch for ci, ch in zip(sci, raw_od.ch_names) if ci < 0.5]
|
|
211
|
+
|
|
212
|
+
# Short channel regression
|
|
213
|
+
raw_od = short_channel_regression(raw_od)
|
|
214
|
+
|
|
215
|
+
# Convert to hemoglobin concentration
|
|
216
|
+
raw_haemo = beer_lambert_law(raw_od, ppf=0.1)
|
|
217
|
+
|
|
218
|
+
# TDDR (motion artifact correction)
|
|
219
|
+
raw_haemo = temporal_derivative_distribution_repair(raw_haemo)
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## iEEG Preprocessing
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
from mne.preprocessing.ieeg import project_sensors_onto_brain
|
|
226
|
+
|
|
227
|
+
# Project electrode contacts onto brain surface
|
|
228
|
+
pos_corrected = project_sensors_onto_brain(
|
|
229
|
+
info, trans, subject, subjects_dir=subjects_dir)
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Eye-tracking Preprocessing
|
|
233
|
+
|
|
234
|
+
```python
|
|
235
|
+
from mne.preprocessing.eyetracking import (
|
|
236
|
+
read_eyelink_calibration, interpolate_blinks, set_channel_types_eyetrack
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
cals = read_eyelink_calibration(raw_et)
|
|
240
|
+
raw_et = interpolate_blinks(raw_et, buffer=(0.05, 0.2))
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Annotations
|
|
244
|
+
|
|
245
|
+
```python
|
|
246
|
+
# Add annotations
|
|
247
|
+
raw.annotations.append(onset=5.0, duration=1.0, description='bad_segment')
|
|
248
|
+
|
|
249
|
+
# Read/write
|
|
250
|
+
annot = mne.read_annotations('annotations.fif')
|
|
251
|
+
raw.set_annotations(annot)
|
|
252
|
+
raw.annotations.save('annotations.fif')
|
|
253
|
+
|
|
254
|
+
# Mark bad segments interactively
|
|
255
|
+
raw.plot() # click and drag to mark bad segments
|
|
256
|
+
|
|
257
|
+
# Convert annotations to events
|
|
258
|
+
events, event_id = mne.events_from_annotations(raw)
|
|
259
|
+
```
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Simulation Reference
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
1. [Creating Objects from Arrays](#from-arrays)
|
|
5
|
+
2. [Simulating Source Activity](#source-activity)
|
|
6
|
+
3. [Simulating Raw Data](#raw-data)
|
|
7
|
+
4. [Simulating Evoked Responses](#evoked)
|
|
8
|
+
5. [Adding Artifacts](#artifacts)
|
|
9
|
+
6. [Adding Noise](#noise)
|
|
10
|
+
7. [SourceSimulator Class](#source-simulator)
|
|
11
|
+
8. [Simulation Metrics](#metrics)
|
|
12
|
+
|
|
13
|
+
## Creating Objects from Arrays
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
import mne
|
|
17
|
+
import numpy as np
|
|
18
|
+
|
|
19
|
+
# Create Info
|
|
20
|
+
info = mne.create_info(ch_names=['Fz', 'Cz', 'Pz'], sfreq=256., ch_types='eeg')
|
|
21
|
+
info.set_montage('standard_1020')
|
|
22
|
+
|
|
23
|
+
# RawArray
|
|
24
|
+
data = np.random.randn(3, 10000) # (n_channels, n_times)
|
|
25
|
+
raw = mne.io.RawArray(data, info)
|
|
26
|
+
|
|
27
|
+
# EpochsArray
|
|
28
|
+
epochs_data = np.random.randn(50, 3, 128) # (n_epochs, n_channels, n_times)
|
|
29
|
+
events = np.column_stack([np.arange(0, 50*128, 128), np.zeros(50, int), np.ones(50, int)])
|
|
30
|
+
epochs = mne.EpochsArray(epochs_data, info, events, tmin=-0.2, event_id={'stim': 1})
|
|
31
|
+
|
|
32
|
+
# EvokedArray
|
|
33
|
+
evoked_data = np.random.randn(3, 128) # (n_channels, n_times)
|
|
34
|
+
evoked = mne.EvokedArray(evoked_data, info, tmin=-0.2)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Simulating Source Activity
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from mne.simulation import simulate_stc, simulate_sparse_stc
|
|
41
|
+
|
|
42
|
+
# Dense source simulation
|
|
43
|
+
stc = simulate_stc(src, labels=[label_lh, label_rh],
|
|
44
|
+
stc_data=np.array([[1, 1, 0], [0, 1, 1]]),
|
|
45
|
+
tmin=0, tstep=1./info['sfreq'])
|
|
46
|
+
|
|
47
|
+
# Sparse source simulation (few active dipoles)
|
|
48
|
+
stc = simulate_sparse_stc(src, n_dipoles=2, times=times,
|
|
49
|
+
data_fun=lambda t: 1e-9 * np.sin(20 * 2 * np.pi * t))
|
|
50
|
+
|
|
51
|
+
# Select source in label
|
|
52
|
+
from mne.simulation import select_source_in_label
|
|
53
|
+
lh_vertno, rh_vertno = select_source_in_label(src, label, location='center')
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Simulating Raw Data
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from mne.simulation import simulate_raw, SourceSimulator
|
|
60
|
+
|
|
61
|
+
# Simple: from source time course + forward model
|
|
62
|
+
raw_sim = simulate_raw(info, stc=stc, forward=fwd)
|
|
63
|
+
|
|
64
|
+
# Complex: using SourceSimulator
|
|
65
|
+
source_sim = SourceSimulator(src, tstep=1./info['sfreq'])
|
|
66
|
+
source_sim.add_data(label, waveform, events)
|
|
67
|
+
raw_sim = simulate_raw(info, source_sim, forward=fwd)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Simulating Evoked Responses
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from mne.simulation import simulate_evoked
|
|
74
|
+
|
|
75
|
+
evoked_sim = simulate_evoked(fwd, stc, info,
|
|
76
|
+
cov=noise_cov, # noise covariance
|
|
77
|
+
nave=100, # number of averages
|
|
78
|
+
random_state=42)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Adding Artifacts
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from mne.simulation import add_ecg, add_eog
|
|
85
|
+
|
|
86
|
+
# Add heartbeat artifact
|
|
87
|
+
raw_sim = add_ecg(raw_sim)
|
|
88
|
+
|
|
89
|
+
# Add eye blink artifact
|
|
90
|
+
raw_sim = add_eog(raw_sim)
|
|
91
|
+
|
|
92
|
+
# Add cHPI signals (MEG)
|
|
93
|
+
from mne.simulation import add_chpi
|
|
94
|
+
raw_sim = add_chpi(raw_sim, head_pos=head_pos)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Adding Noise
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from mne.simulation import add_noise
|
|
101
|
+
|
|
102
|
+
# From covariance
|
|
103
|
+
add_noise(raw_sim, cov=noise_cov, random_state=42)
|
|
104
|
+
add_noise(evoked_sim, cov=noise_cov, random_state=42)
|
|
105
|
+
|
|
106
|
+
# Ad-hoc covariance
|
|
107
|
+
cov = mne.make_ad_hoc_cov(info)
|
|
108
|
+
add_noise(raw_sim, cov, random_state=42)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## SourceSimulator Class
|
|
112
|
+
|
|
113
|
+
For complex experimental designs with multiple conditions:
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from mne.simulation import SourceSimulator
|
|
117
|
+
|
|
118
|
+
source_sim = SourceSimulator(src, tstep=1./info['sfreq'])
|
|
119
|
+
|
|
120
|
+
# Add condition 1: auditory in left hemisphere
|
|
121
|
+
waveform_aud = 1e-9 * np.sin(2 * np.pi * 10 * times)
|
|
122
|
+
source_sim.add_data(label_auditory, waveform_aud, events_aud)
|
|
123
|
+
|
|
124
|
+
# Add condition 2: visual in right hemisphere
|
|
125
|
+
waveform_vis = 1e-9 * np.cos(2 * np.pi * 15 * times)
|
|
126
|
+
source_sim.add_data(label_visual, waveform_vis, events_vis)
|
|
127
|
+
|
|
128
|
+
# Get source estimate
|
|
129
|
+
stc = source_sim.get_stc()
|
|
130
|
+
|
|
131
|
+
# Get stimulus channel
|
|
132
|
+
stim_data = source_sim.get_stim_channel()
|
|
133
|
+
|
|
134
|
+
# Properties
|
|
135
|
+
source_sim.duration
|
|
136
|
+
source_sim.n_times
|
|
137
|
+
|
|
138
|
+
# Generate raw
|
|
139
|
+
raw_sim = simulate_raw(info, source_sim, forward=fwd)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Simulation Metrics
|
|
143
|
+
|
|
144
|
+
Compare simulated ground truth with estimated source activity:
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
from mne.simulation.metrics import (
|
|
148
|
+
cosine_score,
|
|
149
|
+
region_localization_error,
|
|
150
|
+
f1_score,
|
|
151
|
+
precision_score,
|
|
152
|
+
recall_score,
|
|
153
|
+
roc_auc_score,
|
|
154
|
+
spatial_deviation_error,
|
|
155
|
+
peak_position_error
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
# Cosine similarity (0=orthogonal, 1=identical)
|
|
159
|
+
score = cosine_score(stc_true, stc_estimated)
|
|
160
|
+
|
|
161
|
+
# Region localization error (mm)
|
|
162
|
+
rle = region_localization_error(stc_true, stc_estimated, src)
|
|
163
|
+
|
|
164
|
+
# Classification metrics (after binarization)
|
|
165
|
+
f1 = f1_score(stc_true, stc_estimated, threshold='90%')
|
|
166
|
+
prec = precision_score(stc_true, stc_estimated, threshold='90%')
|
|
167
|
+
rec = recall_score(stc_true, stc_estimated, threshold='90%')
|
|
168
|
+
auc = roc_auc_score(stc_true, stc_estimated)
|
|
169
|
+
|
|
170
|
+
# Spatial spread metrics
|
|
171
|
+
sd = spatial_deviation_error(stc_true, stc_estimated, src, threshold='50%')
|
|
172
|
+
ppe = peak_position_error(stc_true, stc_estimated, src)
|
|
173
|
+
```
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# Source Localization Reference
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
1. [Source Space Setup](#source-space)
|
|
5
|
+
2. [BEM Model](#bem)
|
|
6
|
+
3. [Forward Solution](#forward)
|
|
7
|
+
4. [Noise Covariance](#noise-covariance)
|
|
8
|
+
5. [Minimum Norm Estimates](#minimum-norm)
|
|
9
|
+
6. [Beamformers](#beamformers)
|
|
10
|
+
7. [Dipole Fitting](#dipole-fitting)
|
|
11
|
+
8. [Template MRI (fsaverage)](#template-mri)
|
|
12
|
+
9. [Source Estimate Operations](#stc-operations)
|
|
13
|
+
|
|
14
|
+
## Source Space
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
# Surface source space
|
|
18
|
+
src = mne.setup_source_space(subject, spacing='oct6', subjects_dir=subjects_dir)
|
|
19
|
+
# spacing options:
|
|
20
|
+
# 'oct5' ~1026 sources/hemi, 'oct6' ~4098 (default), 'ico4' ~2562, 'ico5' ~10242
|
|
21
|
+
|
|
22
|
+
# Volume source space
|
|
23
|
+
src = mne.setup_volume_source_space(subject, pos=5.0, subjects_dir=subjects_dir)
|
|
24
|
+
# pos: grid spacing in mm
|
|
25
|
+
|
|
26
|
+
# Mixed source space (surface + volume)
|
|
27
|
+
src = mne.setup_source_space(subject, spacing='oct6') + \
|
|
28
|
+
mne.setup_volume_source_space(subject, pos=5.0, volume_label='Left-Hippocampus')
|
|
29
|
+
|
|
30
|
+
# Read/write
|
|
31
|
+
src = mne.read_source_spaces('sample-src.fif')
|
|
32
|
+
src.save('sample-src.fif')
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## BEM
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
# 3-layer BEM for EEG (brain, skull, scalp)
|
|
39
|
+
model = mne.make_bem_model(subject, conductivity=(0.3, 0.006, 0.3),
|
|
40
|
+
subjects_dir=subjects_dir)
|
|
41
|
+
|
|
42
|
+
# 1-layer BEM for MEG only (inner skull)
|
|
43
|
+
model = mne.make_bem_model(subject, conductivity=(0.3,),
|
|
44
|
+
subjects_dir=subjects_dir)
|
|
45
|
+
|
|
46
|
+
# Compute BEM solution
|
|
47
|
+
bem = mne.make_bem_solution(model)
|
|
48
|
+
|
|
49
|
+
# Sphere model (simpler alternative)
|
|
50
|
+
sphere = mne.make_sphere_model(r0='auto', head_radius='auto', info=info)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Forward Solution
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
fwd = mne.make_forward_solution(
|
|
57
|
+
info, trans=trans, src=src, bem=bem,
|
|
58
|
+
eeg=True, meg=True, mindist=5.0, n_jobs=-1)
|
|
59
|
+
|
|
60
|
+
# Read from file
|
|
61
|
+
fwd = mne.read_forward_solution('sample-fwd.fif')
|
|
62
|
+
|
|
63
|
+
# Convert orientation
|
|
64
|
+
fwd = mne.convert_forward_solution(fwd, surf_ori=True, force_fixed=False)
|
|
65
|
+
|
|
66
|
+
# Restrict to label
|
|
67
|
+
fwd_label = mne.forward.restrict_forward_to_label(fwd, label)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Noise Covariance
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
# From pre-stimulus baseline epochs
|
|
74
|
+
noise_cov = mne.compute_covariance(epochs, tmax=0., method='auto')
|
|
75
|
+
# method: 'auto', 'empirical', 'diagonal_fixed', 'shrunk', 'oas',
|
|
76
|
+
# 'ledoit_wolf', 'factor_analysis'
|
|
77
|
+
|
|
78
|
+
# From empty room recording
|
|
79
|
+
noise_cov = mne.compute_raw_covariance(raw_empty_room)
|
|
80
|
+
|
|
81
|
+
# Ad-hoc covariance (for testing)
|
|
82
|
+
noise_cov = mne.make_ad_hoc_cov(info)
|
|
83
|
+
|
|
84
|
+
# Read/write
|
|
85
|
+
noise_cov = mne.read_cov('sample-cov.fif')
|
|
86
|
+
mne.write_cov('sample-cov.fif', noise_cov)
|
|
87
|
+
|
|
88
|
+
# Visualize
|
|
89
|
+
noise_cov.plot(info)
|
|
90
|
+
evoked.plot_white(noise_cov) # check whitening quality
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Minimum Norm Estimates
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from mne.minimum_norm import (
|
|
97
|
+
make_inverse_operator, apply_inverse, apply_inverse_epochs,
|
|
98
|
+
apply_inverse_raw, apply_inverse_cov, read_inverse_operator,
|
|
99
|
+
write_inverse_operator
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
# Create inverse operator
|
|
103
|
+
inv = make_inverse_operator(info, fwd, noise_cov,
|
|
104
|
+
loose=0.2, # 0=fixed, 0.2=default, 1=free
|
|
105
|
+
depth=0.8) # depth weighting (0-1)
|
|
106
|
+
|
|
107
|
+
# Apply to evoked
|
|
108
|
+
snr = 3.0
|
|
109
|
+
lambda2 = 1. / snr ** 2 # = 1/9 ≈ 0.111
|
|
110
|
+
stc = apply_inverse(evoked, inv, lambda2, method='dSPM',
|
|
111
|
+
pick_ori=None) # None, 'normal', 'vector'
|
|
112
|
+
|
|
113
|
+
# Apply to epochs (per-trial source estimates)
|
|
114
|
+
stcs = apply_inverse_epochs(epochs, inv, lambda2, method='dSPM',
|
|
115
|
+
return_generator=True) # memory-efficient
|
|
116
|
+
|
|
117
|
+
# Apply to raw (continuous)
|
|
118
|
+
stc = apply_inverse_raw(raw, inv, lambda2, method='MNE')
|
|
119
|
+
|
|
120
|
+
# Apply to covariance (source power)
|
|
121
|
+
stc_power = apply_inverse_cov(data_cov, info, inv)
|
|
122
|
+
|
|
123
|
+
# Resolution analysis
|
|
124
|
+
from mne.minimum_norm import make_inverse_resolution_matrix, resolution_metrics
|
|
125
|
+
rm = make_inverse_resolution_matrix(fwd, inv, method='dSPM', lambda2=lambda2)
|
|
126
|
+
metrics = resolution_metrics(rm, src, function='psf', metric='peak_err')
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Beamformers
|
|
130
|
+
|
|
131
|
+
### LCMV (time domain)
|
|
132
|
+
```python
|
|
133
|
+
from mne.beamformer import make_lcmv, apply_lcmv, apply_lcmv_epochs, apply_lcmv_raw
|
|
134
|
+
|
|
135
|
+
data_cov = mne.compute_covariance(epochs, tmin=0., tmax=0.5)
|
|
136
|
+
filters = make_lcmv(info, fwd, data_cov,
|
|
137
|
+
noise_cov=noise_cov,
|
|
138
|
+
reg=0.05,
|
|
139
|
+
pick_ori='max-power') # None, 'normal', 'max-power', 'vector'
|
|
140
|
+
|
|
141
|
+
stc = apply_lcmv(evoked, filters)
|
|
142
|
+
stcs = apply_lcmv_epochs(epochs, filters)
|
|
143
|
+
stc = apply_lcmv_raw(raw, filters)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### DICS (frequency domain)
|
|
147
|
+
```python
|
|
148
|
+
from mne.beamformer import make_dics, apply_dics, apply_dics_csd, apply_dics_epochs
|
|
149
|
+
from mne.time_frequency import csd_morlet
|
|
150
|
+
|
|
151
|
+
csd = csd_morlet(epochs, freqs=[10], n_cycles=7)
|
|
152
|
+
noise_csd = csd_morlet(epochs, freqs=[10], n_cycles=7, tmin=-0.5, tmax=0.)
|
|
153
|
+
|
|
154
|
+
filters = make_dics(info, fwd, csd, noise_csd=noise_csd, reg=0.05)
|
|
155
|
+
stc_power, freqs = apply_dics_csd(csd, filters)
|
|
156
|
+
stc = apply_dics(evoked, filters)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### RAP-MUSIC / TRAP-MUSIC
|
|
160
|
+
```python
|
|
161
|
+
from mne.beamformer import rap_music, trap_music
|
|
162
|
+
dipoles, residual = rap_music(evoked, fwd, noise_cov, n_dipoles=2)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Dipole Fitting
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
dip, residual = mne.fit_dipole(evoked, noise_cov, bem, trans,
|
|
169
|
+
min_dist=5.0, n_jobs=-1)
|
|
170
|
+
dip.plot_locations(trans, subject, subjects_dir)
|
|
171
|
+
dip.plot_amplitudes()
|
|
172
|
+
|
|
173
|
+
# Confidence volume
|
|
174
|
+
dip.conf # confidence volume in mm³
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Template MRI (fsaverage)
|
|
178
|
+
|
|
179
|
+
For EEG studies without individual MRI:
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
import os.path as op
|
|
183
|
+
fs_dir = mne.datasets.fetch_fsaverage(verbose=True)
|
|
184
|
+
subjects_dir = op.dirname(fs_dir)
|
|
185
|
+
subject = 'fsaverage'
|
|
186
|
+
trans = 'fsaverage' # built-in identity transform
|
|
187
|
+
|
|
188
|
+
src = mne.setup_source_space(subject, spacing='oct6', subjects_dir=subjects_dir)
|
|
189
|
+
model = mne.make_bem_model(subject, subjects_dir=subjects_dir)
|
|
190
|
+
bem = mne.make_bem_solution(model)
|
|
191
|
+
fwd = mne.make_forward_solution(info, trans, src, bem)
|
|
192
|
+
|
|
193
|
+
# Then proceed with inverse as usual
|
|
194
|
+
inv = make_inverse_operator(info, fwd, noise_cov)
|
|
195
|
+
stc = apply_inverse(evoked, inv, lambda2=1./9., method='dSPM')
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Source Estimate Operations
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
# Visualization
|
|
202
|
+
stc.plot(subject, subjects_dir=subjects_dir, hemi='both',
|
|
203
|
+
surface='inflated', views='lateral')
|
|
204
|
+
brain = stc.plot(subject, hemi='split', size=(800, 400))
|
|
205
|
+
brain.add_foci(vertex_id, hemi='rh', color='yellow')
|
|
206
|
+
brain.save_image('brain.png')
|
|
207
|
+
|
|
208
|
+
# Peak detection
|
|
209
|
+
vertex, time_idx = stc.get_peak(hemi='rh', tmin=0.05, tmax=0.15)
|
|
210
|
+
|
|
211
|
+
# Time operations
|
|
212
|
+
stc.crop(tmin=0., tmax=0.3)
|
|
213
|
+
stc_mean = stc.mean()
|
|
214
|
+
|
|
215
|
+
# ROI extraction
|
|
216
|
+
label = mne.read_label('lh.V1.label')
|
|
217
|
+
stc_label = stc.in_label(label)
|
|
218
|
+
|
|
219
|
+
# Extract label time courses
|
|
220
|
+
labels = mne.read_labels_from_annot(subject, parc='aparc', subjects_dir=subjects_dir)
|
|
221
|
+
label_ts = mne.extract_label_time_course(stcs, labels, src,
|
|
222
|
+
mode='mean_flip') # 'mean', 'mean_flip',
|
|
223
|
+
# 'pca_flip', 'max'
|
|
224
|
+
|
|
225
|
+
# Morphing between subjects
|
|
226
|
+
morph = mne.compute_source_morph(stc, subject_from='sample',
|
|
227
|
+
subject_to='fsaverage',
|
|
228
|
+
subjects_dir=subjects_dir)
|
|
229
|
+
stc_fsaverage = morph.apply(stc)
|
|
230
|
+
|
|
231
|
+
# Arithmetic
|
|
232
|
+
stc_diff = stc1 - stc2
|
|
233
|
+
stc_scaled = stc * 1e9
|
|
234
|
+
```
|