You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The provided solution for exercise 2 in base_data_input.ipynb is as follows:
from nipype import SelectFiles, Node
# String template with {}-based strings
templates = {'anat': 'sub-01/ses-*/anat/sub-01_ses-*_T1w.nii.gz'}
# Create SelectFiles node
sf = Node(SelectFiles(templates),
name='selectfiles')
# Location of the dataset folder
sf.inputs.base_directory = '/data/ds000114'
#sf.inputs.ses_name =
sf.run().outputs
In particular the template line is not using the string formatting feature of SelectFiles at all. It seems like the SelectFiles interface differs from the DataGrabber interface in that it doesn't expand lists in its inputs automatically. It may be that SelectFiles is just busted, but the only way I could get SelectFiles to accept an iterable input was to wrap it in a MapNode like this:
Hi @Shotgunosine - That's a very good question! My intuition was to either use a MapNode or to have a node with iterables that feeds the input from a list individually to the node.
But I think there's even a simpler solution to this: I think SelectFiles comes already with iterables functionality, without using MapNode. An example of this can be found here.
But to be honest, I wasn't able to recreate this behavior in a standalone script. Do you have any luck?
There's also another approach shown here but I'm not sure if this is from an older version, as it doesn't work for me anymore.
The provided solution for exercise 2 in base_data_input.ipynb is as follows:
In particular the template line is not using the string formatting feature of
SelectFiles
at all. It seems like theSelectFiles
interface differs from theDataGrabber
interface in that it doesn't expand lists in its inputs automatically. It may be thatSelectFiles
is just busted, but the only way I could getSelectFiles
to accept an iterable input was to wrap it in a MapNode like this:This seems like kind of a crappy solution though, because if you want to get more than one subject you're typing out:
Alternatively, there is a solution using iterables and a
JoinNode
, but it's pretty ugly and completely specific to the case of just grabbing anats:So my question is, what's going on here? I feel like I must be misunderstanding how to use
SelectFiles
.Also, the tutorial should maybe point out the potential bug in which you specify
base_dir
inside theSelectFiles
definition instead ofbase_directory
.The text was updated successfully, but these errors were encountered: