-
Notifications
You must be signed in to change notification settings - Fork 111
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
Add NIRS support to BIDS Validator #952
Conversation
Codecov Report
@@ Coverage Diff @@
## master bids-standard/legacy-validator#952 +/- ##
==========================================
+ Coverage 83.36% 83.55% +0.19%
==========================================
Files 91 91
Lines 3691 3758 +67
Branches 1123 1146 +23
==========================================
+ Hits 3077 3140 +63
- Misses 518 522 +4
Partials 96 96
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
66afafd
to
0ce8a7e
Compare
@sappelhoff is there a resident javascript expert I can request advice from regarding this PR? I am trying to implement the following logic from bids-standard/bids-specification#802 but I am unable to make it work. Logic:
I have been trying to replicate some of the logic from PET (bids-standard/bids-validator@08d9a4e) but I am new to javascript and cant make sense of the logic. Any help is appreciated, even. link to similar functionality in the codebase may help put me on the right path. |
I hope @rwblair can help with that. I once had a similar issue that would involve checking JSON contingent on TSV contents (so the other way around from your issue): https://github.com/bids-standard/bids-validator/issues/673 Right now, I don't know where to start with that unfortunately. |
My apologies for the delay in response. So pet_blood specifies 'requires_tsv_non_custom_columns' key/value for which tsv columns are required in its json schema spec: Here is the location in the tsv validator where the 'requires_tsv_non_custom_columns' fields are used to make sure the proper columns exist: Here a specific value in a json field forces a specific TSV column to be required, but the NIRS situation is the reverse, a specific value somewhere in TSV forces a json field to become required. I am thinking about how best to approach this and writing up some example code for the tsv validator that I'll push to this branch to see what you think. |
Please don't apologise. We all have other aspects to our lives. I appreciate you taking a look at this problem. If you can push an example solution to this logic I can try and expand on that to each case where we need this behaviour. Thanks again |
I added a new property to the json schema 'required_if_tsv_value_present': Specifies which column in the tsv to check against and which value should be present once. The I added additonal valdiation steps to validateTsvColumns that mirror how pet used their custom schema property. I rerused their error code it probably should be changed, BUT the evidence line there right now is probably good enough to give users an idea of whats going on: @rob-luke how big are these tsv files typically? iteratting over the rows multiple times checking for specific values might become slow if they are massive. I have not tested the code or written tests for it. Is there a good example dataset? Let me know what you think. |
Huge thanks @rwblair.
The not very big. My hardware has 50 channels. I imagine future devices could have 2-300 channels. There would be a practical upper limit to how many sensors you could fit on a head (think EEG).
Lets worry about that when it happens. Lets get the code working correctly first, then optimise.
Here is a dataset that I have been testing on: https://github.com/rob-luke/BIDS-NIRS-Tapping/tree/master I added a ShortChannelCount in the nirs.json file locally and the validator throws this error... Is there any way I can help you debug this issue?
This is awesome. thank you so much! |
Thanks @rwblair the code now runs and ensures the variable |
First batch of work committed last week or so left short_channel requirement out. The spec makes it seem as if it is always optional or recommended not required: ShortChannelCount is listed as recommended. from short_channel entry: My last commit should throw an error if it ShortChannelCount is present but there is no short_channel column, if this is what we want to happen then the spec may need to be updated. I added a 'requires_tsv_non_custom_columns' property to the ShortChannelCount json schema entry specifying 'short_channel'. For pet blood the tsv headers specified in 'requires_tsv_non_custom_columns' would only be evaluated if the json field was boolean, and set to true. I updated this logic to do this check if the field is boolean and its value is true, otherwise do the check if its 'truthy' in javascript, (not 0, false, null, etc). Sorry I never responded with a theory of my first set of commits. Regarding testing, its much easier to debug the validator if you run it from the command-line. Notice the error from the compiled web version you posted doesn't show a filename or line number that corresponds to whats in the repository/uncompiled files. Is running the validator from the command line an option for you? |
Hi @rwblair, You are absolutely correct. I was getting confused. I was mixing up the spec and what I was wondering was possible with the validator. Thanks for sticking with me.
You are correct. My apologies. The spec is correct, I was wrong.
No worries, to be honest I have been kinda short on time lately too.
I haven't tried the command line usage yet. I will try that next, thanks for the tip. I am new to this type of programming, so the tips are appreciated. As next steps I will try and add some test data and tests. And try to understand your code 😉, I will try and be self sufficient, but if I get stuck again I may ping you again. Thanks for the help |
So we probably want to have the short_channel thing be a warning instead of an error. As of right now there is now good way to indicate that using just the json schemas. We could imagine a new property in the json schemas "recommends_tsv_non_custom_columns" alongside "requires_tsv_non_custom_columns". It would be the same code as the Feel free to ask as many questions as you want. I'm having trouble giving good instructions to help situate you but at least I can answer questions! |
Thanks @rwblair I will get back to this soon and will surely have some more questions. I appreciate you keeping this aligned with master! |
Some test data is now available at bids-standard/bids-examples#305 |
a1fbdeb
to
63af1f7
Compare
two small fixes to correctly validate example NIRS dataset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a note: the mne-bids CI is failing due to the nirs validator: https://github.com/mne-tools/mne-bids/runs/7000412391?check_suite_focus=true#step:15:465
it may be beneficial to look into whether this is a validator issue or an mne-bids nirs-specific issue.
It is saying that the filename |
dd1f4f2 seems to have fixed the issue (see mne-tools/mne-bids#1020). However, I am not very confident about my regex skills. So if anyone can take a second look over the regex that would be greatly appreciated |
@rob-luke regex looks good, tested it out with a dataset with nirs with session and seemed to work. Updated the regex to match style of other rules that can match back or forward slashes for directory seperators. |
Thank you kindly @rwblair !!! |
I believe this is ready. I'm going to let it sit for another day pending changes in the specification PR. |
@rwblair in mne-tools/mne-bids#1061 we now have a file like this failing validation:
https://github.com/mne-tools/mne-bids/runs/8116368480?check_suite_focus=true#step:15:470 I believe this should pass 🤔 did the recent changes introduce an issue? cc @rob-luke |
@sappelhoff It's missing a |
a coordsystem shouldn't be task dependent AFAIK 🤔 if adding a task to the file would make it valid, then something's off in the validator 🤔 |
@sappelhoff try with that latest commit. Silly issue in the regex that covers coordsystem suffix. |
This seems to have fixed it, thanks a lot, @rwblair! |
🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 |
This PR is to add NIRS support as described in the NIRS BEP
Note: