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

Link to code

Bases: CommandLine

Classify ICA components using a specific training dataset (<thresh> is in the range 0-100, typically 5-20).

Mandatory Inputs:
  • thresh (an integer) – Threshold for cleanup. Maps to a command-line argument: %d (position: -1).

  • trained_wts_file (a pathlike object or string representing an existing file) – Trained-weights file. Maps to a command-line argument: %s (position: 2).

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • artifacts_list_file (a 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.

  • environ (a 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_ica (a pathlike object or string representing an existing directory) – Melodic output directory or directories. Maps to a command-line argument: %s (position: 1).

Outputs:

artifacts_list_file (a 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

Link to code

Bases: CommandLine

Extract features (for later training and/or classifying)

Mandatory Inputs:

artifacts_list_file (a 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).

Optional Inputs:
  • aggressive (a boolean) – Apply aggressive (full variance) cleanup, instead of the default less-aggressive (unique variance) cleanup. Maps to a command-line argument: -A (position: 3).

  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • cleanup_motion (a boolean) – Cleanup motion confounds, looks for design.fsf for highpass filter cut-off. Maps to a command-line argument: -m (position: 2).

  • confound_file (a pathlike object or string representing a file) – Include additional confound file. Maps to a command-line argument: -x %s (position: 4).

  • confound_file_1 (a pathlike object or string representing a file) – Include additional confound file. Maps to a command-line argument: -x %s (position: 5).

  • confound_file_2 (a pathlike object or string representing a file) – Include additional confound file. Maps to a command-line argument: -x %s (position: 6).

  • environ (a 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: {})

  • highpass (a float) – Cleanup motion confounds. Maps to a command-line argument: -m -h %f (position: 2). (Nipype default value: 100)

Outputs:

cleaned_functional_file (a pathlike object or string representing an existing file) – Cleaned session data.

Cleaner.cmd = 'fix -a'

FeatureExtractor

Link to code

Bases: CommandLine

Extract features (for later training and/or classifying)

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a 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_ica (a pathlike object or string representing an existing directory) – Melodic output directory or directories. Maps to a command-line argument: %s (position: -1).

Outputs:

mel_ica (a 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

Link to code

Bases: CommandLine

Train the classifier based on your own FEAT/MELODIC output directory.

Optional Inputs:
  • args (a string) – Additional parameters to the command. Maps to a command-line argument: %s.

  • environ (a 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: {})

  • loo (a boolean) – Full leave-one-out test with classifier training. Maps to a command-line argument: -l (position: 2).

  • mel_icas (a 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_filestem (a string) – Trained-weights filestem, used for trained_wts_file and output directories. Maps to a command-line argument: %s (position: 1).

Outputs:

trained_wts_file (a pathlike object or string representing an existing file) – Trained-weights file.

Training.cmd = 'fix -t'

TrainingSetCreator

Link to code

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 every time a handlabeled file has been changed, or a new one created.

Optional Inputs:

mel_icas_in (a 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).

Outputs:

mel_icas_out (a 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).