@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,404 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import numpy as np
|
|
3
|
+
import matplotlib.pyplot as plt
|
|
4
|
+
from matplotlib.lines import Line2D
|
|
5
|
+
from matplotlib.patches import FancyArrowPatch
|
|
6
|
+
from mpl_toolkits.mplot3d import proj3d
|
|
7
|
+
import matplotlib.cm as cm
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
EPSILON = 1e-6
|
|
11
|
+
|
|
12
|
+
def pairwise_sqdist(X: np.ndarray) -> np.ndarray:
|
|
13
|
+
X2 = np.sum(X**2, axis=1, keepdims=True)
|
|
14
|
+
D2 = X2 + X2.T - 2 * (X @ X.T)
|
|
15
|
+
return np.maximum(D2, 0.0)
|
|
16
|
+
|
|
17
|
+
def safe_scale(V, s=0.6, eps=EPSILON):
|
|
18
|
+
n = np.linalg.norm(V, axis=1, keepdims=True)
|
|
19
|
+
return V / (eps + n) / s
|
|
20
|
+
|
|
21
|
+
def nice_axes(ax, L):
|
|
22
|
+
y_scale = 1
|
|
23
|
+
z_scale = 1.2
|
|
24
|
+
ax.quiver(0, 0, 0, 0, -L, 0, color="black", linewidth=2, arrow_length_ratio=0.1)
|
|
25
|
+
ax.quiver(0, 0, 0, y_scale*L, 0, 0, color="black", linewidth=2, arrow_length_ratio=0.1)
|
|
26
|
+
ax.quiver(0, 0, 0, 0, 0, z_scale*L, color="black", linewidth=2, arrow_length_ratio=0.1)
|
|
27
|
+
ax.text(0, -L*1.2, 0, "x", color="black", fontsize=36)
|
|
28
|
+
ax.text(y_scale*L*1.05, -0.2, 0, "y", color="black", fontsize=36)
|
|
29
|
+
ax.text(-0.2, 0, z_scale*L*1.05, "z", color="black", fontsize=36)
|
|
30
|
+
ax.grid(False)
|
|
31
|
+
ax.xaxis.pane.set_visible(False)
|
|
32
|
+
ax.yaxis.pane.set_visible(False)
|
|
33
|
+
ax.zaxis.pane.set_visible(False)
|
|
34
|
+
ax.xaxis.line.set_color((1, 1, 1, 0))
|
|
35
|
+
ax.yaxis.line.set_color((1, 1, 1, 0))
|
|
36
|
+
ax.zaxis.line.set_color((1, 1, 1, 0))
|
|
37
|
+
ax.set_xticks([])
|
|
38
|
+
ax.set_yticks([])
|
|
39
|
+
ax.set_zticks([])
|
|
40
|
+
return ax
|
|
41
|
+
|
|
42
|
+
def _to3d_xy(xy):
|
|
43
|
+
x, y = xy[:, 0], xy[:, 1]
|
|
44
|
+
z = np.sqrt(np.clip(1.0 - x*x - y*y, 0.0, 1.0))
|
|
45
|
+
P = np.stack([x, y, z], axis=1)
|
|
46
|
+
# normalize (robust against tiny numerical drift)
|
|
47
|
+
P /= np.linalg.norm(P, axis=1, keepdims=True) + EPSILON
|
|
48
|
+
return P
|
|
49
|
+
|
|
50
|
+
def _slerp_arc(p, q, n=200):
|
|
51
|
+
p = p / (np.linalg.norm(p) + EPSILON)
|
|
52
|
+
q = q / (np.linalg.norm(q) + EPSILON)
|
|
53
|
+
dot = np.clip(np.dot(p, q), -1.0, 1.0)
|
|
54
|
+
theta = np.arccos(dot)
|
|
55
|
+
if theta < EPSILON: # nearly identical points
|
|
56
|
+
return np.repeat(p[None, :], n, axis=0)
|
|
57
|
+
# great-circle via SLERP
|
|
58
|
+
t = np.linspace(0.0, 1.0, n)
|
|
59
|
+
s = np.sin
|
|
60
|
+
arc = (s((1-t)*theta)[:,None]*p + s(t*theta)[:,None]*q) / (s(theta) + EPSILON)
|
|
61
|
+
# normalize for safety
|
|
62
|
+
arc /= np.linalg.norm(arc, axis=1, keepdims=True) + EPSILON
|
|
63
|
+
return arc
|
|
64
|
+
|
|
65
|
+
def draw_geodesic(ax, a2d, b2d, linestyle='-', draw_arrow=True, alpha=0.8,
|
|
66
|
+
num_points_grid=300, color='blue', lw=2.0, arrow_scale=30, shorten=0.04):
|
|
67
|
+
A3, B3 = _to3d_xy(np.array([a2d])), _to3d_xy(np.array([b2d]))
|
|
68
|
+
arc = _slerp_arc(A3[0], B3[0], n=num_points_grid)
|
|
69
|
+
x_full, y_full = arc[:, 0], arc[:, 1]
|
|
70
|
+
|
|
71
|
+
if draw_arrow:
|
|
72
|
+
k0 = int(2 * shorten * num_points_grid)
|
|
73
|
+
k1 = num_points_grid - k0
|
|
74
|
+
else:
|
|
75
|
+
k0 = int(shorten * num_points_grid)
|
|
76
|
+
k1 = num_points_grid - k0
|
|
77
|
+
x, y = x_full[k0:k1], y_full[k0:k1]
|
|
78
|
+
ax.plot(x, y, color=color, lw=lw, solid_capstyle='round', alpha=alpha, linestyle=linestyle)
|
|
79
|
+
|
|
80
|
+
if draw_arrow:
|
|
81
|
+
# Add arrowheads at both ends
|
|
82
|
+
k0 = int(shorten * num_points_grid)
|
|
83
|
+
k1 = num_points_grid - k0
|
|
84
|
+
x, y = x_full[k0:k1], y_full[k0:k1]
|
|
85
|
+
arrow1 = FancyArrowPatch(
|
|
86
|
+
(x[1], y[1]), (x[0], y[0]),
|
|
87
|
+
arrowstyle='-|>', color=color,
|
|
88
|
+
mutation_scale=arrow_scale, lw=0
|
|
89
|
+
)
|
|
90
|
+
arrow2 = FancyArrowPatch(
|
|
91
|
+
(x[-2], y[-2]), (x[-1], y[-1]),
|
|
92
|
+
arrowstyle='-|>', color=color,
|
|
93
|
+
mutation_scale=arrow_scale, lw=0
|
|
94
|
+
)
|
|
95
|
+
ax.add_patch(arrow1)
|
|
96
|
+
ax.add_patch(arrow2)
|
|
97
|
+
return ax
|
|
98
|
+
|
|
99
|
+
class Arrow3D(FancyArrowPatch):
|
|
100
|
+
def __init__(self, xs, ys, zs, *args, **kwargs):
|
|
101
|
+
super().__init__((0, 0), (0, 0), *args, **kwargs)
|
|
102
|
+
self._verts3d = xs, ys, zs
|
|
103
|
+
|
|
104
|
+
def do_3d_projection(self, renderer=None):
|
|
105
|
+
xs3d, ys3d, zs3d = self._verts3d
|
|
106
|
+
xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, self.axes.get_proj())
|
|
107
|
+
self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
|
|
108
|
+
return np.min(zs)
|
|
109
|
+
|
|
110
|
+
def plot_decorrelation(ax):
|
|
111
|
+
num_points_grid = 512
|
|
112
|
+
num_points_on_ellipsoid = 18
|
|
113
|
+
image_scale = 2
|
|
114
|
+
|
|
115
|
+
xs = np.linspace(-2, 2, num_points_grid)
|
|
116
|
+
ys = np.linspace(-2, 2, num_points_grid)
|
|
117
|
+
x, y = np.meshgrid(xs, ys)
|
|
118
|
+
|
|
119
|
+
r2 = x**2 + y**2
|
|
120
|
+
mask_s = r2 <= 1.0
|
|
121
|
+
z_s = np.zeros_like(x)
|
|
122
|
+
z_s[mask_s] = np.sqrt(1.0 - r2[mask_s])
|
|
123
|
+
|
|
124
|
+
nx, ny, nz = x.copy(), y.copy(), z_s.copy()
|
|
125
|
+
nrm = np.sqrt(nx**2 + ny**2 + nz**2) + EPSILON
|
|
126
|
+
nx, ny, nz = nx/nrm, ny/nrm, nz/nrm
|
|
127
|
+
|
|
128
|
+
light_dir = np.array([-0.5, -0.5, 0.8])
|
|
129
|
+
light_dir /= np.linalg.norm(light_dir)
|
|
130
|
+
intensity = np.maximum(0.0, nx*light_dir[0] + ny*light_dir[1] + nz*light_dir[2])
|
|
131
|
+
|
|
132
|
+
img_s = np.ones_like(x)
|
|
133
|
+
img_s[mask_s] = np.clip(0.2 + 0.9*intensity[mask_s], 0, 1)
|
|
134
|
+
ax.imshow(img_s, cmap='gray',
|
|
135
|
+
extent=[-image_scale, image_scale, -image_scale, image_scale],
|
|
136
|
+
vmin=0, vmax=1, alpha=1)
|
|
137
|
+
|
|
138
|
+
a, b, c = 1.50, 0.60, 0.40
|
|
139
|
+
theta = np.deg2rad(30)
|
|
140
|
+
ct, st = np.cos(theta), np.sin(theta)
|
|
141
|
+
|
|
142
|
+
xL = ct*x + st*y
|
|
143
|
+
yL = -st*x + ct*y
|
|
144
|
+
vL = (xL/a)**2 + (yL/b)**2
|
|
145
|
+
mask_e = vL <= 1.0
|
|
146
|
+
zL = np.zeros_like(xL)
|
|
147
|
+
zL[mask_e] = c * np.sqrt(1.0 - vL[mask_e])
|
|
148
|
+
|
|
149
|
+
nxL = xL/(a*a)
|
|
150
|
+
nyL = yL/(b*b)
|
|
151
|
+
nzL = np.zeros_like(zL)
|
|
152
|
+
nzL[mask_e] = zL[mask_e]/(c*c)
|
|
153
|
+
nrm = np.sqrt(nxL**2 + nyL**2 + nzL**2) + EPSILON
|
|
154
|
+
nxL, nyL, nzL = nxL/nrm, nyL/nrm, nzL/nrm
|
|
155
|
+
nxE = ct*nxL - st*nyL
|
|
156
|
+
nyE = st*nxL + ct*nyL
|
|
157
|
+
nzE = nzL
|
|
158
|
+
|
|
159
|
+
light_dir = np.array([0.5, 0.5, -0.8])
|
|
160
|
+
light_dir /= np.linalg.norm(light_dir)
|
|
161
|
+
intensity_e = np.maximum(0.0, nxE*light_dir[0] + nyE*light_dir[1] + nzE*light_dir[2])
|
|
162
|
+
img_e = np.full_like(x, np.nan, dtype=float)
|
|
163
|
+
img_e[mask_e] = np.clip(0.5 + 0.9*intensity_e[mask_e], 0, 1)
|
|
164
|
+
cmap = cm.Blues.copy()
|
|
165
|
+
cmap.set_bad(color="white")
|
|
166
|
+
ax.imshow(img_e, cmap=cmap, origin='lower',
|
|
167
|
+
extent=[-image_scale, image_scale, -image_scale, image_scale],
|
|
168
|
+
vmin=0, vmax=1, alpha=0.4)
|
|
169
|
+
|
|
170
|
+
# Pick points on ellipsoid uniformly.
|
|
171
|
+
phi = np.linspace(0, 2*np.pi, num_points_on_ellipsoid, endpoint=False)
|
|
172
|
+
|
|
173
|
+
# Ellipsoid rim in local coords.
|
|
174
|
+
xL_rim = a*np.cos(phi)
|
|
175
|
+
yL_rim = b*np.sin(phi)
|
|
176
|
+
zL_rim = np.zeros_like(phi)
|
|
177
|
+
|
|
178
|
+
# rotate back to world
|
|
179
|
+
xw = ct*xL_rim - st*yL_rim
|
|
180
|
+
yw = st*xL_rim + ct*yL_rim
|
|
181
|
+
zw = zL_rim
|
|
182
|
+
Pellip = np.stack([xw, yw, zw], axis=1)
|
|
183
|
+
|
|
184
|
+
# matching sphere rim points: same world direction in xy, unit radius, z=0
|
|
185
|
+
rxy = np.sqrt(xw**2 + yw**2) + EPSILON
|
|
186
|
+
Psphere = np.stack([xw/rxy, yw/rxy, np.zeros_like(rxy)], axis=1)
|
|
187
|
+
|
|
188
|
+
ax.scatter(Pellip[:, 0], Pellip[:, 1], s=80, color='#0c2458', alpha=0.5)
|
|
189
|
+
ax.scatter(Psphere[:, 0], Psphere[:, 1], s=80, facecolors='#b64342', alpha=0.5, linewidths=2)
|
|
190
|
+
|
|
191
|
+
for p0, p1 in zip(Pellip, Psphere):
|
|
192
|
+
ax.annotate("", xy=(p1[0], p1[1]), xytext=(p0[0], p0[1]),
|
|
193
|
+
arrowprops=dict(arrowstyle="->", color="#b64342", lw=3, mutation_scale=20))
|
|
194
|
+
|
|
195
|
+
ax.set_xlim([-1.6, 1.6])
|
|
196
|
+
ax.set_ylim([-2, 1.6])
|
|
197
|
+
ax.set_axis_off()
|
|
198
|
+
|
|
199
|
+
arrow_cov = Line2D([], [], color="#b64342", alpha=0.8,
|
|
200
|
+
marker=r'$\rightarrow$', linestyle="None", markersize=35, label="Decorrelation")
|
|
201
|
+
ax.legend(handles=[arrow_cov], frameon=False, loc="lower center", fontsize=24, bbox_to_anchor=(0.5, 0.1))
|
|
202
|
+
return ax
|
|
203
|
+
|
|
204
|
+
def plot_orthogonalization(ax):
|
|
205
|
+
num_points_grid = 512
|
|
206
|
+
|
|
207
|
+
xs = np.linspace(-1, 1, num_points_grid)
|
|
208
|
+
ys = np.linspace(-1, 1, num_points_grid)
|
|
209
|
+
x, y = np.meshgrid(xs, ys)
|
|
210
|
+
r2 = x**2 + y**2
|
|
211
|
+
mask = r2 <= 1.0
|
|
212
|
+
z = np.zeros_like(x)
|
|
213
|
+
z[mask] = np.sqrt(1.0 - r2[mask])
|
|
214
|
+
|
|
215
|
+
nx, ny, nz = x.copy(), y.copy(), z.copy()
|
|
216
|
+
norm = np.sqrt(nx**2 + ny**2 + nz**2) + EPSILON
|
|
217
|
+
nx, ny, nz = nx / norm, ny / norm, nz / norm
|
|
218
|
+
|
|
219
|
+
# light from top left.
|
|
220
|
+
light_dir = np.array([-0.5, 0.5, 0.8])
|
|
221
|
+
light_dir /= np.linalg.norm(light_dir)
|
|
222
|
+
intensity = np.maximum(0.0, nx*light_dir[0] + ny*light_dir[1] + nz*light_dir[2])
|
|
223
|
+
ambient = 0.3
|
|
224
|
+
shade = np.clip(ambient + 0.9*intensity, 0, 1)
|
|
225
|
+
|
|
226
|
+
img = np.ones((num_points_grid, num_points_grid))
|
|
227
|
+
img[mask] = shade[mask]
|
|
228
|
+
|
|
229
|
+
ax.imshow(img, cmap='gray', origin='lower', extent=[-1, 1, -1, 1], vmin=0, vmax=1, alpha=0.5)
|
|
230
|
+
ax.set_ylim([-2.1, 1.5])
|
|
231
|
+
ax.set_axis_off()
|
|
232
|
+
|
|
233
|
+
# add 3 fixed blue points on sphere
|
|
234
|
+
pts = np.array([
|
|
235
|
+
[-0.2, 0.6],
|
|
236
|
+
[0.9, 0.0],
|
|
237
|
+
[-0.75, -0.4],
|
|
238
|
+
])
|
|
239
|
+
ax.scatter(pts[:, 0], pts[:, 1], s=80, color='#0c2458', alpha=0.5)
|
|
240
|
+
ax = draw_geodesic(ax, pts[0], pts[1], color='#b64342', lw=4)
|
|
241
|
+
ax = draw_geodesic(ax, pts[0], pts[2], color='#b64342', lw=4)
|
|
242
|
+
ax = draw_geodesic(ax, pts[1], pts[2], linestyle='--', draw_arrow=False, color='#42949e', lw=4, alpha=0.5)
|
|
243
|
+
ax = draw_geodesic(ax, pts[0], [0, 0], linestyle='--', draw_arrow=False, color='black', lw=1, alpha=0.8, shorten=0)
|
|
244
|
+
ax = draw_geodesic(ax, pts[1], [0, 0], linestyle='--', draw_arrow=False, color='black', lw=1, alpha=0.8, shorten=0)
|
|
245
|
+
ax = draw_geodesic(ax, pts[2], [0, 0], linestyle='--', draw_arrow=False, color='black', lw=1, alpha=0.8, shorten=0)
|
|
246
|
+
|
|
247
|
+
ax.text(0.45, 0.4, "acute angle,\ndisperse", color="#b64342", fontsize=24, ha="center", va="center",
|
|
248
|
+
bbox=dict(facecolor="white", alpha=1, edgecolor="none", boxstyle="round,pad=0.2"))
|
|
249
|
+
ax.text(-0.6, 0.15, "acute angle,\ndisperse", color="#b64342", fontsize=24, ha="center", va="center",
|
|
250
|
+
bbox=dict(facecolor="white", alpha=1, edgecolor="none", boxstyle="round,pad=0.2"))
|
|
251
|
+
ax.text(0.15, -0.36, "obtuse angle,\ndo nothing", color="#42949e", fontsize=24, ha="center", va="center",
|
|
252
|
+
bbox=dict(facecolor="white", alpha=1, edgecolor="none", boxstyle="round,pad=0.2"))
|
|
253
|
+
|
|
254
|
+
arrow_disp = Line2D([], [], color="#b64342", alpha=0.8,
|
|
255
|
+
marker=r'$\leftarrow\rightarrow$', linestyle="None", markersize=50, label="Orthogonalization")
|
|
256
|
+
ax.legend(handles=[arrow_disp], frameon=False, loc="lower center", fontsize=24, bbox_to_anchor=(0.5, 0.15))
|
|
257
|
+
return ax
|
|
258
|
+
|
|
259
|
+
def plot_l2_repel(ax):
|
|
260
|
+
tau = 0.5
|
|
261
|
+
|
|
262
|
+
Z = np.array([
|
|
263
|
+
[ 3.0, -3.0, 0.0],
|
|
264
|
+
[ 1.0, -3.0, 0.0],
|
|
265
|
+
[ -3.0, -2.0, -1.0],
|
|
266
|
+
[ -2.0, -1.0, 1.0],
|
|
267
|
+
[ -2.0, -1.0, 4.0],
|
|
268
|
+
[ 0.0, 2.0, 2.0],
|
|
269
|
+
[ 4.0, 0.0, 2.0],
|
|
270
|
+
[ 4.0, -2.0, 0.0],
|
|
271
|
+
])
|
|
272
|
+
|
|
273
|
+
num_points, d = Z.shape
|
|
274
|
+
|
|
275
|
+
D2 = pairwise_sqdist(Z) / d
|
|
276
|
+
W = np.exp(-D2 / tau)
|
|
277
|
+
|
|
278
|
+
G_disp = np.zeros_like(Z)
|
|
279
|
+
for i in range(num_points):
|
|
280
|
+
diff = Z[i] - Z
|
|
281
|
+
G_disp[i] = (2.0 / tau) * (W[i][:, None] * diff).sum(axis=0)
|
|
282
|
+
|
|
283
|
+
A_disp = safe_scale(G_disp)
|
|
284
|
+
Vn = -Z / (np.linalg.norm(Z, axis=1, keepdims=True) + EPSILON)
|
|
285
|
+
|
|
286
|
+
ax.view_init(elev=30, azim=-60)
|
|
287
|
+
ax = nice_axes(ax, 6)
|
|
288
|
+
ax.set_xlim([-3, 5])
|
|
289
|
+
ax.set_ylim([-3, 5])
|
|
290
|
+
ax.set_zlim([-6, 4])
|
|
291
|
+
ax.scatter(Z[:, 0], Z[:, 1], Z[:, 2], s=80, color='#0c2458', alpha=0.5)
|
|
292
|
+
|
|
293
|
+
for i in range(num_points):
|
|
294
|
+
p0 = Z[i]
|
|
295
|
+
p1 = Z[i] + A_disp[i] * 1.25
|
|
296
|
+
arrow = Arrow3D([p0[0], p1[0]], [p0[1], p1[1]], [p0[2], p1[2]],
|
|
297
|
+
mutation_scale=16, lw=4, arrowstyle='->', color='#b64342', alpha=0.8)
|
|
298
|
+
ax.add_artist(arrow)
|
|
299
|
+
|
|
300
|
+
for i in range(num_points):
|
|
301
|
+
p0 = Z[i]
|
|
302
|
+
p1 = Z[i] + Vn[i] * 1.2
|
|
303
|
+
arrow = Arrow3D([p0[0], p1[0]], [p0[1], p1[1]], [p0[2], p1[2]],
|
|
304
|
+
mutation_scale=10, lw=3, arrowstyle='->', color='#9a4d8e', alpha=0.8)
|
|
305
|
+
ax.add_artist(arrow)
|
|
306
|
+
|
|
307
|
+
for i in range(num_points):
|
|
308
|
+
ax.plot([Z[i, 0], 0], [Z[i, 1], 0], [Z[i, 2], 0],
|
|
309
|
+
linestyle="--", color="black", linewidth=1, alpha=0.8)
|
|
310
|
+
|
|
311
|
+
arrow_disp = Line2D([], [], color="#b64342", alpha=0.8,
|
|
312
|
+
marker=r'$\rightarrow$', linestyle="None", markersize=25,
|
|
313
|
+
label=r"${\ell_2}$-repel")
|
|
314
|
+
arrow_norm = Line2D([0, 1], [0, 0], color="#9a4d8e", alpha=0.8,
|
|
315
|
+
marker=r'$\rightarrow$', linestyle="None", markersize=25,
|
|
316
|
+
label="norm regularization")
|
|
317
|
+
ax.legend(handles=[arrow_disp, arrow_norm], frameon=False, loc="lower center",
|
|
318
|
+
fontsize=24, bbox_to_anchor=(0.5, 0))
|
|
319
|
+
|
|
320
|
+
ax.text(0.8, 0.0, 8.0, "pairwise dispersion", color="#b64342", fontsize=24, ha="left", va="center",
|
|
321
|
+
bbox=dict(facecolor="white", alpha=1, edgecolor="none", boxstyle="round,pad=0.2"))
|
|
322
|
+
ax.text(0.8, 0.0, 6.5, "norm reduction", color="#9a4d8e", fontsize=24, ha="left", va="center",
|
|
323
|
+
bbox=dict(facecolor="white", alpha=1, edgecolor="none", boxstyle="round,pad=0.2"))
|
|
324
|
+
|
|
325
|
+
return ax
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def plot_angular_spread(ax):
|
|
329
|
+
num_points_grid = 512
|
|
330
|
+
|
|
331
|
+
xs = np.linspace(-1, 1, num_points_grid)
|
|
332
|
+
ys = np.linspace(-1, 1, num_points_grid)
|
|
333
|
+
x, y = np.meshgrid(xs, ys)
|
|
334
|
+
r2 = x**2 + y**2
|
|
335
|
+
mask = r2 <= 1.0
|
|
336
|
+
z = np.zeros_like(x)
|
|
337
|
+
z[mask] = np.sqrt(1.0 - r2[mask])
|
|
338
|
+
|
|
339
|
+
nx, ny, nz = x.copy(), y.copy(), z.copy()
|
|
340
|
+
norm = np.sqrt(nx**2 + ny**2 + nz**2) + EPSILON
|
|
341
|
+
nx, ny, nz = nx / norm, ny / norm, nz / norm
|
|
342
|
+
|
|
343
|
+
# light from top left.
|
|
344
|
+
light_dir = np.array([-0.5, 0.5, 0.8])
|
|
345
|
+
light_dir /= np.linalg.norm(light_dir)
|
|
346
|
+
intensity = np.maximum(0.0, nx*light_dir[0] + ny*light_dir[1] + nz*light_dir[2])
|
|
347
|
+
ambient = 0.3
|
|
348
|
+
shade = np.clip(ambient + 0.9*intensity, 0, 1)
|
|
349
|
+
|
|
350
|
+
img = np.ones((num_points_grid, num_points_grid))
|
|
351
|
+
img[mask] = shade[mask]
|
|
352
|
+
|
|
353
|
+
ax.imshow(img, cmap='gray', origin='lower', extent=[-1, 1, -1, 1], vmin=0, vmax=1, alpha=0.5)
|
|
354
|
+
ax.set_ylim([-2.1, 1.5])
|
|
355
|
+
ax.set_axis_off()
|
|
356
|
+
|
|
357
|
+
# add 3 fixed blue points on sphere
|
|
358
|
+
pts = np.array([
|
|
359
|
+
[-0.2, 0.6],
|
|
360
|
+
[0.9, 0.0],
|
|
361
|
+
[-0.75, -0.4],
|
|
362
|
+
])
|
|
363
|
+
ax.scatter(pts[:, 0], pts[:, 1], s=80, color='#0c2458', alpha=0.5)
|
|
364
|
+
ax = draw_geodesic(ax, pts[0], pts[1], color='#b64342', lw=4)
|
|
365
|
+
ax = draw_geodesic(ax, pts[0], pts[2], color='#b64342', lw=4)
|
|
366
|
+
ax = draw_geodesic(ax, pts[1], pts[2], color='#b64342', lw=4)
|
|
367
|
+
ax = draw_geodesic(ax, pts[0], [0, 0], linestyle='--', draw_arrow=False, color='black', lw=1, alpha=0.8, shorten=0)
|
|
368
|
+
ax = draw_geodesic(ax, pts[1], [0, 0], linestyle='--', draw_arrow=False, color='black', lw=1, alpha=0.8, shorten=0)
|
|
369
|
+
ax = draw_geodesic(ax, pts[2], [0, 0], linestyle='--', draw_arrow=False, color='black', lw=1, alpha=0.8, shorten=0)
|
|
370
|
+
|
|
371
|
+
ax.text(0.45, 0.4, "disperse", color="#b64342", fontsize=24, ha="center", va="center",
|
|
372
|
+
bbox=dict(facecolor="white", alpha=1, edgecolor="none", boxstyle="round,pad=0.2"))
|
|
373
|
+
ax.text(-0.6, 0.15, "disperse", color="#b64342", fontsize=24, ha="center", va="center",
|
|
374
|
+
bbox=dict(facecolor="white", alpha=1, edgecolor="none", boxstyle="round,pad=0.2"))
|
|
375
|
+
ax.text(0.15, -0.36, "disperse", color="#b64342", fontsize=24, ha="center", va="center",
|
|
376
|
+
bbox=dict(facecolor="white", alpha=1, edgecolor="none", boxstyle="round,pad=0.2"))
|
|
377
|
+
|
|
378
|
+
arrow_disp = Line2D([], [], color="#b64342", alpha=0.8,
|
|
379
|
+
marker=r'$\leftarrow\rightarrow$', linestyle="None", markersize=50, label="Dispersion loss")
|
|
380
|
+
ax.legend(handles=[arrow_disp], frameon=False, loc="lower center", fontsize=24, bbox_to_anchor=(0.5, 0.145))
|
|
381
|
+
return ax
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
if __name__ == "__main__":
|
|
385
|
+
save_path = './figures/illustration.png'
|
|
386
|
+
plt.rcParams['text.usetex'] = True
|
|
387
|
+
plt.rcParams['font.family'] = 'sans-serif'
|
|
388
|
+
fig = plt.figure(figsize=(24, 8))
|
|
389
|
+
|
|
390
|
+
ax = fig.add_subplot(1, 4, 1)
|
|
391
|
+
plot_angular_spread(ax)
|
|
392
|
+
|
|
393
|
+
ax = fig.add_subplot(1, 4, 2)
|
|
394
|
+
plot_decorrelation(ax)
|
|
395
|
+
|
|
396
|
+
ax = fig.add_subplot(1, 4, 3, projection="3d")
|
|
397
|
+
plot_l2_repel(ax)
|
|
398
|
+
|
|
399
|
+
ax = fig.add_subplot(1, 4, 4)
|
|
400
|
+
plot_orthogonalization(ax)
|
|
401
|
+
|
|
402
|
+
os.makedirs(os.path.dirname(save_path), exist_ok=True)
|
|
403
|
+
fig.tight_layout(pad=2)
|
|
404
|
+
fig.savefig(save_path, dpi=300)
|
|
Binary file
|
package/skills/13_Visualization/nature-figure/assets/figures4papers/figure_FPGM/plot_freq_prior.py
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import numpy as np
|
|
3
|
+
from matplotlib import pyplot as plt
|
|
4
|
+
from matplotlib.ticker import LinearLocator, FormatStrFormatter
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def load_freq_prior_data(data_dir):
|
|
8
|
+
datasets = {}
|
|
9
|
+
for name in sorted(os.listdir(data_dir)):
|
|
10
|
+
if not name.endswith(".npz"):
|
|
11
|
+
continue
|
|
12
|
+
path = os.path.join(data_dir, name)
|
|
13
|
+
data = np.load(path)
|
|
14
|
+
datasets[name] = {key: data[key] for key in data.files}
|
|
15
|
+
return datasets
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def plot_dataset(ax, title, sample1_arr, sample2_arr, max_freq_radius,
|
|
19
|
+
line_colors, line_styles, legend_labels):
|
|
20
|
+
ax.spines['top'].set_visible(False)
|
|
21
|
+
ax.spines['right'].set_visible(False)
|
|
22
|
+
ax.spines['left'].set_linewidth(2)
|
|
23
|
+
ax.spines['bottom'].set_linewidth(2)
|
|
24
|
+
ax.plot(np.arange(len(sample1_arr))[:max_freq_radius],
|
|
25
|
+
sample1_arr[:max_freq_radius],
|
|
26
|
+
color=line_colors[0], linestyle=line_styles[0], linewidth=2.5)
|
|
27
|
+
ax.plot(np.arange(len(sample2_arr))[:max_freq_radius],
|
|
28
|
+
sample2_arr[:max_freq_radius],
|
|
29
|
+
color=line_colors[1], linestyle=line_styles[1], linewidth=2.5)
|
|
30
|
+
ax.set_title(title, fontfamily='monospace')
|
|
31
|
+
ax.set_xlabel('Frequency Radius')
|
|
32
|
+
ax.set_xticks(np.arange(max_freq_radius)[::4])
|
|
33
|
+
ax.set_ylabel('Mean Amplitude')
|
|
34
|
+
ax.set_ylim(bottom=0)
|
|
35
|
+
ax.yaxis.set_major_locator(LinearLocator(4))
|
|
36
|
+
ax.yaxis.set_major_formatter(FormatStrFormatter('%.1f'))
|
|
37
|
+
ax.legend(legend_labels, frameon=False, fontsize=14)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
if __name__ == "__main__":
|
|
41
|
+
data_dir = os.path.join(os.path.dirname(__file__), "data")
|
|
42
|
+
datasets = load_freq_prior_data(data_dir)
|
|
43
|
+
|
|
44
|
+
plt.rcParams['font.family'] = 'helvetica'
|
|
45
|
+
plt.rcParams['font.size'] = 16
|
|
46
|
+
fig = plt.figure(figsize=(20, 7))
|
|
47
|
+
gs = fig.add_gridspec(2, 5, width_ratios=[1, 1, 0, 1, 1])
|
|
48
|
+
|
|
49
|
+
# Part 1. Plot the individual datasets.
|
|
50
|
+
max_freq_radius = 17
|
|
51
|
+
line_colors = ['#2A9D8F', '#E76F51']
|
|
52
|
+
line_styles = ['-', '--']
|
|
53
|
+
subplot_positions = [gs[0, 0], gs[0, 1], gs[1, 0], gs[1, 1]]
|
|
54
|
+
|
|
55
|
+
per_dataset_names = ['Kvasir', 'CVC-ClinicDB', 'CVC-ColonDB', 'ETIS']
|
|
56
|
+
max_name_len = max(len(name) for name in per_dataset_names)
|
|
57
|
+
for dataset_idx, dataset_name in enumerate(per_dataset_names):
|
|
58
|
+
data = datasets[dataset_name.lower() + '_freq_prior.npz']
|
|
59
|
+
sample1_arr = data['data1']
|
|
60
|
+
sample2_arr = data['data2']
|
|
61
|
+
|
|
62
|
+
ax = fig.add_subplot(subplot_positions[dataset_idx])
|
|
63
|
+
plot_dataset(ax, dataset_name, sample1_arr, sample2_arr,
|
|
64
|
+
max_freq_radius, line_colors, line_styles,
|
|
65
|
+
[r'Random subset 1 $(N=50)$', r'Random subset 2 $(N=50)$'])
|
|
66
|
+
|
|
67
|
+
# Part 2. Plot the mixed dataset across two columns.
|
|
68
|
+
data = datasets['mixed_freq_prior.npz']
|
|
69
|
+
sample1_arr = data['data1']
|
|
70
|
+
sample2_arr = data['data2']
|
|
71
|
+
ax = fig.add_subplot(gs[0, 3:5])
|
|
72
|
+
plot_dataset(ax, '', sample1_arr, sample2_arr, max_freq_radius, line_colors, line_styles,
|
|
73
|
+
[r'Random subset 1 $(N=500)$', r'Random subset 2 $(N=500)$'])
|
|
74
|
+
ax.set_title('Mixuture of all four datasets', fontfamily='helvetica')
|
|
75
|
+
|
|
76
|
+
# Part 3. Plot per-dataset mean/std curves in a single panel.
|
|
77
|
+
ax = fig.add_subplot(gs[1, 3])
|
|
78
|
+
per_dataset_colors = ['#4C72B0', '#C2A5CF', '#7B3294', '#8C564B']
|
|
79
|
+
curve_means = []
|
|
80
|
+
for dataset_idx, dataset_name in enumerate(['Kvasir', 'CVC-ClinicDB', 'CVC-ColonDB', 'ETIS']):
|
|
81
|
+
data = datasets[dataset_name.lower() + '_freq_prior.npz']
|
|
82
|
+
sample1_arr = data['data1'][:max_freq_radius]
|
|
83
|
+
sample2_arr = data['data2'][:max_freq_radius]
|
|
84
|
+
stacked = np.stack([sample1_arr, sample2_arr], axis=0)
|
|
85
|
+
mean = stacked.mean(axis=0)
|
|
86
|
+
std = stacked.std(axis=0)
|
|
87
|
+
x_vals = np.arange(len(mean))
|
|
88
|
+
color = per_dataset_colors[dataset_idx]
|
|
89
|
+
padded_name = dataset_name.ljust(max_name_len)
|
|
90
|
+
ax.plot(x_vals, mean, color=color, linewidth=1.5,
|
|
91
|
+
label=f'{padded_name}' + r' $(N=100)$')
|
|
92
|
+
ax.fill_between(x_vals, mean - std, mean + std, color=color, alpha=0.2)
|
|
93
|
+
curve_means.append(mean)
|
|
94
|
+
|
|
95
|
+
ax.spines['top'].set_visible(False)
|
|
96
|
+
ax.spines['right'].set_visible(False)
|
|
97
|
+
ax.spines['left'].set_linewidth(2)
|
|
98
|
+
ax.spines['bottom'].set_linewidth(2)
|
|
99
|
+
ax.axvline(2, color='0.6', linestyle='--', linewidth=1.2, label=r'Radius$=2$')
|
|
100
|
+
x_left = ax.get_xlim()[0]
|
|
101
|
+
for mean, color in zip(curve_means, per_dataset_colors):
|
|
102
|
+
ax.hlines(mean[2], xmin=x_left, xmax=2, color=color, linestyle='--', linewidth=1.0)
|
|
103
|
+
ax.set_xlabel('Frequency Radius')
|
|
104
|
+
ax.set_xticks(np.arange(max_freq_radius)[::4])
|
|
105
|
+
ax.set_xlim(left=x_left, right=max_freq_radius)
|
|
106
|
+
ax.set_ylabel('Mean Amplitude')
|
|
107
|
+
ax.set_ylim(bottom=0, top=3)
|
|
108
|
+
ax.yaxis.set_major_locator(LinearLocator(4))
|
|
109
|
+
ax.yaxis.set_major_formatter(FormatStrFormatter('%.1f'))
|
|
110
|
+
ax.legend(frameon=False, ncol=1, prop={'family': 'monospace', 'size': 12})
|
|
111
|
+
|
|
112
|
+
# Part 4. Plot foreground/background curves in a single panel.
|
|
113
|
+
data = datasets['foreground_background.npz']
|
|
114
|
+
polyp_arr = data['data1'][:max_freq_radius]
|
|
115
|
+
background_arr = data['data2'][:max_freq_radius]
|
|
116
|
+
x_vals = np.arange(len(polyp_arr))
|
|
117
|
+
polyp_color = '#1F3A93'
|
|
118
|
+
background_color = '#16A085'
|
|
119
|
+
|
|
120
|
+
ax = fig.add_subplot(gs[1, 4])
|
|
121
|
+
ax.spines['top'].set_visible(False)
|
|
122
|
+
ax.spines['right'].set_visible(False)
|
|
123
|
+
ax.spines['left'].set_linewidth(2)
|
|
124
|
+
ax.spines['bottom'].set_linewidth(2)
|
|
125
|
+
fb_names = ['Polyp', 'Background']
|
|
126
|
+
fb_max_len = max(len(name) for name in fb_names)
|
|
127
|
+
ax.plot(x_vals, polyp_arr, color=polyp_color, linewidth=2.5,
|
|
128
|
+
label=f'{fb_names[0].ljust(fb_max_len)}' + r' $(N=500)$')
|
|
129
|
+
ax.plot(x_vals, background_arr, color=background_color, linewidth=2.5,
|
|
130
|
+
linestyle=':', label=f'{fb_names[1].ljust(fb_max_len)}' + r' $(N=500)$')
|
|
131
|
+
ax.axvline(2, color='0.6', linestyle='--', linewidth=1.2, label=r'Radius$=2$')
|
|
132
|
+
x_left = ax.get_xlim()[0]
|
|
133
|
+
ax.hlines(polyp_arr[2], xmin=x_left, xmax=2, color=polyp_color, linestyle='--', linewidth=1.2)
|
|
134
|
+
ax.hlines(background_arr[2], xmin=x_left, xmax=2, color=background_color, linestyle='--', linewidth=1.2)
|
|
135
|
+
ax.set_xlabel('Frequency Radius')
|
|
136
|
+
ax.set_xticks(np.arange(max_freq_radius)[::4])
|
|
137
|
+
ax.set_xlim(left=x_left, right=max_freq_radius)
|
|
138
|
+
ax.set_ylabel('Mean Amplitude')
|
|
139
|
+
ax.set_ylim(bottom=0)
|
|
140
|
+
ax.yaxis.set_major_locator(LinearLocator(4))
|
|
141
|
+
ax.yaxis.set_major_formatter(FormatStrFormatter('%.1f'))
|
|
142
|
+
ax.legend(frameon=False, prop={'family': 'monospace', 'size': 12})
|
|
143
|
+
|
|
144
|
+
fig.tight_layout(pad=1)
|
|
145
|
+
os.makedirs('figures', exist_ok=True)
|
|
146
|
+
fig.savefig('figures/freq_prior.png', dpi=300)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|