nipype.interfaces.fsl.fix module¶
The fix module provides classes for interfacing with the FSL FIX <http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FIX/index.html> command line tools.
This was written to work with FSL version v5.0
The following example assumes that melodic has already been run, so the datagrabber is configured to start from there (a list of melodic output directories). If no hand_labels_noise.txt exists already, this will fail and comment on that.
EXAMPLE: subject_list = [‘1’, ‘2’, ‘3’]
fix_pipeline = pe.Workflow(name=’fix_pipeline’) fix_pipeline.base_dir = os.path.abspath(‘./’)
info = dict(mel_ica=[[‘subject_id’]])
datasource = pe.Node(interface=nio.DataGrabber(infields=[‘subject_id’], outfields=[‘mel_ica’]), name=’datasource’) datasource.inputs.base_directory = os.path.abspath(‘<path_to_base_directory>’) datasource.inputs.template = ‘%s/<path_to_melodic_ica>’ datasource.inputs.template_args = info datasource.inputs.subject_id = subject_list datasource.inputs.sort_filelist = True datasource.iterables = (‘subject_id’, subject_list)
# create training set by looking into which mel_icas have hand_labels_noise.txt files in them create_training_set = pe.JoinNode(interface=fix.TrainingSetCreator(), joinfield=[‘mel_icas_in’], joinsource=’datasource’, name=’trainingset_creator’)
# train the classifier train_node = pe.Node(interface=fix.Training(trained_wts_filestem=’foo’), name=’train_node’)
# test accuracy. Probably not necessary, and also failing on my setup because of fix itself (no error msg) accuracy_tester = pe.Node(interface=fix.AccuracyTester(output_directory=’more_foo’), name=’accuracy_tester’)
# classify components classify_node = pe.Node(interface=fix.Classifier(), name=’classify’)
# apply cleanup cleaner_node = pe.Node(interface=fix.Cleaner(), name=’cleaner’)
fix_pipeline.connect(datasource, ‘mel_ica’, create_training_set, ‘mel_icas_in’) fix_pipeline.connect(create_training_set, ‘mel_icas_out’, train_node, ‘mel_icas’) fix_pipeline.connect(train_node, ‘trained_wts_file’, accuracy_tester, ‘trained_wts_file’) fix_pipeline.connect(datasource, ‘mel_ica’, accuracy_tester, ‘mel_icas’) fix_pipeline.connect(train_node, ‘trained_wts_file’, classify_node, ‘trained_wts_file’) fix_pipeline.connect(datasource, ‘mel_ica’, classify_node, ‘mel_ica’) fix_pipeline.connect(classify_node, ‘artifacts_list_file’, cleaner_node, ‘artifacts_list_file’)
fix_pipeline.write_graph() outgraph = fix_pipeline.run()
Classifier¶
Bases: CommandLine
Classify ICA components using a specific training dataset (<thresh> is in the range 0-100, typically 5-20).
- threshan integer
Threshold for cleanup. Maps to a command-line argument:
%d
(position: -1).- trained_wts_filea pathlike object or string representing an existing file
Trained-weights file. Maps to a command-line argument:
%s
(position: 2).
- argsa string
Additional parameters to the command. Maps to a command-line argument:
%s
.- artifacts_list_filea pathlike object or string representing a file
Text file listing which ICs are artifacts; can be the output from classification or can be created manually.
- environa dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’
Environment variables. (Nipype default value:
{}
)- mel_icaa pathlike object or string representing an existing directory
Melodic output directory or directories. Maps to a command-line argument:
%s
(position: 1).
- artifacts_list_filea pathlike object or string representing a file
Text file listing which ICs are artifacts; can be the output from classification or can be created manually.
- Classifier.cmd = 'fix -c'¶
Cleaner¶
Bases: CommandLine
Extract features (for later training and/or classifying)
- artifacts_list_filea pathlike object or string representing an existing file
Text file listing which ICs are artifacts; can be the output from classification or can be created manually. Maps to a command-line argument:
%s
(position: 1).
- aggressivea boolean
Apply aggressive (full variance) cleanup, instead of the default less-aggressive (unique variance) cleanup. Maps to a command-line argument:
-A
(position: 3).- argsa string
Additional parameters to the command. Maps to a command-line argument:
%s
.- cleanup_motiona boolean
Cleanup motion confounds, looks for design.fsf for highpass filter cut-off. Maps to a command-line argument:
-m
(position: 2).- confound_filea pathlike object or string representing a file
Include additional confound file. Maps to a command-line argument:
-x %s
(position: 4).- confound_file_1a pathlike object or string representing a file
Include additional confound file. Maps to a command-line argument:
-x %s
(position: 5).- confound_file_2a pathlike object or string representing a file
Include additional confound file. Maps to a command-line argument:
-x %s
(position: 6).- environa dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’
Environment variables. (Nipype default value:
{}
)- highpassa float
Cleanup motion confounds. Maps to a command-line argument:
-m -h %f
(position: 2). (Nipype default value:100
)
- cleaned_functional_filea pathlike object or string representing an existing file
Cleaned session data.
- Cleaner.cmd = 'fix -a'¶
FeatureExtractor¶
Bases: CommandLine
Extract features (for later training and/or classifying)
- argsa string
Additional parameters to the command. Maps to a command-line argument:
%s
.- environa dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’
Environment variables. (Nipype default value:
{}
)- mel_icaa pathlike object or string representing an existing directory
Melodic output directory or directories. Maps to a command-line argument:
%s
(position: -1).
- mel_icaa pathlike object or string representing an existing directory
Melodic output directory or directories. Maps to a command-line argument:
%s
(position: -1).
- FeatureExtractor.cmd = 'fix -f'¶
Training¶
Bases: CommandLine
Train the classifier based on your own FEAT/MELODIC output directory.
- argsa string
Additional parameters to the command. Maps to a command-line argument:
%s
.- environa dictionary with keys which are a bytes or None or a value of class ‘str’ and with values which are a bytes or None or a value of class ‘str’
Environment variables. (Nipype default value:
{}
)- looa boolean
Full leave-one-out test with classifier training. Maps to a command-line argument:
-l
(position: 2).- mel_icasa list of items which are a pathlike object or string representing an existing directory
Melodic output directories. Maps to a command-line argument:
%s
(position: -1).- trained_wts_filestema string
Trained-weights filestem, used for trained_wts_file and output directories. Maps to a command-line argument:
%s
(position: 1).
- trained_wts_filea pathlike object or string representing an existing file
Trained-weights file.
- Training.cmd = 'fix -t'¶
TrainingSetCreator¶
Bases: BaseInterface
Goes through set of provided melodic output directories, to find all the ones that have a hand_labels_noise.txt file in them.
This is outsourced as a separate class, so that the pipeline is rerun everytime a handlabeled file has been changed, or a new one created.
- mel_icas_ina list of items which are a pathlike object or string representing an existing directory
Melodic output directories. Maps to a command-line argument:
%s
(position: -1).
- mel_icas_outa list of items which are a pathlike object or string representing an existing directory
Hand labels for noise vs signal. Maps to a command-line argument:
%s
(position: -1).