{"id":27180097,"url":"https://github.com/btp-hvision/segmentation","last_synced_at":"2026-04-26T22:31:44.676Z","repository":{"id":284205216,"uuid":"950753720","full_name":"btp-hvision/segmentation","owner":"btp-hvision","description":"3D Slicer module: Femoral head sphere fitting with Unity integration.","archived":false,"fork":false,"pushed_at":"2025-03-24T17:23:07.000Z","size":50,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-09T14:30:06.669Z","etag":null,"topics":["augmented-reality","medical-imaging","slicer","unity"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/btp-hvision.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-18T16:28:29.000Z","updated_at":"2025-03-24T17:23:10.000Z","dependencies_parsed_at":"2025-03-24T18:40:50.062Z","dependency_job_id":null,"html_url":"https://github.com/btp-hvision/segmentation","commit_stats":null,"previous_names":["btp-hvision/segmentation"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/btp-hvision/segmentation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btp-hvision%2Fsegmentation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btp-hvision%2Fsegmentation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btp-hvision%2Fsegmentation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btp-hvision%2Fsegmentation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/btp-hvision","download_url":"https://codeload.github.com/btp-hvision/segmentation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/btp-hvision%2Fsegmentation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32315711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T21:09:39.134Z","status":"ssl_error","status_checked_at":"2026-04-26T21:09:21.240Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["augmented-reality","medical-imaging","slicer","unity"],"created_at":"2025-04-09T14:25:35.936Z","updated_at":"2026-04-26T22:31:44.659Z","avatar_url":"https://github.com/btp-hvision.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Femoral Head Fitting Module for 3D Slicer\n\n## Overview\n\nThe **Femoral Head Fitting** module is a custom extension for [3D Slicer](https://www.slicer.org), designed to assist in orthopedic analysis by fitting a sphere to the femoral head of a 3D model. This module enables users to:\n\n- Place two fiducial points on a 3D model to define the center and a surface point of the femoral head.\n- Compute and visualize a 3D sphere based on these points.\n- Send the sphere’s center coordinates (with Y-coordinate flipped for Unity compatibility) and radius to a Unity AR application via an API endpoint.\n\nThis tool is ideal for medical professionals, researchers, and developers working on medical augmented reality (AR) applications, preoperative planning, or educational tools.\n\n---\n\n## Table of Contents\n\n1. [Installation](#installation)\n2. [Usage](#usage)\n   - [Placing Fiducial Points](#placing-fiducial-points)\n   - [Fitting the Sphere](#fitting-the-sphere)\n   - [Sending Coordinates to Unity](#sending-coordinates-to-unity)\n3. [Module Architecture](#module-architecture)\n4. [Dependencies](#dependencies)\n5. [Contributing](#contributing)\n6. [License](#license)\n7. [Acknowledgements](#acknowledgements)\n\n---\n\n## Installation\n\nTo install and use the **Femoral Head Fitting** module in 3D Slicer, follow these steps:\n\n1. **Install 3D Slicer:**\n   - Download and install the latest stable version of 3D Slicer from [https://www.slicer.org](https://www.slicer.org).\n\n2. **Clone the Repository:**\n   - Clone this GitHub repository to your local machine:\n     ```bash\n     git clone https://github.com/btp-hvision/segmentation.git\n     ```\n\n3. **Load the Module in 3D Slicer:**\n   - Open 3D Slicer.\n   - Enable Developer Mode:\n     - Navigate to **Edit** \u003e **Application Settings** \u003e **Modules** tab and check **Enable Developer Mode**.\n   - Open the Python Interactor:\n     - Go to **View** \u003e **Python Interactor**.\n   - Load the script:\n     - In the Python Interactor, run:\n       ```python\n       slicer.util.loadScriptedModule(\"path/to/FemoralHeadFitting.py\")\n       ```\n     - Replace `\"path/to/FemoralHeadFitting.py\"` with the actual file path to the `FemoralHeadFitting.py` script.\n\n4. **Alternative Installation:**\n   - Move the `FemoralHeadFitting.py` file to the Slicer Modules directory (e.g., `~/Slicer-Modules/`), then restart 3D Slicer. The module will appear under **Orthopedic Analysis** in the Modules dropdown.\n\n---\n\n## Usage\n\nAfter loading the module, access it via the **Modules** dropdown in 3D Slicer: **Orthopedic Analysis** \u003e **Femoral Head Fitting**. The interface includes three main buttons:\n\n### Placing Fiducial Points\n\n1. Click the **Select Fiducial Points** button.\n2. Place exactly **two fiducial points** on the 3D model:\n   - **First Point:** The approximate center of the femoral head.\n   - **Second Point:** Any point on the surface of the femoral head.\n3. These points are stored as a `vtkMRMLMarkupsFiducialNode` named \"FemoralHeadPoints\" in the scene.\n\n### Fitting the Sphere\n\n1. Click the **Fit Sphere from Points** button.\n2. The module:\n   - Verifies that exactly two fiducial points are placed.\n   - Computes the sphere’s radius as the Euclidean distance between the center (first point) and the surface point (second point).\n   - Generates a 3D sphere using VTK, centered at the first point with the calculated radius.\n3. The sphere is displayed in the 3D scene as a red, fully opaque model named \"FemoralHeadSphere\".\n\n**Note:** If fewer or more than two points are placed, or if the radius is invalid (≤ 0), an error message will appear.\n\n### Sending Coordinates to Unity\n\n1. Click the **Send Coordinates to Unity** button.\n2. The module:\n   - Flips the Y-coordinate of the sphere’s center. (This can be adjusted relative to the model)\n   - Prepares a JSON payload with the transformed center (`x`, `y`, `z`) and radius.\n   - Sends the data to the API endpoint: `https://cobridge.vercel.app/api/coordinates`.\n3. A success message (✅) appears if the data is sent successfully (HTTP 200), otherwise an error message (❌) is displayed with the status code or exception details.\n\n**Example Payload:**\n```json\n{\n  \"x\": 10.0,\n  \"y\": -5.0,\n  \"z\": 2.0,\n  \"radius\": 15.0\n}\n```\n\n---\n\n## Module Architecture\n\nThe module is implemented in Python and consists of three main classes:\n\n1. **`FemoralHeadFitting` (ScriptedLoadableModule):**\n   - Defines metadata: Title, Category, Contributors, Help Text, Acknowledgement\n\n2. **`FemoralHeadFittingWidget` (ScriptedLoadableModuleWidget):**\n   - Manages the GUI with three buttons:\n     - **Select Fiducial Points:** Initiates fiducial placement via the Markups module.\n     - **Fit Sphere from Points:** Triggers sphere computation and visualization.\n     - **Send Coordinates to Unity:** Sends sphere data to the Unity API.\n   - Stores fiducial node, sphere center, and radius as instance variables.\n\n3. **`FemoralHeadFittingLogic` (ScriptedLoadableModuleLogic):**\n   - Handles computations and visualization:\n     - **`createSphere`:** Uses `vtk.vtkSphereSource` to generate a sphere with 50x50 theta/phi resolution, adds it to the scene as a red model.\n\nThe module leverages:\n- **VTK** for 3D sphere rendering.\n- **NumPy** for radius computation.\n- **Requests** for API communication.\n\n---\n\n## Dependencies\n\nThe module requires the following dependencies, most of which are bundled with 3D Slicer:\n- **3D Slicer** (latest stable version)\n- **VTK** (included with 3D Slicer)\n- **NumPy** (included with 3D Slicer)\n- **Requests** (for HTTP requests to Unity API)\n\nIf the `requests` library is missing, install it within Slicer’s Python environment:\n```python\nslicer.util.pip_install(\"requests\")\n```\n\n---\n\n## Contributing\n\nContributions are welcome! To contribute:\n1. Fork the repository.\n2. Create a feature or bugfix branch:\n   ```bash\n   git checkout -b my-feature-branch\n   ```\n3. Commit your changes with clear messages:\n   ```bash\n   git commit -m \"Add feature X\"\n   ```\n4. Push to your fork and submit a pull request:\n   ```bash\n   git push origin my-feature-branch\n   ```\n\nPlease include detailed descriptions in your pull requests and adhere to the existing code style.\n\n---\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE). See the `LICENSE` file for details.\n\n---\n\n## Acknowledgements\n\n- Thanks to the 3D Slicer community for providing a robust platform and resources.\n\n---\n\nThis README provides a complete guide to installing, using, and contributing to the **Femoral Head Fitting** module. For questions or issues, please open a ticket on the GitHub repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbtp-hvision%2Fsegmentation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbtp-hvision%2Fsegmentation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbtp-hvision%2Fsegmentation/lists"}