Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
dfa81b7
Merge pull request #4 from bbuchsbaum/codex/audit-eventemitter.js-class
bbuchsbaum May 28, 2025
ddea078
Merge pull request #5 from bbuchsbaum/codex/guard-console.log-with-de…
bbuchsbaum May 28, 2025
56f5b0b
Merge pull request #6 from bbuchsbaum/codex/implement-method-to-stop-…
bbuchsbaum May 28, 2025
7cf4757
Validate ColorMap inputs
bbuchsbaum May 28, 2025
6faf732
Merge pull request #11 from bbuchsbaum/codex/extend-parsecolor-valida…
bbuchsbaum May 28, 2025
bf13b4b
Handle edge cases in ColorMap getColor
bbuchsbaum May 28, 2025
5b85874
Merge pull request #12 from bbuchsbaum/codex/enhance-getcolor-and-get…
bbuchsbaum May 28, 2025
748a9b6
Use namespaced message for config updates
bbuchsbaum May 28, 2025
9267f89
Merge pull request #13 from bbuchsbaum/codex/update-message-type-to-n…
bbuchsbaum May 28, 2025
c93b1e2
Add widget update wrappers
bbuchsbaum May 28, 2025
297a864
Merge pull request #14 from bbuchsbaum/codex/implement-updatezoom-and…
bbuchsbaum May 28, 2025
bb3c629
Validate widget config options
bbuchsbaum May 28, 2025
3584ed7
Merge pull request #15 from bbuchsbaum/codex/extend-process_config-fo…
bbuchsbaum May 28, 2025
313e64a
Add roxygen docs for surfwidget update helpers
bbuchsbaum May 28, 2025
483b4e8
Merge pull request #16 from bbuchsbaum/codex/add-roxygen-comments-to-…
bbuchsbaum May 28, 2025
1cb2c3d
Remove debugging print statements
bbuchsbaum May 28, 2025
4542697
Merge pull request #17 from bbuchsbaum/codex/remove-debugging-prints-…
bbuchsbaum May 28, 2025
6755bb6
Avoid duplicate animation loops
bbuchsbaum May 28, 2025
36f7d04
Merge pull request #18 from bbuchsbaum/codex/check-animation-loop-bef…
bbuchsbaum May 28, 2025
6119e52
chore: use strict mode in widget
bbuchsbaum May 28, 2025
34ede64
Merge pull request #19 from bbuchsbaum/codex/refactor-variable-declar…
bbuchsbaum May 28, 2025
9594b21
Respect user config in viewer initialization
bbuchsbaum May 28, 2025
f854d8c
Add data validation in surfwidget
bbuchsbaum May 28, 2025
690f76a
Merge pull request #21 from bbuchsbaum/codex/validate-arrays-in-rende…
bbuchsbaum May 28, 2025
27bd90a
Merge pull request #20 from bbuchsbaum/codex/adjust-neurosurfaceviewe…
bbuchsbaum May 28, 2025
19f1ae9
Add vertex picking callback
bbuchsbaum May 28, 2025
60933ed
Merge pull request #22 from bbuchsbaum/codex/add-vertex/roi-picking-w…
bbuchsbaum May 28, 2025
d54c016
Merge pull request #23 from bbuchsbaum/codex/audit-r/arith.r
bbuchsbaum May 28, 2025
ef5471b
Merge pull request #24 from bbuchsbaum/codex/update-setcolormap-to-ch…
bbuchsbaum May 28, 2025
d844f8b
Rename AFNI data meta constructor and update docs
bbuchsbaum May 28, 2025
cb7506b
Merge pull request #25 from bbuchsbaum/codex/decide-on-afnisurfacedat…
bbuchsbaum May 28, 2025
b34494c
fix data_reader class
bbuchsbaum May 28, 2025
7703f03
Merge pull request #26 from bbuchsbaum/codex/replace-data_reader-meth…
bbuchsbaum May 28, 2025
ec2d19d
Fix typo in read_meta_info docs
bbuchsbaum May 28, 2025
b28b0f1
Merge pull request #27 from bbuchsbaum/codex/update-roxygen-comment-a…
bbuchsbaum May 28, 2025
0889f7d
Ensure file connections closed on error
bbuchsbaum May 28, 2025
a73c36a
Merge pull request #28 from bbuchsbaum/codex/wrap-file-calls-with-on.…
bbuchsbaum May 28, 2025
982a635
Remove unused variables in read_freesurfer_annot
bbuchsbaum May 28, 2025
81005fd
Merge pull request #29 from bbuchsbaum/codex/refactor-read_freesurfer…
bbuchsbaum May 28, 2025
05363f7
Fix hemisphere detection and add unit test
bbuchsbaum May 28, 2025
51751cc
Merge pull request #31 from bbuchsbaum/codex/edit-grep-conditions-in-…
bbuchsbaum May 28, 2025
9101a5a
Validate inputs in SurfaceDisk
bbuchsbaum May 28, 2025
8ad0d47
Merge pull request #32 from bbuchsbaum/codex/update-input-validation-…
bbuchsbaum May 28, 2025
595f4fc
Fix missing closing brace after deletion
bbuchsbaum May 28, 2025
ce78981
Merge pull request #33 from bbuchsbaum/codex/decide-public-access-for…
bbuchsbaum May 28, 2025
edfdb91
Validate ROI indices
bbuchsbaum May 28, 2025
f6af6a5
Merge pull request #34 from bbuchsbaum/codex/update-constructors-in-r…
bbuchsbaum May 28, 2025
2b30e8a
feat(viewer): add PBR material with HDR environment
bbuchsbaum May 28, 2025
801bdc9
Merge pull request #35 from bbuchsbaum/codex/add-pbr-material-and-hdr…
bbuchsbaum May 28, 2025
aaee4d1
RandomSurfaceSearchlight deflist random order
bbuchsbaum May 28, 2025
b290034
Merge pull request #36 from bbuchsbaum/codex/audit-r/searchlight.r
bbuchsbaum May 28, 2025
f4b4077
Fix cluster_threshold, normalize, and export
bbuchsbaum May 28, 2025
8bd8472
Merge pull request #37 from bbuchsbaum/codex/audit-r/neuro_surface.r
bbuchsbaum May 28, 2025
319d4c4
feat(viewer): add rim lighting control
bbuchsbaum May 28, 2025
d647fd8
Merge branch 'master' into codex/add-dynamic-rim-light-to-neurosurfac…
bbuchsbaum May 28, 2025
50340e1
Merge pull request #38 from bbuchsbaum/codex/add-dynamic-rim-light-to…
bbuchsbaum May 28, 2025
385a65c
Add SSAO post-processing to NeuroSurfaceViewer
bbuchsbaum May 28, 2025
5b28b33
Merge branch 'master' into codex/add-ssao-to-neurosurfaceviewer.js
bbuchsbaum May 28, 2025
6ff1983
Merge pull request #39 from bbuchsbaum/codex/add-ssao-to-neurosurface…
bbuchsbaum May 28, 2025
342b2e4
Add radius validation to RandomSurfaceSearchlight
bbuchsbaum May 28, 2025
9aff7ec
Merge branch 'master' into codex/validate-radius-and-nodeset-in-rando…
bbuchsbaum May 28, 2025
5975bcf
Merge pull request #40 from bbuchsbaum/codex/validate-radius-and-node…
bbuchsbaum May 28, 2025
0d071dd
Add index bounds check and tests
bbuchsbaum May 28, 2025
ca428d9
Merge branch 'master' into codex/modify-fun-functions-to-check-n->=-1
bbuchsbaum May 28, 2025
e856718
Add roxygen block for read_meta_info and protect generic
bbuchsbaum May 28, 2025
202e046
Merge pull request #42 from bbuchsbaum/codex/update-r/all_generic.r-w…
bbuchsbaum May 28, 2025
ee7ae88
Merge pull request #41 from bbuchsbaum/codex/modify-fun-functions-to-…
bbuchsbaum May 28, 2025
2809e1b
chore: clean up all_generic.R whitespace
bbuchsbaum May 28, 2025
2c7bd94
Merge pull request #43 from bbuchsbaum/codex/remove-leading/trailing-…
bbuchsbaum May 28, 2025
73de136
Add input validation for ROI boundary detection
bbuchsbaum May 28, 2025
83b9403
Merge pull request #44 from bbuchsbaum/codex/add-validation-checks-fo…
bbuchsbaum May 28, 2025
3ea7eba
fix(boundaries): detect color difference for single face edges
bbuchsbaum May 28, 2025
f1d5f66
Merge pull request #45 from bbuchsbaum/codex/revise-diff_color-calcul…
bbuchsbaum May 28, 2025
4e0655c
Improve edge_faces cycle handling
bbuchsbaum May 28, 2025
3c684a1
Merge pull request #46 from bbuchsbaum/codex/replace-placeholder-loop…
bbuchsbaum May 28, 2025
37df010
Handle missing shortest paths
bbuchsbaum May 28, 2025
0df0bcf
Merge pull request #47 from bbuchsbaum/codex/wrap-igraph--shortest_pa…
bbuchsbaum May 28, 2025
24e7947
doc: clarify find_roi_boundaries return
bbuchsbaum May 28, 2025
c231f0b
Merge pull request #48 from bbuchsbaum/codex/update-roxygen-details-f…
bbuchsbaum May 28, 2025
7202630
Add tests for ROI boundary methods
bbuchsbaum May 28, 2025
12cb2e1
Merge pull request #49 from bbuchsbaum/codex/create-unit-tests-for-me…
bbuchsbaum May 28, 2025
934e58c
Add radius assertion and update docs
bbuchsbaum May 28, 2025
b0ea84f
Merge pull request #50 from bbuchsbaum/codex/add-assertion-and-update…
bbuchsbaum May 28, 2025
552fa64
Remove unused index from RandomSurfaceSearchlight and test progress
bbuchsbaum May 28, 2025
fd0fab7
Merge pull request #51 from bbuchsbaum/codex/decide-progress-tracking…
bbuchsbaum May 28, 2025
63f83a2
Randomize deflist order
bbuchsbaum May 28, 2025
80e821f
Merge branch 'master' into codex/update-randomsurfacesearchlight-with…
bbuchsbaum May 28, 2025
9071a62
Merge pull request #52 from bbuchsbaum/codex/update-randomsurfacesear…
bbuchsbaum May 28, 2025
ead2d6c
Add validation checks for RandomSurfaceSearchlight
bbuchsbaum May 28, 2025
171b228
Implement radius-based smoothing
bbuchsbaum May 28, 2025
bca113f
Merge pull request #54 from bbuchsbaum/codex/modify-neurosurface-smoo…
bbuchsbaum May 28, 2025
629d04a
Clamp spherical distance and test
bbuchsbaum May 28, 2025
bc9eb95
Merge pull request #55 from bbuchsbaum/codex/refactor-cosine-calculat…
bbuchsbaum May 28, 2025
89d6e4d
Fix documentation merge conflict
bbuchsbaum May 28, 2025
50286e8
Merge pull request #56 from bbuchsbaum/codex/fix-merge-conflict-in-se…
bbuchsbaum May 28, 2025
7c7af6c
Validate neighbor search inputs and cap knn
bbuchsbaum May 28, 2025
63e838a
Merge pull request #57 from bbuchsbaum/codex/cap-k-at-vcount(g)-1-and…
bbuchsbaum May 28, 2025
5565a04
Add validation to neighbor functions
bbuchsbaum May 28, 2025
28a73ad
Merge pull request #58 from bbuchsbaum/codex/add-validations-and-erro…
bbuchsbaum May 28, 2025
bdc781a
rename coords arg to points in projectCoordinates
bbuchsbaum May 28, 2025
01f6c92
Merge pull request #59 from bbuchsbaum/codex/rename-function-argument…
bbuchsbaum May 28, 2025
00d03ac
Add curvature support to surfwidget
bbuchsbaum May 28, 2025
65ad117
Merge pull request #60 from bbuchsbaum/codex/add-curvature-support-to…
bbuchsbaum May 28, 2025
746d681
Merge branch 'master' into codex/add-assertions-and-update-documentat…
bbuchsbaum May 28, 2025
ca16968
Merge pull request #53 from bbuchsbaum/codex/add-assertions-and-updat…
bbuchsbaum May 28, 2025
5fbb7bb
Fix merge conflict markers in RandomSurfaceSearchlight
bbuchsbaum May 28, 2025
d543968
Merge pull request #61 from bbuchsbaum/codex/fix-merge-issues-with-se…
bbuchsbaum May 28, 2025
75280b0
Merged and resolved local + remote changes
bbuchsbaum May 28, 2025
c1ab726
Add missing R files to Collate
bbuchsbaum May 30, 2025
c2e11cd
Merge pull request #62 from bbuchsbaum/codex/fix-missing-files-in-col…
bbuchsbaum May 30, 2025
63ed233
Move boundary detection to experimental folder and update documentation
bbuchsbaum Aug 20, 2025
6684c13
Bump braces and gulp in /inst/htmlwidgets/neurosurface
dependabot[bot] Aug 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@
^codecov.yml
^README.Rmd
^.travis.yml
inst/htmlwidgets/neurosurface/node_modules
testshiny
testshiny/test_shiny.R
.cursor$
^CLAUDE\.md$
^CRAN_prompt\.md$
^cran_check\.log$
^cran_check_final\.log$
25 changes: 25 additions & 0 deletions .cursor/rules/roxygendocs.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
description:
globs:
alwaysApply: true
---
Rules for Documenting S4 Generics and Methods in R using roxygen2:

Centralize Documentation in Generic: The primary documentation (@description, @details, @param for generic parameters, @return, @examples, etc.) MUST reside in the roxygen block of the S4 generic function.

Use Consistent @rdname: The generic function and ALL its associated S4 methods MUST use the exact same @rdname tag value. This ensures they all contribute to a single help file.

Minimize Method Documentation: Roxygen blocks for S4 methods should be minimal. Typically, they only require:

@rdname [value] (Matching the generic's @rdname).

@export (Only if the method itself needs exporting, which is less common than exporting the generic).

Document ONLY New Method Parameters: If an S4 method signature includes additional parameters not present in the generic, document only these new parameters using @param tags within that method's roxygen block. Do not re-document parameters inherited from the generic.

Avoid Redundant Core Tags in Methods: Do NOT add tags like @description, @return, or @param (for generic parameters) to method documentation, as the shared @rdname links to the generic's definition. This prevents conflicting or duplicate information in the final help file.

Use @details or @note for Method Specifics: If a particular method has unique behavior or implementation details critical for the user to know, add this information to the method's roxygen block using tags like @details or @note. This information should supplement, not replace or conflict with, the generic's
documentation.

Never use "dontrun", use "donttest" instead if it's a long-running task. All examples should in theory be runnable.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
109 changes: 109 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

`neurosurf` is an R package for surface-based neuroimaging data analysis. It provides data structures and visualization tools for working with triangle mesh surfaces (e.g., cortical surfaces) with support for FreeSurfer and GIFTI formats.

## Key Commands

### Package Development
```bash
# Install dependencies and build package
R -e "devtools::install_deps()"
R -e "devtools::build()"

# Check package (runs R CMD check)
R -e "devtools::check()"

# Run tests
R -e "devtools::test()"

# Run a single test file
R -e "testthat::test_file('tests/testthat/test_boundaries_methods.R')"

# Document package (generate/update roxygen documentation)
R -e "devtools::document()"

# Build and reload package
R -e "devtools::load_all()"
```

### JavaScript Development (for htmlwidgets)
```bash
# Navigate to JavaScript source
cd inst/htmlwidgets/neurosurface

# Install dependencies
npm install

# Build JavaScript bundle
npm run build
```

## Architecture

### R Package Structure
- **S4 Classes**: The package uses S4 object-oriented programming extensively
- Core geometry classes: `SurfaceGeometry`, `NeuroSurface`, `ColorMappedNeuroSurface`
- Vector classes: `NeuroSurfaceVector`, `BilatNeuroSurfaceVector`
- ROI classes: `ROISurface`, `ROISurfaceVector`
- File format classes for FreeSurfer, GIFTI, AFNI, and NIML formats

- **Key Components**:
- `geometry.R`: Core surface geometry operations and data structures
- `neuro_surface.R`: Surface data mapping and visualization structures
- `surfwidget.R`: Interactive 3D visualization using htmlwidgets
- `Searchlight.R`: Surface-based searchlight analysis for machine learning
- `neighborhood.R`: Graph-based neighborhood computations on surfaces
- `IO.R`: File I/O for various surface formats

### JavaScript/HTMLWidget Architecture
- Uses Three.js for 3D rendering
- Tweakpane for UI controls
- Built with Rollup bundler
- Main viewer: `inst/htmlwidgets/neurosurface/src/NeuroSurfaceViewer.js`

## Documentation Guidelines

When documenting S4 methods (per `.cursor/rules/roxygendocs.mdc`):
- Document parameters, description, and examples ONLY in the generic function
- Methods should only have `@rdname` matching the generic and `@export` if needed
- Use `@details` or `@note` in methods only for method-specific behavior
- Never use `@dontrun`, use `@donttest` for long-running examples

## Testing

Tests use `testthat` framework and are located in `tests/testthat/`. Key test areas:
- Boundary detection algorithms
- File I/O for different formats
- Neighborhood graph computations
- Searchlight analysis
- Surface smoothing operations

## Dependencies

Key R dependencies:
- `igraph`: Graph operations on surface meshes
- `rgl`: 3D rendering (backend)
- `Rvcg`: Mesh operations (smoothing, remeshing)
- `Matrix`: Sparse matrix operations
- `htmlwidgets`: Interactive visualizations
- `neuroim2`: Neuroimaging data structures (custom package)

## File Formats

The package supports:
- FreeSurfer surface formats (ASCII and binary)
- GIFTI surface format
- AFNI/SUMA surface formats
- NIML format

## HTMLWidget Integration

The `surfwidget()` function creates interactive 3D visualizations. Key features:
- Curvature-based shading (computed automatically for `SurfaceGeometry` objects)
- Multiple color mapping options
- Interactive controls via Tweakpane
- Support for bilateral surface display
Loading