-
Notifications
You must be signed in to change notification settings - Fork 2
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
Sentences with missing information are retained in the rendered text #4
Comments
Yeah so for pybids-report there is a "keep" on main branch of chevron that would at least leave the name of the missing parameters rather than those annoying blanks. But the package has not been updated in a long while... 😒 |
Ideally I would prefer to have
But I think this is something that should be handled by the pybids-reports |
That's reasonable. Can bids-methods handle conditional logic, or does that need to happen on pybids-reports' side? |
yes the mustache templating language can handle some conditional logic, by using sections: https://mustache.github.io/mustache.5.html See the mustache spec: https://github.com/mustache/spec/blob/master/specs/sections.yml Let me create a MWE. |
You can open and close "sections" with import chevron
template = """Data was acquired on a {{model_name}} system
{{#manufacturer}}from {{manufacturer}}, {{/manufacturer}}
{{#DeviceSerialNumber}}with serial number {{DeviceSerialNumber}}{{/DeviceSerialNumber}}."""
data = {'model_name': 'UNKNWON', "DeviceSerialNumber": 1234}
text = chevron.render(template, data)
print(text) $ /home/remi/miniconda3/bin/python /home/remi/github/bids/pybids-reports/tmp.py
Data was acquired on a UNKNWON system
with serial number 1234. Does that help? |
We could add some conditional logic in the templates that way to avoid some of ugliest renders. |
I will try to address #7 and then I can try to update pybids-report accordingly to take this into account |
In the pre-template version of BIDSReport, optional or recommended information that was missing was excluded from the rendered text. For example, when it comes to the MR scanner information, some info was required (or at least needed a stand-in value of "UNKNOWN"), while other info would just be dropped, but the current version has something like the following:
Instead, I think something like the following would be better:
The text was updated successfully, but these errors were encountered: