meica package

Submodules

meica.alignp_mepi_anat module

meica.meica module

meica.t2smap module

meica.tedana module

Module contents

meica.afni_fname_parse(f, echo_ind=None)

Filename parser for AFNI file types (.BRIK/.HEAD). For AFNI file types, the space (e.g., +tlrc) is considered as the file type.

Parameters:f (string) – the filename represented as a string
Returns:
  • prefix (str) – the prefix for each filename, up to the echo number
  • trailing (str) – any part of filename after echo up to extension
  • ftype (str) – file type for the acquired functional datasets
meica.check_obliquity(fname)

Generates obliquity (in degrees) of fname

Parameters:fname (str) – path to neuroimage
Returns:ang merit – angle from plumb (in degrees)
Return type:float
meica.find_CM(fname)

Generates center of mass for fname

Will only use the first volume if a 4D image is supplied

Parameters:fname (str) – path to neuroimage
Returns:float, float, float
Return type:x, y, z coordinates of center of mass
meica.fname_parse(flist)

Filename parser for AFNI and NIFTI files

Returns prefix from input datafiles (e.g., sub_001), trailing file part (e.g., in BIDS spec, ‘_bold’), and filetype extension (e.g., .nii). If AFNI format is supplied, will extract space (+tlrc, +orig, or +mni) as filetype.

Parameters:flist (str / list) – list of filenames for acquired functional datasets. if provided with a string, will coerce to list of length 1.
Returns:
  • prefix (str) – the prefix for each filename, up to the echo number
  • trailing (str) – any part of filename after echo number, up to file extension
  • ftype (str) – extension or file type for the acquired functional datasets
meica.format_dset(inset)

Parse input file specification as short- or longhand

Given a dataset specification (usually from options.input_ds), parse and identify a file prefix, trailing file part, and file type.

Can handle ‘shorthand’ specification (with bash shell expansion), or ‘longhand’ specification (writing out each filename– in either a comma- separated string _OR_ a list).

Parameters:inset (str) – filenames for acquired functional datasets
Returns:
  • prefix (str) – the prefix for each filename, before the echo num
  • trailing (str) – part of filename after echo number (in BIDS spec, ‘_bold’)
  • ftype (str) – file type for the acquired functional datasets
meica.format_inset(inset, tes, e=2)

Parse and create a setname for all output files.

Requires that files are available in the present working directory (in order to assert that number of identified input datasets match the specified number of echoes.)

Parameters:
  • inset (str) – filenames for acquired functional datasets
  • tes (str) – acquired TEs
  • e (int) – exemplar echo, default second acquired echo
Returns:

  • dsname (str) – dataset name
  • setname (str) – name to be “set” for any output files

meica.format_tes(tes)

Identify the number of echoes acquired based on the provided TEs.

Supports TE specification as comma-separated string _OR_ list.

Parameters:tes (str) – acquired TEs
Returns:echo_nums – a list of the number of echoes collected (e.g., [1, 2])
Return type:list
meica.gen_script(options)

Parses input options to generate working ME-ICA script based on inputs

Parameters:options (argparse) – from get_options()
Returns:list
Return type:ME-ICA script for input data
meica.get_dsname(inset, tes, e)

Return the filename for the specified echo.

Parameters:
  • inset (str) – filenames for acquired functional datasets
  • tes (str) – acquired TEs in milliseconds
  • e (int) – echo to find filename, default second acquired echo
Returns:

dsname – filename name of specified echo

Return type:

str

meica.get_setname(inset, tes)

Return the dataset prefix for any created derivatives

Parameters:
  • inset (str) – filenames for acquired functional datasets
  • tes (str) – acquired TEs in milliseconds
  • e (int) – echo to find filename, default second acquired echo
Returns:

setname – prefix to be “set” for any created output files

Return type:

str

meica.nii_convert(f)

Converts a given file type to a gzipped-nifti.

Parameters
fname : str
The full filename of the file to be converted
Returns:nii_fname – The .nii.gz filename to be returned
Return type:str
meica.nii_fname_parse(f, echo_ind=None)

Filename parser for NIfTI file types (.nii; can also handle gzipped nii files).

Parameters:f (string) – the filename represented as a string
Returns:
  • prefix (str) – the prefix for each filename, up to the echo number
  • trailing (str) – any part of filename after echo up to extension
  • ftype (str) – file type for the acquired functional datasets