[FieldTrip] error using ft_read_header func

Lang, Johannes Johannes.Lang at uk-erlangen.de
Thu Jul 2 11:59:06 CEST 2020


Dear Jan-Mathijs, dear Stephen,

thank you for your answers! Indeed changing the input variables in ft_read_header, line 1762 to 0 and 0 solved the issue. Now it works just fine and returns the header struct perfectly!
Concerning the PR: sure why not. A silly change might just be an appropriate starting point for a coding rookie MD like me ☺

As a side note, in my version it was located in line 1762 as well, not 1792.

Thanks again to you both!
Best wishes,
Johannes


Dr. med. Johannes Lang
Universität Erlangen
Neurologische Klinik
Epilepsiezentrum
Schwabachanlage 6
91054 Erlangen

+49 (0)9131/85-33001




Von: fieldtrip <fieldtrip-bounces at science.ru.nl> Im Auftrag von Stephen Whitmarsh
Gesendet: Mittwoch, 1. Juli 2020 17:49
An: FieldTrip discussion list <fieldtrip at science.ru.nl>
Betreff: Re: [FieldTrip] error using ft_read_header func

Dear Jan and J-M,

Since I was lurking, let me chime in for a second;

1) ft_read_header works as it is now works for me.
2) I replaced the 1 with a 0 as JM suggested, with same behaviour, so it won't break it. Although it's on line 1792 instead of 1762, I assume a typo by JM. I won't take your chance of having yoru first FieldTrip commit though :-)
3) I have encountered this error before, but probably when reading corrupt data. I have to say, .ncs files have given me a headache when dealing with missing data (indicated by missing timestamps).
4) I tried it on a clean, fresh, Fieldtrip pull, without external neuralynx libraries. However, we do use those provided by Neuralynx (download info when you use ft_read_header), which greatly speeds up loading data.
5) I have had weirdly 'stuck' mex files, with unclear errors, which only restarting my computer fixed. Seriously, at least give it a shot. I wouldn't be surprised if that would work.

Let me know if I can help in another way.

Cheers,
Stephen


Op wo 1 jul. 2020 om 17:14 schreef Schoffelen, J.M. (Jan Mathijs) <jan.schoffelen at donders.ru.nl<mailto:jan.schoffelen at donders.ru.nl>>:
Dear Johannes,

Welcome to the community! I am not so familiar with this fileformat, but looking in the code it seems that this is a genuine bug. I am wondering whether this has ever worked at all.

Long story short, in reading the header, it seems, as per line 177 in read_neuralynx_ncs, that both begrecord AND endrecord need to be defined as 0. However, in ft_read_header, line 1762, read_neuralynx_ncs is called with 1 and 0 as input arguments, rather than (what I would expect) 0 and 0. Perhaps other people might chime in here to confirm, particularly those who are reading along and who work with this fileformat themselves, but I would say that this is incorrect.

Could you try in your own code, to change the ‘1’ on line 1762 in ft_read_header into a ‘0’, and confirm that reading in of the header information then works for you?

If so, then feel free to make a PR on github for this. I know it’s a silly change, which I could easily do myself, but in the spirit of ‘we’re all in it together’ I don’t want to take the opportunity away from you :).

Of course I am just kidding, but also partly serious: if you make the suggested change in a pull request, then this improvement of the codebase will be forever in www-space associated with you (and who knows what the effect of this will be on your professional career, and on the grand scheme of things). This last remark is just a gentle nudge to everybody who is reading along. Oh, and did I already raise the argument that a medical degree does not forbid you to write code?


Best wishes,

Jan-Mathijs

J.M.Schoffelen, MD PhD
Associate PI, VIDI-fellow - PI, language in interaction
Telephone: +31-24-3614793
Physical location: room 00.028
Donders Centre for Cognitive Neuroimaging, Nijmegen, The Netherlands


On 1 Jul 2020, at 16:23, Lang, Johannes <Johannes.Lang at uk-erlangen.de<mailto:Johannes.Lang at uk-erlangen.de>> wrote:

Dear all,

I’m new to the community and keep running into an error using the ft_read_header function.

The way I understood the documentation

hdr = ft_read_header(‘filename’)

should read the header information into an array.
However, I keep running into an error

Error using read_neuralynx_ncs (line 182)
cannot read beyond the last record

Error in ft_read_header (line 1762)
    ncs = read_neuralynx_ncs(filename, 1, 0);

Not sure why this is. Has anyone had the same issue before?
Thanks in advance.

Kind regards,

Johannes Lang

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202



_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200702/56505cae/attachment.htm>


More information about the fieldtrip mailing list