{"slug": "neurotrace-turning-brain-mri-segmentation-into-an-evidence-driven-research", "title": "NeuroTrace: Turning Brain MRI Segmentation into an Evidence-Driven Research Workflow", "summary": "A developer built NeuroTrace, an open-source research platform that combines a pretrained 3D U-Net brain tumor segmentation model with multi-planar 2D and interactive 3D visualization, deterministic volume and quality analysis, and a Gemma 4-powered research copilot. The agent operates through an allowlisted tool architecture in which Python performs all measurements and the model only explains structured results, and it marks metrics like Dice and IoU as unavailable rather than fabricating them when no ground truth exists. Physical tumor volume is computed from actual NIfTI voxel spacing rather than assumed uniform dimensions.", "body_md": "*This is a submission for the [MLH x DEV Writing Challenge](https://dev.to/mlh-hackathon)*\n\nBrain MRI segmentation is an important part of computational neuroimaging research. Deep learning models can identify potential tumor regions, but obtaining a segmentation mask is only one part of the workflow.\n\nResearchers still need to inspect the results, visualize the segmentation in different anatomical planes, calculate meaningful measurements, perform quality checks and document their findings.\n\nThese activities are often spread across multiple tools.\n\nI wanted to explore a different approach: **What if segmentation, visualization, quantitative analysis and AI-assisted research could exist within one integrated workflow?**\n\nThat idea became **NeuroTrace — an Agentic Brain MRI Segmentation Analysis & Research Copilot.**\n\nNeuroTrace is an open-source research platform that combines an existing trained 3D U-Net segmentation model with interactive visualization, deterministic computational analysis, Google's Gemma 4 and research report generation.\n\nThe objective is not to replace researchers or make clinical decisions. It is to make the computational research workflow more accessible, structured and reproducible.\n\nAt the core of NeuroTrace is a pretrained 3D U-Net model that performs brain tumor segmentation using FLAIR MRI volumes.\n\nOne of the decisions I made early was to preserve the existing trained model rather than build an entirely new architecture just for the hackathon.\n\nThe integrated model has:\n\nThe application supports CPU inference, so a CUDA-enabled GPU is not mandatory.\n\nThe MRI is loaded as a NIfTI volume, validated and preprocessed before inference. The resulting segmentation mask is exported while preserving the reference scan's spatial geometry.\n\nA segmentation mask is difficult to interpret when it is presented only as a file or a numerical array.\n\nI wanted visualization to be a central part of NeuroTrace rather than an additional feature.\n\nThe platform includes:\n\n**Multi-planar 2D visualization**\n\n**Interactive 3D visualization**\n\nThe 3D viewer uses Plotly volume and isosurface rendering, with downsampling options to make visualization more practical.\n\nAnother important part of NeuroTrace is moving beyond visual inspection.\n\nThe analysis layer calculates:\n\nAn important implementation detail is that physical volume is calculated using the actual voxel spacing obtained from the NIfTI geometry.\n\nThe calculation is:\n\n`Volume (mL) = Tumor voxels × dx × dy × dz / 1000`\n\nThis avoids assuming that every MRI scan has identical voxel dimensions.\n\nNeuroTrace also performs technical quality checks, including empty segmentation detection, boundary overflow checks, connected-component analysis and signal-to-noise estimation.\n\nI also wanted to avoid a common problem in AI-assisted analysis: reporting evaluation metrics when no reference segmentation exists.\n\nWhen ground truth is unavailable, metrics such as Dice and IoU are marked as unavailable rather than being fabricated or represented as zero.\n\nThis was one of the most interesting parts of the project and a major reason I wanted to participate in the Best Use of Gemma 4 track.\n\nI didn't want to add a chatbot that simply answers generic questions about brain tumors.\n\nInstead, I wanted Gemma 4 to interact with the actual computational workflow.\n\nNeuroTrace uses Gemma 4 through an allowlisted tool architecture.\n\nThe agent can interact with validated operations such as:\n\n`validate_mri_study`` run_neurosegnet``calculate_tumor_volumes`` inspect_segmentation_quality``generate_research_report`\nThe important distinction is that Gemma does not independently calculate or invent the numerical findings.\n\nPython performs the actual measurements. The agent receives structured results and uses them to explain the analysis, answer questions and generate research-oriented summaries.\n\nThe integration supports two Gemma 4 model configurations:\n\n`gemma-4-31b-it`` gemma-4-26b-a4b-it`\nIt can use the Gemini API when configured with an API key. NeuroTrace also provides a deterministic local synthesis mode when live API access is unavailable.\n\nAnother design decision was privacy. Raw MRI volumes remain on the local machine. The hosted AI assistant receives structured metadata and computational results rather than the original MRI voxel data.\n\nThis separation between deterministic computation and AI-generated explanation was one of the most important architectural decisions in the project.\n\nThe final stage brings the analysis together.\n\nNeuroTrace generates downloadable PDF research reports containing:\n\nThe idea is to make the workflow useful beyond the application itself by providing artifacts that researchers can inspect, preserve and share.\n\n| Area | Technology | \n|---|---|\n| Programming language | Python | \n| Deep learning | PyTorch, 3D U-Net | \n| MRI processing | NiBabel, NumPy | \n| Visualization | Plotly, Matplotlib | \n| Web application | React 18, Flask | \n| Alternative interface | Streamlit | \n| AI assistant | Google Gemma 4 | \n| PDF generation | ReportLab | \n| Configuration and validation | Pydantic | \n| Testing | Pytest | \n\nThe biggest lesson was that building an AI application is not just about integrating a model or connecting an LLM API.\n\nA useful system needs reliable data handling, well-defined interfaces, meaningful measurements, proper error handling, testing and a clear separation of responsibilities.\n\nI also learned how important it is to constrain AI agents. Giving an LLM access to computational tools is much more useful when those tools have explicit contracts and return verifiable results.\n\nMost importantly, I learned to think beyond model predictions and focus on the complete workflow around them.\n\n**GitHub Repository:**\n\n[https://github.com/AmanPathan24/NeuroTrace](https://github.com/AmanPathan24/NeuroTrace)\n\nThe repository contains the implementation, architecture, documentation, installation instructions and testing workflow.\n\nNeuroTrace provides two ways to explore the application:\n\nTo run the React/Flask application:\n\n```\npython flask_app.py\n```\n\nTo run the Streamlit application:\n\n```\nstreamlit run app.py\n```\n\nI recommend adding the following visuals to this section:\n\nA short screen recording demonstrating the complete journey from MRI upload to segmentation, visualization, AI interaction and report generation would make the demo even more useful.\n\nGemma 4 was the central partner technology I wanted to explore.\n\nMy goal was to use it as more than a conversational interface.\n\nI integrated it into NeuroTrace as an agentic research assistant that can interact with a controlled set of computational tools.\n\nThe architecture separates three responsibilities:\n\nThis makes the assistant context-aware without allowing it to independently invent measurements.\n\nI also explored different Gemma 4 model configurations for research-oriented reasoning and interactive question answering.\n\nWorking with Gemma 4 helped me understand how an LLM can become part of a larger application workflow instead of remaining an isolated chatbot.\n\nThe most valuable takeaway was that the quality of an agent depends not only on the model, but also on the tools, context and constraints surrounding it.\n\nOn October 31, 2026, I had the opportunity to participate in **Hacktoberfest Hack Day Pune × AIDN**, organized with the support of MLH and DEV.\n\nIt was a wonderful experience to work on an idea I genuinely cared about, turn it into a working implementation and present the engineering decisions behind it.\n\nThere were challenges along the way: integrating an existing deep learning model, preserving MRI spatial geometry, building interactive 3D visualizations, designing a reliable tool-based AI assistant and bringing everything together into one coherent application.\n\nBut those challenges made the experience even more rewarding.\n\nAnd the result made the day particularly special.\n\n**NeuroTrace won both categories:**\n\nWinning both categories was something I am genuinely grateful for. Along with the recognition, I was fortunate to receive a $100 cash prize, swags, credits and an Arduino UNO Q board.\n\nA huge thank you to **Hacktoberfest, MLH, DEV and AIDN Pune** for organizing the event and creating this opportunity.\n\nI am also grateful to the judges and mentors for their time, feedback and encouragement.\n\nAnd a special thank you to my teammates. The discussions, collaboration and effort throughout the experience made this journey even more memorable.\n\nI am taking away much more than prizes or certificates: new perspectives, practical experience, connections and plenty of motivation to keep building.\n\nThis is just the beginning for NeuroTrace.\n\nThere is still a lot to improve, test and explore, and I am excited to continue working on it.\n\n**If you're interested in computational neuroimaging, open-source AI or agentic applications, I'd love for you to explore the project and share your feedback.**\n\nGitHub: [https://github.com/AmanPathan24/NeuroTrace](https://github.com/AmanPathan24/NeuroTrace)\n\nThank you for reading! 🚀\n\n*This project is intended strictly for research and educational purposes. It is not a clinical diagnostic system and should not be used to make medical decisions.*", "url": "https://wpnews.pro/news/neurotrace-turning-brain-mri-segmentation-into-an-evidence-driven-research", "canonical_source": "https://dev.to/aman_ayubkhanpathan_1c06/neurotrace-turning-brain-mri-segmentation-into-an-evidence-driven-research-workflow-2fa8", "published_at": "2026-11-02 14:48:35+00:00", "updated_at": "2026-11-02 14:53:49.761830+00:00", "lang": "en", "topics": ["artificial-intelligence", "machine-learning", "computer-vision", "ai-agents", "ai-tools"], "entities": ["NeuroTrace", "Gemma 4", "Google", "MLH", "DEV", "Plotly"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/neurotrace-turning-brain-mri-segmentation-into-an-evidence-driven-research", "markdown": "https://wpnews.pro/news/neurotrace-turning-brain-mri-segmentation-into-an-evidence-driven-research.md", "text": "https://wpnews.pro/news/neurotrace-turning-brain-mri-segmentation-into-an-evidence-driven-research.txt", "jsonld": "https://wpnews.pro/news/neurotrace-turning-brain-mri-segmentation-into-an-evidence-driven-research.jsonld"}}