A Python + R program for consensus clustering implementation based on this paper.
Python packages: matplotlib, pandas, seaborn, numpy, and PIL
R libraries: no specific library is needed
I explain the method via an example. Here we have a six clusters data corresponding to 'no artifact', 'other artifacts', 'ringing', 'ghosting', 'banding', and 'motion' classes. The values of the data for each cluster along with the cluster labels is saved in .txt files (see files directory).
The first step is to run the R code named R. The input of the script is two .txt files and the output is a out_text.txt file and a folder named "saved_folder" containing the consensus plots. Since here we have six clusters (k=6) we will need the plot named consensus06.png which looks like the follwoing plot.
The second step is to run the Python code named P. The input of the script is the out_text.txt file and the output is a report.xlsx file and three .png plots as follows.
The metrics of each cluster is in the following format.
ClassNumber | ClassName | TP | FP | TN | FN | Accuracy | Recall | Precision |
---|---|---|---|---|---|---|---|---|
5 | banding | 9 | 0 | 90 | 1 | 0.99 | 0.9 | 1 |
1 | no artifact | 31 | 2 | 66 | 1 | 0.97 | 0.97 | 0.94 |
2 | other artifacts | 2 | 0 | 97 | 0 | 1 | 1 | 1 |
3 | ringing | 16 | 1 | 82 | 4 | 0.95 | 0.8 | 0.94 |
6 | motion | 12 | 1 | 86 | 3 | 0.96 | 0.8 | 0.92 |
4 | ghosting | 20 | 5 | 74 | 0 | 0.95 | 1 | 0.8 |
Finally, a .pptx file is made to visualize the whole result.