1
1
library(tidyverse )
2
- data <- read.csv(" test_output.csv" , skip = 1 , col.names = c(" Algorithm" , " Region" , " SNR" , " Truth" , " Fitted" ))
3
- data <- separate_wider_delim(data , cols = Truth , delim = " ," , names = c(" f" , " D" , " Dp" ))
4
- data $ f <- substring(data $ f , 2 )
5
- data $ Dp <- substring(data $ Dp , 1 , nchar(data $ Dp ) - 1 )
6
- data <- separate_wider_delim(data , cols = Fitted , delim = " ," , names = c(" f_fitted" , " D_fitted" , " Dp_fitted" ))
7
- data $ f_fitted <- substring(data $ f_fitted , 2 )
8
- data $ Dp_fitted <- substring(data $ Dp_fitted , 1 , nchar(data $ Dp_fitted ) - 1 )
9
- data [c(" Algorithm" , " Region" )] <- sapply(data [c(" Algorithm" , " Region" )], as.factor )
10
- data [c(" SNR" , " f" , " D" , " Dp" , " f_fitted" , " D_fitted" , " Dp_fitted" )] <- sapply(data [c(" SNR" , " f" , " D" , " Dp" , " f_fitted" , " D_fitted" , " Dp_fitted" )], as.numeric )
11
- ggplot(data , aes(x = Algorithm )) + geom_boxplot(aes(y = f_fitted )) + geom_boxplot(color = " red" , aes(y = f )) + facet_grid(SNR ~ Region ) + scale_x_discrete(guide = guide_axis(angle = 90 )) + ylim(0 , 1 ) + ggtitle(" Perfusion fraction grid" ) + xlab(" Perfusion fraction" )
12
- ggsave(" f.pdf" , width = 50 , height = 50 , units = " cm" )
13
- ggplot(data , aes(x = Algorithm )) + geom_boxplot(aes(y = D_fitted )) + geom_boxplot(color = " red" , aes(y = D )) + facet_grid(SNR ~ Region ) + scale_x_discrete(guide = guide_axis(angle = 90 )) + ggtitle(" Diffusion grid" ) + xlab(" Diffusion" )
14
- ggsave(" D.pdf" , width = 50 , height = 50 , units = " cm" )
15
- ggplot(data , aes(x = Algorithm )) + geom_boxplot(aes(y = Dp_fitted )) + geom_boxplot(color = " red" , aes(y = Dp )) + facet_grid(SNR ~ Region ) + scale_x_discrete(guide = guide_axis(angle = 90 )) + ggtitle(" Perfusion grid" ) + xlab(" Perfusion" )
16
- ggsave(" Dp.pdf" , width = 50 , height = 50 , units = " cm" )
17
- # why?
18
- ggplot(data , aes(x = Algorithm )) + geom_boxplot(aes(y = D_fitted )) + geom_boxplot(color = " red" , aes(y = Dp )) + facet_grid(SNR ~ Region ) + scale_x_discrete(guide = guide_axis(angle = 90 )) + ggtitle(" Diffusion grid" ) + xlab(" Diffusion" )
19
- ggsave(" D_tweak.pdf" , width = 50 , height = 50 , units = " cm" )
20
- ggplot(data , aes(x = Algorithm )) + geom_boxplot(aes(y = Dp_fitted )) + geom_boxplot(color = " red" , aes(y = D )) + facet_grid(SNR ~ Region ) + scale_x_discrete(guide = guide_axis(angle = 90 )) + ggtitle(" Perfusion grid" ) + xlab(" Perfusion" )
21
- ggsave(" Dp_tweak.pdf" , width = 50 , height = 50 , units = " cm" )
2
+ library(plyr )
3
+
4
+ plot_ivim <- function (data , fileExtension ) {
5
+ ggplot(data , aes(x = Algorithm )) + geom_boxplot(aes(y = f_fitted )) + geom_boxplot(color = " red" , aes(y = f )) + facet_grid(SNR ~ Region ) + scale_x_discrete(guide = guide_axis(angle = 90 )) + ylim(0 , 1 ) + ggtitle(" Perfusion fraction grid" ) + ylab(" Perfusion fraction" )
6
+ ggsave(paste(" f" , fileExtension , sep = " " ), width = 50 , height = 50 , units = " cm" )
7
+ ggplot(data , aes(x = Algorithm )) + geom_boxplot(aes(y = D_fitted )) + geom_boxplot(color = " red" , aes(y = D )) + facet_grid(SNR ~ Region ) + scale_x_discrete(guide = guide_axis(angle = 90 )) + ggtitle(" Diffusion grid" ) + ylab(" Diffusion" )
8
+ ggsave(paste(" D" , fileExtension , sep = " " ), width = 50 , height = 50 , units = " cm" )
9
+ ggplot(data , aes(x = Algorithm )) + geom_boxplot(aes(y = Dp_fitted )) + geom_boxplot(color = " red" , aes(y = Dp )) + facet_grid(SNR ~ Region ) + scale_x_discrete(guide = guide_axis(angle = 90 )) + ylim(0 , 0.25 ) + ggtitle(" Perfusion grid" ) + ylab(" Perfusion" )
10
+ ggsave(paste(" Dp" , fileExtension , sep = " " ), width = 50 , height = 50 , units = " cm" )
11
+ }
12
+
13
+ data <- read.csv(" test_output.csv" )
14
+ data <- data %> % mutate_if(is.character , as.factor )
15
+ plot_ivim(data , " .pdf" )
16
+
17
+ data_restricted <- data [data $ Region %in% c(" Liver" , " spleen" , " Right kydney cortex" , " right kidney medulla" ),]
18
+ plot_ivim(data_restricted , " _limited.pdf" )
19
+
20
+ data_duration <- read.csv(" test_duration.csv" )
21
+ data_duration <- data_duration %> % mutate_if(is.character , as.factor )
22
+ data_duration $ ms <- data_duration $ Duration..us. / data_duration $ Count / 1000
23
+ ggplot(data_duration , aes(x = Algorithm , y = ms )) + geom_boxplot() + scale_x_discrete(guide = guide_axis(angle = 90 )) + ggtitle(" Fit Duration" ) + ylab(" Time (ms)" )
24
+ ggsave(" durations.pdf" , width = 20 , height = 20 , units = " cm" )
25
+
0 commit comments