User Tools

Site Tools


neuroimagen:bioface_atn

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
neuroimagen:bioface_atn [2021/09/12 10:21]
osotolongo [What we got so far]
neuroimagen:bioface_atn [2022/06/10 09:04]
osotolongo [evaluando WMH]
Line 263: Line 263:
 </code> </code>
  
-{{ :neuroimagen:rf_classifier_bioface.png?600 |}}+^ Clasificación ^ Probabilidades de N+ ^ 
 +{{ :neuroimagen:rf_classifier_bioface.png?600 |}} | {{ :neuroimagen:rf_prob_profile_bioface.png?600 |}} |
  
 **FACEHBI**  **FACEHBI** 
Line 274: Line 275:
 </code> </code>
  
-{{ :neuroimagen:rf_classifier_facehbi.png?600 |}}+^ Clasificación ^ Probabilidades de N+ ^ 
 +{{ :neuroimagen:rf_classifier_facehbi.png?600 |}} | {{ :neuroimagen:rf_prob_profile_facehbi.png?600 |}} |
  
 === support-vector machine === === support-vector machine ===
Line 296: Line 298:
  
 {{ :neuroimagen:svm_classifier_facehbi.png?600 |}} {{ :neuroimagen:svm_classifier_facehbi.png?600 |}}
 +
 +===== Introduciendo WMH en AT(N)=====
 +
 +¿Son las afecciones vasculares parte de la neurodegeneracion? ¿Debe ser considerado el aumento en el volumen de WMH una parte fundamental de la evaluacion de N?
 +
 +Pues si queremos hacerlo de esta manera, hay basicamente dos maneras. Utilizando las WMH de Freesurfer (T1w) o las calculadas por un soft independiente (T2w). Si tenemos un FLAIR 3D podemos hacerlo de ambas maneras pero en caso contrario. 
 +
 +==== evaluando WMH ====
 +
 +Las WMH vienen ya calculadas en el procedimiento //standard// asi que esto deberia ser //painless//. Pero en la DB de ADNIMERGE, no vienen integradas en la tabla de resumen que estamos usando, asi que hay que incluirlas. Pero revisando el procedimiento de integracion (adnimerger) veo que hay que arreglar un poco las //VISCODE//
 +
 +<code RMarkdown>
 +ucsffsx -> ucsffsx_t
 +ucsffsx_t$VISCODE <- ifelse(ucsffsx_t$VISCODE == "sc", "bl", ucsffsx_t$VISCODE)
 +a1 <- merge(pop, ucsffsx_t, by=c("RID", "VISCODE"))
 +</code>
 +
 + y esto hay que hacerlo para cada una de las tablas y despues concatenar los resutados. Despues se incluye el WMH en el analisis y ya esta.
 +
 +++++ que se dice un poco mas rapido de lo que se hace, tambien es cierto, |
 +
 +<code Rmarkdown>
 +library("e1071")
 +library("caret")
 +library("caTools")
 +library("tidyverse")
 +library("ADNIMERGE")
 +
 +input_file="input_data.csv"
 +output_file="classifier_output_w.csv"
 +output_fig="classifier_output_hippocampus_w.ps"
 +pop <- adnimerge[(adnimerge$DX=="Dementia" | adnimerge$DX=="CN"),];
 +pop$ND = as.factor(ifelse(pop$DX == "Dementia", 1, 0))
 +ucsffsx -> ucsffsx_t
 +ucsffsx_t$VISCODE <- ifelse(ucsffsx_t$VISCODE == "sc", "bl", ucsffsx_t$VISCODE)
 +a1 <- merge(pop, ucsffsx_t, by=c("RID", "VISCODE"))
 +ucsffsx51 -> ucsffsx_t
 +ucsffsx_t$VISCODE <- ifelse(ucsffsx_t$VISCODE == "sc", "bl", ucsffsx_t$VISCODE)
 +a2 <- merge(pop, ucsffsx_t, by=c("RID", "VISCODE"))
 +ucsffsx6 -> ucsffsx_t
 +ucsffsx_t$VISCODE <- ifelse(ucsffsx_t$VISCODE == "sc", "bl", ucsffsx_t$VISCODE)
 +a3 <- merge(pop, ucsffsx_t, by=c("RID", "VISCODE"))
 +a1t <- a1[, c("Hippocampus", "Entorhinal", "Ventricles", "MidTemp", "AGE", "ICV", "ST128SV", "ND")]
 +a2t <- a2[, c("Hippocampus", "Entorhinal", "Ventricles", "MidTemp", "AGE", "ICV", "ST128SV", "ND")]
 +a3t <- a3[, c("Hippocampus", "Entorhinal", "Ventricles", "MidTemp", "AGE", "ICV", "ST128SV", "ND")]
 +axt <- rbind(a1t, a2t, a3t)
 +xt <- rename(axt, "WMH" = "ST128SV")
 +classifier_cl <- naiveBayes(ND ~ ., data = xt)
 +base <- read.csv(input_file)
 +base$Hippocampus = base$Left.Hippocampus + base$Right.Hippocampus
 +base$Entorhinal = base$lh.entorhinal.GrayVol + base$rh.entorhinal.GrayVol
 +base$Ventricles <- base$Left.Inf.Lat.Vent + base$Right.Inf.Lat.Vent + base$Left.Lateral.Ventricle + base$Right.Lateral.Ventricle
 +base$MidTemp = base$lh.middletemporal.GrayVol + base$rh.middletemporal.GrayVol
 +base$ICV = base$eTIV
 +base$WMH = base$WM.hypointensities
 +base$ND <- predict(classifier_cl, newdata = base)
 +base2e = base[, c("Subject_ID", "ND")]
 +write.csv(base2e, file=output_file, row.names=FALSE, quote=FALSE)
 +a <- lm(base$Hippocampus ~ base$ICV)
 +base$aHV = base$Hippocampus - a$coefficients[[2]]*(base$ICV - mean(base$ICV, na.rm=TRUE))
 +postscript(output_fig, width=1024, height=600, bg="white")
 +plot(base$AGE, base$aHV, main = "Hippocampus volume versus Age", xlab="Age", ylab="adjusted HV", pch=19, col=ifelse(base$ND==1,"red","green"))
 +dev.off()
 +a <- lm(base$MidTemp ~ base$ICV)
 +base$aMidTemp = base$MidTemp - a$coefficients[[2]]*(base$ICV - mean(base$ICV, na.rm=TRUE))
 +output_fig="classifier_output_middletemporal_w.ps"
 +postscript(output_fig, width=1024, height=600, bg="white")
 +plot(base$AGE, base$aMidTemp, main = "Middle temporal cortex volume versus Age", xlab="Age", ylab="adjusted MidTemp Volume", pch=19, col=ifelse(base$ND==1,"red","green"))
 +dev.off()
 +a <- lm(base$Entorhinal ~ base$ICV)
 +base$aEntorhinal = base$Entorhinal - a$coefficients[[2]]*(base$ICV - mean(base$ICV, na.rm=TRUE))
 +output_fig="classifier_output_entorhinal_w.ps"
 +postscript(output_fig, width=1024, height=600, bg="white")
 +plot(base$AGE, base$aEntorhinal, main = "Entorhinal cortex volume versus Age", xlab="Age", ylab="adjusted Entorhinal Volume", pch=19, col=ifelse(base$ND==1,"red","green"))
 +dev.off()
 +</code>
 +++++
 +
 +
 +++++ OK, ya puestos también podemos hacerlo con las WMH calculadas desde T2W |
 +<code Rmarkdown>
 +library("e1071")
 +library("caret")
 +library("caTools")
 +library("ADNIMERGE")
 +input_file="input_dataw.csv"
 +output_file="classifier_output_w2.csv"
 +output_fig="classifier_output_hippocampus_w2.ps"
 +pop <- adnimerge[(adnimerge$DX=="Dementia" | adnimerge$DX=="CN"),];
 +ucd_wmh -> ucd_t
 +ucd_t$VISCODE <- ifelse(ucd_t$VISCODE == "scmri", "bl", ucd_t$VISCODE)
 +ucd_t$VISCODE <- ifelse(ucd_t$VISCODE == "sc", "bl", ucd_t$VISCODE)
 +pop <- merge(pop, ucd_t, by=c("RID", "VISCODE"))
 +pop$ND = as.factor(ifelse(pop$DX == "Dementia", 1, 0))
 +xt <- pop[, c("Hippocampus", "Entorhinal", "Ventricles", "MidTemp", "AGE", "ICV", "TOTAL_WMH", "ND")]
 +classifier_cl <- naiveBayes(ND ~ ., data = xt)
 +base <- read.csv(input_file)
 +base$Hippocampus = base$Left.Hippocampus + base$Right.Hippocampus
 +base$Entorhinal = base$lh.entorhinal.GrayVol + base$rh.entorhinal.GrayVol
 +base$Ventricles <- base$Left.Inf.Lat.Vent + base$Right.Inf.Lat.Vent + base$Left.Lateral.Ventricle + base$Right.Lateral.Ventricle
 +base$MidTemp = base$lh.middletemporal.GrayVol + base$rh.middletemporal.GrayVol
 +base$ICV = base$eTIV
 +base$TOTAL_WMH = base$WMH*0.001
 +base$ND <- predict(classifier_cl, newdata = base)
 +base$posterior <- predict(classifier_cl, newdata = base, type="raw")
 +base2e = base[, c("Subject_ID", "ND", "posterior")]
 +write.csv(base2e, file=output_file, row.names=FALSE, quote=FALSE)
 +a <- lm(base$Hippocampus ~ base$ICV)
 +base$aHV = base$Hippocampus - a$coefficients[[2]]*(base$ICV - mean(base$ICV, na.rm=TRUE))
 +postscript(output_fig, width=1024, height=600, bg="white")
 +plot(base$AGE, base$aHV, main = "Hippocampus volume versus Age", xlab="Age", ylab="adjusted HV", pch=19, col=ifelse(base$ND==1,"red","green"))
 +dev.off()
 +a <- lm(base$MidTemp ~ base$ICV)
 +base$aMidTemp = base$MidTemp - a$coefficients[[2]]*(base$ICV - mean(base$ICV, na.rm=TRUE))
 +output_fig="classifier_output_middletemporal_w2.ps"
 +postscript(output_fig, width=1024, height=600, bg="white")
 +plot(base$AGE, base$aMidTemp, main = "Middle temporal cortex volume versus Age", xlab="Age", ylab="adjusted MidTemp", pch=19, col=ifelse(base$ND==1,"red","green"))
 +dev.off()
 +a <- lm(base$Entorhinal ~ base$ICV)
 +base$aEntorhinal = base$Entorhinal - a$coefficients[[2]]*(base$ICV - mean(base$ICV, na.rm=TRUE))
 +output_fig="classifier_output_entorhinal_w2.ps"
 +postscript(output_fig, width=1024, height=600, bg="white")
 +plot(base$AGE, base$aEntorhinal, main = "Entorhinal cortex volume versus Age", xlab="Age", ylab="adjusted Entorhinal", pch=19, col=ifelse(base$ND==1,"red","green"))
 +dev.off()
 +
 +</code>
 +
 +++++ (**NO WAY**, explicar como se hace que hay que meter el ucd_wmh de ADNI y sacar wl WMH con PGS)
 +
 +^ no WMH ^ T1w WMH ^ T2w WMH ^
 +| {{ :neuroimagen:bioface_classifier_output_hippocampus.png?400 |}} | {{ :neuroimagen:bioface_classifier_output_hippocampus_w.png?400 |}} | {{ :neuroimagen:bioface_classifier_output_hippocampus_w2.png?400 |}} |
neuroimagen/bioface_atn.txt · Last modified: 2022/06/14 08:22 by osotolongo