-
Notifications
You must be signed in to change notification settings - Fork 45
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
Make heuristics a simple set of "if .. elif .. else" statements and use a dictionary instead of variables. #209
Conversation
Codecov Report
@@ Coverage Diff @@
## master #209 +/- ##
==========================================
- Coverage 94.46% 94.32% -0.14%
==========================================
Files 7 7
Lines 578 582 +4
==========================================
+ Hits 546 549 +3
- Misses 32 33 +1
|
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.
LGTM! 👍
I really like the idea of using a dictionary to have the BIDS keys accessible at all times. It makes the code much easier to read imo.
I'm not worried about the decrease in coverage. I think we can ignore it this time.
@@ -0,0 +1,93 @@ | |||
import fnmatch |
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.
I assume this one is an example?
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.
Yep, why not.
it's the one used for a dataset that will be shared at a certain point.
@eurunuela I addressed your point - hopefully also the coverage decrease. @rmarkello @RayStick I had the same issue as #208 related to the deleted file. I think I solved it but @RayStick and @vinferrer please confirm that for our aims this old file: https://osf.io/u5dq8/ and this new file: https://osf.io/5829m/ are the same. |
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.
Hey @smoia! Thanks for all this 🙌
I made a few (very minor) suggestions below, but otherwise this looks good 💯
One lingering question that this all raised for me, though: is there a way to handle the heuristic files such that users don't have to specify the exact run
number if they have multiple runs of the same task? Could we use a list to store the info and just loop through? I know heudiconv
uses an approach like that so I'm wondering if it would be feasible here!
That said, I think we can merge this as-is in and open another issue to address this stuff more broadly!
Apologies for that @smoia. I deleted them for a reason, but it was a stupid reason. Instead of explaining, I have actually just put those text files back now. They may be slightly different lengths (i.e. different number of samples) compared to the original file, but otherwise they are the same. You can use either of those files, that you linked to (though 'Test3' will have have a new hyperlink now). Let me know if there are any issues. |
Co-Authored-By: Ross Markello <rossmarkello@gmail.com>
Co-Authored-By: Ross Markello <rossmarkello@gmail.com>
Co-Authored-By: Ross Markello <rossmarkello@gmail.com>
Co-Authored-By: Ross Markello <rossmarkello@gmail.com>
@RayStick, no worries! If it's shorter than the one we were using before and it has the same characteristics as the previous one that we use to test, then it's even better! @rmarkello, it's a great idea and we should implement it - not only for heuristics but also for mappings! |
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.
@smoia: a few thoughts on the heuristics files, then!
- I vote to remove the logger import and statement from all the examples. Handle this inside
phys2bids
(i.e., iftask
isn't set then raise an error). - It is unclear from the doc-string in the heuristic files that the parameter
physinfo
is the filename. You currently say"Name of the file or partial match"
but it's always a filename. It would be great to clarify this (as you have done in the documentation)! - Is it possible to avoid pass
info
to the heuristic function? I know it comes from the calling function but can't you just defineinfo
as a dict inside theheur()
function, update it accordingly, and then update theinfo
dict in the calling function? I'm thinking something like:
filename = 'my_physio_data.txt'
info = {'sub': '001', 'ses': '01'}
info.update(heuristic.heur(filename))
That way heur()
only has one parameter (the filename, for now—eventually more info!).
Let me know what you think.
… than passing it as an argument
@rmarkello good ideas! I implemented them in the last commit. |
Ok, codecov is not happy about the decrease in testing due to the new line that is in the function. |
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.
This is great! Thanks so much for this @smoia !
This might now count as a breaking change... Let me know and I'll update the labels + merge in accordingly. |
@rmarkello I trust you - up to you to decide which label to add (majormod or minormod) and merge in! |
Closes #89, #44
Proposed Changes
All the heuristics set run to
run-01
rather thanrun-00
(closes 0- vs 1-indexing therun
keyword inuse_heuristic()
#89 )The tests have been updated consequently to this change
All the "functional code" of the heuristics moved to
phys2bids.use_heuristics
rather than in the heuristic file, leaving it cleaner for the user (closes Making heuristic functions a simple set of if elif else statements #44 ).Instead of variables, the heuristic file populates a dictionary (this will be used to read yaml files too).
The documentation has been updated to reflect the changes.
Now, I have two doubts: