osl_ephys.source_recon#
Submodules#
- osl_ephys.source_recon.batch
- osl_ephys.source_recon.beamforming
- osl_ephys.source_recon.freesurfer_utils
- osl_ephys.source_recon.minimum_norm
- osl_ephys.source_recon.nii
- osl_ephys.source_recon.parcellation
- osl_ephys.source_recon.rhino
- osl_ephys.source_recon.sign_flipping
- osl_ephys.source_recon.wrappers
Attributes#
Functions#
|
Checks if an output directory exists and if not creates it. |
|
|
|
Set all random seeds. |
|
Load config. |
|
Find a source reconstruction function. |
|
Source reconstruction. |
|
Batch source reconstruction. |
|
Setup FSL. |
Check FSL is installed. |
|
|
Setup FreeSurfer. |
Check FreeSurfer is installed. |
|
|
|
|
Wrapper for |
|
|
|
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.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.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.setup_freesurfer(directory, subjects_dir=None)[source]#
Setup FreeSurfer.
- Parameters:
directory (str) – Path to FreeSurfer installation.
- osl_ephys.source_recon.make_watershed_bem(outdir, subject, **kwargs)[source]#
Wrapper for
mne.bem.make_watershed_bemmaking a watershed BEM with FreeSurfer.
- 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