Skip to content

Commit 55e14e4

Browse files
XeniosPclaude
andcommitted
added CLAUDE.md for Claude Code guidance
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2639dd6 commit 55e14e4

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed

CLAUDE.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
BioImage Suite Web (bisweb) is a web-based medical image analysis suite primarily for neuroimaging. It's a hybrid application with:
8+
- Web applications (browser-based)
9+
- Desktop applications (Electron)
10+
- Command-line tools (Node.js and Python)
11+
- WebAssembly modules compiled from C++
12+
13+
## Build Commands
14+
15+
### Initial Setup
16+
```bash
17+
npm install
18+
node ./config/createbuild.js # Creates build directories and installs emscripten
19+
```
20+
21+
### Full Build
22+
```bash
23+
cd build
24+
./fullbuild.sh # Builds WASM, web app, native bindings, and runs tests
25+
```
26+
27+
### Individual Build Components
28+
```bash
29+
cd build
30+
./wasmbuild.sh # Build C++ to WebAssembly
31+
./webbuild.sh # Build JS bundles for web
32+
./nativebuild.sh # Build Python/Matlab bindings
33+
./testbuild.sh # Run subset of tests
34+
```
35+
36+
### Development Server
37+
```bash
38+
gulp # Starts dev server with webpack watch on port 8080
39+
gulp serve # Same as above
40+
gulp --portno 9000 # Use different port
41+
```
42+
43+
### Build Web Application
44+
```bash
45+
gulp build -m # Build with minification
46+
gulp zip # Create distribution zip
47+
```
48+
49+
### Electron Desktop App
50+
```bash
51+
gulp package # Package as desktop application
52+
```
53+
54+
### Linting
55+
```bash
56+
gulp eslint # Run ESLint on all JS files
57+
gulp watch # Watch and lint on changes
58+
```
59+
60+
## Running Tests
61+
62+
### Node.js Tests (Mocha)
63+
```bash
64+
npm test # Run all tests
65+
mocha test # Same as above
66+
mocha test/test_module.js # Run module tests
67+
mocha test/test_module.js --input local # Use local test data
68+
mocha test/test_module.js --first 0 --last 10 # Run tests 0-10
69+
mocha test/test_module.js --testname smoothImage # Run specific module test
70+
```
71+
72+
### Browser Tests
73+
```bash
74+
gulp serve
75+
# Navigate to http://localhost:8080/web/biswebtest.html
76+
```
77+
78+
### C++ Tests (after WASM build)
79+
```bash
80+
cd build/wasm
81+
make test
82+
```
83+
84+
## Architecture
85+
86+
### Directory Structure
87+
- `js/` - JavaScript source code
88+
- `core/` - Core utilities (IO, WASM interface, preferences)
89+
- `dataobjects/` - Data object classes (BisWebImage, BisWebMatrix, transformations)
90+
- `modules/` - Processing modules (each inherits from BaseModule)
91+
- `webcomponents/` - Custom HTML elements for web UI
92+
- `node/` - Node.js specific code
93+
- `bin/` - Command-line entry points
94+
- `cpp/` - C++ source for WebAssembly modules
95+
- `web/` - HTML/CSS files and Electron configuration
96+
- `config/` - Webpack and build configuration
97+
- `compiletools/` - Build scripts
98+
- `test/` - Test files and test data
99+
- `biswebpython/` - Python wrapper package
100+
101+
### Key Patterns
102+
103+
**Module Architecture**: All processing modules extend `BaseModule` (`js/modules/basemodule.js`). Modules have:
104+
- `createDescription()` - Returns JSON description with inputs, outputs, parameters
105+
- `directInvokeAlgorithm()` - Core algorithm implementation
106+
- Automatic command-line and GUI generation from description
107+
108+
**Data Objects**: Image and transform classes in `js/dataobjects/`:
109+
- `BisWebImage` - Medical image class (NIfTI, etc.)
110+
- `BisWebMatrix` - Matrix class
111+
- `BisWeb*Transformation` - Linear, grid, combo transformations
112+
113+
**WASM Interface**: C++ code compiled to WebAssembly via Emscripten
114+
- `libbiswasm_wrapper.js` - Auto-generated JS wrapper for C++ functions
115+
- Memory management through serialized data transfer between JS and WASM
116+
117+
**Web Components**: Custom elements in `js/webcomponents/` provide reusable UI
118+
- Viewers, controllers, dialogs built as web components
119+
- Entry point: `bislib.js` bundles all components
120+
121+
### Configuration Files
122+
- `package.json` - NPM dependencies and scripts
123+
- `gulpfile.js` - Gulp task definitions
124+
- `config/webpack.config.js` - Webpack bundling configuration
125+
- `web/images/tools.json` - Tool definitions (viewers, applications)
126+
- `test/module_tests.json` - Test definitions for modules
127+
128+
### Adding a New Module
129+
1. Create module file in `js/modules/` extending `BaseModule`
130+
2. Implement `createDescription()` and `directInvokeAlgorithm()`
131+
3. Register in `js/modules/moduleindex.js`
132+
4. Add tests to `test/module_tests.json`
133+
134+
## C++ Development
135+
136+
WASM build uses CMake with Emscripten:
137+
```bash
138+
cd build/wasm
139+
../cmake.sh . # Configure (uses emscripten toolchain)
140+
make -j4 # Build
141+
```
142+
143+
Key C++ files:
144+
- `cpp/bisExportedFunctions.cpp` - Functions exported to JS
145+
- `cpp/bisImageAlgorithms.txx` - Image processing algorithms
146+
- `cpp/CMakeLists.txt` - Build configuration

0 commit comments

Comments
 (0)