histocartography / patho-quant-explainer

Code for replicating results presented in the paper: "Quantifying Explainers of Graph Neural Networks in Computational Pathology"
MIT License
43 stars 7 forks source link

ndata[`concepts`] not created because nuclei extractor detects too few nuclei #8

Open CarlinLiao opened 1 year ago

CarlinLiao commented 1 year ago

I first noticed this issue in run_qualitative_analysis.py where it would error in main at line 315

concepts = [cg.ndata['concepts'].cpu().detach().numpy() for cg in cell_graphs]

because a cell graph wouldn't have a concepts data field.

I traced this back to graph creation and generate_cell_graphs.py, where the concepts not being created error was being silenced due to a try-except statement.

            # e. build a kNN graph
            try:
                graph = knn_graph_builder.process(nuclei_map, features)
            except:
                print('Warning: {} failed during kNN graph building.'.format(image_path))
                image_ids_failing.append(image_path)
                pass

When I dug into this, I noticed that the nuclei_map, according to the second output of nuclei_detector.process(image), there are far fewer nuclei detected than there should be! I'm talking only 4 nuclei for BRACS_1897_DCIS_4.png!

Speaking of try-excepts silencing critical errors, when I isolated graph creation to just one graph, I noticed that the knn graph builder was failing as well due to the same only-4-nuclei-detected, but when creating all the graphs in series that error wasn't noticeable because the code was just using the knn graph from the prior ROI in the list instead of throwing a visible error. But that's a separate issue.