osl_ephys.source_recon#

Submodules#

Attributes#

logger

__doc__

Functions#

validate_outdir(outdir)

Checks if an output directory exists and if not creates it.

find_run_id(infile[, preload])

set_random_seed([seed])

Set all random seeds.

load_config(config)

Load config.

find_func(method, extra_funcs)

Find a source reconstruction function.

run_src_chain(config, outdir, subject[, preproc_file, ...])

Source reconstruction.

run_src_batch(config, outdir, subjects[, ...])

Batch source reconstruction.

setup_fsl(directory)

Setup FSL.

check_fsl()

Check FSL is installed.

setup_freesurfer(directory[, subjects_dir])

Setup FreeSurfer.

check_freesurfer()

Check FreeSurfer is installed.

recon_all(smri_file, subjects_dir, subject)

make_watershed_bem(outdir, subject, **kwargs)

Wrapper for mne.bem.make_watershed_bem making a watershed BEM with FreeSurfer.

make_fsaverage_src(subjects_dir[, spacing])

find_template_subject(outdir, subjects[, ...])

Function to find a good subject to align other subjects to in the sign flipping.

Package Contents#

osl_ephys.source_recon.validate_outdir(outdir)[source]#

Checks if an output directory exists and if not creates it.

osl_ephys.source_recon.find_run_id(infile, preload=True)[source]#
osl_ephys.source_recon.set_random_seed(seed=None)[source]#

Set all random seeds.

This includes Python’s random module and NumPy.

Parameters:

seed (int) – Random seed.

osl_ephys.source_recon.logger = None[source]#
osl_ephys.source_recon.load_config(config)[source]#

Load config.

Parameters:

config (str or dict) – Path to yaml file or str to convert to dict or a dict.

Returns:

config – Source reconstruction config.

Return type:

dict

osl_ephys.source_recon.find_func(method, extra_funcs)[source]#

Find a source reconstruction function.

Parameters:
  • method (str) – Function name.

  • extra_funcs (list of functions) – Custom functions.

Returns:

func – Function to use.

Return type:

function

osl_ephys.source_recon.run_src_chain(config, outdir, subject, preproc_file=None, smri_file=None, epoch_file=None, surface_extraction_method='fsl', logsdir=None, reportdir=None, gen_report=True, verbose='INFO', mneverbose='WARNING', extra_funcs=None, random_seed='auto')[source]#

Source reconstruction.

Parameters:
  • config (str or dict) – Source reconstruction config.

  • outdir (str) – Source reconstruction directory.

  • subject (str) – Subject name.

  • surface_extraction_method (str) – Can be ‘fsl’ or ‘freesurfer’.

  • preproc_file (str) – Preprocessed fif file.

  • smri_file (str) – Structural MRI file.

  • epoch_file (str) – Epoched fif file.

  • logsdir (str) – Directory to save log files to.

  • reportdir (str) – Directory to save report files to.

  • gen_report (bool) – Should we generate a report?

  • verbose (str) – Level of verbose.

  • mneverbose (str) – Level of MNE verbose.

  • extra_funcs (list of functions) – Custom functions.

  • random_seed ('auto' (default), int or None) – Random seed to set. If ‘auto’, a random seed will be generated. Random seeds are set for both Python and NumPy. If None, no random seed is set.

Returns:

flag – Flag indicating whether source reconstruction was successful.

Return type:

bool

osl_ephys.source_recon.run_src_batch(config, outdir, subjects, preproc_files=None, smri_files=None, epoch_files=None, surface_extraction_method='fsl', logsdir=None, reportdir=None, gen_report=True, verbose='INFO', mneverbose='WARNING', extra_funcs=None, dask_client=False, random_seed='auto')[source]#

Batch source reconstruction.

Parameters:
  • config (str or dict) – Source reconstruction config.

  • outdir (str) – Source reconstruction directory.

  • subjects (list of str) – Subject names.

  • surface_extraction_method (str) – Can be ‘fsl’ or ‘freesurfer’.

  • preproc_files (list of str) – Preprocessed fif files.

  • smri_files (list of str or str) – Structural MRI files. Can be ‘standard’ to use MNI152_T1_2mm.nii for the structural.

  • epoch_files (list of str) – Epoched fif file.

  • logsdir (str) – Directory to save log files to.

  • reportdir (str) – Directory to save report files to.

  • gen_report (bool) – Should we generate a report?

  • verbose (str) – Level of verbose.

  • mneverbose (str) – Level of MNE verbose.

  • extra_funcs (list of functions) – Custom functions.

  • dask_client (bool) – Are we using a dask client?

  • random_seed ('auto' (default), int or None) – Random seed to set. If ‘auto’, a random seed will be generated. Random seeds are set for both Python and NumPy. If None, no random seed is set.

Returns:

flags – Flags indicating whether coregistration was successful.

Return type:

list of bool

osl_ephys.source_recon.setup_fsl(directory)[source]#

Setup FSL.

Parameters:

directory (str) – Path to FSL installation.

osl_ephys.source_recon.check_fsl()[source]#

Check FSL is installed.

osl_ephys.source_recon.setup_freesurfer(directory, subjects_dir=None)[source]#

Setup FreeSurfer.

Parameters:

directory (str) – Path to FreeSurfer installation.

osl_ephys.source_recon.check_freesurfer()[source]#

Check FreeSurfer is installed.

osl_ephys.source_recon.recon_all(smri_file, subjects_dir, subject)[source]#
osl_ephys.source_recon.make_watershed_bem(outdir, subject, **kwargs)[source]#

Wrapper for mne.bem.make_watershed_bem making a watershed BEM with FreeSurfer.

osl_ephys.source_recon.make_fsaverage_src(subjects_dir, spacing='oct6')[source]#
osl_ephys.source_recon.find_template_subject(outdir, subjects, n_embeddings=1, standardize=True, epoched=False, source_method='lcmv')[source]#

Function to find a good subject to align other subjects to in the sign flipping.

Note, this function expects parcellated data to exist in the following location: outdir//parc/parc-.fif, the * here represents subject directories or ‘raw’ vs ‘epo’.

Parameters:
  • outdir (str) – Path to where to output the source reconstruction files.

  • subjects (str) – Subjects to include.

  • n_embeddings (int, optional) – Number of time-delay embeddings that we will use (if we are doing any).

  • standardize (bool, optional) – Should we standardize (z-transform) the data before sign flipping?

  • epoched (bool, optional) – Are we performing sign flipping on parc-raw.fif (epoched=False) or parc-epo.fif files (epoched=True)?

  • source_method (str, optional) – Method to used for inverse modelling (e.g., LCMV, MNE, eLORETA).

Returns:

template – Template subject.

Return type:

str

osl_ephys.source_recon.__doc__[source]#