-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path05_source_reconstruct.py
65 lines (51 loc) · 1.79 KB
/
05_source_reconstruct.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""Source reconstruction.
This includes beamforming, parcellation and orthogonalisation.
"""
# Authors: Chetan Gohil <chetan.gohil@psych.ox.ac.uk>
import os
import pandas as pd
from dask.distributed import Client
from osl_ephys import source_recon, utils
# Directories
preproc_dir = "/home/mtrubshaw/Documents/ALS_dyn/data/preproc_ssp"
coreg_dir = "/home/mtrubshaw/Documents/ALS_dyn/data/coreg"
src_dir = "/home/mtrubshaw/Documents/ALS_dyn/data/src"
# Files
preproc_file = preproc_dir + "/{subject}/{subject}_preproc-raw.fif" # {subject} will be replaced by the subject name
# Settings
config = """
source_recon:
- beamform_and_parcellate:
freq_range: [1, 80]
chantypes: [mag, grad]
rank: {meg: 60}
parcellation_file: Glasser52_binary_space-MNI152NLin6_res-8x8x8.nii.gz
method: spatial_basis
orthogonalisation: symmetric
"""
if __name__ == "__main__":
utils.logger.set_up(level="INFO")
# Copy directory containing the coregistration
if not os.path.exists(src_dir):
cmd = f"cp -r -u {coreg_dir} {src_dir}"
print(cmd)
os.system(cmd)
# Get paths to files
participants = pd.read_csv(f"../../demographics/old/complete_demo_dyn_als.csv")
subjects = participants["Subject"].values
preproc_files = []
for subject in subjects:
preproc_files.append(f"{preproc_dir}/{subject}/{subject}_preproc_raw.fif")
# Setup parallel processing
#
# n_workers is the number of CPUs to use,
# we recommend less than half the total number of CPUs you have
client = Client(n_workers=6, threads_per_worker=1)
# Source reconstruction
source_recon.run_src_batch(
config,
outdir=src_dir,
subjects=subjects,
preproc_files=preproc_files,
dask_client=True,
)