[FieldTrip] Load BIDS motion data

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Mon Aug 11 18:25:29 CEST 2025


Hi Katy,

I think that in principle it should be possible to load in the data using ft_preprocessing(cfg), provided your data is properly BIDS formatted. Does the data pass the BIDS validator?

Something like:

cfg = [];
cfg.dataset = ’sub-something_task-somethingelse_etc.tsv’;
data = ft_preprocessing(cfg);

The error you get seems to be related to a low level json-file parsing issue, which suggests either that the json file(s) are incompatible with the code that is reading the json file, or that the code that reads the json file is buggy.

To distinguish between the two possibilities, I would start by trying to read in the *.json file in another way (i.e. using some software different than matlab). If that also throws an error (or if the BIDS validation fails), it’s probably an issue with the formatting of the json file.

I never work with this type of data myself, so I cannot comment any further on this. Perhaps anyone else can chime in?

BW,
JM


On 11 Aug 2025, at 18:02, Cross, Kathryn A. via fieldtrip <fieldtrip at science.ru.nl> wrote:

I am trying to load BIDS formatted motion data and am  unsure of the correct way to do this.
When I try to use ft_read_data I am receiving the below error.
Is my input wrong? It seems to be trying to read a tsv file as a json in line 317 of ft_read_header. I have tried a few variations of headerformat and dataformat arguments without success.

Thank you in advance for any advice!

Katy


data = ft_read_data(‘sub-CM01_task-reaching_tracksys-apdm_run-1_motion.tsv’,’dataformat’,’bids_tsv’);

208 [filename, headerfile, datafile] = dataset2files(filename, dataformat);
found matching BIDS sidecar 'G:\PROJECTS\Cueing_Noninvasive\data\bids\sub-CM01\motion\sub-CM01_task-reaching_tracksys-apdm_run-1_motion.tsv'
reading 'G:\PROJECTS\Cueing_Noninvasive\data\bids\sub-CM01\motion\sub-CM01_task-reaching_tracksys-apdm_run-1_motion.tsv'
Error using loadjson>error_pos
JSONLAB:JSON:InvalidFormat: Outer level structure must be an object or an array: 3<error>

Error in loadjson (line 143)
                pos=error_pos('Outer level structure must be an object or an array',inputstr,pos);

Error in ft_read_json (line 45)
  json = loadjson(filename);

Error in ft_read_header (line 317)
      data_json = ft_read_json(sidecar);

Error in ft_read_data (line 223)
  hdr = ft_read_header(filename, 'headerformat', headerformat, 'checkmaxfilter', checkmaxfilter, 'password', password, 'cache', cache);




________________________________

UCLA HEALTH SCIENCES IMPORTANT WARNING: This email (and any attachments) is only intended for the use of the person or entity to which it is addressed, and may contain information that is privileged and confidential. You, the recipient, are obligated to maintain it in a safe, secure and confidential manner. Unauthorized redisclosure or failure to maintain confidentiality may subject you to federal and state penalties. If you are not the intended recipient, please immediately notify us by return email, and delete this message from your computer.
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Ce2c671dc5df9468514ec08ddd8f3af9a%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638905263307062216%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=HSKT48AuKzLAEhYqdEn6XJzigAzeC%2BucSRmUUefq7jQ%3D&reserved=0>
https://doi.org/10.1371/journal.pcbi.1002202<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7Ce2c671dc5df9468514ec08ddd8f3af9a%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638905263307094926%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=Yf6%2Bsd%2FYaWsHV1%2BEvrKtYGyZ6GTCXEI%2FYiu0wjwpVQM%3D&reserved=0>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20250811/716362b0/attachment.htm>


More information about the fieldtrip mailing list