You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#set directory
setwd("C:/Users/larke/OneDrive/Desktop/R/R")
#step 1 - import the cilia text file#import text file #tabs delimitedmy_data<- read.csv("pixel intensity data tab.txt", header=TRUE, sep='\t')
#testing data class
class(my_data)
#renames columns
names(my_data)[1]<-"Frame"
names(my_data)[2]<-"Mean1"#step 2 - fourier transform of the values#will use fft (fast fourier transform)#will first test fft on one columnMean1four= fft(my_data$Mean1)
#now do the fft on whole dataframefourierd= apply(my_data,2,function(x) fft(as.numeric(x))) #it's now a matrix#turn it into a data framefourierdat= as.data.frame(fourierd)
#fix frame numbers (they were also fft-ed)fourierdat$Frame= seq(1:256)
#Error in `$<-.data.frame`(`*tmp*`, Frame, value = 1:512) : # replacement has 512 rows, data has 256# Therefore IL canged "(1:512)" to "(1:256)#step 3 - get the absolute value of the complex numbers resulting from the fft#in excel this is done using =IMABS(range)absTest= abs(fourierdat$Mean1) #testing on one columnabsTestAll= abs(fourierdat) #converts all the complex numbers to absolute numbers#step 4 - calculating the CBF#if frequency resolution is = 0.94#if is not 0.94, replace with correct valueFRadjusted=absTestAll$Frame*0.94absTestAll$Frame=FRadjusted#this updates the frame to 0.94#Pre-defining the matrixHisDat<-1# For each column of data, find the max number & corrisponding row number.# multiply the two new values together -> HisDat (Histogram Data)for(iin1:lengths(absTestAll)){
MaxNum<- max(absTestAll[[i]]);
MaxRow<- which(grepl(max(absTestAll[[i]]), absTestAll[[i]]))
HisDat[i] <-MaxNum*MaxRow
}
# Plot the Histogram
hist(HisDat,
breaks=256)
# multiply max ab no. by row number and frequency resolution# to result in 1600 data points which = CBF in 1600 areas of interest|#Playing with my histogramhistinfo<- hist(HisDat)
#step 5 - CBF Histogram
Hi @issylarken28 here's the code and the output (I removed some parts to make it more concise).
Hope this helps
#import text filemy_data<- read.csv("https://github.com/ucl-ihi/CodeClub/files/3579119/pixel.intensity.data.tab.txt", header=TRUE, sep='\t')
#now do the fft on whole dataframefourierd<- apply(my_data,2,function(x) fft(as.numeric(x))) #it's now a matrix#turn it into a data framefourierdat<- as.data.frame(fourierd)
#step 3 - get the absolute value of the complex numbers resulting from the fftabsTestAll<- abs(fourierdat)
# histogramhistData<- sapply(absTestAll[2:nrow(absTestAll),], which.max) *0.94
hist(histData[2:length(histData)], breaks=1000, xlim= c(0,20), ylim=c(0,150))
Data: pixel intensity data tab.txt
The text was updated successfully, but these errors were encountered: