MATLAB Answers

EDF reading: edfread gives timetable; possible to get struct?

4 ビュー (過去 30 日間)
Andrew M
Andrew M 2021 年 7 月 24 日
コメント済み: Andrew M 2021 年 7 月 26 日
My friend and I are working with the same function that utilizes '[hdr data] = edfread(file)'. The code depends on edfread() returning the outputs as struct, not timetable.
When he runs the file it appropriately returns as struct. However, when I run it, it returns as timetable.
Troubleshooting I've tried:
  • Using table2struct() converts to struct including the columns of the timetable, but it is missing other pieces of data (e.g., hdr.samples)
  • Downloading the old function edfRead solved the issue and allowed me to unpack correctly. However, this file is no longer supported.
  • We are both using 2021a and both have signal processing toolbox installed
My understanding is that matlab now has the built in function 'edfread()' and it returns timetables. Although I've found a potential workaround by using an outdated/deprecated file, it still confuses me that he's able to get the struct.
  1 件のコメント
dpb
dpb 2021 年 7 月 24 日
Undoubtedly your colleague still has the FEX version and has it where it aliases the builtin version.
This would happen transparently if he's actually using running in the same directory as the m-file, for instance, for just one way.
Ask him to run
which -all edfread
and see what it returns.
Just because TMW has chosen to implement a builtin version of similar functionality, if it doesn't meet your requirements there's certainly nothing wrong with continuing to use the FEX submission. And, it's no more (or less) supported by TMW now than before; TMW doesn't support anything on FEX; that's totally up to the submitter and the community feedback.
I'd say go for what works for you and submit a bug report/enhancement request for the lost functionality (depending upon whether what is lost is really totally lost/not returned data that is in the file or just a translation problem from the returned table to the struct).
I've never run across EDF files so I "know nuthink!" a la Sgt Schultz regarding them or their structure.

サインインしてコメントする。

採用された回答

dpb
dpb 2021 年 7 月 24 日
編集済み: dpb 2021 年 7 月 25 日
Undoubtedly your colleague still has the FEX version and has it where it aliases the builtin version.
This would happen transparently if it's in the same directory as the calling m-file, for instance, for just one way.
Ask him to run
which -all edfread
and see what it returns.
Just because TMW has chosen to implement a builtin version of similar functionality, if it doesn't meet your requirements there's certainly nothing wrong with continuing to use the FEX submission. And, it's no more (or less) supported by TMW now than before; TMW doesn't support anything on FEX; that's totally up to the submitter and the community feedback.
I'd say go for what works for you and submit a bug report/enhancement request for the missing functionality (depending upon whether what is missing is really totally lost/not returned data that is in the file or just a translation problem from the returned table to the struct).
I've never run across EDF files so I "know nuthink!" a la Sgt Schultz regarding them or their structure.
  1 件のコメント
Andrew M
Andrew M 2021 年 7 月 25 日
Solved! With a little more context:
With the new edfread(), the output is a timetable containing data. It used to be a struct containing fields with the data, as well as fields specifying metadata.
To get the metadata now you must use the function edfinfo(). Note the names of the output variables are different from the outputs from the old FEX file, but they do contain all the same datapoints.
I think the most likely explanation in my specific case is that my friend inexplicably has the FEX version.

サインインしてコメントする。

その他の回答 (1 件)

Peter Perkins
Peter Perkins 2021 年 7 月 26 日
Andrew, FEX issues aside, it's possible that the DataRecordOutputType parameter to edfread may help. But it's also possible that going with timetables would make your code easier and simpler. Just sayin'.
  1 件のコメント
Andrew M
Andrew M 2021 年 7 月 26 日
I completely agree - I think timetable is the ideal output. It just took me a long time to understand how/why he was getting metadata out of the function and I wasn't!

サインインしてコメントする。

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by