Talaromyces marneffei infection vs TB: 2.5D deep learning
A cough and a shadow on a CT scan open the story for both diseases, and only one of them is treated with rifampicin. Talaromyces marneffei infection is a fungal disease of the immunocompromised, and it overlaps pulmonary tuberculosis in nodules, consolidation, and cavitation. In a population with advanced HIV the overlap runs close enough that clinicians routinely reach for the wrong drug. A retrospective study of 380 patients has now put numbers on how much of that overlap a machine can resolve. A multimodal model that combines clinical data, radiomics, and a 2.5D deep learning representation reached an AUC of 0.931 with a specificity of 0.981.
Quick answer
In 380 patients with advanced HIV and pulmonary infection, 203 with tuberculosis and 177 with Talaromyces marneffei infection, the combined model reached an AUC of 0.931 (95% CI 0.888 to 0.9753) on a held-out test set. The best clinical model managed 0.856, and the best radiomics model 0.866. Specificity came in at 0.981 and sensitivity at 0.717. The combined model beat the clinical model by a margin that survived testing (delta AUC 0.075, P = 0.020) and the radiomics model as well (delta AUC 0.065, P = 0.008). It did not clearly beat the standalone deep learning model (delta AUC 0.046, P = 0.116).
Why Talaromyces marneffei infection and tuberculosis look the same
The fungus responsible is thermally dimorphic. It disseminates through the body in people whose cellular immunity is depleted, and its pulmonary form speaks the same radiographic language as tuberculosis: nodules, patchy consolidation, cavitary lesions. In a patient with advanced HIV, neither the symptom list nor a single CT slice separates the two reliably.
The conventional tools are slow or blunt. Culture is still the reference standard, yet fungal growth takes 5 to 14 days and can miss as many as 50 percent of infections, which delays both the diagnosis and the start of treatment. Serology lacks sufficient specificity, and sputum smear microscopy for tuberculosis carries a relatively high false-negative rate. So the call gets made under time pressure with imperfect instruments, and the price of a wrong one is measured in weeks.
The two diseases also sit at different points on the immunity spectrum, and that is what makes a combined clinical and imaging approach plausible. Tuberculosis tends to present at relatively preserved CD4 counts, somewhere between 200 and 500 cells/mL. Most fungal opportunistic infections wait until counts fall below 200 cells/mL.
How the study was built
The cohort was assembled retrospectively at a single center between January 2018 and August 2025: 380 patients with HIV and pulmonary infection, 203 with pulmonary tuberculosis and 177 with the fungal infection. There were 296 men (77.9 percent) and 84 women (22.1 percent), a ratio near 3.5 to 1 that tracks the demographics of the regional HIV population.
Every patient had a thin-slice CT with isotropic 1-mm reconstruction, and the images were segmented into regions of interest covering the lesions. Patients were excluded if they had taken antifungal or anti-tuberculosis therapy, including regimens built on isoniazid, rifampicin, ethambutol, and pyrazinamide, for more than 72 hours before the scan; if reconstruction thickness exceeded 1 mm; or if key variables such as CD4 count were missing.
The split was made at the patient level, 7 to 3, giving 266 training cases and 114 test cases. That detail carries more weight than it sounds. All preprocessing, including intensity normalization, feature selection, and model tuning, happened on the training set only, and the test set was used once for final validation. No slice from any patient appeared in both sets, which removes the most common source of leakage in imaging studies.
What clinical features alone could do
Five machine learning algorithms were compared on a feature set drawn from demographics, immunological markers including CD3, CD4, and CD8 counts, routine hematology, and inflammatory markers. Random Forest came out ahead, with a test AUC of 0.856, a sensitivity of 0.817, and a specificity of 0.815.
The independent predictors were CD4 count, hemoglobin level, fever, diabetes, and hypertension, and the group differences behind them were large. Patients with Talaromyces marneffei infection had a median CD4 count of 17 cells/mL against 127 cells/mL in tuberculosis, platelet counts of 137 against 219 x 10^9/L, and hemoglobin of 81 against 102 g/L, all with P below 0.001. Tuberculosis patients were older and carried more hypertension and diabetes.
| Model | Test AUC | Sensitivity | Specificity |
|---|---|---|---|
| Clinical Random Forest | 0.856 | 0.817 | 0.815 |
| Radiomics XGBoost | 0.866 | 0.717 | 0.870 |
| 2.5D ResNet18 slice level | 0.865 | not reported | 0.918 |
| MIL patient level support vector machine | 0.885 | 0.667 | 0.926 |
| Combined multimodal | 0.931 | 0.717 | 0.981 |
That profile has a biological reading. CD4 count carries the immunological signal, because a count of 17 cells/mL puts a patient firmly in the territory where fungal opportunistic infection dominates. Platelets and hemoglobin may reflect the tropism of the fungus for the mononuclear phagocyte system, together with the marrow suppression that follows dissemination.
What imaging features alone could do
The radiomics pipeline extracted 1,561 quantitative features from each region of interest, covering gray-level distribution, morphological properties, and textural heterogeneity. Features that failed univariate testing or that were correlated above an absolute value of 0.9 were dropped, minimum redundancy maximum relevance reduced the pool to 32 variables, and a LASSO-regularized logistic regression with 10-fold cross-validation selected the final subset with non-zero coefficients.
XGBoost was the best performer on that subset, with a test AUC of 0.866 against 0.873 in training, the smallest train-to-test gap of any algorithm tested. The near-identical training and test numbers are the point: the feature selection was honest, and the model was not memorizing.
What the 2.5D deep learning model added
The deep learning arm treated a CT series as an ordered stack of slices rather than as a single image. A central axial slice was classified together with its neighbors at offsets of 1, 2, and 4 slices, which is what the 2.5D designation means: three-dimensional context without the cost of a full volumetric network.
Several architectures were compared at the slice level, and ResNet18 performed best overall with an AUC of 0.865, a specificity of 0.918, and a positive predictive value of 0.892. ResNet50 reached 0.937 in training but fell to 0.782 in testing, a textbook overfit that the authors report rather than hide. At the patient level, a multi-instance learning framework aggregated the slice predictions and fused them with the radiomic descriptors through a support vector machine, reaching an AUC of 0.885 with a specificity of 0.926 and a sensitivity of 0.667.
What the combined model achieved
The combined model concatenated the discriminative clinical features, the selected radiomics features, and the high-level representations from the deep learning arm, and it outperformed every single modality. On the held-out test set it reached an AUC of 0.931 (95% CI 0.888 to 0.9753) with a specificity of 0.981, a sensitivity of 0.717, and a positive predictive value of 0.977.
DeLong testing confirmed the gain against the two weaker baselines. The combined model beat the clinical model by 0.075 AUC units (95% CI 0.012 to 0.138, P = 0.020) and the radiomics model by 0.065 units (P = 0.008). It did not significantly beat the standalone 2.5D deep learning model, gaining 0.046 units with P = 0.116, and that is an honest result worth reading carefully: most of the discriminative work was already being done by the image representation, while the clinical and radiomics features added precision rather than raw separation.
Calibration followed the same ordering. The combined model achieved the lowest Brier score at 0.089, against 0.112 for the deep learning model, 0.149 for radiomics, and 0.156 for the clinical model, and the Hosmer-Lemeshow test supported consistency between predicted probabilities and observed outcomes.
Where the model is looking
Grad-CAM visualization of the final convolutional layer showed the two diseases lighting up different anatomy. In true-positive tuberculosis cases, activation concentrated on cavitary lesions. In true-positive cases of the fungal disease, activation covered nodular and infiltrative disease. The model is not exploiting a shortcut such as scan metadata or patient positioning; it is reading the lesion patterns that radiologists describe in words.
Why this matters for rifampicin-based treatment
Rifampicin anchors the rifamycin class and sits at the center of first-line tuberculosis therapy, with rifapentine used where a longer-acting partner simplifies directly observed therapy. The cost of confusing the two diseases is therefore asymmetric and concrete. A patient with Talaromyces marneffei infection who is started on a rifampicin-based tuberculosis regimen receives weeks of a drug that does nothing for the fungus while the actual infection advances, and a patient with tuberculosis who is treated as a fungal case loses the drug the entire regimen depends on.
For rifamycin programs the lesson is about where diagnostic value sits. A model with 0.981 specificity and 0.717 sensitivity is not a replacement for clinical judgment, but it is a triage instrument: a positive call can justify holding the antifungal or the antitubercular decision until etiological evidence returns, and the 5 to 14 day culture window is exactly where that time is won. The same logic applies to any program whose drug is only useful if the right patient is identified early.
Limitations
The study is retrospective and single-center, and the authors state that external validation is required before clinical use. The cohort was 77.9 percent male, so performance in women is thinly supported. A sensitivity of 0.717 means roughly three in ten cases were missed, and the reported operating point depends on the chosen threshold rather than on a universally optimal cut-off. The comparator group was defined by etiological criteria that themselves carry error, and no prospective impact on treatment decisions or outcomes was measured.
Bottom line
In 380 patients with advanced HIV, a model combining clinical features, radiomics, and a 2.5D deep learning representation separated Talaromyces marneffei infection from pulmonary tuberculosis with an AUC of 0.931, a specificity of 0.981, and a sensitivity of 0.717, significantly beating the clinical model (P = 0.020) and the radiomics model (P = 0.008). The clinical signal came down to CD4 count, hemoglobin, fever, diabetes, and hypertension, and the imaging signal came down to cavitary versus nodular disease. For anyone whose product depends on getting the tuberculosis diagnosis right before rifampicin starts, that is a triage tool worth watching.
FAQ
What is Talaromyces marneffei infection
Talaromyces marneffei infection is a fungal disease caused by a thermally dimorphic fungus that disseminates through the body in people with depleted cellular immunity. It is most often seen in patients with advanced HIV, and its pulmonary form produces nodules, consolidation, and cavitary lesions on CT. Diagnosis is slow because culture can take 5 to 14 days and can miss as many as half of infections.
Why is Talaromyces marneffei infection confused with tuberculosis
Both diseases produce overlapping CT findings of nodules, consolidation, and cavitary lesions, and both present with cough and systemic symptoms in the same immunocompromised population. Conventional tests are slow or blunt: fungal culture needs 5 to 14 days, serology lacks specificity, and sputum smear for tuberculosis has a high false-negative rate. The overlap is why treatment can start on the wrong disease.
How many patients were in the deep learning study
The study enrolled 380 patients with HIV and pulmonary infection, comprising 203 with pulmonary tuberculosis and 177 with talaromyces infection. The cohort was 296 men and 84 women. Cases were split at the patient level into a training set of 266 and a test set of 114, with all preprocessing and feature selection performed only on the training set to prevent leakage.
What is a 2.5D deep learning model
A 2.5D model classifies a CT slice together with its neighbors at fixed offsets, here 1, 2, and 4 slices on either side of a central axial slice. This gives the network three-dimensional context without the computational cost of a full volumetric model. The slice predictions are then aggregated at the patient level through a multi-instance learning framework.
What accuracy did the combined model reach
The combined multimodal model reached an AUC of 0.931 with a 95% confidence interval of 0.888 to 0.9753 on the held-out test set. Specificity was 0.981 and sensitivity was 0.717. It significantly outperformed the clinical model (delta AUC 0.075, P = 0.020) and the radiomics model (delta AUC 0.065, P = 0.008), but not the standalone deep learning model (P = 0.116).
Which clinical features predicted the diagnosis
Five variables were independent predictors: CD4 count, hemoglobin level, fever, diabetes, and hypertension. Patients with Talaromyces marneffei infection had a median CD4 count of 17 cells/mL against 127 cells/mL in tuberculosis, platelet counts of 137 against 219 x 10^9/L, and hemoglobin of 81 against 102 g/L. All three laboratory differences were significant at P below 0.001.
How many radiomics features were used
A total of 1,561 quantitative features were extracted from each lesion region of interest. Univariate filtering and a correlation threshold of 0.9 removed most of them, minimum redundancy maximum relevance reduced the pool to 32, and a LASSO-regularized logistic regression with 10-fold cross-validation selected the final subset. XGBoost on that subset reached a test AUC of 0.866.
Why did ResNet18 outperform ResNet50
ResNet18 reached a test AUC of 0.865 with a specificity of 0.918 and a positive predictive value of 0.892, and the gap between its training and test performance was small. ResNet50 reached 0.937 in training but dropped to 0.782 in testing, which is classic overfitting on a cohort of this size. The smaller network generalized better.
Where does the model focus on the CT images
Grad-CAM activation maps showed different patterns for the two diseases. In true-positive tuberculosis cases the activation concentrated on cavitary lesions, while in true-positive talaromyces cases it covered nodular and infiltrative disease. That difference matches how radiologists describe the two diseases and suggests the model reads lesion biology rather than image metadata.
Why does the distinction matter for rifampicin treatment
Tuberculosis regimens are built around rifampicin and rifapentine, and neither drug treats a fungal infection. A patient with Talaromyces marneffei infection who receives a rifamycin-based regimen loses the window in which antifungal therapy works, while a tuberculosis patient treated as a fungal case loses the drug the regimen depends on. A high-specificity triage model can shorten that period of uncertainty.
What are the limitations of the study
The study is retrospective, single-center, and validated internally only, so external validation is needed before clinical use. The cohort was 77.9 percent male, which limits confidence in female patients. A sensitivity of 0.717 means about three in ten cases were missed at the chosen threshold, and no prospective effect on treatment decisions or outcomes was measured.


