@@ -42,3 +42,23 @@ Dp_model <- lm(Dp ~ Dp_fitted_IAR_LU_biexp + Dp_fitted_IAR_LU_modified_mix + Dp_
42
42
# Dp_model <- lm(Dp ~ Dp_fitted_ETP_SRI_LinearFitting + Dp_fitted_IAR_LU_biexp + Dp_fitted_IAR_LU_modified_mix + Dp_fitted_IAR_LU_modified_topopro + Dp_fitted_IAR_LU_segmented_2step + Dp_fitted_IAR_LU_segmented_3step + Dp_fitted_IAR_LU_subtracted, data=data_new_wide)
43
43
# predict new data from existing model
44
44
predict(object = f_model , newdata = data_wide )
45
+
46
+
47
+ ivim_decay <- function (f , D , Dp , bvalues ) {
48
+ return (f * exp(- Dp * bvalues ) + (1 - f )* exp(- D * bvalues ))
49
+ }
50
+ bvalues <- c(0.0 , 1.0 , 2.0 , 5.0 , 10.0 , 20.0 , 30.0 , 50.0 , 75.0 , 100.0 , 150.0 , 250.0 , 350.0 , 400.0 , 550.0 , 700.0 , 850.0 , 1000.0 )
51
+
52
+ generate_curves <- function (data , bvalues , appended_string ) {
53
+ curves <- apply(data [,c(paste(" f" , appended_string , sep = " " ), paste(" D" , appended_string , sep = " " ), paste(" Dp" , appended_string , sep = " " ))], 1 , function (x ) ivim_decay(x [1 ], x [2 ], x [3 ], bvalues ))
54
+ curves <- transpose(data.frame (curves ))
55
+ colnames(curves ) <- paste(" b" , bvalues , sep = " _" )
56
+ data_curves <- cbind(data , curves )
57
+ data_curves <- pivot_longer(data_curves , starts_with(" b_" ), names_to = " bvalue" , values_to = paste(" signal" , appended_string , sep = " " ), names_prefix = " b_" , names_transform = list (bvalue = as.numeric ))
58
+ return (data_curves )
59
+ }
60
+ curves_restricted_fitted <- generate_curves(data_restricted , bvalues , " _fitted" )
61
+ curves_restricted <- generate_curves(data_restricted , bvalues , " " )
62
+
63
+ data_curves_restricted <- cbind(curves_restricted , signal_fitted = curves_restricted_fitted $ signal_fitted )
64
+ ggplot(data_curves_restricted , aes(x = bvalue )) + facet_grid(Region ~ SNR ) + geom_line(alpha = 0.2 , aes(y = signal_fitted , group = interaction(Algorithm , index ), color = Algorithm )) + geom_line(aes(y = signal )) + ylim(0 , 1 ) + ylab(" Signal (a.u.)" )
0 commit comments