Forum: help
Monitor Forum | Start New ThreadRE: Problems with plotting (frequency analysis) [ Reply ] By: Constantino Antonio on 2017-01-07 12:55 | [forum:43780] |
Dear Gabriela, 1.- If you don't mind about the SDANN values it is fine if you don't change the window size. In fact, I am not sure about the validity of the SDANN in short recordings. So, it is probably a good idea to ignore it. 2.- The results of the CalculatePSD function are stored under >hrv.data$FreqAnalysis[[the_freq_index_you_have_used]]$periodogram as a "spec" object. The values of the spectrogram (the most interesting variable) are stored as >hrv.data$FreqAnalysis[[the_freq_index_you_have_used]]$periodogram$spec However, you may find more useful to calculate the Energy of the different HRV bands using: >CalculateEnergyInPSDBands(HRVData, the_freq_index_you_have_used) 3.- The analysis of each of the individuals can be certainly automated with a loop by changing the filename of the data in each of the iterations. Kind regards |
RE: Problems with plotting (frequency analysis) [ Reply ] By: Gabriela Czarnek on 2017-01-04 09:20 | [forum:43774] |
Dear Constantino, thank you for providing this information along with the code. If it is okey, I have a few follow-up questions. 1. You mentioned: "Note that you should also use a smaller value of 'size' in your time-analysis". Could you suggest how smaller should be the 'size' of the time analyzes? As I am interested only in the short periods of HRV (5-minute ones) it is fine for me not to get estimates of SDANN. 2. How to get results and store it from freqAnalysis with PSD function (apart from the plot)? I tried the function "hrv.data$FreqAnalysis" but it does not work as nicely as it was for CalculatePowerBand function and cannot be stored as data.frame. 3. In your reply you provided a code to append the results from the analyses of multiple subjects but I was wondering if the analyses for raw data have to be performed separately per each subject or, alternatively, it could be automated with a kind of for loop or some of apply family of function? Many thanks and kind regards, Gabriela |
RE: Problems with plotting (frequency analysis) [ Reply ] By: Constantino Antonio on 2016-12-31 11:09 | [forum:43770] |
Dear Mrs. Czarnek, The problem with your analysis is that you are using a time-frequency analysis with a window of 300 seconds on a time series of 300 seconds. Hence, the time-frequency analysis returns a single value, which cannot be plotted as a time series. When dealing with short time series, I would use the new function CalculatePSD, which is just a frequency analysis: hrv.data = CalculatePSD(hrv.data, 1) Note that you should also use a smaller value of 'size' in your time-analysis. Concerning your second question, we have not included functions to analyse multiple subjects at the same analysis. However, this can be achieved arranging the data in a data.frame and using other packages (see for example, ggplot2 for plotting utilities). I would use something like: allAnalyses = list(hrv.data1, hrv.data2 # , etc. ) # the groups of the hrv analyses groups = factor(c("group1", "group2" #, etc )) # get the timeAnalyses from the allAnalyses list timeAnalyses = sapply(allAnalyses, function(x, timeIndex) { results = as.numeric(x$TimeAnalysis[[timeIndex]]) names(results) = names(x$TimeAnalysis[[timeIndex]]) results }, timeIndex=1) # transpose to get each subject in a different row timeAnalyses = data.frame(t(timeAnalyses)) # add groups to the data.frame timeAnalyses$groups = groups # use ggplot2 to get plot depending on groups library(ggplot2) ggplot(timeAnalyses, aes(x = groups, y = SDNNIDX )) + geom_point() Kind regards |
RE: Problems with plotting (frequency analysis) [ Reply ] By: Gabriela Czarnek on 2016-12-28 22:34 | [forum:43768] id1.png (16) downloads |
I'm attaching how the plot looks like [I'm sorry for multiple posts]. Thanks, Gabriela |
Problems with plotting (frequency analysis) [ Reply ] By: Gabriela Czarnek on 2016-12-28 22:31 | [forum:43767] pulse.txt (30) downloads |
Dear all, I've run frequency analysis according to the instructions in the manual. However, the graph for frequency analysis doesn't look good (it is empty, though the X and Y axes are present). As I've checked, there are components calculated for each band of frequency. Does anyone know how to deal with that kind of problem? I am attaching the code (below) and sample data (attached file). Also, is it possible to calculate HRV indices (both time and frequency) for multiple subjects at the same analysis? And then to get results as well as the plots according to their group membership (e.g., group 1 - subjects 1:10, group 2 - subjects 11:20, etc)? **************************** #The code I used hrv.data = CreateHRVData() hrv.data = SetVerbose(hrv.data, TRUE) #loading RR intervals hrv.data=LoadBeatRR(hrv.data, "Pulse.txt", RecordPath=".", scale = 0.001) #building HR hrv.data = BuildNIHR(hrv.data)#creating from RR intervals PlotNIHR(hrv.data)#plotting non-interpolated HR hrv.data = FilterNIHR(hrv.data)#filtering hrv.data = InterpolateNIHR (hrv.data)#interpolating PlotHR(hrv.data)#plotting interpolated HR #frequency analysis hrv.data = CreateFreqAnalysis(hrv.data) hrv.data = CalculatePowerBand(hrv.data, type='fourier', indexFreqAnalysis= 1, size = 300, shift = 30) PlotPowerBand(hrv.data, indexFreqAnalysis = 1) hrv.data$FreqAnalysis #time analysis hrv.data = CreateTimeAnalysis(hrv.data, size = 300) ##Saving results timedata <- as.data.frame(hrv.data$TimeAnalysis) write.table(timedata, "time.txt") freqdata <- as.data.frame(hrv.data$FreqAnalysis) write.table(freqdata, "freq.txt") |