-
Notifications
You must be signed in to change notification settings - Fork 90
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
Extend method BIDSPath().match() to enable smart path search #1098
Comments
Line 796 in 1b04da8
I also have a use case for not ignoring json files. I would like to save my FOOOF fit data as json files and get the paths using the |
just to be sure doing:
paths = BIDSPath().match(task="Rest")
is the same as
paths = BIDSPath().copy().update(task="Rest").match()
right?
if so you just want to be able to passe a list of task? or subject...
… Message ID: ***@***.***>
|
Yes exactly @agramfort. If I want to analyze certain files subjects = ["01", "02", "03"]
tasks = ["Rest", "Move"]
sessions = ["MedOn", "MedOff"] it would be nice if paths = []
bids_path = BIDSPath(root=root)
for subject in subjects:
bids_path.update(subject=subject)
for session in sessions:
bids_path.update(session=session)
for task in tasks:
paths.extend(bids_path.update(task=task).match()) would reduce to paths = BIDSPath(root=root).match(task=tasks, subject=subjects, session=sessions) |
I would rather have something like:
paths = find_matching_paths(root=root, tasks=tasks, subjects=subjects,
sessions=sessions)
doing for a parameter singular=plurar does not seem great to me
Message ID: ***@***.***>
… |
That would solve the issue 🙂 |
great !
could open a PR to do this? thx
… Message ID: ***@***.***>
|
Lines 817 to 830 in 1b04da8
I don't understand lines 817-822. Why do we search for |
I don't know / remember but this looks like too much magic to me.... What I
could suggest is to add parameter
to the match method to activate this "exception" or not.
def match(self, check=False, *, exclude_json=True, ...)
I would also try to comment out these lines and see what test it breaks
my 2c
… Message ID: ***@***.***>
|
I now understand this.
bids_path.fpath = 'rawdata/sub-EL002/ses-EcogLfpMedOff02/ieeg/sub-EL002_ses-EcogLfpMedOff02_task-Rest_acq-StimOff_run-1_proc-cleaned_rec-TMSi_channels.tsv' -> fname = "sub-EL002_ses-EcogLfpMedOff02_task-Rest_acq-StimOff_run-1_proc-cleaned_rec-TMSi_channels.tsv' |
Yes, I'm working on it |
Describe the problem
I love the
BIDSPath().match()
method for returnigng all bids paths in my root directory as a list. I can then loop over this list to, for example, preprocess all my files.However, often I would like to filter that list and only loop over some subjects or some tasks. Unfortunately, this is not possible at the moment.
Describe your solution
One could add all the keyword arguments from the
BIDSPath
class to thematch()
method. The allowed kwarg types should be both strings (as forBIDSPath
) but also list of strings.If I have
subjects=["sub-01", "sub-02", "sub-03"]
and I want to loop over the first two, I could getpaths = BIDSPath().match(subject=["sub-01", "sub-02"])
or
paths = BIDSPath().match(task="Rest")
or
paths = BIDSPath().match(task=["Rest", "Move"])
Describe possible alternatives
One could also consider to use the ignore kwargs from
mne_bids.get_entity_vals()
paths = BIDSPath().match(ignore_subjects=["sub-03"])
Additional context
No response
The text was updated successfully, but these errors were encountered: