Forum: open-discussion


RE: Do you have any plans to create Garmin (LoadBeatGarmin) and Edge 1040?m [ Reply ] By: Kizen Sasaki on 2023-11-14 00:02 | [forum:49803] |
RESOLVED!! Sorry for confusing you. R, RStudio. XQuartz and their associated files were completely deleted, the Mac was restarted and reinstalled from R, which also erased the PRam. The RHRV package was also reinstalled and the code was executed and plotted without any problems.Quitting and restarting RStudio and the Mac also executed and plotted the code.Chapter 4 took more than 15 minutes, but now we can proceed to chapter 5! Chapter 4 took more than 15 minutes, but I can now move on to chapter 5. It remains unclear why these two codes did not plot. It may be a problem with the new Mac OS. |
RE: Do you have any plans to create Garmin (LoadBeatGarmin) and Edge 1040? [ Reply ] By: Kizen Sasaki on 2023-11-07 13:05 | [forum:49798] |
Sorry, it was not easy to clear. Resolved was by macOS Big Sur, 11.7.10, but by Sonoma 14.0 can not plot # Plotting Fourier analysis, PlotPowerBand(hrv.data, ymax = 200, ymaxratio = 1.7) and # p61 Plotting # Plotting Wavelet analysis PlotPowerBand(hrv.data, indexFreqAnalysis = 2, ymax = 700, ymaxratio = 50) kizen |
RE: Do you have any plans to create Garmin (LoadBeatGarmin) and Edge 1040? [ Reply ] By: Kizen Sasaki on 2023-11-07 09:53 | [forum:49797] |
RESOLVE! I believe the root cause is largely due to my lack of understanding of the English language. When running Plot Fourier and Plot Wevelet, I was running a series of functions with indexFreqAnalysis = 1. If I wanted to plot a wevelet, I had to process a series of related functions with indexFreqAnalysis = 2. This gave me the textual plots without any problems. My problem was my understanding of the English language, not the PC or OS. |
RE: Do you have any plans to create Garmin (LoadBeatGarmin) and Edge 1040? [ Reply ] By: Abraham Otero on 2023-11-06 09:49 | [forum:49794] |
I'm glad you solved your problems :) Due to the graphics libraries that we actually use, sometimes the graphics do not work in some versions of Mac. This is quite problematic for the development team, because we are not Mac users... |
RE: Do you have any plans to create Garmin (LoadBeatGarmin) and Edge 1040? [ Reply ] By: Kizen Sasaki on 2023-11-04 14:55 | [forum:49792]![]() |
Both plots were made on VS Code. PlotPowerBand(hrv.data, indexFreqAnalysis = 1, ymax = 200, ymaxratio = 1.7) PlotPowerBand(hrv.data, indexFreqAnalysis = 2, ymax = 700, ymaxratio = 50) In RStudio 2023.09.1+496 on the Mac, the code was the same, but the error was that unused arguments were used. Thank you for being so supportive. |
RE: Do you have any plans to create Garmin (LoadBeatGarmin) and Edge 1040? [ Reply ] By: Kizen Sasaki on 2023-10-28 15:36 | [forum:49787] |
I restarted to study Chapter 4 of Getting Started with RHRV using example.beats. In the R code I got the same behavior and results up to page 60 of the text. However, on page 61, Plotting, I had to stop learning because of the following error. PlotPowerBand(hrv.data, indexFreqAnalysis = 1, ymax = 200, ymaxratio = 1.7) error. "Arguments not used (ymax = 200, ymaxratio = 1.7)".odel"), I couldn't show Figures 4.4 and 4.5. |
RE: Do you have any plans to create Garmin (LoadBeatGarmin) and Edge 1040? [ Reply ] By: Abraham Otero on 2023-10-27 14:06 | [forum:49786] |
It's a bit complicated to fully check the code as there are a few things that depend on your particular execution environment. But, after having tried to skip the initial part of the script, a clear issue that I see is that you start performing frequecy analysis without having created a heart rate interpolated at a constant sampling rate: hrv.data <- InterpolateNIHR(hrv.data) |
RE: Do you have any plans to create Garmin (LoadBeatGarmin) and Edge 1040? [ Reply ] By: Kizen Sasaki on 2023-10-26 10:56 | [forum:49785]![]() |
Your offer is truly appreciated. I am sorry for the messy code. I would appreciate your review. ### datetime, HRよりRHRVへのデータの入力 ### Analysis for Grmin fit file ### 2023.10.24 K. Sasasaki ### Extraction HR from fit file. ### Thanks Abraham Otero on 2023-10-24 19:25 # Installing the FITfileR package if not installed if(!requireNamespace("remotes")) { install.packages("remotes") } remotes::install_github("grimbough/FITfileR") library("FITfileR") # Installing the RHRV package if not installed if (!require("RHRV")) { install.packages("RHRV") library(RHRV) } # Installing the tidyverse package if not installed if (!require("tidyverse")) { install.packages("tidyverse") library(tidyverse) } # # Installing the openxlsx package if not installed. if (!require("openxlsx")) { install.packages("openxlsx") library(openxlsx) } # read_fitfile old_wd <- getwd() # Select the folder where the fit files are stored. TargetDir <- paste(as.character(tkchooseDirectory(title = "Choose a folder"), sep = "", collapse ="")) # To the working directory for fit files ##### setwd(TargetDir) FitNameList <- list.files(path = TargetDir) %>% str_extract("^.*fit*$") %>% na.omit() FitNameList # check # Get ".fit" files in a folder # ex. the third fit file would be [3] Input file no. ReadFit <- readFitFile(FitNameList[65]) # This time the 65th "go Western an hour" # ReadFit # check # Fit File # ├╴File created: 2023-10-15 06:41:42 # Warning! This is not JST. # ├╴Device: garmin NA # └╴Number of data messages: 13676 # Verigy message_type listMessageTypes(ReadFit) # "record" contains the data required for analysis. # [1] "file_id" "device_settings" "user_profile" "zones_target" # [5] "sport" "session" "lap" "record" # [9] "event" "device_info" "activity" "file_creator" # [13] "hrv" # 元のディレクトリに戻す setwd(old_wd) # Data processing ##### # Edge1040 can retrieve record data, and this includes the necessary data types. # FITよりrecordデータ取得 [8] "record"。 RecodeData <- getMessagesByType(ReadFit, message_type = "record") #record # RecodeData #check # Convert the date to Japan Standard Time(JST). MasterRecord <- NULL # Loop processing for RecodeData for(i in seq(RecodeData)){ Recode <- bind_cols("id" = i, RecodeData[[i]]) MasterRecord <- bind_rows(MasterRecord, Recode) } # Convert date data. MasterRecord <- MasterRecord %>% mutate_if(is.POSIXt, ~with_tz(., tz = "Asia/Tokyo")) # Sort MasterRecord by time. MasterRecord <- MasterRecord %>% arrange(timestamp) # Create time_hr.csv to replace example.beta in RHVR. # Extract timestamp and heart_rate from MasterRecord to time_hr. time_hr <- MasterRecord[, c("timestamp", "heart_rate")] %>% na.omit() # delete NA # Time and heart rate data will be saved as a CSV file in the csv_xls folder. # A csv_xls folder will be created. if (!dir.exists("csv_xls")) { dir.create("csv_xls") } write.csv(time_hr, file = "csv_xls/time_hr.csv", row.names = FALSE) # The CSV file will be retrieved from the csv_xls directory. # The csv_xls directory will be specified. csv_xls_dir <- "csv_xls/" # Thanks Abraham Otero on 2023-10-24 19:25 data <- read.table(paste0(csv_xls_dir, "time_hr.csv"), header = TRUE, sep = ",", colClasses = c("character", "numeric")) hr <- data[, 2] #Extract the hear_rate from the second line and assign it to hr rr <- 1/hr #Calculate the RR interval rr = rr*60*1000 #Convert to ms # rr <- as.list(rr) library(lubridate) date <- data[1,1] #Extract the date from the first line and assign it to date # date_posixlt <- parse_date_time(date, "%d/%m/%Y %H:%M:%S") # Convert the format of the timestamp from year-month to day-month-year. # time_hr$timestamp <- format(as.POSIXct(time_hr$timestamp, # format = "%Y-%m-%d %H:%M:%S"), # "%d/%m/%Y %H:%M:%S") date_posixlt <- format(as.POSIXct(time_hr$timestamp, format = "%Y-%m-%d %H:%M:%S"), "%d/%m/%Y %H:%M:%S") hrv.data = CreateHRVData()#Create an empty HRVData object hrv.data = SetVerbose(hrv.data, TRUE) #Set the verbose mode to TRUE hrv.data$Beat <- rr #Assign the RR interval to the RR field of the Beat object hrv.data$datetime <- date_posixlt #Assign the date to the datetime field of the HRVData object hrv.data$Beat$niHR <- hr #Assign the heart rate to the niHR field of the Beat object hrv.data$Beat$Time <- cumsum(rr)/1000 #Calculate the time in seconds #proceed normally with the analysis hrv.data = BuildNIHR(hrv.data) #Calculate the NIHR PlotNIHR(hrv.data) #Plot the NIHR hrv.data = CreateTimeAnalysis(hrv.data, size = 300, interval = 7.8125) cat("The SDNN has a value of ", hrv.data$TimeAnalysis[[1]]$SDNN, " ms\n") hrv.data <- CreateFreqAnalysis(hrv.data) # Creating frequency analysis # Data has now 2 frequency analysis hrv.data <- CalculatePowerBand(hrv.data, indexFreqAnalysis = 1, size = 300, shift = 30, sizesp = 2048, type = "fourier", ULFmin = 0, ULFmax = 0.03, VLFmin = 0.03, VLFmax = 0.05, LFmin = 0.05, LFmax = 0.15, HFmin = 0.15, HFmax = 0.4) # Calculating power per band # Using Fourier analysis # Windowing signal... 237 windows # Power per band calculated hrv.data <- CalculatePowerBand(hrv.data, indexFreqAnalysis = 1, size = 300, shift = 30) # wavelets hrv.data <- CalculatePowerBand(hrv.data, indexFreqAnalysis = 1, size = 300, shift = 30, sizesp = 2048, type = "wavelet", wavelet = "la8", bandtolerance = 0.01, relative = FALSE, ULFmin = 0, ULFmax = 0.03, VLFmax = 0.05, LFmin = 0.05, LFmax = 0.15, HFmin = 0.15, HFmax = 0.4) # Calculating power per band # Using Wavelet analysis # Power per band calculated # Creating several analysis p59-60 # create structure, load beats, filter and interpolate hrv.data <- CreateFreqAnalysis(hrv.data) hrv.data <- SetVerbose(hrv.data, TRUE) # use freqAnalysis number 1 for perfoming # Fourirer analysis, This time, we do not # write the band's bouundaries hrv.data <- CalculatePowerBand(hrv.data, indexFreqAnalysis = 1, size = 300, shift = 30, sizesp = 2048, type = "fourier") # Calculating power per band # Using Fourier analysis # Windowing signal... 237 windows # Power per band calculated # use freqAnalysis number 2 for perfoming p60 # Wavelet analysis, Note the indexFreqAnalysis = 2!!! hrv.data = CreateFreqAnalysis(hrv.data) # Creating frequency analysis # Data has now 24 frequency analysis # p60 hrv.data = CalculatePowerBand(hrv.data, indexFreqAnalysis = 2, type = "wavelet", wavelet = "la8", bandtolerance = 0.01, relative = FALSE) # Calculating power per band # Using Wavelet analysis # Power per band calculated # Plotting Fourier analysis p61 Can't plot!!! # PlotPowerBand(hrv.data, indexFreqAnalysis = 1, ymax = 200, ymaxratio = 1.7) # # # Plotting wavelet analysis p61 # PlotPowerBand(hrv.data, indexFreqAnalysis = 2, ymax = 200, ymaxratio = 1.7) |
RE: Do you have any plans to create Garmin (LoadBeatGarmin) and Edge 1040? [ Reply ] By: Abraham Otero on 2023-10-26 08:58 | [forum:49784] |
Hello, If you send the full code I will try to take a look at it to see what's going on. All the best |
RE: Do you have any plans to create Garmin (LoadBeatGarmin) and Edge 1040? [ Reply ] By: Kizen Sasaki on 2023-10-26 06:54 | [forum:49783] |
I don't know if this is the right solution, but I am forwarding it. I put the "#" at the beginning of columns 8 and 40 in CreateHRVData.R. #VerboseMessage(Verbose, "Creating data model"), #VerboseMessage(HRVData$Verbose, "Data model created") |
RE: Do you have any plans to create Garmin (LoadBeatGarmin) and Edge 1040? [ Reply ] By: Kizen Sasaki on 2023-10-25 06:19 | [forum:49782] |
Hi Abraham, Thank you for your prompt reply. There are three issues to be addressed 1. "date_posixlt <- parse_date_time(date, "%d/%m/%Y %H:%M:%S") " does not work well. I have modified the below date_posixlt <- format(as.POSIXct(time_hr$timestamp, format = "%Y-%m-%d %H:%M:%S"), "%d/%m/%Y %H:%M:%S") then it showed the European timestamp format. 2. Received error message below when I executed "hrv.data = CreateHRVData()" function in Chapter 4 A 15-minutes guide to RHRV page 42 and by your script. Error in `$<-`(`*tmp*`, Verbose, value = TRUE):. There is no method to append a subset of this S4 class 3. And also by page 61 the function PlotPowerBand(hrv.data, indexFreqAnalysis = 1, ymax = 200, ymaxration = 1.7) and PlotPowerBand(hrv.data, indexFreqAnalysis = 2, ymax = 200, ymaxration = 1.7) My PC is MBP 2018, OS is Sonoma 14.0, R version is 4.3.1(2023-06-16), RStudio 2023.09.0 Build 463 Thanks Kizen |
RE: Do you have any plans to create Garmin (LoadBeatGarmin) and Edge 1040? [ Reply ] By: Abraham Otero on 2023-10-24 10:25 | [forum:49781] |
You may use the following code: data <- read.table("time_hr.csv", header = TRUE, sep = ",", colClasses = c("character", "numeric")) hr <- data[,2] rr <- 1/hr rr = rr*60*1000 library(lubridate) date <- data[1,1] date_posixlt <- parse_date_time(date, "%d/%m/%Y %H:%M:%S") hrv.data = CreateHRVData() hrv.data = SetVerbose(hrv.data, TRUE) hrv.data$Beat$RR = rr hrv.data$Beat$niHR = hr hrv.data$Beat$Time = cumsum(rr)/1000 hrv.data$datetime = date_posixlt #proceed normally with the analysis hrv.data = FilterNIHR(hrv.data) PlotNIHR(hrv.data) hrv.data = CreateTimeAnalysis(hrv.data, size = 300, interval = 7.8125) .... |
RE: Do you have any plans to create Garmin (LoadBeatGarmin) and Edge 1040? [ Reply ] By: Kizen Sasaki on 2023-10-23 15:37 | [forum:49777]![]() |
I will also send you the Garmin Edge1040 fit file. I wish that you would like to make LoadBeatGarmin(). Thanks and kind regards, Kizen |
RE: Do you have any plans to create Garmin (LoadBeatGarmin) and Edge 1040? [ Reply ] By: Kizen Sasaki on 2023-10-23 15:32 | [forum:49776] |
Hello Abraham, I have attached on my first mail. Thanks and regards |
RE: Do you have any plans to create Garmin (LoadBeatGarmin) and Edge 1040? [ Reply ] By: Abraham Otero on 2023-10-23 06:06 | [forum:49775] |
Hello, I think you forgot to attach the file. All the best |
Do you have any plans to create Garmin (LoadBeatGarmin) and Edge 1040? [ Reply ] By: Kizen Sasaki on 2023-10-21 03:32 | [forum:49774]![]() |
If there are no development plans, is it okay to convert the heart rate recorded at 1-second intervals from the fit file to a csv file and run the LoadBeatAscii() function? I can attach fit file at any time if you need it. |