question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix how build_path deals with run entity

See original GitHub issue

Is there a good reason for “run” to parse as a integer (instead of a string)? It means that layout.build_path does not return something matching the original…

data_path = os.path.join(get_test_data_path(), 'ds005')
layout = BIDSLayout(data_path)
f = layout.get(suffix = 'bold')[1]
rebuilt_path = layout.build_path(f.entities)
assert f.filename == os.path.basename(rebuilt_path)
orig_filename 		sub-12_task-mixedgamblestask_run-02_bold.nii.gz
recontructed to 	sub-12_task-mixedgamblestask_run-2_bold.nii.gz

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
effigiescommented, Feb 10, 2019

Might be worth entering into the record, I almost always see run-01 instead of run-1 in existing datasets, which, given my sampling pool, means a good chunk of OpenFMRI/OpenNeuro.

I suspect many people in practice use OpenNeuro as a model for their BIDS datasets, rather than reading the spec with a pedantic eye, so this practice is bound to spread. I’m not sure that we can really put our foot down here; the spec is permissive if fairly negative: (“In contrast to other labels, run and echo labels MUST be integers. Those labels MAY include zero padding, but this is NOT RECOMMENDED to maintain their uniqueness.”)

I’m not really sure that there is a good pybids solution, but if you’re confident in the naming schemes of your dataset, you can do the following programmatically:

layout = BIDSLayout(data_path)
layout.path_patterns = [path.replace('run-{run}', 'run-{run:02d}')
                        for path in layout.path_patterns]
...

This obviously isn’t going to match a dataset that doesn’t zero-pad. You could get fancy and do a regex to count the number of digits… But then you’re really running into the generality issues that we’ve avoided by refusing to accommodate zero-padding.

That will use your customized config instead of the BIDS-compliant one. I can’t guarantee that everything will work properly throughout the codebase if you start treating run_index as a string, but nothing jumps out at me as an obvious pain point.

Layouts should be fine. IIRC Analysis has the assumption that run is an int baked in pretty heavily.

0reactions
tyarkonicommented, Feb 12, 2019

There seems to be agreement that the solution is for users to either rename their files or use one of the above workarounds, so I’m closing this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

fmriprep failing with "Could not build path with entities" error ...
Our user is running fmriprep version 20.2.0 via singularity/docker singularity exec -e \ docker://poldracklab/fmriprep:20.2.0 ...
Read more >
eclipse - The project cannot be built until the build path errors ...
Right click on your project (from package explorer) · Got build path -> configure build path · Select the libraries tab · Fix...
Read more >
build path not set correctly after importing fr... - JBoss.org
I have noticed that with my multi-module Mavenized Seam 2.1 project, I must always run 'mvn eclipse:eclipse' after I have imported the project ......
Read more >
Solve “pkix path building failed” - Packagecloud Blog
The error 'pkix path building failed' is tough to troubleshoot. Use a reliable package repository like Packagecloud that works all the time.
Read more >
Tutorial: Get Started with Entity Framework 6 Code First using ...
If you want to create the database in your App_Data folder, you could add AttachDBFilename=|DataDirectory|\ContosoUniversity1.mdf to the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found