Skip to content

Commit

Permalink
Disabled synthetic tests by default, added some analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
etpeterson committed Oct 25, 2023
1 parent b46f643 commit f14a7fc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[pytest]
markers =
slow: marks tests as slow (deselect with '-m "not slow"')
addopts =
-m 'not slow'
21 changes: 21 additions & 0 deletions tests/IVIMmodels/unit_tests/analyze.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
library(tidyverse)
data <- read.csv("test_output.csv", skip=1, col.names=c("Algorithm", "Region", "SNR", "Truth", "Fitted"))
data<-separate_wider_delim(data, cols = Truth, delim = ",", names = c("f", "D", "Dp"))
data$f <- substring(data$f, 2)
data$Dp <- substring(data$Dp, 1, nchar(data$Dp) - 1)
data<-separate_wider_delim(data, cols = Fitted, delim = ",", names = c("f_fitted", "D_fitted", "Dp_fitted"))
data$f_fitted <- substring(data$f_fitted, 2)
data$Dp_fitted <- substring(data$Dp_fitted, 1, nchar(data$Dp_fitted) - 1)
data[c("Algorithm", "Region")] <- sapply(data[c("Algorithm", "Region")], as.factor)
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)
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")
ggsave("f.pdf", width = 50, height = 50, units = "cm")
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")
ggsave("D.pdf", width = 50, height = 50, units = "cm")
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")
ggsave("Dp.pdf", width = 50, height = 50, units = "cm")
#why?
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")
ggsave("D_tweak.pdf", width = 50, height = 50, units = "cm")
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")
ggsave("Dp_tweak.pdf", width = 50, height = 50, units = "cm")
3 changes: 2 additions & 1 deletion tests/IVIMmodels/unit_tests/test_ivim_synthetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from utilities.data_simulation.GenerateData import GenerateData

#run using pytest <path_to_this_file> --saveFileName test_output.txt --SNR 50 100 200
#e.g. pytest tests/IVIMmodels/unit_tests/test_ivim_synthetic.py --saveFileName test_output.txt --SNR 50 100 200
#e.g. pytest -m slow tests/IVIMmodels/unit_tests/test_ivim_synthetic.py --saveFileName test_output.csv --SNR 10 50 100 200 --fitCount 20
@pytest.mark.slow
def test_generated(ivim_algorithm, ivim_data, SNR, rtol, atol, fit_count, save_file):
# assert save_file == "test"
random.seed(42)
Expand Down

0 comments on commit f14a7fc

Please sign in to comment.