-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFP_simulation.py
More file actions
50 lines (39 loc) · 1.49 KB
/
FP_simulation.py
File metadata and controls
50 lines (39 loc) · 1.49 KB
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
import os
from simnibs import sim_struct, run_simnibs
# Path to the folder containing all participant subfolders
base_folder = r"C:\Users\z5171263\Downloads\Augusta_nifti\simulations"
participant_folders = [f for f in os.listdir(base_folder) if os.path.isdir(os.path.join(base_folder, f))]
for participant in participant_folders:
print(f"Running simulation for {participant}")
participant_path = os.path.join(base_folder, participant)
clean_name = participant.replace("m2m_", "")
output_folder = os.path.join(base_folder, f"{clean_name}_FrontoParietal_simulation_results")
# create output folder if it doesn't exist
os.makedirs(output_folder, exist_ok=True)
# Create session object
S = sim_struct.SESSION()
S.subpath = participant_path
S.pathfem = output_folder
S.map_to_surf = False
S.open_in_gmsh = False
S.fields = "eEjJ"
# Set up tDCS electrodes
tdcslist = S.add_tdcslist()
tdcslist.currents = [-1e-3, 1e-3]
# Cathode
cathode = tdcslist.add_electrode()
cathode.channelnr = 1
cathode.dimensions = [50, 50]
cathode.shape = 'ellipse'
cathode.thickness = [1.75, 1]
cathode.centre = 'C2'
# Anode
anode = tdcslist.add_electrode()
anode.channelnr = 2
anode.dimensions = [50, 50]
anode.shape = 'ellipse'
anode.thickness = [1.75, 1]
anode.centre = 'Fp2'
# Run the simulation
run_simnibs(S)
print(f"Simulation finished for {participant}\n")