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

[FIX][SCHEMA] Add conditionals for PET ReconMethod* and ReconFilter #1299

Conversation

bendhouseart
Copy link
Collaborator

Adds conditionals to change required PET fields to optional when "parent" fields are unknown or "none", specifically:

  • add conditionals for ReconMethod Metadata

  • add min and max values to scatter fraction

  • add conditional for ReconFilterSize

Intention is to avoid users adding unnecessary place holders to pass validation, e.g. [0, 0], ["none", "none"], hopefully avoids ambiguity instead of increasing it.

Arguments could be made that fields should always be required, but several recent use cases have prompted this minor change to the spec. Additionally, it's more straight forward (to this user) to toggle optional than to define null placeholders for values and datatypes.

* add conditionals for ReconMethod Metadata

* add min and max values to scatter fraction

* add conditional for ReconFilterSize
@codecov
Copy link

codecov bot commented Sep 22, 2022

Codecov Report

Base: 88.39% // Head: 88.33% // Decreases project coverage by -0.06% ⚠️

Coverage data is based on head (d616e82) compared to base (2383c56).
Patch has no changes to coverable lines.

❗ Current head d616e82 differs from pull request most recent head 3341a07. Consider uploading reports for the commit 3341a07 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1299      +/-   ##
==========================================
- Coverage   88.39%   88.33%   -0.07%     
==========================================
  Files          11       11              
  Lines        1086     1080       -6     
==========================================
- Hits          960      954       -6     
  Misses        126      126              
Impacted Files Coverage Δ
tools/schemacode/bidsschematools/render/text.py 97.39% <0.00%> (-0.08%) ⬇️
...ools/schemacode/bidsschematools/render/__init__.py 100.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

tsalo
tsalo previously requested changes Sep 22, 2022
Copy link
Member

@tsalo tsalo left a comment

Choose a reason for hiding this comment

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

I think the rules need to be reconfigured a bit.

src/schema/rules/sidecars/pet.yaml Outdated Show resolved Hide resolved
src/schema/rules/sidecars/pet.yaml Outdated Show resolved Hide resolved
src/schema/rules/sidecars/pet.yaml Outdated Show resolved Hide resolved
@effigies
Copy link
Collaborator

@bendhouseart While working through some examples, we've found that it's going to be very difficult to both render and enforce rules that have required fields and then relax under certain conditions. So we can do two things:

  1. Make the optional default and use level_addendum to describe when it's required, and then add a required rule with a selector. Here only the first table will get rendered, and it will say something like OPTIONAL, but REQUIRED if XYZ.
PETReconstruction:
  selectors:
    - modality == "pet"
    - suffix == "pet"
  fields:
    ReconMethodParameterLabels:
      level: required
    ReconMethodParameterUnits:
      level: optional
      level_addendum: |
        required if `ReconMethodParameterLabels` does not contain 'none'

PETReconstructionReq:
  selectors:
    - modality == "pet"
    - suffix == "pet"
    - '!intersects(sidecar.ReconMethodParameterLabels, ["none"])'
  fields:
    ReconMethodParameterUnits: required
  1. Split the rule into two separate tables, one required and one optional, and then combine during the render:
PETReconstruction:
  selectors:
    - modality == "pet"
    - suffix == "pet"
  fields:
    ReconMethodParameterLabels:
      level: required

PETReconstructionReq:
  selectors:
    - modality == "pet"
    - suffix == "pet"
    - '!intersects(sidecar.ReconMethodParameterLabels, ["none"])'
  fields:
    ReconMethodParameterUnits:
      level: required
      level_addendum: |
        optional if `ReconMethodParameterLabels` does not contain 'none'

PETReconstructionOpt:
  selectors:
    - modality == "pet"
    - suffix == "pet"
    - intersects(sidecar.ReconMethodParameterLabels, ["none"])
    ReconMethodParameterUnits: optional
{{ MACROS___make_sidecar_table(["pet.PETReconstruction". "pet.PETReconstructionReq"]) }}

@CPernet
Copy link
Collaborator

CPernet commented Sep 26, 2022

@effigies isn't OPTIONAL but REQUIRED if similar to what is already used for 'NonlinearGradientCorrection' which then would make sense to use as a rule for conditional stuff -- although that case this is RECOMMENDED, but REQUIRED if (which would also actually be better for ReconMethod Parameters and ReconFilter Parameters

@effigies
Copy link
Collaborator

Yes, these are equivalent approaches in terms of enforcement. The choice between the two is which way PET maintainers would prefer it to be rendered.

Note that if you make a field RECOMMENDED, there will be warnings when it is missing. (The current validator does not follow this rule, but the schematized one will.)

@melanieganz
Copy link
Contributor

@effigies, so we just discussed this again in the OpenNeuroDev meeting and we agreed upon going for RECOMMENDED, but REQUIRED if . We'd like it to spit out a warning during validation , since we want to encourage people to go look for the values, but we accept that they might be hard to find/dig out.

…dhouseart/bids-specification into update-pet-recon-method-recon-filter

Update with suggestions to use recommended instead of optional as
we want to raise warnings if ReconMethod* fields are missing when
ReconMethodParameterLabels does not contain "None".

This change allows users to proceed when they are unable to source
the specifics relating to a reconstruction method apart from the
name.
@bendhouseart bendhouseart marked this pull request as ready for review September 29, 2022 15:58
Copy link
Collaborator

@effigies effigies left a comment

Choose a reason for hiding this comment

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

Looks right. Some styling fixes for the table.

src/schema/rules/sidecars/pet.yaml Outdated Show resolved Hide resolved
src/schema/rules/sidecars/pet.yaml Outdated Show resolved Hide resolved
src/schema/rules/sidecars/pet.yaml Outdated Show resolved Hide resolved
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
@effigies
Copy link
Collaborator

effigies commented Oct 4, 2022

Final render: image

@effigies
Copy link
Collaborator

@melanieganz @CPernet @mnoergaard Any of you up for giving this another review and a green check if you're happy with it?

@effigies effigies dismissed tsalo’s stale review October 12, 2022 18:33

Changes applied

@effigies effigies added this to the 1.8.0 milestone Oct 12, 2022
@sappelhoff
Copy link
Member

tagging again: @melanieganz @CPernet @mnoergaard

@CPernet
Copy link
Collaborator

CPernet commented Oct 17, 2022

yep that's what we discussed, if not then recommended (to avoid validation error) - thx @effigies

@sappelhoff sappelhoff merged commit 5c84df3 into bids-standard:master Oct 21, 2022
@sappelhoff
Copy link
Member

Thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants