-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainscrcall_dwi_dtitk_preproc
executable file
·536 lines (423 loc) · 21.9 KB
/
mainscrcall_dwi_dtitk_preproc
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
#! /bin/bash
# Does pre-processing of FSL files processed by dtifit to be used by DTI-TK#
# Sourcing of functions library files #
. mainscrcall_funclib
# Setting Ctrl + C as key combination to go back to PROCESSING menu. Also signals to the log file (=if there is one) that this script was interrupted
trap "echo -en '\n\nGoing back to the PROCESSING menu '; sleep 2; log_file_scripts_used interrupt; exit" SIGINT
# Checking if variables are not empty
emptvar=${MEDIA}
var_checked="THE MAIN FOLDER HOLDING MRI DATA"
checkemptvar
emptvar=${EXPERIMENT}
var_checked="THE EXPERIMENT NAME"
checkemptvar
emptvar="${SUBJLIST}"
var_checked="THE SUBJECT(S) TO BE PROCESSED"
checkemptvar
emptvar="${SUBJS_FOLDERS_PATH}"
var_checked="THE FOLDER CONTAINING ALL SUBJECTS' FOLDERS"
checkemptvar
########## FUNCTIONS USED IN THIS SCRIPT ##########
function dtifit_output_folder {
# This function allows the user to input the dtifit output files folder path and the basename for the files
# It uses 1 parameter:
# 1. Flag if it is being called for preprocessing or for copying files
# The "local" before the variable ensure that the variable is limited only to within this function
local preprocess_copying="$1"
# Asking the user to confirm or enter a new folder name for the folder holding the dtifit output files for each subject
while [ 1 ]
do
echo
# Checking which option is calling this function
if [ ${preprocess_copying} = preprocess ]
then
echo -e "The folder name holding the dtifit output files is currently entered as: ${dwi_dtifit_foldername}"
elif [ ${preprocess_copying} = copying ]
then
echo -e "The folder name holding the dtitk output files is currently entered as: ${dwi_dtitk_foldername}"
fi
echo -e "The basename for the dtifit output files is currently entered as: ${dwi_dtifit_basename}"
# Asking for the user's input
echo
echo -en "Do you want to: (1) Keep both names as is; or (2) enter new names: "
read dtifit_foldername
# Checking user's answer and asking for confirmation
if [ ${dtifit_foldername} = 1 ]
then
echo
# Checking which option is calling this function
if [ ${preprocess_copying} = preprocess ]
then
echo -en "Keeping the dtifit output files folder name as: \"${dwi_dtifit_foldername}\", and the basename as \"${dwi_dtifit_basename}\" "
elif [ ${preprocess_copying} = copying ]
then
echo -en "Keeping the dtitk output files folder name as: \"${dwi_dtitk_foldername}\", and the basename as \"${dwi_dtifit_basename}\" "
fi
sleep 2
break
elif [ ${dtifit_foldername} = 2 ]
then
echo
# Checking which option is calling this function
if [ ${preprocess_copying} = preprocess ]
then
echo -en "Please enter a new folder name: "
read dwi_dtifit_foldername
elif [ ${preprocess_copying} = copying ]
then
echo -en "Please enter a new folder name: "
read dwi_dtitk_foldername
fi
echo
echo -en "Please enter a new basename: "
read dwi_dtifit_basename
# Giving feedback to the user
echo
if [ ${preprocess_copying} = preprocess ]
then
echo -en "dtifit output files folder name entered as: \"${dwi_dtifit_foldername}\"\ndtifit basename entered as \"${dwi_dtifit_basename}\" "
elif [ ${preprocess_copying} = copying ]
then
echo -en "dtifit output files folder name entered as: \"${dwi_dtitk_foldername}\"\ndtifit basename entered as \"${dwi_dtifit_basename}\" "
fi
sleep 2
echo
break
fi
done
}
function dtitk_preprocess {
# This function will check if all output files from dtifit are available for each subject
# If it find all files, it will then preprocess them for use with DTI-TK using the tool "fsl_to_dtitk"
# Loop to preprocess dtifit output files for each subject
for SUBJ in ${SUBJLIST}
do
while [ 1 ]
do
# Checking if the above folder exists for the subject being processed
if [ -d ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtifit_foldername} ]
then
# Giving feedback to the user
echo -e "\n"
echo -en "Subject ${SUBJ} has an existing dtifit output files folder "
# Storing the full path for the needed files for preprocessing into variables
dtifile_L1=`ls ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtifit_foldername}/${dwi_dtifit_basename}_L1.nii.gz 2> /dev/null`
dtifile_L2=`ls ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtifit_foldername}/${dwi_dtifit_basename}_L2.nii.gz 2> /dev/null`
dtifile_L3=`ls ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtifit_foldername}/${dwi_dtifit_basename}_L3.nii.gz 2> /dev/null`
dtifile_V1=`ls ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtifit_foldername}/${dwi_dtifit_basename}_V1.nii.gz 2> /dev/null`
dtifile_V2=`ls ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtifit_foldername}/${dwi_dtifit_basename}_V2.nii.gz 2> /dev/null`
dtifile_V3=`ls ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtifit_foldername}/${dwi_dtifit_basename}_V3.nii.gz 2> /dev/null`
break
else
# Warning the user that the folder does not exists
echo
echo -en "\n*** This folder does not exists within this path: ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder} *** "
sleep 2
echo
echo -e "You will need to enter below the proper folder name holding the dtifit output files for this subject"
echo
echo -en "Please enter a new folder name: "
read dwi_dtifit_foldername
echo
echo -en "Please enter a new basename: "
read dwi_dtifit_basename
fi
done
# Checking if all needed files for dwifit are available
if [ -z "${dtifile_L1}" ] # Checking if this variable is zero in length
then
dtifile_L1=none
elif [ -z "${dtifile_L2}" ] # Checking if this variable is zero in length
then
dtifile_L2=none
elif [ -z "${dtifile_L3}" ] # Checking if this variable is zero in length
then
dtifile_L3=none
elif [ -z "${dtifile_V1}" ] # Checking if this variable is zero in length
then
dtifile_V1=none
elif [ -z "${dtifile_V2}" ] # Checking if this variable is zero in length
then
dtifile_V2=none
elif [ -z "${dtifile_V3}" ] # Checking if this variable is zero in length
then
dtifile_V3=none
fi
# This will see if any of the needed files for dtifit are missing
if [ "${dtifile_L1}" != none ] && [ "${dtifile_L2}" != none ] && [ "${dtifile_L3}" != none ] && [ "${dtifile_V1}" != none ] && [ "${dtifile_V2}" != none ] && [ "${dtifile_V3}" != none ] # If any of these variables is equal to "none", it means that they are empty
then
#####################################
# Using the fsl_to_dtitk tool to preprocess the dtifit output files into DTI-TK format, then create a folder and move all dtitk files to it
# Putting the full command into a variable
command_processing=`echo -e "cd ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtifit_foldername}; fsl_to_dtitk ${dwi_dtifit_basename} > ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtifit_foldername}/LOGFILE_Preprocessing_dtitk_conversion-from-fsl_OUTPUT.txt; mkdir ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtitk_foldername}; mv ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtifit_foldername}/*dtitk* ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtitk_foldername}"`
# Adding the command to the ppss processing text file
echo "${command_processing}" >> ${temp_folder}/${ppss_command_file}
##### Creating a LOG file with the commands used for later QA if needed #####
echo "OS name and version: ${os_nameandversion}; Command: fsl_to_dtitk; DTI-TK version: `echo ${DTITK_ROOT} | awk -F/ '{print $NF}'`; Date and time: `current_date_time 2`" > ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtifit_foldername}/LOGFILE_Preprocessing_dtitk_conversion-from-fsl_COMMAND-USED.txt
echo -e "Command \"fsl_to_dtitk\" to preprocess FSL dtifit output files for use with DTI-TK, and create a folder and move all dtitk files to it" >> ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtifit_foldername}/LOGFILE_Preprocessing_dtitk_conversion-from-fsl_COMMAND-USED.txt
echo -e "\n${command_processing}" >> ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtifit_foldername}/LOGFILE_Preprocessing_dtitk_conversion-from-fsl_COMMAND-USED.txt
#####################################
# Gathering this subject into a variable for processing. This will be used by the function "subjects_processed" in functionslibr_FSL
subj_process="${subj_process} ${SUBJ}"
else
echo -e "\n"
echo -e "##### One of the necessary files for \"fsl_to_dtitk\" was not found for subject \"$SUBJ\" #####"
echo -e "Please check the dtifit output folder name AND the basename for dtifit files for this subject"
echo
echo -e "Content of variables holding the path to each file:"
echo -e "Path to dtifit output files' folder: ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtifit_foldername}"
echo -e "Basename for dtifit output files: ${dwi_dtifit_basename}"
echo
echo -e "Skipping this subject for preprocessing dtifit output files\n"
echo -en "Press any key to continue "
read -n1 anykey
# Gathering this subject into a variable for NOT processing. This will be used by the function "subjects_processed" in functionslibr_FSL
subj_NOT_process="${subj_NOT_process} ${SUBJ}"
fi
done
}
function dtitk_files_copy {
# Asking the user if the dtitik main folder exists, and if not offers to create it
echo -e "\n"
echo -e "A main folder is needed to hold all preprocessed dtitik files from each subject"
echo -en "Did you create already such folder? (y/n) "
read yesno
# Checking the user's response and acting accordingly
if [ ${yesno} = y ]
then
# Asking the user to enter the path to the folder
echo
echo -en "Please enter the fullpath to the dtitk main folder: "
read dtitk_mainfolder_fullpath_temp
# Checking if this folder exists
if [ -d "${dtitk_mainfolder_fullpath_temp}" ]
then
# Since the folder exists, adding it to the variable for processing
dtitk_mainfolder_fullpath=${dtitk_mainfolder_fullpath_temp}
else
# The folder does not exist, so asking the user to enter another path
echo
echo -en "The folder does not exist in the provided fullpath "
sleep 2
fi
fi
# Checking if the variable "dtitk_mainfolder_fullpath" is a valid folder path, and if not offers to create a dtitk main folder
if [ -d "${dtitk_mainfolder_fullpath}" ]
then
echo
else
# Allowing the user to create a dtitk main folder
echo
echo -en "There is no dtitk main folder. Do you want to create one? (y/n) "
read yesno
if [ ${yesno} = y ]
then
while [ 1 ]
do
echo -e "\n"
echo -en "Please enter the fullpath where the dtitk main folder will be created: "
read dtitk_mainfolder_fullpath_mkdir
echo
echo -en "Now enter the dtitk main folder name: "
read dtitk_mainfolder_name
# Checking if this is a valid path
if [ -d "${dtitk_mainfolder_fullpath_mkdir}" ]
then
# Creating the dtitk main folder
mkdir ${dtitk_mainfolder_fullpath_mkdir}/${dtitk_mainfolder_name} 2> /dev/null
# Assigning the fullpath to a variable
dtitk_mainfolder_fullpath=${dtitk_mainfolder_fullpath_mkdir}/${dtitk_mainfolder_name}
break
else
# Giving feedback to the user
echo
echo -en "This is not a valid path. Please enter another one "
sleep 2
fi
done
else
# Giving feedback to the user
echo
echo -en "A main folder for dtitk is needed before proceeding. Exiting now..."
sleep 2
exit
fi
fi
# Copying each subjects' dtitk preprocessed file to the main dtitk main folder
for SUBJ in ${SUBJLIST}
do
# Giving feedback to the user
echo -e "\nProcessing subject ${SUBJ} "
# Gathering the subject's ID into a variable
subj_id=`echo ${SUBJ} | awk -F_ '{printf $1}'`
# Copy command
cp ${dwi_mainfolder_path}/${SUBJ}/${dwi_subject_subfolder}/${dwi_dtitk_foldername}/${dwi_dtifit_basename}_dtitk.nii.gz ${dtitk_mainfolder_fullpath}/${subj_id}_data_DTI_dtitk.nii.gz
# Creating the subjects' files list text file (needed for DTI-TK registration and spatial normalization)
ls -1 ${dtitk_mainfolder_fullpath}/*.nii.gz | awk -F/ '{print $NF}' > ${dtitk_mainfolder_fullpath}/subjs.txt
echo
done
}
###########################################################################
############### MAIN MENU ROUTINE ###############
###########################################################################
##### VARIABLES TO BE USED IN THIS SCRIPT #####
# Assigning a variable to hold the main location of the files generated by this script
temp_folder=/tmp/ppss_tempdir_dtitk_preproc # Where the temporary files will be held
ppss_command_file=dtitk_files_list.txt
dwi_mainfolder_path=${SUBJS_FOLDERS_PATH} # Where the DWI files are. Can be modified by the user in this script.
dwi_subject_subfolder=DWI/DWI_42dirs_01 # To be used with "ls" command: The path to the subfolder within each subject's folder
dwi_dtifit_foldername=dtifit_output # The folder name where the output files of dtifit are located (this may be changed later by the user)
dwi_dtifit_basename=data_DTI # The basename for the dtifit output files (this may be changed later by the user)
dwi_dtitk_foldername=dtitk-format # The folder name where the output files of dtifit are located (this may be changed later by the user)
######################################################################
######### Script Main menu - Informing the user what this script does and asking for input #########
clear
# Changing directory to /tmp in case the script commits some error - this will make any commands to be run within /tmp, preventing damage to the file system
cd /tmp
# Removing temporary folders and files created, just in case they were not deleted properly by a previously ran script
rm -r ${temp_folder} 2> /dev/null
# Creating a temporary folder to hold the text file with the subjects to be processed
mkdir ${temp_folder} 2> /dev/null
echo -e "This program will pre-process the dtifit output files for each subject for use with DTI-TK"
echo -e "It will use the DTI-TK command \"fsl_to_dtitk\"\n"
echo -e "#######################################################"
echo -e "*** IMPORTANT - this program makes one assumption:"
echo -e "1. You have processed your files with FSL following the steps for FDT and fitted a diffusion tensor model using dtifit. The dtifit output files are expected to be stores in a single folder for each subject"
echo -e "#######################################################"
##### GATHERING THE PATH TO THE ANALYSIS FOLDER #####
# FUNCTION CALL: calls the function "analysis_mainfolder" in "mainscrcall_funclib" to allow the user to select the path to the subject's folders
analysis_mainfolder DWI
# Assigning the output variable from the function above to a local variable
dwi_mainfolder_path=${ANALYSIS_MAINFOLDER_PATH}
######################################################
# MAIN MENU
echo
echo -e "Please choose which step to proceed:"
echo -e "\t1. Preprocess dtifit output files for DTI-TK use"
echo -e "\t2. Copy each subject's pre-processed DTI file into a single folder for posterior registration and spatial normalization"
echo -e "\t0. Back to main menu\n"
echo -en "Please enter your option: "
read dwifit_process_steps
# Ask for user input to continue
while [ 1 ]
do
case ${dwifit_process_steps} in
0)
echo
echo -en "Going back to the PROCESSING menu "
sleep 2
exit
;;
1)
# Creating a log file. STEP 1 of 2 = start call
# Calling the function "log_file_scripts_used" in "mainscrcall_funclib" to output the characteristics of this script. It uses 4 parameters: 1. Flag to signal if this function is being called when the calling script starts or when it has finished; 2. The calling script and its purposes (separated by a semicolon); 3. The analysis software type (FSL, Freesurfer, DTI-TK) related to the script's use; 4. The tools used (e.g., fsl_motion_outliers, fslreorient2std, etc.)
log_file_scripts_used start "mainscrall_dwi_dtitk_preproc:Preprocessing FSL dtifit output files for use with DTI-TK" DTI-TK "(dtitk_preprocess) fsl_to_dtitk"
####### MAIN PATH TO SUBJECTS FOLDER CHECK ##############
# Checking if used the original path to DWI files or the user entered another one ("default_path" variable originates from function "DWI_mainfolder" in "mainscrcall_funclib")
if [ ${default_path} = yes ]
then
# Creating a log file. STEP 1.5 of 2 = midscript call
# Calling the function "log_file_scripts_used" in "mainscrcall_funclib" to output the characteristics of this script. It uses 4 parameters: 1. Flag to signal if this function is being called when the calling script starts or when it has finished; 2. Reason for midscript call
log_file_scripts_used midscript "Used the default path for DWI data: ${dwi_mainfolder_path}"
elif [ ${default_path} = no ]
then
# Creating a log file. STEP 1.5 of 2 = midscript call
# Calling the function "log_file_scripts_used" in "mainscrcall_funclib" to output the characteristics of this script. It uses 4 parameters: 1. Flag to signal if this function is being called when the calling script starts or when it has finished; 2. Reason for midscript call
log_file_scripts_used midscript "Used an alternative path for DWI data: ${dwi_mainfolder_path}"
fi
#########################################################
# Giving information to the user on what this script will do
echo
echo -e "This script will preprocess the dtifit output files to be used by DTI-TK for the subjects listed:\n"
# Making the subjects within the "SUBJLIST" variable to be listed in a numbered list for the user
# Establishing the initial subject numbering
count=1
for SUBJ in ${SUBJLIST}
do
# This is to add trailing zeros to this number, so instead of "2" you have "002" for example. Maybe needed if subject's listing gets mixed up due to numbers like "10" being listed before "2", e.g. 1 10 11 2 3 4
counter=`printf "%02d" ${count}`
echo "${counter}) ${SUBJ}"
# Adding a unit to the numbering variable
((count++))
done
# Cleaning the contents of the variable below
unset count counter
# Warning the user about the script assumptions
echo
echo -e "*** Please note that this script expects the eigenvector (*_V1, *_V2, *_V3) and eigenvalue (*_L1, *_L2, *_L3) files from dtifit in a single folder for each subject ***"
echo -e "If not it will generate an error"
echo -en "Press any key to continue "
read anykey
# FUNCTION CALL: Calls the function "dtifit_output_folder" to confirm dtifit output files folder
dtifit_output_folder preprocess
# FUNCTION CALL: Calls the function "dtitk_preprocess" to proceed with dtitk preprocessing
dtitk_preprocess
# Checking if there is a PPSS processing file
if [ -f "${temp_folder}/${ppss_command_file}" ] # Checking if this file exists and is a file
then
# Calling the function "parallel_processing_ppss" to run the motion outliers command. Note 2 parameters: 1) path to the folder holding the temporary files for this script; 2) the name of the files holding the commands for PPSS to run. Added a 3rd parameter to signal the function "parallel_processing_ppss" that the PPSS log files will be deleted there.
# Not using the 4th parameter (list of unique identifiers for differentiating commands, e.g. a list of subjects), SO ALL SUBJECT'S FILES ARE PROCESSED IN A ROW, INSTEAD OF ON A SUBJECT-BY-SUBJECT BASIS (FASTER AND OPTIMIZED USE OF PPSS).
parallel_processing_ppss ${temp_folder} ${ppss_command_file} ppss_function
echo -e "\n"
echo -e "Finished processing at: `current_date_time 2`"
else
echo
echo -en "*** No PPSS processing file was generated - please check the reason ***"
echo -en "Press any key to continue "
read -n1 anykey
fi
###### Listing the subjects processed ######
# FUNCTION CALL: Calls the function "subjects_listed2process" in "mainscrcall_funclib" to list to the user all subjects processed and those not processed by the script invoking it
subjects_listed2process
################################################
# Ask for user input to continue
echo
echo -en "Press any key to continue to the PROCESSING menu "
read -n1 anykey
echo
echo -e "Finished processing for the above subjects"
break
;;
2)
# Giving information to the user on what this script will do
echo
echo -e "This script will copy the DTI-TK preprocessed file for each subjects listed into a single folder for later processing, and will also create a text file named \"subjs.txt\" listing all files within this folder:\n"
# Making the subjects within the "SUBJLIST" variable to be listed in a numbered list for the user
# Establishing the initial subject numbering
count=1
for SUBJ in ${SUBJLIST}
do
# This is to add trailing zeros to this number, so instead of "2" you have "002" for example. Maybe needed if subject's listing gets mixed up due to numbers like "10" being listed before "2", e.g. 1 10 11 2 3 4
counter=`printf "%02d" ${count}`
echo "${counter}) ${SUBJ}"
# Adding a unit to the numbering variable
((count++))
done
# Cleaning the contents of the variable below
unset count counter
echo -en "Press any key to continue "
read anykey
# FUNCTION CALL: Calls the function "dtifit_output_folder" to confirm dtitk output files folder
dtifit_output_folder copying
# FUNCTION CALL: Calls the function "dtitk_files_copy" to copy dtifit output files to the dtitk main folder
dtitk_files_copy
# Ask for user input to continue
echo
echo -en "Press any key to continue to the PROCESSING menu "
read -n1 anykey
echo
echo -e "Finished processing for the above subjects"
break
;;
*)
echo -e "No valid option chosen"
echo -en "Please re-enter an option "
sleep 2
;;
esac
done
# Creating a log file. STEP 2 of 2 = finish call
# Calling the function "log_file_scripts_used" in "functionslibr_FSL" to output the characteristics of this script. It uses 1 parameters: 1. Flag to signal if this function is being called when the calling script starts or when it has finished; 2. List of subjects processed
log_file_scripts_used finish "${SUBJLIST}"
# Removing temporary folders and files created
rm -r ${temp_folder} 2> /dev/null