Inspiration
Liver fibrosis is usually caught late, because checking for it properly means a biopsy or a FibroScan, and most people never get either. Dual-echo liver MRI is common and often just sits there, read for gross structure and nothing else. We wanted to know how much more that same scan could say, and we wanted to be honest about the limits instead of dressing up a rough estimate as a diagnosis.
What it does
FibroLens takes two things that don't depend on each other and shows them side by side:
- From the MRI: it finds the liver, then measures fat percentage and a texture score directly from the pixels.
- From six questions (age, sex, BMI, waist size, diabetes, weekly alcohol): a model trained on real health survey data estimates the chance of significant fibrosis, and projects how that could change over time.
Neither one is allowed to pretend it's more certain than it is, and they're never merged into a single made-up "risk score."
How we built it
The MRI upload gets unzipped, and the in-phase and opposed-phase image series get identified from their DICOM tags. TotalSegmentator finds the liver, and MedSAM refines the boundary inside that area, falling back to the TotalSegmentator mask if MedSAM's result looks wrong. Fat percentage is a two-point Dixon-style estimate:
$$ f = \frac{S_{\text{ip}} - S_{\text{op}}}{2\,S_{\text{ip}}} $$
taken as the median over the liver region. Texture comes from a gray-level co-occurrence matrix (32 gray levels, 4 directions), giving contrast, homogeneity, and entropy:
$$ \text{entropy} = -\sum_{i,j} P_{ij}\log_2 P_{ij} $$
The questionnaire side is an XGBoost model trained on NHANES survey data, labeled using real elastography cutoffs. It cross-validates at 0.774 AUROC for detecting significant fibrosis, and holds at 0.751 on a separate, independent group of people it never saw during training.
The backend is Python and FastAPI. The frontend is React and Vite. One endpoint runs the whole pipeline and returns everything the UI needs in one response.
Challenges we ran into
- In the survey data, people who report drinking more show up as lower risk, most likely because people who already got sick and quit drinking get counted as non-drinkers. We couldn't let the model use that, so alcohol is shown as its own separate, rule-based note instead.
- Fibrosis stages are wildly imbalanced in the data (about 90% of people are the healthiest stage), so just predicting "the most likely stage" is nearly useless. We had to show the full probability spread instead of one answer.
- Some scans gave a fat measurement that came out negative on noisy pixels. We clip it to zero and flag it, instead of quietly showing a clean number that isn't real.
- MedSAM's segmentation isn't always right, so we check it against a second, independent segmentation method and fall back to that one when MedSAM's result looks broken.
- Midway through, we redesigned the entire frontend without breaking the pipeline underneath it, then proved it still worked by running a real scan through the real backend, not just fake preview data.
Accomplishments that we're proud of
- A fibrosis risk model that beats the standard bloodwork-based score (NAFLD Fibrosis Score) using nothing but a short questionnaire, and holds up on people outside its training data.
- A liver segmentation step that agrees with expert-labeled ground truth scans over 90% of the time.
- Keeping imaging and questionnaire results honestly separate instead of the easier, flashier route of mashing them into one number.
- A full pipeline that actually runs end to end: upload a real scan, answer real questions, and get a real result back, not a mockup.
What we learned
- Real health data comes with real bias baked in, and you have to go looking for it before you trust what a model learned.
- Two different kinds of evidence (an image and a questionnaire) are more useful kept apart than blended.
- Any number you call "entropy" or "texture" needs its exact method written down, or it means nothing once the data changes.
- Testing against fake preview data isn't enough. Real bugs only showed up once we ran a real scan through the real system.
What's next for FibroLens
- Calibrate the fat measurement against a real PDFF standard instead of our own two-point estimate.
- Test on more scanners and more patients outside NHANES and CHAOS.
- Get real clinician feedback on whether the risk estimate is actually useful in a conversation, not just accurate on paper.
Log in or sign up for Devpost to join the conversation.