Skip to content

Commit

Permalink
Option to pass an mne object to voxel_timeseries.
Browse files Browse the repository at this point in the history
  • Loading branch information
cgohil8 committed Sep 1, 2024
1 parent 053633a commit a8485f8
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions osl/source_recon/beamforming.py
Original file line number Diff line number Diff line change
Expand Up @@ -1307,15 +1307,19 @@ def voxel_timeseries(
Voxel coordinates in MNI space.
"""

# Load sensor data
if "raw.fif" in preproc_file:
# Load preprocessed data
data = mne.io.read_raw_fif(preproc_file, preload=True)
elif "epo.fif" in preproc_file:
# Load epoched data
data = mne.read_epochs(preproc_file, preload=True)
if isinstance(preproc_file, str):
# Load sensor data
if "raw.fif" in preproc_file:
# Load preprocessed data
data = mne.io.read_raw_fif(preproc_file, preload=True)
elif "epo.fif" in preproc_file:
# Load epoched data
data = mne.read_epochs(preproc_file, preload=True)
else:
raise ValueError("fif file must end in 'raw.fif' or 'epo.fif'.")
else:
raise ValueError("fif file must end in 'raw.fif' or 'epo.fif'.")
# Assume an mne Raw or Epochs object has been passed
data = preproc_file

log_or_print(f"using chantypes: {chantypes}")
if isinstance(chantypes, str):
Expand All @@ -1332,10 +1336,10 @@ def voxel_timeseries(
bf_data = apply_lcmv(data, filters, reject_by_annotation)

# Transform to MNI space
if "epo.fif" in preproc_file:
bf_data = np.transpose([bf.data for bf in bf_data], axes=[1, 2, 0])
else:
if isinstance(data, mne.io.Raw):
bf_data = bf_data.data
else:
bf_data = np.transpose([bf.data for bf in bf_data], axes=[1, 2, 0])
voxel_timeseries, _, voxel_coords, _ = transform_recon_timeseries(
subjects_dir=subjects_dir,
subject=subject,
Expand Down

0 comments on commit a8485f8

Please sign in to comment.