@brainpilot/skills 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/package.json +2 -2
  2. package/skills/01_Meta-Skills/academic-research-hub/SKILL.md +108 -0
  3. package/skills/01_Meta-Skills/academic-research-hub/scripts/requirements.txt +17 -0
  4. package/skills/01_Meta-Skills/academic-research-hub/scripts/research.py +781 -0
  5. package/skills/01_Meta-Skills/beautiful-log/SKILL.md +64 -0
  6. package/skills/01_Meta-Skills/beautiful-log/scripts/beautiful_log.py +274 -0
  7. package/skills/01_Meta-Skills/ethoclaw-daily-paper/SKILL.md +130 -0
  8. package/skills/01_Meta-Skills/ethoclaw-daily-paper/assets/config.template.yaml +54 -0
  9. package/skills/01_Meta-Skills/ethoclaw-daily-paper/assets/top5_digest_template.md +5 -0
  10. package/skills/01_Meta-Skills/ethoclaw-daily-paper/scripts/build_top5_digest.py +300 -0
  11. package/skills/01_Meta-Skills/ethoclaw-daily-paper/scripts/common.py +137 -0
  12. package/skills/01_Meta-Skills/ethoclaw-daily-paper/scripts/merge_results.py +106 -0
  13. package/skills/01_Meta-Skills/ethoclaw-daily-paper/scripts/run_pipeline.py +177 -0
  14. package/skills/01_Meta-Skills/ethoclaw-daily-paper/scripts/search_arxiv.py +162 -0
  15. package/skills/01_Meta-Skills/ethoclaw-daily-paper/scripts/search_pubmed.py +202 -0
  16. package/skills/01_Meta-Skills/ethoclaw-normalize-tabular/SKILL.md +173 -0
  17. package/skills/01_Meta-Skills/ethoclaw-normalize-tabular/scripts/normalize_data.py +874 -0
  18. package/skills/01_Meta-Skills/ethoclaw-pdf-research/SKILL.md +134 -0
  19. package/skills/01_Meta-Skills/ethoclaw-pdf-research/references/confirmation-prompts.md +31 -0
  20. package/skills/01_Meta-Skills/ethoclaw-pdf-research/references/output-patterns.md +45 -0
  21. package/skills/01_Meta-Skills/ethoclaw-pdf-research/scripts/build_markdown_deliverables.py +41 -0
  22. package/skills/01_Meta-Skills/ethoclaw-pdf-research/scripts/build_research_log.py +84 -0
  23. package/skills/01_Meta-Skills/ethoclaw-pdf-research/scripts/build_summary_md.py +63 -0
  24. package/skills/01_Meta-Skills/ethoclaw-pdf-research/scripts/extract_pdf_bundle.py +140 -0
  25. package/skills/01_Meta-Skills/experiment-controller/SKILL.md +140 -0
  26. package/skills/01_Meta-Skills/knowledge-graph-builder/SKILL.md +366 -0
  27. package/skills/01_Meta-Skills/knowledge-graph-builder/scripts/entity_resolution.py +120 -0
  28. package/skills/01_Meta-Skills/knowledge-graph-builder/scripts/extraction_prompt_template.txt +19 -0
  29. package/skills/01_Meta-Skills/knowledge-graph-builder/scripts/graph_query.py +106 -0
  30. package/skills/01_Meta-Skills/knowledge-graph-builder/scripts/hypothesis_cli_reference.py +42 -0
  31. package/skills/01_Meta-Skills/knowledge-graph-builder/scripts/new_data_source_template.py +116 -0
  32. package/skills/01_Meta-Skills/knowledge-graph-builder/scripts/requirements.txt +15 -0
  33. package/skills/01_Meta-Skills/method-design/SKILL.md +61 -0
  34. package/skills/01_Meta-Skills/multi-search-engine/SKILL.md +119 -0
  35. package/skills/01_Meta-Skills/research-idea/SKILL.md +65 -0
  36. package/skills/05_EEG_ERP/eeg-skill/SKILL.md +197 -0
  37. package/skills/05_EEG_ERP/meg-skill/SKILL.md +188 -0
  38. package/skills/05_EEG_ERP/meg-skill/scripts/time_frequency.py +223 -0
  39. package/skills/05_EEG_ERP/mne-eeg-tool/SKILL.md +165 -0
  40. package/skills/05_EEG_ERP/mne-eeg-tool/scripts/eeg_pipeline_reference.py +231 -0
  41. package/skills/05_EEG_ERP/seed-iv-skill/SKILL.md +184 -0
  42. package/skills/05_EEG_ERP/seed-iv-skill/scripts/classify_seed_iv.py +154 -0
  43. package/skills/05_EEG_ERP/seed-iv-skill/scripts/extract_seed_iv_features.py +190 -0
  44. package/skills/05_EEG_ERP/seed-iv-skill/scripts/validate_seed_iv.py +102 -0
  45. package/skills/05_EEG_ERP/seed-vig-skill/SKILL.md +182 -0
  46. package/skills/05_EEG_ERP/seed-vig-skill/scripts/classify_seed_vig.py +165 -0
  47. package/skills/05_EEG_ERP/seed-vig-skill/scripts/extract_seed_vig_features.py +185 -0
  48. package/skills/05_EEG_ERP/seed-vig-skill/scripts/validate_seed_vig.py +88 -0
  49. package/skills/06_fMRI_Neuroimaging/abcd-skill/SKILL.md +308 -0
  50. package/skills/06_fMRI_Neuroimaging/abcd-skill/scripts/abcd_qc_summary.py +449 -0
  51. package/skills/06_fMRI_Neuroimaging/abcd-skill/scripts/extract_abcd_phenotype.py +292 -0
  52. package/skills/06_fMRI_Neuroimaging/abcd-skill/scripts/reorganize_abcd.py +387 -0
  53. package/skills/06_fMRI_Neuroimaging/abide-skill/SKILL.md +302 -0
  54. package/skills/06_fMRI_Neuroimaging/abide-skill/scripts/abide_qc_summary.py +317 -0
  55. package/skills/06_fMRI_Neuroimaging/abide-skill/scripts/extract_abide_phenotype.py +267 -0
  56. package/skills/06_fMRI_Neuroimaging/abide-skill/scripts/reorganize_abide.py +387 -0
  57. package/skills/06_fMRI_Neuroimaging/adhd200-skill/SKILL.md +244 -0
  58. package/skills/06_fMRI_Neuroimaging/adhd200-skill/scripts/adhd200_qc_summary.py +98 -0
  59. package/skills/06_fMRI_Neuroimaging/adhd200-skill/scripts/extract_adhd200_phenotype.py +134 -0
  60. package/skills/06_fMRI_Neuroimaging/adhd200-skill/scripts/reorganize_adhd200.py +206 -0
  61. package/skills/06_fMRI_Neuroimaging/adni-skill/SKILL.md +358 -0
  62. package/skills/06_fMRI_Neuroimaging/adni-skill/scripts/generate_adni_task_files.py +1305 -0
  63. package/skills/06_fMRI_Neuroimaging/adni-skill/scripts/generate_vqa_from_tasks.py +766 -0
  64. package/skills/06_fMRI_Neuroimaging/adni-skill/scripts/reorganize_adni.py +491 -0
  65. package/skills/06_fMRI_Neuroimaging/aibl-skill/SKILL.md +295 -0
  66. package/skills/06_fMRI_Neuroimaging/aibl-skill/scripts/aibl_qc_summary.py +260 -0
  67. package/skills/06_fMRI_Neuroimaging/aibl-skill/scripts/extract_aibl_phenotype.py +365 -0
  68. package/skills/06_fMRI_Neuroimaging/aibl-skill/scripts/reorganize_aibl.py +394 -0
  69. package/skills/06_fMRI_Neuroimaging/aomic-skill/SKILL.md +292 -0
  70. package/skills/06_fMRI_Neuroimaging/aomic-skill/scripts/aomic_qc_summary.py +258 -0
  71. package/skills/06_fMRI_Neuroimaging/aomic-skill/scripts/extract_aomic_phenotype.py +284 -0
  72. package/skills/06_fMRI_Neuroimaging/aomic-skill/scripts/reorganize_aomic.py +322 -0
  73. package/skills/06_fMRI_Neuroimaging/asl-skill/SKILL.md +168 -0
  74. package/skills/06_fMRI_Neuroimaging/asl-skill/scripts/compute_cbf.py +224 -0
  75. package/skills/06_fMRI_Neuroimaging/bids-organizer/SKILL.md +241 -0
  76. package/skills/06_fMRI_Neuroimaging/bold5000-skill/SKILL.md +186 -0
  77. package/skills/06_fMRI_Neuroimaging/bold5000-skill/scripts/bold5000_qc_summary.py +96 -0
  78. package/skills/06_fMRI_Neuroimaging/bold5000-skill/scripts/extract_bold5000_stimulus.py +125 -0
  79. package/skills/06_fMRI_Neuroimaging/bold5000-skill/scripts/reorganize_bold5000.py +102 -0
  80. package/skills/06_fMRI_Neuroimaging/camcan-skill/SKILL.md +213 -0
  81. package/skills/06_fMRI_Neuroimaging/camcan-skill/scripts/camcan_qc_summary.py +131 -0
  82. package/skills/06_fMRI_Neuroimaging/camcan-skill/scripts/extract_camcan_phenotype.py +145 -0
  83. package/skills/06_fMRI_Neuroimaging/camcan-skill/scripts/validate_camcan.py +141 -0
  84. package/skills/06_fMRI_Neuroimaging/cobre-skill/SKILL.md +201 -0
  85. package/skills/06_fMRI_Neuroimaging/cobre-skill/scripts/cobre_qc_summary.py +95 -0
  86. package/skills/06_fMRI_Neuroimaging/cobre-skill/scripts/extract_cobre_phenotype.py +104 -0
  87. package/skills/06_fMRI_Neuroimaging/cobre-skill/scripts/reorganize_cobre.py +140 -0
  88. package/skills/06_fMRI_Neuroimaging/conn-tool/SKILL.md +180 -0
  89. package/skills/06_fMRI_Neuroimaging/dcm2nii/SKILL.md +189 -0
  90. package/skills/06_fMRI_Neuroimaging/dmt-har-med-skill/SKILL.md +183 -0
  91. package/skills/06_fMRI_Neuroimaging/dmt-har-med-skill/scripts/dmt_har_med_qc_summary.py +96 -0
  92. package/skills/06_fMRI_Neuroimaging/dmt-har-med-skill/scripts/extract_dmt_har_med_phenotype.py +121 -0
  93. package/skills/06_fMRI_Neuroimaging/dmt-har-med-skill/scripts/reorganize_dmt_har_med.py +125 -0
  94. package/skills/06_fMRI_Neuroimaging/dwi-skill/SKILL.md +359 -0
  95. package/skills/06_fMRI_Neuroimaging/fmri-skill/SKILL.md +371 -0
  96. package/skills/06_fMRI_Neuroimaging/fmriprep-tool/SKILL.md +228 -0
  97. package/skills/06_fMRI_Neuroimaging/freesurfer-tool/SKILL.md +286 -0
  98. package/skills/06_fMRI_Neuroimaging/freesurfer-tool/scripts/freesurfer_processor.py +145 -0
  99. package/skills/06_fMRI_Neuroimaging/fsl-tool/SKILL.md +208 -0
  100. package/skills/06_fMRI_Neuroimaging/hbn-skill/SKILL.md +271 -0
  101. package/skills/06_fMRI_Neuroimaging/hbn-skill/scripts/extract_hbn_phenotype.py +107 -0
  102. package/skills/06_fMRI_Neuroimaging/hbn-skill/scripts/hbn_qc_summary.py +96 -0
  103. package/skills/06_fMRI_Neuroimaging/hbn-skill/scripts/reorganize_hbn.py +150 -0
  104. package/skills/06_fMRI_Neuroimaging/hcpa-skill/SKILL.md +210 -0
  105. package/skills/06_fMRI_Neuroimaging/hcpa-skill/scripts/extract_hcpa_phenotype.py +146 -0
  106. package/skills/06_fMRI_Neuroimaging/hcpa-skill/scripts/hcpa_qc_summary.py +120 -0
  107. package/skills/06_fMRI_Neuroimaging/hcpa-skill/scripts/reorganize_hcpa.py +155 -0
  108. package/skills/06_fMRI_Neuroimaging/hcpd-skill/SKILL.md +210 -0
  109. package/skills/06_fMRI_Neuroimaging/hcpd-skill/scripts/extract_hcpd_phenotype.py +148 -0
  110. package/skills/06_fMRI_Neuroimaging/hcpd-skill/scripts/hcpd_qc_summary.py +125 -0
  111. package/skills/06_fMRI_Neuroimaging/hcpd-skill/scripts/reorganize_hcpd.py +146 -0
  112. package/skills/06_fMRI_Neuroimaging/hcpep-skill/SKILL.md +215 -0
  113. package/skills/06_fMRI_Neuroimaging/hcpep-skill/scripts/extract_hcpep_phenotype.py +157 -0
  114. package/skills/06_fMRI_Neuroimaging/hcpep-skill/scripts/hcpep_qc_summary.py +143 -0
  115. package/skills/06_fMRI_Neuroimaging/hcpep-skill/scripts/reorganize_hcpep.py +146 -0
  116. package/skills/06_fMRI_Neuroimaging/hcppipeline-tool/SKILL.md +217 -0
  117. package/skills/06_fMRI_Neuroimaging/hcpya-skill/SKILL.md +214 -0
  118. package/skills/06_fMRI_Neuroimaging/hcpya-skill/scripts/extract_hcpya_phenotype.py +190 -0
  119. package/skills/06_fMRI_Neuroimaging/hcpya-skill/scripts/hcpya_qc_summary.py +152 -0
  120. package/skills/06_fMRI_Neuroimaging/hcpya-skill/scripts/reorganize_hcpya.py +203 -0
  121. package/skills/06_fMRI_Neuroimaging/ixi-skill/SKILL.md +198 -0
  122. package/skills/06_fMRI_Neuroimaging/ixi-skill/scripts/ixi_qc_summary.py +137 -0
  123. package/skills/06_fMRI_Neuroimaging/ixi-skill/scripts/reorganize_ixi.py +190 -0
  124. package/skills/06_fMRI_Neuroimaging/mnd-skill/SKILL.md +191 -0
  125. package/skills/06_fMRI_Neuroimaging/mnd-skill/scripts/extract_mnd_phenotype.py +143 -0
  126. package/skills/06_fMRI_Neuroimaging/mnd-skill/scripts/mnd_qc_summary.py +120 -0
  127. package/skills/06_fMRI_Neuroimaging/mnd-skill/scripts/validate_mnd.py +107 -0
  128. package/skills/06_fMRI_Neuroimaging/mschallenge-skill/SKILL.md +203 -0
  129. package/skills/06_fMRI_Neuroimaging/mschallenge-skill/scripts/analyze_lesions.py +119 -0
  130. package/skills/06_fMRI_Neuroimaging/mschallenge-skill/scripts/longitudinal_lesion.py +148 -0
  131. package/skills/06_fMRI_Neuroimaging/mschallenge-skill/scripts/mschallenge_qc_summary.py +132 -0
  132. package/skills/06_fMRI_Neuroimaging/mschallenge-skill/scripts/validate_mschallenge.py +116 -0
  133. package/skills/06_fMRI_Neuroimaging/nibabel-skill/SKILL.md +184 -0
  134. package/skills/06_fMRI_Neuroimaging/nibabel-skill/scripts/atlas_coordinate_reference.py +61 -0
  135. package/skills/06_fMRI_Neuroimaging/nibabel-skill/scripts/freesurfer_io_reference.py +34 -0
  136. package/skills/06_fMRI_Neuroimaging/nibabel-skill/scripts/nifti_inspection_reference.py +35 -0
  137. package/skills/06_fMRI_Neuroimaging/nifd-skill/SKILL.md +205 -0
  138. package/skills/06_fMRI_Neuroimaging/nifd-skill/scripts/extract_nifd_phenotype.py +132 -0
  139. package/skills/06_fMRI_Neuroimaging/nifd-skill/scripts/nifd_qc_summary.py +111 -0
  140. package/skills/06_fMRI_Neuroimaging/nifd-skill/scripts/validate_nifd.py +111 -0
  141. package/skills/06_fMRI_Neuroimaging/nii2dcm/SKILL.md +143 -0
  142. package/skills/06_fMRI_Neuroimaging/nilearn-tool/SKILL.md +266 -0
  143. package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/connectome_reference.py +65 -0
  144. package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/denoise_timeseries_reference.py +58 -0
  145. package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/hierarchical_parcellation_reference.py +53 -0
  146. package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/kmeans_parcellation_reference.py +53 -0
  147. package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/preprocess_bold_reference.py +76 -0
  148. package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/rest_dictlearning_reference.py +56 -0
  149. package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/rest_ica_reference.py +59 -0
  150. package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/second_level_glm_reference.py +58 -0
  151. package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/spacenet_classifier_reference.py +59 -0
  152. package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/svm_classifier_reference.py +60 -0
  153. package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/task_glm_reference.py +63 -0
  154. package/skills/06_fMRI_Neuroimaging/nilearn-tool/scripts/zalff_summary_reference.py +109 -0
  155. package/skills/06_fMRI_Neuroimaging/nsd-skill/SKILL.md +210 -0
  156. package/skills/06_fMRI_Neuroimaging/nsd-skill/scripts/extract_nsd_stimulus.py +171 -0
  157. package/skills/06_fMRI_Neuroimaging/nsd-skill/scripts/nsd_qc_summary.py +142 -0
  158. package/skills/06_fMRI_Neuroimaging/nsd-skill/scripts/validate_nsd.py +142 -0
  159. package/skills/06_fMRI_Neuroimaging/oasis-skill/SKILL.md +205 -0
  160. package/skills/06_fMRI_Neuroimaging/oasis-skill/scripts/extract_oasis_phenotype.py +126 -0
  161. package/skills/06_fMRI_Neuroimaging/oasis-skill/scripts/oasis_qc_summary.py +115 -0
  162. package/skills/06_fMRI_Neuroimaging/oasis-skill/scripts/validate_oasis.py +119 -0
  163. package/skills/06_fMRI_Neuroimaging/pet-skill/SKILL.md +173 -0
  164. package/skills/06_fMRI_Neuroimaging/pet-skill/scripts/compute_suvr.py +202 -0
  165. package/skills/06_fMRI_Neuroimaging/pnc-skill/SKILL.md +206 -0
  166. package/skills/06_fMRI_Neuroimaging/pnc-skill/scripts/extract_pnc_phenotype.py +136 -0
  167. package/skills/06_fMRI_Neuroimaging/pnc-skill/scripts/pnc_qc_summary.py +116 -0
  168. package/skills/06_fMRI_Neuroimaging/pnc-skill/scripts/validate_pnc.py +120 -0
  169. package/skills/06_fMRI_Neuroimaging/ppmi-skill/SKILL.md +209 -0
  170. package/skills/06_fMRI_Neuroimaging/ppmi-skill/scripts/extract_ppmi_phenotype.py +138 -0
  171. package/skills/06_fMRI_Neuroimaging/ppmi-skill/scripts/ppmi_qc_summary.py +111 -0
  172. package/skills/06_fMRI_Neuroimaging/ppmi-skill/scripts/validate_ppmi.py +117 -0
  173. package/skills/06_fMRI_Neuroimaging/qsiprep-tool/SKILL.md +320 -0
  174. package/skills/06_fMRI_Neuroimaging/rest-mneta-mdd-skill/SKILL.md +215 -0
  175. package/skills/06_fMRI_Neuroimaging/rest-mneta-mdd-skill/scripts/extract_rest_mdd_phenotype.py +132 -0
  176. package/skills/06_fMRI_Neuroimaging/rest-mneta-mdd-skill/scripts/harmonize_sites.py +152 -0
  177. package/skills/06_fMRI_Neuroimaging/rest-mneta-mdd-skill/scripts/rest_mdd_qc_summary.py +124 -0
  178. package/skills/06_fMRI_Neuroimaging/rest-mneta-mdd-skill/scripts/validate_rest_mdd.py +103 -0
  179. package/skills/06_fMRI_Neuroimaging/smri-skill/SKILL.md +302 -0
  180. package/skills/06_fMRI_Neuroimaging/tcp-skill/SKILL.md +204 -0
  181. package/skills/06_fMRI_Neuroimaging/tcp-skill/scripts/extract_tcp_phenotype.py +139 -0
  182. package/skills/06_fMRI_Neuroimaging/tcp-skill/scripts/tcp_qc_summary.py +111 -0
  183. package/skills/06_fMRI_Neuroimaging/tcp-skill/scripts/validate_tcp.py +99 -0
  184. package/skills/06_fMRI_Neuroimaging/ucla-cnp-skill/SKILL.md +217 -0
  185. package/skills/06_fMRI_Neuroimaging/ucla-cnp-skill/scripts/extract_ucla_cnp_phenotype.py +145 -0
  186. package/skills/06_fMRI_Neuroimaging/ucla-cnp-skill/scripts/ucla_cnp_qc_summary.py +111 -0
  187. package/skills/06_fMRI_Neuroimaging/ucla-cnp-skill/scripts/validate_ucla_cnp.py +113 -0
  188. package/skills/06_fMRI_Neuroimaging/ukb-skill/SKILL.md +310 -0
  189. package/skills/06_fMRI_Neuroimaging/ukb-skill/scripts/build_ukb_survival.py +210 -0
  190. package/skills/06_fMRI_Neuroimaging/ukb-skill/scripts/extract_ukb_cases.py +308 -0
  191. package/skills/06_fMRI_Neuroimaging/ukb-skill/scripts/extract_ukb_phenotype.py +232 -0
  192. package/skills/06_fMRI_Neuroimaging/ukb-skill/scripts/ukb_qc_summary.py +158 -0
  193. package/skills/06_fMRI_Neuroimaging/wmh-segmentation/SKILL.md +133 -0
  194. package/skills/07_Computational_Modeling/detrending/SKILL.md +118 -0
  195. package/skills/07_Computational_Modeling/dictlearning/SKILL.md +122 -0
  196. package/skills/07_Computational_Modeling/filtering/SKILL.md +121 -0
  197. package/skills/07_Computational_Modeling/glm/SKILL.md +153 -0
  198. package/skills/07_Computational_Modeling/hierarchical/SKILL.md +121 -0
  199. package/skills/07_Computational_Modeling/ica/SKILL.md +122 -0
  200. package/skills/07_Computational_Modeling/kmeans/SKILL.md +119 -0
  201. package/skills/07_Computational_Modeling/run_models/SKILL.md +427 -0
  202. package/skills/07_Computational_Modeling/spacenet/SKILL.md +122 -0
  203. package/skills/07_Computational_Modeling/svm/SKILL.md +120 -0
  204. package/skills/08_Computational_Neuroscience/brain_gnn/SKILL.md +183 -0
  205. package/skills/08_Computational_Neuroscience/dipy-tool/SKILL.md +239 -0
  206. package/skills/08_Computational_Neuroscience/dipy-tool/scripts/dti_metrics_reference.py +70 -0
  207. package/skills/08_Computational_Neuroscience/dipy-tool/scripts/load_and_mask_reference.py +76 -0
  208. package/skills/08_Computational_Neuroscience/dipy-tool/scripts/roi_stats_reference.py +59 -0
  209. package/skills/08_Computational_Neuroscience/fm_app/SKILL.md +195 -0
  210. package/skills/08_Computational_Neuroscience/neurostorm/SKILL.md +151 -0
  211. package/skills/13_Visualization/brain-visualization/SKILL.md +191 -0
  212. package/skills/13_Visualization/brain-visualization/scripts/connectome_reference.py +108 -0
  213. package/skills/13_Visualization/brain-visualization/scripts/freesurfer_ply_reference.py +54 -0
  214. package/skills/13_Visualization/brain-visualization/scripts/zalff_summary_reference.py +116 -0
  215. package/skills/13_Visualization/ethoclaw-paper-figure-layout/SKILL.md +78 -0
  216. package/skills/13_Visualization/ethoclaw-paper-figure-layout/assets/naturecomm_figures.tex +74 -0
  217. package/skills/13_Visualization/ethoclaw-paper-figure-layout/scripts/layout_results_foldered.py +579 -0
  218. package/skills/14_Writing/overleaf-skill/SKILL.md +184 -0
  219. package/skills/14_Writing/overleaf-skill/scripts/install.sh +30 -0
  220. package/skills/14_Writing/paper-writing/SKILL.md +146 -0
  221. package/skills/14_Writing/paper-writing/scripts/data_statement_templates.py +164 -0
  222. package/skills/14_Writing/paper-writing/scripts/figure_templates.py +315 -0
  223. package/skills/14_Writing/paper-writing/scripts/nature_figure_style.py +214 -0
  224. package/skills/14_Writing/paper-writing/scripts/section_phrasebank.py +246 -0
  225. package/skills/16_Animal_Behavior/deeplabcut/SKILL.md +154 -0
  226. package/skills/16_Animal_Behavior/deeplabcut/references/3d-pose.md +89 -0
  227. package/skills/16_Animal_Behavior/deeplabcut/references/maDLC.md +123 -0
  228. package/skills/16_Animal_Behavior/deeplabcut/references/modelzoo.md +98 -0
  229. package/skills/16_Animal_Behavior/deeplabcut/references/standard-pipeline.md +165 -0
  230. package/skills/16_Animal_Behavior/deeplabcut/references/utilities.md +146 -0
  231. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/SKILL.md +274 -0
  232. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/report_template_en.html +112 -0
  233. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/report_template_en.md +21 -0
  234. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/cluster-section.md +5 -0
  235. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/heatmap-section.md +5 -0
  236. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/integrated-interpretation.md +3 -0
  237. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/overview.md +3 -0
  238. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/project-summary.md +3 -0
  239. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/radar-section.md +5 -0
  240. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/raw-trajectory.md +3 -0
  241. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/sample-check.md +3 -0
  242. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/single-subject-section.md +3 -0
  243. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/assets/section_templates/stats-section.md +5 -0
  244. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/experiment-types/epm.md +52 -0
  245. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/experiment-types/fst.md +37 -0
  246. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/experiment-types/nor.md +39 -0
  247. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/experiment-types/oft.md +43 -0
  248. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/experiment-types/tcst.md +45 -0
  249. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/experiment-types/tst.md +36 -0
  250. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/input-types.md +59 -0
  251. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/interpretation-guardrails.md +45 -0
  252. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/metadata-schema.md +57 -0
  253. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/report-sections.md +86 -0
  254. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/references/section-selection-rules.md +169 -0
  255. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/scripts/build_report_manifest.py +27 -0
  256. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/scripts/render_report.py +34 -0
  257. package/skills/16_Animal_Behavior/ethoclaw-analysis-report/scripts/report_utils.py +1121 -0
  258. package/skills/16_Animal_Behavior/ethoclaw-animal-grounding/SKILL.md +390 -0
  259. package/skills/16_Animal_Behavior/ethoclaw-animal-grounding/reference_code.py +98 -0
  260. package/skills/16_Animal_Behavior/ethoclaw-animal-pose-estimation/SKILL.md +336 -0
  261. package/skills/16_Animal_Behavior/ethoclaw-kinematic-parameter-generator/README.md +21 -0
  262. package/skills/16_Animal_Behavior/ethoclaw-kinematic-parameter-generator/SKILL.md +41 -0
  263. package/skills/16_Animal_Behavior/ethoclaw-kinematic-parameter-generator/batch_kinematic_generator.py +663 -0
  264. package/skills/16_Animal_Behavior/ethoclaw-kinematic-parameter-generator/config.json +19 -0
  265. package/skills/16_Animal_Behavior/ethoclaw-kinematic-parameter-generator/generate_kinematic_parameter.py +401 -0
  266. package/skills/16_Animal_Behavior/ethoclaw-kinematic-parameter-generator/kinematic_generator.py +265 -0
  267. package/skills/16_Animal_Behavior/ethoclaw-multiparameter-clustermap-generate/SKILL.md +72 -0
  268. package/skills/16_Animal_Behavior/ethoclaw-multiparameter-clustermap-generate/references/config.example.toml +56 -0
  269. package/skills/16_Animal_Behavior/ethoclaw-multiparameter-clustermap-generate/scripts/cluster_all_params.py +232 -0
  270. package/skills/16_Animal_Behavior/ethoclaw-multiparameter-clustermap-generate/scripts/cluster_all_params_from_config.py +236 -0
  271. package/skills/16_Animal_Behavior/ethoclaw-multiparameter-radar-generate/SKILL.md +68 -0
  272. package/skills/16_Animal_Behavior/ethoclaw-multiparameter-radar-generate/references/notes.md +5 -0
  273. package/skills/16_Animal_Behavior/ethoclaw-multiparameter-radar-generate/scripts/plot_h5_radar.py +513 -0
  274. package/skills/16_Animal_Behavior/ethoclaw-multiparameter-violin-stats-generate/SKILL.md +52 -0
  275. package/skills/16_Animal_Behavior/ethoclaw-multiparameter-violin-stats-generate/config.toml +81 -0
  276. package/skills/16_Animal_Behavior/ethoclaw-multiparameter-violin-stats-generate/references/stats-rule.md +18 -0
  277. package/skills/16_Animal_Behavior/ethoclaw-multiparameter-violin-stats-generate/scripts/h5_inspect.py +79 -0
  278. package/skills/16_Animal_Behavior/ethoclaw-multiparameter-violin-stats-generate/scripts/h5_violin_batch.py +624 -0
  279. package/skills/16_Animal_Behavior/ethoclaw-multiparameter-violin-stats-generate/scripts/h5_violin_stats.py +438 -0
  280. package/skills/16_Animal_Behavior/ethoclaw-trajectory-velocity-heatmap-generate/SKILL.md +280 -0
  281. package/skills/16_Animal_Behavior/ethoclaw-trajectory-velocity-heatmap-generate/core_scripts/heatmap_trajectory.py +790 -0
  282. package/skills/16_Animal_Behavior/ethoclaw-trajectory-velocity-heatmap-generate/core_scripts/heatmap_velocity.py +855 -0
  283. package/skills/16_Animal_Behavior/ethoclaw-trajectory-velocity-heatmap-generate/reference_data/reference_2d.csv +101 -0
  284. package/skills/16_Animal_Behavior/ethoclaw-trajectory-velocity-heatmap-generate/reference_data/reference_2d.h5 +0 -0
  285. package/skills/16_Animal_Behavior/ethoclaw-trajectory-velocity-heatmap-generate/reference_data/reference_data_readme.md +126 -0
@@ -0,0 +1,120 @@
1
+ ---
2
+ name: svm
3
+ description: "Use this model doc whenever the user wants to perform disease classification with SVM. This is a non-deep-learning supervised route focused on neuroimaging-based case-control prediction from ROI-wise or tabular features."
4
+ license: MIT License (NeuroClaw custom skill - freely modifiable within the project)
5
+ layer: base
6
+ skill_type: model
7
+ dependencies:
8
+ - fmri-skill
9
+ - smri-skill
10
+ - nilearn-tool
11
+ - run_models
12
+ ---
13
+ # SVM Model Doc
14
+
15
+ ## Overview
16
+ SVM is a classical non-deep-learning method for neuroimaging-based disease classification.
17
+
18
+ - Model family: non-deep-learning supervised classification method
19
+ - Typical objectives:
20
+ - classify patient vs control groups from neuroimaging features
21
+ - build discriminative models from ROI features or tabular summaries
22
+ - export predictive scores and evaluation metrics
23
+ - Primary input: preprocessed fMRI / sMRI derived features, labels, optional covariates
24
+ - Primary output: class predictions, decision scores, cross-validation metrics
25
+
26
+ In NeuroClaw, this document is model-level guidance for SVM-based disease classification workflows rather than deep learning phenotype prediction.
27
+
28
+ Upstream preparation should usually be delegated to:
29
+ - `fmri-skill` for fMRI preprocessing and ROI / voxel feature preparation
30
+ - `smri-skill` for structural feature extraction when disease classification uses sMRI
31
+ - `nilearn-tool` for concrete SVM fitting on prepared feature tables
32
+
33
+ **Research use only.**
34
+
35
+ ---
36
+
37
+ ## Quick Start
38
+
39
+ ### 1) Prepare disease classification inputs
40
+ Expected inputs:
41
+ - subject-level labels such as patient / control
42
+ - preprocessed imaging features
43
+ - optional covariates such as age, sex, site
44
+ - optional train / validation / test split definition
45
+
46
+ If features are not ready, delegate preprocessing to `fmri-skill` or `smri-skill` first.
47
+
48
+ ### 2) SVM route
49
+ Representative operations:
50
+ - prepare ROI-wise or tabular neuroimaging features
51
+ - standardize features within the training fold
52
+ - fit linear or kernel SVM for disease classification
53
+ - export predictions, decision scores, and performance metrics
54
+
55
+ Example execution route:
56
+ ```bash
57
+ # delegated through claw-shell after features are prepared
58
+ python skills/nilearn-tool/scripts/svm_classifier_reference.py \
59
+ --features path/to/features.csv \
60
+ --labels path/to/labels.csv \
61
+ --target diagnosis \
62
+ --cv 5 \
63
+ --output-dir run_models_output/svm
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Input / Output Contract
69
+
70
+ ### Required inputs
71
+ - subject-level labels for disease classification
72
+ - feature table or ROI summary matrix
73
+
74
+ ### Optional inputs
75
+ - confounds or covariates table
76
+ - train / validation / test split file
77
+ - hyperparameter settings such as kernel, C, or number of CV folds
78
+
79
+ ### Produced outputs
80
+ - predicted labels and decision scores
81
+ - cross-validation metrics such as accuracy, AUC, sensitivity, specificity
82
+ - fitted model artifact or coefficient table
83
+
84
+ ---
85
+
86
+ ## Recommended Delegation
87
+
88
+ - imaging preprocessing and feature preparation -> `fmri-skill` and/or `smri-skill`
89
+ - concrete implementation of SVM -> `nilearn-tool`
90
+ - shell execution and logging -> `claw-shell`
91
+
92
+ No execution before explicit plan confirmation.
93
+
94
+ ---
95
+
96
+ ## When to Use SVM
97
+
98
+ - The user wants classical disease classification instead of a deep learning model.
99
+ - The dataset size is moderate and model interpretability matters.
100
+ - ROI-level features are already prepared and SVM is sufficient.
101
+ - The task is case-control prediction, diagnosis support, or cross-validated disease discrimination.
102
+
103
+ ---
104
+
105
+ ## Limitations and Notes
106
+
107
+ - SVM performance depends strongly on feature engineering, scaling, and leakage-free cross-validation.
108
+ - Site effects and confounds can dominate disease classification if not controlled properly.
109
+ - Small sample sizes can lead to optimistic estimates unless split strategy is rigorously managed.
110
+
111
+ ---
112
+
113
+ ## Reference
114
+
115
+ - Cortes C, Vapnik V. Support-vector networks.
116
+ - Nilearn decoding documentation: https://nilearn.github.io/stable/decoding/index.html
117
+
118
+ Created At: 2026-04-14 00:34 HKT
119
+ Last Updated At: 2026-04-14 00:45 HKT
120
+ Author: chengwang96
@@ -0,0 +1,183 @@
1
+ ---
2
+ name: braingnn
3
+ description: "Use this model doc whenever the user wants to run BrainGNN for fMRI phenotype prediction, including graph construction, training, and evaluation. This document focuses on model-level usage and delegates upstream preprocessing to fmri-skill (and optionally hcpya-skill for HCP data)."
4
+ license: MIT License (NeuroClaw custom skill - freely modifiable within the project)
5
+ layer: base
6
+ skill_type: model
7
+ dependencies:
8
+ - fmri-skill
9
+ - run_models
10
+ ---
11
+ # BrainGNN Model Doc
12
+
13
+ ## Overview
14
+ BrainGNN is an interpretable graph neural network for fMRI analysis and phenotype prediction.
15
+
16
+ - Paper: Li et al., 2020, BrainGNN
17
+ - Official code: https://github.com/xxlya/BrainGNN_Pytorch/tree/main
18
+ - Primary input: ROI-level fMRI data (timeseries/connectivity)
19
+ - Primary output: phenotype prediction (classification/regression, task-dependent)
20
+
21
+ In NeuroClaw, this document is model-level guidance. Upstream data preparation should be delegated to:
22
+ - `fmri-skill` for fMRI preprocessing and ROI extraction
23
+ - `hcpya-skill` when HCP Young Adult dataset download/orchestration is needed
24
+
25
+ **Research use only.**
26
+
27
+ ---
28
+
29
+ ## Quick Start (From git clone)
30
+
31
+ ### 1) Clone repository
32
+ ```bash
33
+ git clone https://github.com/xxlya/BrainGNN_Pytorch.git
34
+ cd BrainGNN_Pytorch
35
+ ```
36
+
37
+ ### 2) Create environment and install dependencies
38
+ ```bash
39
+ python -m venv .venv
40
+ source .venv/bin/activate
41
+ pip install -r requirements.txt
42
+ ```
43
+
44
+ If using GPU, install version-matched PyTorch/PyG builds first, then install remaining requirements.
45
+
46
+ ### 3) Prepare data (ROI first)
47
+ Use `fmri-skill` to prepare ROI timeseries and metadata, then arrange files under:
48
+ - `data/{dataset_name}-rest.csv`
49
+ - `data/{dataset_name}_roi/`
50
+
51
+ ### 4) Run 3-phase pipeline
52
+ ```bash
53
+ # Phase 1: build connectivity matrices
54
+ python 01-fetch_data.py --atlas aal3 --dataset_name adhd200 --dataset_dir data
55
+
56
+ # Phase 2: convert to graph samples
57
+ python 02-process_data.py --atlas aal3 --dataset_name adhd200 --dataset_dir data --nclass 2 --score DX
58
+
59
+ # Phase 3: train/evaluate BrainGNN
60
+ CUDA_VISIBLE_DEVICES=0 python 03-main.py \
61
+ --atlas aal3 --dataset_name adhd200 --dataset_dir data \
62
+ --indim 166 --nroi 166 --nclass 2 --fold 0
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Pipeline Definition
68
+
69
+ ### Phase 1: Connectivity Generation (`01-fetch_data.py`)
70
+ Purpose: convert ROI timeseries to connectivity features.
71
+
72
+ Outputs:
73
+ - `data/{dataset_name}_roi/braingnn_{atlas}/*.mat`
74
+ - `data/{dataset_name}_roi/braingnn_{atlas}/valid_subject_list.pkl`
75
+
76
+ Key args:
77
+ - `--atlas`: `aal3`, `dk`, `cc200`, `ho`
78
+ - `--dataset_name`: `adhd200`, `cobre`, `UCLA`, `hcp-d`, `hcp-ep`, `ABCD`
79
+ - `--dataset_dir`: root data dir, default `data`
80
+
81
+ ### Phase 2: Graph Construction (`02-process_data.py`)
82
+ Purpose: convert connectivity matrices into per-subject graph files.
83
+
84
+ Outputs:
85
+ - `data/{dataset_name}_roi/braingnn_{atlas}/raw/{subject_id}.h5`
86
+
87
+ Common args:
88
+ - `--nclass`: class count
89
+ - `--score`: label key (`DX`, `Gender`, `Age`)
90
+ - `--seed`: random seed
91
+
92
+ ### Phase 3: Training and Evaluation (`03-main.py`)
93
+ Purpose: train BrainGNN with fold-wise evaluation and checkpointing.
94
+
95
+ Outputs:
96
+ - `model/{fold}.pth`
97
+ - `model/log/{fold}/` (TensorBoard)
98
+
99
+ Core model options:
100
+ - `--indim`, `--nroi`: must match atlas ROI count
101
+ - `--nclass`: output classes
102
+ - `--fold`: CV fold index
103
+ - `--n_epochs`, `--batchSize`, `--lr`, `--weightdecay`
104
+
105
+ ---
106
+
107
+ ## Input / Output Contract
108
+
109
+ ### Required inputs
110
+ - ROI timeseries per subject
111
+ - Subject metadata CSV with labels
112
+ - Dataset name and atlas selection
113
+
114
+ ### Produced outputs
115
+ - Connectivity matrices and graph files
116
+ - Trained checkpoint(s)
117
+ - Evaluation logs and metrics
118
+
119
+ ---
120
+
121
+ ## Atlas and Dimension Mapping
122
+
123
+ | Atlas | Typical ROI count | Required flags |
124
+ |---|---:|---|
125
+ | `aal3` | 166 | `--indim 166 --nroi 166` |
126
+ | `cc200` | 200 | `--indim 200 --nroi 200` |
127
+ | `dk` | atlas-dependent | set both flags to actual ROI count |
128
+ | `ho` | atlas-dependent | set both flags to actual ROI count |
129
+
130
+ If `--indim` or `--nroi` does not match the real ROI count, training will fail.
131
+
132
+ ---
133
+
134
+ ## Recommended Directory Layout
135
+
136
+ ```text
137
+ BrainGNN_Pytorch/
138
+ data/
139
+ {dataset_name}-rest.csv
140
+ {dataset_name}_roi/
141
+ braingnn_{atlas}/
142
+ *.mat
143
+ valid_subject_list.pkl
144
+ raw/*.h5
145
+ model/
146
+ {fold}.pth
147
+ log/{fold}/
148
+ ```
149
+
150
+ ---
151
+
152
+ ## NeuroClaw Delegation Rules
153
+
154
+ - ROI generation and preprocessing: delegate to `fmri-skill`
155
+ - HCP download/orchestration (if needed): delegate to `hcpya-skill` (or `hcpa-skill` / `hcpd-skill` / `hcpep-skill` for other HCP variants)
156
+ - Dependency checks: `dependency-planner` + `conda-env-manager`
157
+ - Execution routing: `claw-shell`
158
+
159
+ No execution before explicit plan confirmation.
160
+
161
+ ---
162
+
163
+ ## Limitations and Notes
164
+
165
+ - This workflow assumes ROI data already exists before Phase 1.
166
+ - GPU is strongly recommended for training speed.
167
+ - Cross-validation is controlled by running Phase 3 repeatedly with different `--fold` values.
168
+ - TensorBoard command:
169
+ ```bash
170
+ tensorboard --logdir ./model/log/
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Reference
176
+
177
+ - Li X, Zhou Y, Dvornek N, Zhang M, Gao S, Zhuang J, Scheinost D, Staib L, Ventola P, Duncan J. 2020. BrainGNN.
178
+ - Official repository: https://github.com/xxlya/BrainGNN_Pytorch/tree/main
179
+ - PyG installation notes: https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html
180
+
181
+ Created At: 2026-03-28 19:53 HKT
182
+ Last Updated At: 2026-03-28 19:53 HKT
183
+ Author: chengwang96
@@ -0,0 +1,239 @@
1
+ ---
2
+ name: dipy-tool
3
+ description: "Use this skill whenever any NeuroClaw diffusion MRI / DWI modality skill needs to execute concrete DIPY operations: load DWI (NIfTI+bvals+bvecs), optional masking, DTI fitting, compute FA/MD/AD/RD, and extract ROI statistics. This is the dedicated base/tool skill that contains all specific DIPY code and usage patterns. Never called directly by the user."
4
+ license: MIT License (NeuroClaw custom skill – freely modifiable within the project)
5
+ layer: base
6
+ skill_type: tool
7
+ dependencies:
8
+ - claw-shell
9
+ ---
10
+ # DIPY Tool (Base/Tool Layer)
11
+
12
+ ## Overview
13
+ `dipy-tool` is the **NeuroClaw base/tool skill** that provides the concrete **DIPY** implementation for diffusion MRI (DWI/DTI) processing and feature extraction.
14
+
15
+ It is **never called directly by the user**. It is delegated to by a diffusion modality-layer skill (e.g., future `dwi-skill` / `dmri-skill`) and executed via `claw-shell` for safety, logging, and long-running stability.
16
+
17
+ This skill provides:
18
+ - Robust loading of **DWI NIfTI + bvals + bvecs** with sanity checks.
19
+ - Brain mask generation (`median_otsu`) or use of a provided mask.
20
+ - **DTI fitting** (optionally selecting a b-value range) and metric export:
21
+ - **FA / MD / AD / RD** as NIfTI maps
22
+ - **ROI / atlas statistics** extraction (CSV summaries).
23
+
24
+ **Research use only** — not for clinical diagnosis.
25
+
26
+ ## Agent Reference Rule
27
+
28
+ When the agent needs DIPY-based implementation code, it should first consult the curated snippets in `skills/dipy-tool/scripts/` instead of copying the large embedded wrapper or unrelated tutorial files with hard-coded paths.
29
+
30
+ Reference snippets available:
31
+ - `scripts/load_and_mask_reference.py` -> DWI + gradients loading, b0 discovery, `median_otsu` brain masking
32
+ - `scripts/dti_metrics_reference.py` -> tensor fitting and FA/MD/AD/RD export
33
+ - `scripts/roi_stats_reference.py` -> atlas-based summary statistics on tensor metrics
34
+
35
+ ---
36
+
37
+ ## Quick Reference (Core Tasks)
38
+
39
+ | Task | What it does | Output |
40
+ |---|---|---|
41
+ | Load DWI + gradients | Validates shapes, loads NIfTI+bvals+bvecs | in-memory arrays |
42
+ | Brain mask | Auto mask (median_otsu) or use external | `brain_mask.nii.gz` |
43
+ | DTI fit | TensorModel fit on selected volumes | tensor fit object |
44
+ | Export tensor metrics | Compute & save FA/MD/AD/RD | `FA.nii.gz`, `MD.nii.gz`, `AD.nii.gz`, `RD.nii.gz` |
45
+ | ROI stats | Per-label summary (mean/median/std/p05/p95) | `roi_stats_FA.csv`, etc. |
46
+
47
+ ---
48
+
49
+ ## Curated Reference Scripts
50
+
51
+ These scripts are aligned with NeuroClaw's DWI handling pattern and with the modality / dependency expectations documented in `rs-fMRI-Pipeline-Tutorial/`:
52
+ - the tutorial explicitly includes DTI/DWI as a supported modality
53
+ - the tutorial installs `dipy` as a core dependency
54
+ - the tutorial's multimodal structure motivates deterministic outputs and atlas-based summaries
55
+
56
+ ### `scripts/load_and_mask_reference.py`
57
+ - Loads DWI NIfTI + bvals + bvecs with shape checks
58
+ - Finds b0 volumes and builds a brain mask with `median_otsu`
59
+ - Exports `brain_mask.nii.gz`, `mean_b0.nii.gz`, and `dwi_summary.txt`
60
+
61
+ Example:
62
+ ```bash
63
+ python skills/dipy-tool/scripts/load_and_mask_reference.py \
64
+ --dwi path/to/sub-001_dwi.nii.gz \
65
+ --bval path/to/sub-001_dwi.bval \
66
+ --bvec path/to/sub-001_dwi.bvec \
67
+ --output-dir dwi_output/sub-001/dipy/load_mask
68
+ ```
69
+
70
+ ### `scripts/dti_metrics_reference.py`
71
+ - Filters gradients for tensor fitting
72
+ - Fits a tensor model with DIPY
73
+ - Exports `FA.nii.gz`, `MD.nii.gz`, `AD.nii.gz`, and `RD.nii.gz`
74
+
75
+ Example:
76
+ ```bash
77
+ python skills/dipy-tool/scripts/dti_metrics_reference.py \
78
+ --dwi path/to/sub-001_dwi.nii.gz \
79
+ --bval path/to/sub-001_dwi.bval \
80
+ --bvec path/to/sub-001_dwi.bvec \
81
+ --mask dwi_output/sub-001/dipy/load_mask/brain_mask.nii.gz \
82
+ --output-dir dwi_output/sub-001/dipy/metrics
83
+ ```
84
+
85
+ ### `scripts/roi_stats_reference.py`
86
+ - Computes atlas-level statistics from tensor metrics
87
+ - Supports optional label names for structured CSV outputs
88
+ - Intended for FA/MD/AD/RD summaries after tensor fitting
89
+
90
+ Example:
91
+ ```bash
92
+ python skills/dipy-tool/scripts/roi_stats_reference.py \
93
+ --metric dwi_output/sub-001/dipy/metrics/FA.nii.gz \
94
+ --roi path/to/JHU_labels_in_dwi_space.nii.gz \
95
+ --output dwi_output/sub-001/dipy/roi_stats_FA.csv
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Installation (Handled by `dependency-planner`)
101
+ This tool is installed automatically when required.
102
+
103
+ Recommended isolated environment:
104
+ ```bash
105
+ conda create -n neuroclaw-dipy python=3.11 -y
106
+ conda activate neuroclaw-dipy
107
+ conda install -c conda-forge dipy nibabel numpy scipy scikit-image pandas -y
108
+ # Optional:
109
+ conda install -c conda-forge matplotlib -y
110
+ ```
111
+
112
+ **Recommended execution pattern (avoids shell activation pitfalls):**
113
+ - Use `conda run -n neuroclaw-dipy ...` routed through `claw-shell`.
114
+
115
+ ---
116
+
117
+ ## NeuroClaw recommended wrapper
118
+
119
+ If a single entry point is still needed later, it should be assembled from the curated snippets in `skills/dipy-tool/scripts/` rather than keeping a long monolithic example embedded in this document.
120
+
121
+ Recommended composition:
122
+ - `load_and_mask_reference.py` for DWI sanity checks and mask creation
123
+ - `dti_metrics_reference.py` for tensor fitting and FA/MD/AD/RD export
124
+ - `roi_stats_reference.py` for atlas-based feature summarization
125
+
126
+ All real runs must still be delegated to `claw-shell`.
127
+
128
+ ---
129
+
130
+ ## Example execution (must be routed via `claw-shell`)
131
+ ```bash
132
+ conda run -n neuroclaw-dipy python skills/dipy-tool/dipy_pipeline.py \
133
+ --dwi /data/sub-001_dwi.nii.gz \
134
+ --bval /data/sub-001_dwi.bval \
135
+ --bvec /data/sub-001_dwi.bvec \
136
+ --outdir dwi_output/sub-001 \
137
+ --dti-bmax 1200 \
138
+ --roi /data/JHU_labels_in_dwi_space.nii.gz
139
+ ```
140
+
141
+ ---
142
+
143
+ ## Important Notes & Limitations
144
+ - **Preprocessing matters**: FA/MD are highly sensitive to motion/eddy/susceptibility distortions. Best practice is to run **topup/eddy** first (e.g., via `fsl-tool` or HCP diffusion pipeline) and use the **rotated bvecs** output by eddy.
145
+ - **DTI vs multi-shell**: DTI fitting is most stable on low b-values (commonly b≤1000–1200). Higher-order models (DKI/NODDI) require separate implementations (extend this tool if needed).
146
+ - **ROI alignment**: ROI/atlas labels must be in the *same voxel space* as the DWI-derived metrics. Registration/warping is handled by other tools (e.g., FSL/ANTs/HCP pipelines).
147
+ - **Numerical stability**: small negative eigenvalues can occur; this pipeline clips them to zero before FA computation.
148
+
149
+ ## Benchmark Adapter Guidance
150
+
151
+ For benchmark-style ROI-statistics tasks, treat this tool as a library of narrow downstream building blocks rather than a mandatory full DWI pipeline.
152
+
153
+ - If the prompt already provides metric maps plus an ROI/atlas image, start directly from `scripts/roi_stats_reference.py` or an equivalent narrow ROI-statistics implementation.
154
+ - Do not automatically prepend DWI loading, masking, or tensor fitting when the required metric maps already exist.
155
+ - Preserve the benchmark output contract: when the task expects separate ROI summary files per metric, write one CSV per selected metric rather than a single combined table unless the prompt explicitly asks for a merged export.
156
+
157
+ ---
158
+
159
+ ## Complementary / Related Skills
160
+ - `dependency-planner` + `conda-env-manager` → install/manage `neuroclaw-dipy`
161
+
162
+ ---
163
+
164
+ ## Reference
165
+ - DIPY documentation: https://dipy.org/documentation/latest/
166
+ - DIPY DTI reconstruction examples (tensor fitting + FA/MD/AD/RD)
167
+ - rs-fMRI-Pipeline-Tutorial: https://github.com/Karcen/rs-fMRI-Pipeline-Tutorial
168
+ - Curated code snippets in this skill:
169
+ - `skills/dipy-tool/scripts/load_and_mask_reference.py`
170
+ - `skills/dipy-tool/scripts/dti_metrics_reference.py`
171
+ - `skills/dipy-tool/scripts/roi_stats_reference.py`
172
+ - Aligned with NeuroClaw base/tool skill pattern (`mne-eeg-tool`, etc.)
173
+
174
+ ## Post-Execution Verification (Harness Integration)
175
+
176
+ After DIPY processing completes, this skill **automatically invokes harness-core's VerificationRunner** to validate output integrity:
177
+
178
+ **Integrated verification checks**:
179
+
180
+ ```python
181
+ from skills.harness_core import VerificationRunner, AuditLogger
182
+
183
+ verifier = VerificationRunner(task_type="dipy_dti_processing")
184
+
185
+ # 1. DWI file loading and shape validation
186
+ verifier.add_check("dwi_loading",
187
+ checker=lambda: verify_dwi_loaded(output_dir),
188
+ severity="error"
189
+ )
190
+
191
+ # 2. Brain mask existence and coverage
192
+ verifier.add_check("brain_mask",
193
+ checker=lambda: verify_brain_mask(output_dir),
194
+ severity="error"
195
+ )
196
+
197
+ # 3. Gradient table validity (bvals/bvecs)
198
+ verifier.add_check("gradient_table",
199
+ checker=lambda: verify_gradient_table(output_dir),
200
+ severity="error"
201
+ )
202
+
203
+ # 4. Tensor metrics bounds (FA: 0–1, MD/AD/RD: reasonable μm²/ms)
204
+ verifier.add_check("tensor_bounds",
205
+ checker=lambda: verify_tensor_metrics_bounds(output_dir),
206
+ severity="warning"
207
+ )
208
+
209
+ # 5. Data integrity (NaN/Inf checks)
210
+ verifier.add_check("data_integrity",
211
+ checker=lambda: verify_no_nan_inf(output_dir),
212
+ severity="error"
213
+ )
214
+
215
+ # 6. ROI statistics shape (if extracted)
216
+ verifier.add_check("roi_statistics",
217
+ checker=lambda: verify_roi_stats_shape(output_dir),
218
+ severity="warning"
219
+ )
220
+
221
+ report = verifier.run(output_dir)
222
+
223
+ # Log verification results
224
+ logger = AuditLogger(log_file=f"{output_dir}/dipy_verification.jsonl")
225
+ logger.log_validation(
226
+ task_name="dipy_dti_processing",
227
+ checks_passed=len([r for r in report.results if r.passed]),
228
+ total_checks=len(report.results),
229
+ output_path=output_dir
230
+ )
231
+ ```
232
+
233
+ **Output**: `{output_dir}/dipy_verification.jsonl` (structured audit log with JSONL format)
234
+
235
+ ---
236
+
237
+ Created At: 2026-03-26 00:40 HKT
238
+ Last Updated At: 2026-04-14 00:28 HKT
239
+ Author: chengwang96
@@ -0,0 +1,70 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ from pathlib import Path
5
+
6
+ import nibabel as nib
7
+ import numpy as np
8
+ from dipy.core.gradients import gradient_table
9
+ from dipy.io.gradients import read_bvals_bvecs
10
+ from dipy.io.image import load_nifti, save_nifti
11
+ from dipy.reconst.dti import TensorModel, fractional_anisotropy
12
+
13
+
14
+ def fit_dti(data: np.ndarray, bvals: np.ndarray, bvecs: np.ndarray, mask: np.ndarray, b0_threshold: float, dti_bmax: float):
15
+ keep = (bvals <= dti_bmax) | (bvals < b0_threshold)
16
+ if not np.any(keep):
17
+ raise ValueError("No DTI-compatible volumes retained after b-value filtering.")
18
+
19
+ gtab = gradient_table(bvals[keep], bvecs[keep], b0_threshold=b0_threshold)
20
+ model = TensorModel(gtab)
21
+ return model.fit(data[..., keep], mask=mask.astype(bool))
22
+
23
+
24
+ def save_metrics(tenfit, affine: np.ndarray, mask: np.ndarray, output_dir: Path) -> None:
25
+ evals = np.clip(tenfit.evals, 0, None)
26
+ fa = fractional_anisotropy(evals)
27
+ fa[~np.isfinite(fa)] = 0.0
28
+ fa[mask == 0] = 0.0
29
+
30
+ metrics = {
31
+ "FA.nii.gz": fa.astype(np.float32),
32
+ "MD.nii.gz": tenfit.md.astype(np.float32),
33
+ "AD.nii.gz": tenfit.ad.astype(np.float32),
34
+ "RD.nii.gz": tenfit.rd.astype(np.float32),
35
+ }
36
+ for name, values in metrics.items():
37
+ values[~np.isfinite(values)] = 0.0
38
+ save_nifti(str(output_dir / name), values, affine)
39
+
40
+
41
+ def main() -> None:
42
+ parser = argparse.ArgumentParser(description="Reference DIPY snippet for DTI fitting and FA/MD/AD/RD export.")
43
+ parser.add_argument("--dwi", type=Path, required=True, help="Input DWI 4D NIfTI.")
44
+ parser.add_argument("--bval", type=Path, required=True, help="Input bvals file.")
45
+ parser.add_argument("--bvec", type=Path, required=True, help="Input bvecs file.")
46
+ parser.add_argument("--mask", type=Path, required=True, help="Brain mask NIfTI in DWI space.")
47
+ parser.add_argument("--output-dir", type=Path, required=True, help="Directory for tensor metrics.")
48
+ parser.add_argument("--b0-threshold", type=float, default=50.0, help="Threshold for identifying b0 volumes.")
49
+ parser.add_argument("--dti-bmax", type=float, default=1200.0, help="Max b-value for tensor fitting.")
50
+ args = parser.parse_args()
51
+
52
+ args.output_dir.mkdir(parents=True, exist_ok=True)
53
+ data, affine = load_nifti(str(args.dwi))
54
+ bvals, bvecs = read_bvals_bvecs(str(args.bval), str(args.bvec))
55
+ mask = nib.load(str(args.mask)).get_fdata() > 0
56
+
57
+ tenfit = fit_dti(
58
+ data=data.astype(np.float32),
59
+ bvals=bvals.astype(float),
60
+ bvecs=bvecs.astype(float),
61
+ mask=mask.astype(np.uint8),
62
+ b0_threshold=args.b0_threshold,
63
+ dti_bmax=args.dti_bmax,
64
+ )
65
+ save_metrics(tenfit, affine, mask.astype(np.uint8), args.output_dir)
66
+ print(f"Saved tensor metrics to: {args.output_dir}")
67
+
68
+
69
+ if __name__ == "__main__":
70
+ main()
@@ -0,0 +1,76 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ from pathlib import Path
5
+
6
+ import nibabel as nib
7
+ import numpy as np
8
+ from dipy.io.gradients import read_bvals_bvecs
9
+ from dipy.io.image import load_nifti, save_nifti
10
+ from dipy.segment.mask import median_otsu
11
+
12
+
13
+ def load_dwi(dwi_path: Path, bval_path: Path, bvec_path: Path) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
14
+ data, affine = load_nifti(str(dwi_path))
15
+ bvals, bvecs = read_bvals_bvecs(str(bval_path), str(bvec_path))
16
+
17
+ if data.ndim != 4:
18
+ raise ValueError(f"DWI must be 4D. Got shape={data.shape}")
19
+ if data.shape[-1] != len(bvals) or data.shape[-1] != len(bvecs):
20
+ raise ValueError(
21
+ "Gradient count does not match DWI volumes: "
22
+ f"volumes={data.shape[-1]}, bvals={len(bvals)}, bvecs={len(bvecs)}"
23
+ )
24
+
25
+ return data.astype(np.float32), affine, bvals.astype(float), bvecs.astype(float)
26
+
27
+
28
+ def make_mask(data: np.ndarray, bvals: np.ndarray, affine: np.ndarray, out_mask_path: Path, b0_threshold: float) -> np.ndarray:
29
+ b0_indices = np.where(bvals < b0_threshold)[0]
30
+ if b0_indices.size == 0:
31
+ raise ValueError("No b0 volumes found; cannot build mask with median_otsu.")
32
+
33
+ _, mask = median_otsu(data, vol_idx=b0_indices, numpass=4, autocrop=False)
34
+ save_nifti(str(out_mask_path), mask.astype(np.uint8), affine)
35
+ return mask.astype(np.uint8)
36
+
37
+
38
+ def save_b0_mean(data: np.ndarray, bvals: np.ndarray, affine: np.ndarray, out_path: Path, b0_threshold: float) -> None:
39
+ b0_indices = np.where(bvals < b0_threshold)[0]
40
+ if b0_indices.size == 0:
41
+ raise ValueError("No b0 volumes found; cannot save mean b0 image.")
42
+ b0_mean = np.mean(data[..., b0_indices], axis=3)
43
+ nib.save(nib.Nifti1Image(b0_mean.astype(np.float32), affine), str(out_path))
44
+
45
+
46
+ def main() -> None:
47
+ parser = argparse.ArgumentParser(description="Reference DIPY snippet for DWI loading and brain mask generation.")
48
+ parser.add_argument("--dwi", type=Path, required=True, help="Input DWI 4D NIfTI.")
49
+ parser.add_argument("--bval", type=Path, required=True, help="Input bvals file.")
50
+ parser.add_argument("--bvec", type=Path, required=True, help="Input bvecs file.")
51
+ parser.add_argument("--output-dir", type=Path, required=True, help="Directory for mask and summary outputs.")
52
+ parser.add_argument("--b0-threshold", type=float, default=50.0, help="Threshold for identifying b0 volumes.")
53
+ args = parser.parse_args()
54
+
55
+ args.output_dir.mkdir(parents=True, exist_ok=True)
56
+ data, affine, bvals, bvecs = load_dwi(args.dwi, args.bval, args.bvec)
57
+ mask = make_mask(data, bvals, affine, args.output_dir / "brain_mask.nii.gz", args.b0_threshold)
58
+ save_b0_mean(data, bvals, affine, args.output_dir / "mean_b0.nii.gz", args.b0_threshold)
59
+
60
+ summary = args.output_dir / "dwi_summary.txt"
61
+ summary.write_text(
62
+ "\n".join(
63
+ [
64
+ f"shape={data.shape}",
65
+ f"n_bvals={len(bvals)}",
66
+ f"n_bvecs={len(bvecs)}",
67
+ f"mask_voxels={int(mask.sum())}",
68
+ ]
69
+ ),
70
+ encoding="utf-8",
71
+ )
72
+ print(f"Saved mask and DWI summary to: {args.output_dir}")
73
+
74
+
75
+ if __name__ == "__main__":
76
+ main()