Skip to content

Instantly share code, notes, and snippets.

@dangom
Last active May 2, 2018 08:41
Show Gist options
  • Save dangom/f377fff32010f045abb35253d98b3374 to your computer and use it in GitHub Desktop.
Save dangom/f377fff32010f045abb35253d98b3374 to your computer and use it in GitHub Desktop.
import subprocess
import io
import pandas as pd
# The fslcc binary to use
FSLCC = '/opt/fsl/5.0.11/bin/fslcc'
# Parameters for the command line. No thresholding, report 4 digits.
FSLCC_PARAMS = ['-t', '0', '-p', '4']
def call_fslcc(file1, file2):
"""
Compute cross-correlation by calling fslcc and parsing the output
into a pd DataFrame.
"""
cc = subprocess.check_output([FSLCC, *FSLCC_PARAMS, file1, file2])
return pd.read_csv(io.StringIO(cc.decode()), delimiter='\s+',
header=None, names=['file1', 'file2', 'CC'])
# Example:
df = call_fslcc('sub-01.ica/melodic_IC.nii.gz', 'sub-02.ica/melodic_IC.nii.gz')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment