Webknossos Segment Renamer
A Tampermonkey userscript that adds quick semantic renaming to Webknossos segments via context menus.
Features
β¨ Two Ways to Rename Segments:
- π±οΈ Right-click segments in the segment list for instant renaming
- π― Right-click segments in 2D viewports via integrated context menu
π¨ Pre-defined Semantic Categories:
- π΄ Dendrite
- π΅ Axon
- π‘ Soma
- π£ Nucleus
- π Glia
- βͺ Extracellular Space
- π€ Myelin
- β€οΈ Blood Vessel
- π Merge Between Classes
- β Uncertain
β‘ Smart Features:
- Automatic edit mode activation
- Smart submenu positioning (never goes off-screen!)
- Works with Webknossosβs native context menus
- Visual feedback with emoji icons
Installation
Prerequisites
- Install Tampermonkey extension for your browser:
Install the Script
Option 1: Direct Install (Recommended)
- Click on the raw script file: webknossos-segment-renamer.user.js
- Tampermonkey will automatically detect it and show an installation prompt
- Click Install
Option 2: Manual Install
- Copy the contents of webknossos-segment-renamer.user.js
- Open Tampermonkey Dashboard
- Click β+β to create a new script
- Paste the code
- Save (Ctrl+S / Cmd+S)
Usage
Renaming from Segment List
- Open a Webknossos annotation
- Right-click any segment in the segment list
- Choose a semantic ID from the popup menu
- β
Segment automatically renamed!
Renaming from 2D View
- Open a Webknossos annotation
- Right-click on a segment in any 2D viewport
- Look for βπ·οΈ Rename Segment βΆβ in the context menu
- Hover to see submenu with semantic IDs
- Click your choice
- β
Segment automatically renamed!
Configuration
Custom Webknossos Domain
If your Webknossos instance is on a custom domain, update the @match directives:
// Add your domain to the script header
// @match https://your-domain.com/*
// @match http://your-domain.com:9000/*
Custom Semantic IDs
Edit the SEMANTIC_IDS array in the script:
const SEMANTIC_IDS = [
{ id: 'your-id', label: 'Your Label', emoji: 'π―' },
{ id: 'another', label: 'Another Type', emoji: 'π' },
// Add more...
];
Compatibility
- β
Webknossos (tested on wk.zetta.ai)
- β
Chrome/Brave/Edge (Chromium-based browsers)
- β
Firefox
- β
Tampermonkey 5.0+
Troubleshooting
Script not working?
- Check Tampermonkey icon - should show the script is enabled
- Open Console (F12) - look for βWebknossos Segment Renamer initializedβ
- Verify URL match - script only runs on configured domains
- Check console for
[2D Menu] debug messages
- Ensure youβre right-clicking directly on a segment
- Webknossos should show segment ID in its context menu
Renaming not saving?
- The script automatically clicks the save button
- Check console for any error messages
- Verify you can rename manually (pencil icon β edit β enter)
Development
Debug Mode
The script logs detailed information to the console:
[2D Menu] Found segment context menu with ID: 23
[2D Menu] Injecting rename menu item for segment: 23
[2D Menu] Inserted menu item before divider
Open DevTools (F12) β Console to see these messages.
Project Structure
tampermonkey-scripts/
βββ README.md # This file
βββ CHANGELOG.md # Version history
βββ LICENSE # License information
βββ QUICK_START.md # Quick reference guide
βββ scripts/
βββ webknossos-segment-renamer.user.js # Main script
Contributing
Contributions are welcome! To contribute:
- Fork this repository
- Create a feature branch (
git checkout -b feature/amazing-feature)
- Make your changes
- Test thoroughly on your Webknossos instance
- Commit your changes (
git commit -m 'Add amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
License
MIT License - see LICENSE file for details.
Free to use for research, personal, and commercial projects.
Acknowledgments
- Built for the neuroscience community
- Designed for Webknossos - open-source annotation tool
- Uses Ant Design context menu patterns
Changelog
See CHANGELOG.md for version history and updates.
Support
Made with β€οΈ for efficient connectomics annotation