shah-in-boots/EGM

Not calling or finding WFDB on Windows

Closed this issue · 32 comments

Reported by @ssandu2 - ot clear if reproducible

Error in setnames(x, value) : 
  Can't assign 1 names to a 0 column data.table
In addition: Warning messages:
1: In find_wfdb_command("rdsamp") :
  Cannot find 'rdsamp' in 'wsl -e /usr/local/bin'
2: In (if (.Platform$OS.type == "unix") system else shell)(paste0("(",  :
  '(Cannot find 'rdsamp' in 'wsl -e /usr/local/bin' -r 44 -v) > C:\Users\shsan\AppData\Local\Temp\RtmpK2hucW\file6a9444073298' execution failed with error code 1
3: In data.table::fread(cmd = cmd) :
  File 'C:\Users\shsan\AppData\Local\Temp\RtmpK2hucW\file6a9444073298' has size 0. Returning a NULL data.table.

Issue appears to be related to package startup issues. Will need to evaluate how R on windows conducts package start up, and there may be updates in using system commands.

  • Use a Windows instance of R to evaluate path evaluation
  • Check installation status of WFDB software
  • Assess terminal or system call methods from R

Windows PowerShell version:

PSVersion 5.1.22621.2506
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.2506
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Can we check if this works now? @dsean2112 and @ssandu2 ?

I've adjusted in the most recent commit an acceptable workaround for file system issues. The WFDB path finding commands were not suited for evaluating WSL-based directories from a Windows root, thus erroring even though the C-based WFDB program worked without issue on manual, CLI-based testing.

Looks like I'm getting a similar error:

'Cannot' is not recognized as an internal or external command,
operable program or batch file.
Error in setnames(x, value) :
Can't assign 1 names to a 0 column data.table
In addition: Warning messages:
1: In find_wfdb_command("rdsamp", wfdb_path) :
Cannot find 'rdsamp' in 'wsl /usr/local/bin'
2: In (if (.Platform$OS.type == "unix") system else shell)(paste0("(", :
'(Cannot find 'rdsamp' in 'wsl /usr/local/bin' -r 44 -v) > C:\Users\darre\AppData\Local\Temp\RtmpK2jc3v\file845c6ec012b0' execution failed with error code 1
3: In data.table::fread(cmd = cmd) :
File 'C:\Users\darre\AppData\Local\Temp\RtmpK2jc3v\file845c6ec012b0' has size 0. Returning a NULL data.table.

Okay. I will have to look again at this. It may be system dependent on how WSL directory is being structured. If you can bare to trouble shoot further, I would appreciate it. I've narrowed it down to an issue with how the system() commands are interacting or how the WSL directory is being recognized.

Please attempt the following:

  • When looking at global options within R studio, under the "Terminal" section, change the default terminal to PowerShell
  • I've adjusted the code further to allow for differences in how WSL can be recognized. Can you attempt to re-run the code as above?
  • In powershell, the command cd \\wsl$\Ubuntu\' should take you to the appropriate linux file structure. Type in pwd` and report back what the full path is.
  • Do this again, but use the command cd \\wsl.localhost\Ubuntu\' followed by pwd` and share the full path.

Let me know! I appreciate your help in this. I'd like if this software was a bit more universal. @ssandu2 @dsean2112

Please try the following:

# Setup
devtools::install_github('asshah4/shiva')
library(shiva)
filePath <- system.file('extdata', package = 'shiva')

# Reading in an ECG
ecg <- read_wfdb('muse-sinus', record_dir = filePath, annotator = 'ecgpuwave')
ecg
class(ecg)

# Visualize the ECG
ggm(ecg)

# Read in the annotation data
ann <- read_annotation('muse-sinus', record_dir = filePath, annotator = 'ecgpuwave')
head(ann)

@ssandu2 @dsean2112

If this works - please respond and I'll close the issue.

This worked for me.

Looks like an error in the find_wfdb_command.

If I bypass this, and simply output "cmd", I later run into the error in the read_annotation function line 127:
data.table::fread(cmd = cmd, header = FALSE)
Error:
Warning messages:
1: In (if (.Platform$OS.type == "unix") system else shell)(paste0("(", :
'(wsl /usr/local/bin/rdann -r muse-sinus -a ecgpuwave -e) > C:\Users\darre\AppData\Local\Temp\RtmpYJEGxY\file9f542f57ef2' execution failed with error code 1
2: In data.table::fread(cmd = cmd, header = FALSE) :
Stopped early on line 9. Expected 11 fields but found 11. Consider fill=TRUE and comment.char=. First discarded non-empty line: <<>>

@dsean2112

Okay - please try re-installing and seeing if it works.

Also, if there is an error, please try the following.

# XXX represents the path to your WFDB install
options(wfdb_path = 'XXX')

That is supposed to be the first work around, but I may have resolved it by broadening hte base paths to include Cygwin.

I installed wsl and the wfdb commands now appear under usr/local/bin, so that's great. sudo install seemed to do the trick.

After running:
ecg <- read_wfdb('muse-sinus', record_dir = filePath, annotator = 'ecgpuwave')
on R, I am receiving the same error:
'Cannot' is not recognized as an internal or external command,
operable program or batch file
Error in setnames(x, value) :
Can't assign 1 names to a 0 column data.table
In addition: Warning messages:
1: In (if (.Platform$OS.type == "unix") system else shell)(paste0("(", :
'(//wsl.localhost/Ubuntu/usr/local/bin/rdsamp -r muse-sinus -v) > C:\Users\darre\AppData\Local\Temp\RtmpOsRX9W\file3b385865550c' execution failed with error code 1
2: In data.table::fread(cmd = cmd) :
File 'C:\Users\darre\AppData\Local\Temp\RtmpOsRX9W\file3b385865550c' has size 0. Returning a NULL data.table.

It seems to be an issue with the path. If I run them line by line, I first define the wfdb_path as: //wsl$/Ubuntu/usr/local/bin
or
//wsl.localhost/Ubuntu/usr/local/bin

Then I'm able to run read_signal() and read_header(). I then run into issues with read_annotator(), with the error message seen above.

If I do not define the wfdb_path via:
wfdb_path = options(wfdb_path = '//wsl.localhost/Ubuntu/usr/local/bin')

I receive the error:
'//wsl.localhost/Ubuntu/usr/local/bin/rdsamp' is not recognized as an internal or external command, operable program or batch file.
Error in setnames(x, value) :
Can't assign 1 names to a 0 column data.table
In addition: Warning messages:
1: In (if (.Platform$OS.type == "unix") system else shell)(paste0("(", :
'(//wsl.localhost/Ubuntu/usr/local/bin/rdsamp -r muse-sinus -v) > C:\Users\darre\AppData\Local\Temp\RtmpOURdPm\file6ef0ce1608' execution failed with error code 1
2: In data.table::fread(cmd = cmd) :
File 'C:\Users\darre\AppData\Local\Temp\RtmpOURdPm\file6ef0ce1608' has size 0. Returning a NULL data.table.

If I run read_annotation() line by line, it worked once, and output the annotation_table.

I tried it again and it is stuck on line 127 of the read_annotation function:
withr::with_dir(new = wd, code = {
dat <-
data.table::fread(cmd = cmd, header = FALSE)
})

with the error:
'//wsl.localhost/Ubuntu/usr/local/bin/rdann' is not recognized as an internal or external command,
operable program or batch file.
Warning messages:
1: In (if (.Platform$OS.type == "unix") system else shell)(paste0("(", :
'(//wsl.localhost/Ubuntu/usr/local/bin/rdann -r muse-sinus -a ecgpuwave -e) > C:\Users\darre\AppData\Local\Temp\RtmpyMqbdH\file60d48a642a' execution failed with error code 1
2: In data.table::fread(cmd = cmd, header = FALSE) :
File 'C:\Users\darre\AppData\Local\Temp\RtmpyMqbdH\file60d48a642a' has size 0. Returning a NULL data.table.

When viewing in WSL, rdann is present in usr/local/bin

I am receiving the following error:
Error in option("wfdb_path") <- "wsl /usr/local/bin" :
target of assignment expands to non-language object

I received the same thing when using options()

Cool thank you. I verified I was able to navigate to wsl$/Ubuntu/usr/local/bin in R, however I noticed I do not have execute permissions for the contained files when viewing in R.

When I view usr/local/bin in wsl, I have read write execute for all users

The most recent update to the software does two things - branches out the windows safety checks to a developmental branch and removes safety checks from the main version.

@dsean2112 and @ssandu2

What does options("wfdb_path") look like for you using the most RECENT version of this software?

The installation code is: devtools::install_github("shah-in-boots/EGM") from R directly.

If there is an issue, please feel free to revert to an older version. I'm aiming to publish this and want to include the correct path recommendations/examples in the guide.

The software runs for you? Something like read_wfdb() pulls in signal okay?

If so, all is well.

read_wfdb() runs without issue, and the output header, annotations and signal look accurate.

Fantastic. Thank you for the input. Will like release v0.1.0 after a bit more documentation.