Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add default path patterns to derivatives.json #605

Merged
merged 8 commits into from
Jul 25, 2022

Conversation

effigies
Copy link
Collaborator

This takes the MR data types from the bids.json file, and adds optional space and desc keywords. It adds desc to events.tsv. I left out the electrophysiological ones for now, as I don't know them well enough to add, and I'd rather it be done correctly later than poorly now.

I also haven't added res/den, which will need to be added soon enough, but they're not even in the entities yet.

@tyarkoni
Copy link
Collaborator

I'm fine adding the patterns, but do we want to add tests before merging? I know it's a PITA, and I'm not suggesting you should write them right now (I'm fine leaving this open and marking as "help wanted"), but we've been bitten in the ass before by this, so I'm hesitant to merge without them.

I wonder if rather than manually writing a long series of tests, we could just add a generic function that takes one of the test datasets, gets all filenames, and for each, extracts its entities and then tries to build the path and makes sure the two match (in cases where there isn't any ambiguity in the building).

@effigies
Copy link
Collaborator Author

Sure. Mostly just playing around preparing a presentation and realized we don't have them.

@effigies
Copy link
Collaborator Author

@Remi-Gau Will this get scooped up by the tests added in #846, or do I need to add something?

@codecov
Copy link

codecov bot commented Jul 22, 2022

Codecov Report

Merging #605 (925855b) into master (a8aea54) will increase coverage by 0.05%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #605      +/-   ##
==========================================
+ Coverage   86.37%   86.42%   +0.05%     
==========================================
  Files          35       35              
  Lines        3984     3984              
  Branches     1034     1034              
==========================================
+ Hits         3441     3443       +2     
+ Misses        352      350       -2     
  Partials      191      191              
Impacted Files Coverage Δ
bids/layout/layout.py 87.86% <0.00%> (-0.21%) ⬇️
bids/layout/index.py 85.82% <0.00%> (+1.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a8aea54...925855b. Read the comment docs.

@effigies effigies added this to the 0.15.2 milestone Jul 22, 2022
@Remi-Gau
Copy link
Contributor

This should be picked up automatically I think.

@Remi-Gau
Copy link
Contributor

I could try it locally and update the json to make sure if you want.

@effigies effigies force-pushed the bep003/default_path_patterns branch from eebf40f to 4722519 Compare July 22, 2022 18:37
@effigies
Copy link
Collaborator Author

@Remi-Gau Would you mind having a quick look? I'm okay merging this before Monday's release if you don't have time, but I would appreciate your eyes.

Comment on lines 80 to 81
if {"label"} & set(entities): # BEP011
continue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that would skip the mask and segmentation as they are currently in the spec, correct?

Do you want me to add them to the config ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're up for it, sure!

"default_path_patterns": [
"sub-{subject}[/ses-{session}]/{datatype<anat>|anat}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_space-{space}][_desc-{desc}]_{suffix<T1w|T2w|T1rho|T1map|T2map|T2star|FLAIR|FLASH|PDmap|PD|PDT2|inplaneT[12]|angio>}{extension<.nii|.nii.gz|.json>|.nii.gz}",
"sub-{subject}[/ses-{session}]/{datatype<anat>|anat}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_mod-{modality}][_space-{space}][_desc-{desc}]_{suffix<defacemask>}{extension<.nii|.nii.gz|.json>|.nii.gz}",
"sub-{subject}[/ses-{session}]/{datatype{anat}|anat}/sub-{subject}[_ses-{session}][_acq-{acquisition}][_ce-{ceagent}][_rec-{reconstruction}][_part-{part}][_space-{space}][_res-{res}][_den-{den}][_label-{label}][_desc-{desc}]_{suffix<mask>}{extension<.nii|.nii.gz|.json>|.nii.gz}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have kept the "part" entity in the path patterns for the mask but it is not there in the other ones: should I

  • a) remove it from the mask pattern?
  • b) add it to all the others?

I have a preference for "b" because it would stick closer to the spec even if this is an edge case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

part does not make sense for a mask. A mask is binary, not complex.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha

but could it be that some other derivatives may need it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minimally preprocessed files, I guess, so the ones that are just copies of raw + space/desc. Otherwise probably not. (Fieldmaps already account for it with suffix.) If someone comes up with a use case, they can open an issue. Or hopefully we move away from this onto something schema defined before they have a chance.

@Remi-Gau
Copy link
Contributor

Temp TODO:

  • add segmentation path patterns
  • add test for path building on ds000001-fmriprep example

effigies and others added 5 commits July 25, 2022 10:21
We had been testing the raw scope separately for datasets with and
without derivatives. Now test the raw scope for all examples, then test
each derivative individually.

Synthetic contains some unfinalized derivatives, so make some temporary
exceptions.
@effigies effigies force-pushed the bep003/default_path_patterns branch from b09877c to b3f7349 Compare July 25, 2022 14:21
@effigies
Copy link
Collaborator Author

@Remi-Gau Tested the latest commit before pushing. Not sure if you're still working on this, but a heads up that there's a change.

@Remi-Gau
Copy link
Contributor

No worries. I was just working on it but I caught up quickly.

@Remi-Gau
Copy link
Contributor

@effigies
Feel free to merge already if you like.
Will update segmentation related config in another PR.
Won't make it today.

@effigies effigies merged commit 37dc6ea into bids-standard:master Jul 25, 2022
@effigies effigies deleted the bep003/default_path_patterns branch July 25, 2022 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants