-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGooeyV1.py
208 lines (169 loc) · 8.25 KB
/
GooeyV1.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Importing necessary libraries
import tkinter as tk
from tkinter import scrolledtext, ttk
import os
import json
import sv_ttk as sv_ttk
# Function to update the shell script display based on user inputs and selections
def update_shell_script(*args):
# Collecting user inputs with updated variable names
bids_dir = bids_dir_var.get()
fmriprep_container_dir = fmriprep_container_dir_var.get()
fmriprep_job_file_out_dir = fmriprep_job_file_out_dir_var.get()
fmriprep_out_dir = fmriprep_out_dir_var.get()
fmriprep_error_out_dir = fmriprep_error_out_dir_var.get()
fmriprep_freesurfer_license_dir = fmriprep_freesurfer_license_dir_var.get()
xcpd_container_dir = xcpd_container_dir_var.get()
xcpd_job_file_out_dir = xcpd_job_file_out_dir_var.get()
xcpd_out_dir = xcpd_out_dir_var.get()
xcpd_error_out_dir = xcpd_error_out_dir_var.get()
user_email = user_email_var.get()
# Building the shell script sample dynamically
# The string content is not updated here as per instruction
shell_script = f"""
#fmriscript
#!/bin/bash
#$ -pe smp 56
#$ -q UI
#$ -m bea
#$ -M {user_email}
#$ -j y
#$ -o {fmriprep_out_dir}
#$ -e {fmriprep_error_out_dir}
OMP_NUM_THREADS=10
singularity run --cleanenv -H ${{HOME}}/singularity_home -B /Shared/vosslabhpc:/mnt \\
/{fmriprep_container_dir} \\
/{bids_dir} \\
/{fmriprep_out_dir} \\
participant --participant_label SUBJECT WILL GO HERE \\
--dummy-scans 5 \\
-f 0.5 \\
--license /{fmriprep_freesurfer_license_dir} \\
--atlases 4S456Parcels
#path: {fmriprep_job_file_out_dir}
#xcpdscript
#!/bin/bash
#$ -pe smp 56
#$ -q UI
#$ -m bea
#$ -M {user_email}
#$ -j y
#$ -e {xcpd_error_out_dir}
#$ -o {xcpd_out_dir}
singularity run -B /Users/bmadero/xcpEngine/utils:/xcpEngine/utils \\
-H /Users/bmadero/singularity_home \\
/{xcpd_container_dir} \\
/{fmriprep_out_dir} \\
-d /Shared/vosslabhpc/Projects/BikeExtend/3-Experiment/2-Data/BIDS/derivatives/code/xcp/job_scripts/day1pre/fc-acompcor.dsn \\
--participant_label SUBJECT WILL GO HERE \\
-o {xcpd_out_dir} \\
-t 2 -r /Shared/vosslabhpc/Projects/BikeExtend/3-Experiment/2-Data/BIDS/derivatives/
#path: {xcpd_job_file_out_dir}
"""
# Updating the shell script display
shell_script_display.config(state=tk.NORMAL)
shell_script_display.delete(1.0, tk.END)
shell_script_display.insert(tk.INSERT, shell_script)
shell_script_display.config(state=tk.DISABLED)
# Creating the main window
root = tk.Tk()
root.title("fMRI Preprocessing GUI")
# Defining user input variables with updated names
bids_dir_var = tk.StringVar()
fmriprep_container_dir_var = tk.StringVar()
fmriprep_job_file_out_dir_var = tk.StringVar()
fmriprep_out_dir_var = tk.StringVar()
fmriprep_error_out_dir_var = tk.StringVar()
fmriprep_freesurfer_license_dir_var = tk.StringVar()
xcpd_container_dir_var = tk.StringVar()
xcpd_job_file_out_dir_var = tk.StringVar()
xcpd_out_dir_var = tk.StringVar()
xcpd_error_out_dir_var = tk.StringVar()
user_email_var = tk.StringVar()
subject_ids_var = tk.StringVar() # Ensure this variable is defined as it's used in the function
# Function to bind variable changes to the update function
def bind_variable_updates():
variables = [
bids_dir_var, fmriprep_container_dir_var, fmriprep_job_file_out_dir_var,
fmriprep_out_dir_var, fmriprep_error_out_dir_var, fmriprep_freesurfer_license_dir_var,
xcpd_container_dir_var, xcpd_job_file_out_dir_var, xcpd_out_dir_var,
xcpd_error_out_dir_var, user_email_var, subject_ids_var
]
for var in variables:
var.trace_add("write", update_shell_script)
# Binding variable changes to the update function
bind_variable_updates()
# Creating the layout
left_frame = ttk.Frame(root)
left_frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
right_frame = ttk.Frame(root)
right_frame.pack(side=tk.RIGHT, fill=tk.BOTH, expand=True)
# Starting row for the grid layout
row_index = 0
def save_config(self):
config_data = {name: var.get() for name, var in self.variables.items()}
with open("config.json", "w") as file:
json.dump(config_data, file, indent=4)
messagebox.showinfo("Info", "Configuration saved.")
def load_config(self):
if os.path.exists("config.json"):
with open("config.json", "r") as file:
config_data = json.load(file)
for name, value in config_data.items():
if name in self.variables:
self.variables[name].set(value)
# Widget for BIDS Directory
ttk.Label(left_frame, text="BIDS Directory:").grid(row=row_index, column=0, sticky=tk.W, padx=5, pady=2)
ttk.Entry(left_frame, textvariable=bids_dir_var).grid(row=row_index, column=1, sticky=tk.EW, padx=5, pady=2)
row_index += 1
# Widget for fmriprep Container Directory
ttk.Label(left_frame, text="fmriprep Container Directory:").grid(row=row_index, column=0, sticky=tk.W, padx=5, pady=2)
ttk.Entry(left_frame, textvariable=fmriprep_container_dir_var).grid(row=row_index, column=1, sticky=tk.EW, padx=5, pady=2)
row_index += 1
# Widget for fmriprep Job File Output Directory
ttk.Label(left_frame, text="fmriprep Job File Output Directory:").grid(row=row_index, column=0, sticky=tk.W, padx=5, pady=2)
ttk.Entry(left_frame, textvariable=fmriprep_job_file_out_dir_var).grid(row=row_index, column=1, sticky=tk.EW, padx=5, pady=2)
row_index += 1
# Widget for fmriprep Output Directory
ttk.Label(left_frame, text="fmriprep Output Directory:").grid(row=row_index, column=0, sticky=tk.W, padx=5, pady=2)
ttk.Entry(left_frame, textvariable=fmriprep_out_dir_var).grid(row=row_index, column=1, sticky=tk.EW, padx=5, pady=2)
row_index += 1
# Widget for fmriprep Error Output Directory
ttk.Label(left_frame, text="fmriprep Error Output Directory:").grid(row=row_index, column=0, sticky=tk.W, padx=5, pady=2)
ttk.Entry(left_frame, textvariable=fmriprep_error_out_dir_var).grid(row=row_index, column=1, sticky=tk.EW, padx=5, pady=2)
row_index += 1
# Widget for fmriprep Freesurfer License Directory
ttk.Label(left_frame, text="fmriprep Freesurfer License Directory:").grid(row=row_index, column=0, sticky=tk.W, padx=5, pady=2)
ttk.Entry(left_frame, textvariable=fmriprep_freesurfer_license_dir_var).grid(row=row_index, column=1, sticky=tk.EW, padx=5, pady=2)
row_index += 1
# Widget for xcp-d Container Directory
ttk.Label(left_frame, text="xcp-d Container Directory:").grid(row=row_index, column=0, sticky=tk.W, padx=5, pady=2)
ttk.Entry(left_frame, textvariable=xcpd_container_dir_var).grid(row=row_index, column=1, sticky=tk.EW, padx=5, pady=2)
row_index += 1
# Widget for xcp-d Job File Output Directory
ttk.Label(left_frame, text="xcp-d Job File Output Directory:").grid(row=row_index, column=0, sticky=tk.W, padx=5, pady=2)
ttk.Entry(left_frame, textvariable=xcpd_job_file_out_dir_var).grid(row=row_index, column=1, sticky=tk.EW, padx=5, pady=2)
row_index += 1
# Widget for xcp-d Output Directory
ttk.Label(left_frame, text="xcp-d Output Directory:").grid(row=row_index, column=0, sticky=tk.W, padx=5, pady=2)
ttk.Entry(left_frame, textvariable=xcpd_out_dir_var).grid(row=row_index, column=1, sticky=tk.EW, padx=5, pady=2)
row_index += 1
# Widget for xcp-d Error Output Directory
ttk.Label(left_frame, text="xcp-d Error Output Directory:").grid(row=row_index, column=0, sticky=tk.W, padx=5, pady=2)
ttk.Entry(left_frame, textvariable=xcpd_error_out_dir_var).grid(row=row_index, column=1, sticky=tk.EW, padx=5, pady=2)
row_index += 1
# Widget for User Email
ttk.Label(left_frame, text="User Email for HPC:").grid(row=row_index, column=0, sticky=tk.W, padx=5, pady=2)
ttk.Entry(left_frame, textvariable=user_email_var).grid(row=row_index, column=1, sticky=tk.EW, padx=5, pady=2)
row_index += 1
# Widget for Subject IDs
ttk.Label(left_frame, text="Subject IDs (comma-separated):").grid(row=row_index, column=0, sticky=tk.W, padx=5, pady=2)
ttk.Entry(left_frame, textvariable=subject_ids_var).grid(row=row_index, column=1, sticky=tk.EW, padx=5, pady=2)
# Right frame widget (shell script display)
shell_script_display = scrolledtext.ScrolledText(right_frame, wrap=tk.WORD, state=tk.DISABLED)
shell_script_display.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
sv_ttk.set_theme("Dark")
# Initial update of the shell script display
update_shell_script()
# Start the GUI event loop
root.mainloop()