I have downlaoded datase from PhysioNet/Computing in Cardiology Challenge 2019. Here all the data are in .psv format. Can anyone help me showing the way of loading this format data.

5 comentarios

KSSV
KSSV el 9 de Mayo de 2019
Attach the file........the link you gave is asking for credentials....do you expect us to create account in there and download the file?
Jhon Gray
Jhon Gray el 9 de Mayo de 2019
Sorry this I am very new in asking questions. I have attached the file.
Jan
Jan el 10 de Mayo de 2019
The data looks like:
HR|O2Sat|Temp
NaN|NaN|NaN
97|95|NaN
So these are really pipe-separated text files.
Diana Simona
Diana Simona el 11 de Oct. de 2019
Editada: Diana Simona el 11 de Oct. de 2019
Hey,
Have you figured it out how to do this?
Because i have encountered the same problem, i can't see and extract the values.
I can open the file and see the headers (HR|O2Sat|Temp|SBP|MAP|DBP|Resp etc). I can also see some values here and there, but i get a lot of NaN values.
ps: i dont have a lot of Matlab experience
Walter Roberson
Walter Roberson el 11 de Oct. de 2019
What happened when you used the two methods that Jan suggested?

Iniciar sesión para comentar.

 Respuesta aceptada

Jan
Jan el 9 de Mayo de 2019
Editada: Jan el 13 de Mayo de 2019
A small example would reveal, if this guess is correct: It is a pipe-separated text file. Then:
readmatrix(filename, 'Delimiter', '|', 'FileType', 'text')
[EDITED] And a dull manual method:
function [Data, Header] = ReadPSV(File)
% [Data, Header] = ReadPSV(File)
% INPUT:
% File: Char vector or string: Name of the file
% OUTPUT:
% Data: Double matrix, [nVariables x nFrames]
% Header: {nVariables x 1} cell string
%
% License: CC BY-SA 3.0
[fid, msg] = fopen(File, 'rt');
assert(fid ~= -1, 'Tools:ReadPSV:MissFile', ...
'Cannot open file:%s\n%s', File, msg);
Line1 = fgetl(fid); % Import 1st line
Header = strsplit(Line1, '|'); % Reply variables as cell string
n = numel(Header); % Number of variables
% [EDITED] start
str = fread(fid, [1, inf], '*char'); % Import data as string
str(str == char(10)) = '|'; % Replace line break by |
% [EDITED] end
Data = sscanf(str, '%f|', [n, inf]); % Extract numbers
fclose(fid);
end

3 comentarios

The key for readmatrix is
readmatrix(filename, 'Filetype', 'text')
readmatrix is able to figure out the | delimiter, and also is smart enough to remove the header.
It might make more sense to use
readtable(filename, 'filetype', 'text')
as that gets you useful headers.
Walter Roberson
Walter Roberson el 10 de Mayo de 2019
Jan, you can't fileread() a fid.
Jan
Jan el 13 de Mayo de 2019
@Walter: Thank you. Fixed. And the next bug was:
str(str = char(10)) = '|';
% ^ Of course: ==

Iniciar sesión para comentar.

Más respuestas (1)

Ricardo Salinas Martinez
Ricardo Salinas Martinez el 28 de Mayo de 2019

0 votos

Hello!
Jan's answer works preaty well, but if you read the codes provided by the challenge you will see how they read the files and there is no need for you to read them differently.

Categorías

Más información sobre Chemistry en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 9 de Mayo de 2019

Comentada:

el 11 de Oct. de 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by